@nestia/core 3.1.0-dev.20240429 → 3.1.0-dev.20240430
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/package.json +3 -3
- package/src/decorators/DynamicModule.ts +39 -39
- package/src/decorators/EncryptedBody.ts +105 -105
- package/src/decorators/EncryptedController.ts +38 -38
- package/src/decorators/EncryptedModule.ts +96 -96
- package/src/decorators/EncryptedRoute.ts +182 -182
- package/src/decorators/PlainBody.ts +75 -75
- package/src/decorators/TypedBody.ts +62 -62
- package/src/decorators/TypedException.ts +90 -90
- package/src/decorators/TypedFormData.ts +219 -219
- package/src/decorators/TypedHeaders.ts +69 -69
- package/src/decorators/TypedParam.ts +64 -64
- package/src/decorators/TypedRoute.ts +144 -144
- package/src/decorators/internal/EncryptedConstant.ts +4 -4
- package/src/decorators/internal/NoTransformConfigureError.ts +8 -8
- package/src/decorators/internal/get_path_and_querify.ts +106 -106
- package/src/decorators/internal/get_path_and_stringify.ts +91 -91
- package/src/decorators/internal/get_text_body.ts +20 -20
- package/src/decorators/internal/headers_to_object.ts +13 -13
- package/src/decorators/internal/load_controller.ts +51 -51
- package/src/decorators/internal/route_error.ts +45 -45
- package/src/index.ts +5 -5
- package/src/options/INestiaTransformOptions.ts +17 -17
- package/src/options/INestiaTransformProject.ts +7 -7
- package/src/options/IRequestBodyValidator.ts +20 -20
- package/src/options/IRequestFormDataProps.ts +27 -27
- package/src/options/IRequestHeadersValidator.ts +22 -22
- package/src/options/IRequestQueryValidator.ts +20 -20
- package/src/options/IResponseBodyQuerifier.ts +25 -25
- package/src/options/IResponseBodyStringifier.ts +25 -25
- package/src/programmers/PlainBodyProgrammer.ts +52 -52
- package/src/programmers/TypedBodyProgrammer.ts +108 -108
- package/src/programmers/TypedExceptionProgrammer.ts +71 -71
- package/src/programmers/TypedHeadersProgrammer.ts +56 -56
- package/src/programmers/TypedParamProgrammer.ts +24 -24
- package/src/programmers/TypedQueryBodyProgrammer.ts +56 -56
- package/src/programmers/TypedQueryProgrammer.ts +56 -56
- package/src/programmers/TypedQueryRouteProgrammer.ts +51 -51
- package/src/programmers/TypedRouteProgrammer.ts +51 -51
- package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +58 -58
- package/src/programmers/http/HttpIsQuerifyProgrammer.ts +62 -62
- package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +63 -63
- package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
- package/src/transform.ts +35 -35
- package/src/transformers/FileTransformer.ts +66 -66
- package/src/transformers/MethodTransformer.ts +97 -97
- package/src/transformers/NodeTransformer.ts +16 -16
- package/src/transformers/ParameterTransformer.ts +48 -48
- package/src/transformers/TypedExceptionTransformer.ts +44 -44
- package/src/transformers/TypedRouteTransformer.ts +81 -81
- package/src/typings/Creator.ts +3 -3
- package/src/utils/ExceptionManager.ts +112 -112
- package/src/utils/Singleton.ts +20 -20
- package/src/utils/SourceFinder.ts +57 -57
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { JsonMetadataFactory } from "typia/lib/factories/JsonMetadataFactory";
|
|
3
|
-
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
4
|
-
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
5
|
-
|
|
6
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
7
|
-
|
|
8
|
-
export namespace TypedExceptionProgrammer {
|
|
9
|
-
export const generate =
|
|
10
|
-
({ checker }: INestiaTransformProject) =>
|
|
11
|
-
(expression: ts.CallExpression): ts.CallExpression => {
|
|
12
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
13
|
-
if (!expression.typeArguments?.[0])
|
|
14
|
-
throw TransformerError.from("nestia.core.TypedException")([
|
|
15
|
-
{
|
|
16
|
-
name: "uknown",
|
|
17
|
-
messages: [NOT_SPECIFIED],
|
|
18
|
-
explore: {
|
|
19
|
-
top: true,
|
|
20
|
-
object: null,
|
|
21
|
-
property: null,
|
|
22
|
-
nested: null,
|
|
23
|
-
escaped: false,
|
|
24
|
-
aliased: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
]);
|
|
28
|
-
// CHECK DUPLICATED TRNASFORMATION
|
|
29
|
-
else if (expression.arguments.length === 3) return expression;
|
|
30
|
-
|
|
31
|
-
// GET TYPE INFO
|
|
32
|
-
const node: ts.TypeNode = expression.typeArguments[0];
|
|
33
|
-
const type: ts.Type = checker.getTypeFromTypeNode(node);
|
|
34
|
-
|
|
35
|
-
// VALIDATE TYPE
|
|
36
|
-
if (type.isTypeParameter())
|
|
37
|
-
throw TransformerError.from("nestia.core.TypedException")([
|
|
38
|
-
{
|
|
39
|
-
name: TypeFactory.getFullName(checker)(type),
|
|
40
|
-
messages: [NO_GENERIC_ARGUMENT],
|
|
41
|
-
explore: {
|
|
42
|
-
top: true,
|
|
43
|
-
object: null,
|
|
44
|
-
property: null,
|
|
45
|
-
nested: null,
|
|
46
|
-
escaped: false,
|
|
47
|
-
aliased: false,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
JsonMetadataFactory.analyze("@nestia.core.TypedException")(checker)(type);
|
|
52
|
-
|
|
53
|
-
// DO TRANSFORM
|
|
54
|
-
const name: string = TypeFactory.getFullName(checker)(type);
|
|
55
|
-
return ts.factory.updateCallExpression(
|
|
56
|
-
expression,
|
|
57
|
-
expression.expression,
|
|
58
|
-
expression.typeArguments,
|
|
59
|
-
[
|
|
60
|
-
expression.arguments[0],
|
|
61
|
-
expression.arguments[1] ?? ts.factory.createIdentifier("undefined"),
|
|
62
|
-
ts.factory.createStringLiteral(name),
|
|
63
|
-
],
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const NOT_SPECIFIED =
|
|
69
|
-
"Error on @nestia.core.TypedException(): generic argument is not specified.";
|
|
70
|
-
const NO_GENERIC_ARGUMENT =
|
|
71
|
-
"Error on @nestia.core.TypedException(): non-specified generic argument.";
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { JsonMetadataFactory } from "typia/lib/factories/JsonMetadataFactory";
|
|
3
|
+
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
4
|
+
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
5
|
+
|
|
6
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
7
|
+
|
|
8
|
+
export namespace TypedExceptionProgrammer {
|
|
9
|
+
export const generate =
|
|
10
|
+
({ checker }: INestiaTransformProject) =>
|
|
11
|
+
(expression: ts.CallExpression): ts.CallExpression => {
|
|
12
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
13
|
+
if (!expression.typeArguments?.[0])
|
|
14
|
+
throw TransformerError.from("nestia.core.TypedException")([
|
|
15
|
+
{
|
|
16
|
+
name: "uknown",
|
|
17
|
+
messages: [NOT_SPECIFIED],
|
|
18
|
+
explore: {
|
|
19
|
+
top: true,
|
|
20
|
+
object: null,
|
|
21
|
+
property: null,
|
|
22
|
+
nested: null,
|
|
23
|
+
escaped: false,
|
|
24
|
+
aliased: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
// CHECK DUPLICATED TRNASFORMATION
|
|
29
|
+
else if (expression.arguments.length === 3) return expression;
|
|
30
|
+
|
|
31
|
+
// GET TYPE INFO
|
|
32
|
+
const node: ts.TypeNode = expression.typeArguments[0];
|
|
33
|
+
const type: ts.Type = checker.getTypeFromTypeNode(node);
|
|
34
|
+
|
|
35
|
+
// VALIDATE TYPE
|
|
36
|
+
if (type.isTypeParameter())
|
|
37
|
+
throw TransformerError.from("nestia.core.TypedException")([
|
|
38
|
+
{
|
|
39
|
+
name: TypeFactory.getFullName(checker)(type),
|
|
40
|
+
messages: [NO_GENERIC_ARGUMENT],
|
|
41
|
+
explore: {
|
|
42
|
+
top: true,
|
|
43
|
+
object: null,
|
|
44
|
+
property: null,
|
|
45
|
+
nested: null,
|
|
46
|
+
escaped: false,
|
|
47
|
+
aliased: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
JsonMetadataFactory.analyze("@nestia.core.TypedException")(checker)(type);
|
|
52
|
+
|
|
53
|
+
// DO TRANSFORM
|
|
54
|
+
const name: string = TypeFactory.getFullName(checker)(type);
|
|
55
|
+
return ts.factory.updateCallExpression(
|
|
56
|
+
expression,
|
|
57
|
+
expression.expression,
|
|
58
|
+
expression.typeArguments,
|
|
59
|
+
[
|
|
60
|
+
expression.arguments[0],
|
|
61
|
+
expression.arguments[1] ?? ts.factory.createIdentifier("undefined"),
|
|
62
|
+
ts.factory.createStringLiteral(name),
|
|
63
|
+
],
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const NOT_SPECIFIED =
|
|
69
|
+
"Error on @nestia.core.TypedException(): generic argument is not specified.";
|
|
70
|
+
const NO_GENERIC_ARGUMENT =
|
|
71
|
+
"Error on @nestia.core.TypedException(): non-specified generic argument.";
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { HttpAssertHeadersProgrammer } from "typia/lib/programmers/http/HttpAssertHeadersProgrammer";
|
|
3
|
-
import { HttpIsHeadersProgrammer } from "typia/lib/programmers/http/HttpIsHeadersProgrammer";
|
|
4
|
-
import { HttpValidateHeadersProgrammer } from "typia/lib/programmers/http/HttpValidateHeadersProgrammer";
|
|
5
|
-
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedHeadersProgrammer {
|
|
11
|
-
export const generate =
|
|
12
|
-
(project: INestiaTransformProject) =>
|
|
13
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
-
(type: ts.Type): ts.Expression => {
|
|
15
|
-
// GENERATE VALIDATION PLAN
|
|
16
|
-
const parameter =
|
|
17
|
-
(key: IRequestHeadersValidator<any>["type"]) =>
|
|
18
|
-
(
|
|
19
|
-
programmer: (
|
|
20
|
-
project: IProject,
|
|
21
|
-
) => (
|
|
22
|
-
modulo: ts.LeftHandSideExpression,
|
|
23
|
-
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
-
) =>
|
|
25
|
-
ts.factory.createObjectLiteralExpression([
|
|
26
|
-
ts.factory.createPropertyAssignment(
|
|
27
|
-
ts.factory.createIdentifier("type"),
|
|
28
|
-
ts.factory.createStringLiteral(key),
|
|
29
|
-
),
|
|
30
|
-
ts.factory.createPropertyAssignment(
|
|
31
|
-
ts.factory.createIdentifier(key),
|
|
32
|
-
programmer({
|
|
33
|
-
...project,
|
|
34
|
-
options: {
|
|
35
|
-
numeric: false,
|
|
36
|
-
finite: false,
|
|
37
|
-
functional: false,
|
|
38
|
-
},
|
|
39
|
-
})(modulo)(type),
|
|
40
|
-
),
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
// RETURNS
|
|
44
|
-
const category = project.options.validate;
|
|
45
|
-
if (category === "is" || category === "equals")
|
|
46
|
-
return parameter("is")(HttpIsHeadersProgrammer.write);
|
|
47
|
-
else if (
|
|
48
|
-
category === "validate" ||
|
|
49
|
-
category === "validateEquals" ||
|
|
50
|
-
category === "validateClone" ||
|
|
51
|
-
category === "validatePrune"
|
|
52
|
-
)
|
|
53
|
-
return parameter("validate")(HttpValidateHeadersProgrammer.write);
|
|
54
|
-
return parameter("assert")(HttpAssertHeadersProgrammer.write);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { HttpAssertHeadersProgrammer } from "typia/lib/programmers/http/HttpAssertHeadersProgrammer";
|
|
3
|
+
import { HttpIsHeadersProgrammer } from "typia/lib/programmers/http/HttpIsHeadersProgrammer";
|
|
4
|
+
import { HttpValidateHeadersProgrammer } from "typia/lib/programmers/http/HttpValidateHeadersProgrammer";
|
|
5
|
+
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedHeadersProgrammer {
|
|
11
|
+
export const generate =
|
|
12
|
+
(project: INestiaTransformProject) =>
|
|
13
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type): ts.Expression => {
|
|
15
|
+
// GENERATE VALIDATION PLAN
|
|
16
|
+
const parameter =
|
|
17
|
+
(key: IRequestHeadersValidator<any>["type"]) =>
|
|
18
|
+
(
|
|
19
|
+
programmer: (
|
|
20
|
+
project: IProject,
|
|
21
|
+
) => (
|
|
22
|
+
modulo: ts.LeftHandSideExpression,
|
|
23
|
+
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
+
) =>
|
|
25
|
+
ts.factory.createObjectLiteralExpression([
|
|
26
|
+
ts.factory.createPropertyAssignment(
|
|
27
|
+
ts.factory.createIdentifier("type"),
|
|
28
|
+
ts.factory.createStringLiteral(key),
|
|
29
|
+
),
|
|
30
|
+
ts.factory.createPropertyAssignment(
|
|
31
|
+
ts.factory.createIdentifier(key),
|
|
32
|
+
programmer({
|
|
33
|
+
...project,
|
|
34
|
+
options: {
|
|
35
|
+
numeric: false,
|
|
36
|
+
finite: false,
|
|
37
|
+
functional: false,
|
|
38
|
+
},
|
|
39
|
+
})(modulo)(type),
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// RETURNS
|
|
44
|
+
const category = project.options.validate;
|
|
45
|
+
if (category === "is" || category === "equals")
|
|
46
|
+
return parameter("is")(HttpIsHeadersProgrammer.write);
|
|
47
|
+
else if (
|
|
48
|
+
category === "validate" ||
|
|
49
|
+
category === "validateEquals" ||
|
|
50
|
+
category === "validateClone" ||
|
|
51
|
+
category === "validatePrune"
|
|
52
|
+
)
|
|
53
|
+
return parameter("validate")(HttpValidateHeadersProgrammer.write);
|
|
54
|
+
return parameter("assert")(HttpAssertHeadersProgrammer.write);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
5
|
-
|
|
6
|
-
export namespace TypedParamProgrammer {
|
|
7
|
-
export const generate =
|
|
8
|
-
(project: INestiaTransformProject) =>
|
|
9
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
10
|
-
(parameters: readonly ts.Expression[]) =>
|
|
11
|
-
(type: ts.Type): readonly ts.Expression[] => {
|
|
12
|
-
// ALREADY BEING TRANSFORMED
|
|
13
|
-
if (parameters.length !== 1) return parameters;
|
|
14
|
-
return [
|
|
15
|
-
parameters[0],
|
|
16
|
-
HttpParameterProgrammer.write({
|
|
17
|
-
...project,
|
|
18
|
-
options: {
|
|
19
|
-
numeric: true,
|
|
20
|
-
},
|
|
21
|
-
})(modulo)(type),
|
|
22
|
-
];
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
5
|
+
|
|
6
|
+
export namespace TypedParamProgrammer {
|
|
7
|
+
export const generate =
|
|
8
|
+
(project: INestiaTransformProject) =>
|
|
9
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
10
|
+
(parameters: readonly ts.Expression[]) =>
|
|
11
|
+
(type: ts.Type): readonly ts.Expression[] => {
|
|
12
|
+
// ALREADY BEING TRANSFORMED
|
|
13
|
+
if (parameters.length !== 1) return parameters;
|
|
14
|
+
return [
|
|
15
|
+
parameters[0],
|
|
16
|
+
HttpParameterProgrammer.write({
|
|
17
|
+
...project,
|
|
18
|
+
options: {
|
|
19
|
+
numeric: true,
|
|
20
|
+
},
|
|
21
|
+
})(modulo)(type),
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
|
|
3
|
-
import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
|
|
4
|
-
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
|
|
5
|
-
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedQueryBodyProgrammer {
|
|
11
|
-
export const generate =
|
|
12
|
-
(project: INestiaTransformProject) =>
|
|
13
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
-
(type: ts.Type): ts.ObjectLiteralExpression => {
|
|
15
|
-
// GENERATE VALIDATION PLAN
|
|
16
|
-
const parameter =
|
|
17
|
-
(key: IRequestQueryValidator<any>["type"]) =>
|
|
18
|
-
(
|
|
19
|
-
programmer: (
|
|
20
|
-
project: IProject,
|
|
21
|
-
) => (
|
|
22
|
-
modulo: ts.LeftHandSideExpression,
|
|
23
|
-
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
-
) =>
|
|
25
|
-
ts.factory.createObjectLiteralExpression([
|
|
26
|
-
ts.factory.createPropertyAssignment(
|
|
27
|
-
ts.factory.createIdentifier("type"),
|
|
28
|
-
ts.factory.createStringLiteral(key),
|
|
29
|
-
),
|
|
30
|
-
ts.factory.createPropertyAssignment(
|
|
31
|
-
ts.factory.createIdentifier(key),
|
|
32
|
-
programmer({
|
|
33
|
-
...project,
|
|
34
|
-
options: {
|
|
35
|
-
numeric: false,
|
|
36
|
-
finite: false,
|
|
37
|
-
functional: false,
|
|
38
|
-
},
|
|
39
|
-
})(modulo)(type),
|
|
40
|
-
),
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
// RETURNS
|
|
44
|
-
const category = project.options.validate;
|
|
45
|
-
if (category === "is" || category === "equals")
|
|
46
|
-
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
47
|
-
else if (
|
|
48
|
-
category === "validate" ||
|
|
49
|
-
category === "validateEquals" ||
|
|
50
|
-
category === "validateClone" ||
|
|
51
|
-
category === "validatePrune"
|
|
52
|
-
)
|
|
53
|
-
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
54
|
-
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
|
|
3
|
+
import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
|
|
4
|
+
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
|
|
5
|
+
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedQueryBodyProgrammer {
|
|
11
|
+
export const generate =
|
|
12
|
+
(project: INestiaTransformProject) =>
|
|
13
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type): ts.ObjectLiteralExpression => {
|
|
15
|
+
// GENERATE VALIDATION PLAN
|
|
16
|
+
const parameter =
|
|
17
|
+
(key: IRequestQueryValidator<any>["type"]) =>
|
|
18
|
+
(
|
|
19
|
+
programmer: (
|
|
20
|
+
project: IProject,
|
|
21
|
+
) => (
|
|
22
|
+
modulo: ts.LeftHandSideExpression,
|
|
23
|
+
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
+
) =>
|
|
25
|
+
ts.factory.createObjectLiteralExpression([
|
|
26
|
+
ts.factory.createPropertyAssignment(
|
|
27
|
+
ts.factory.createIdentifier("type"),
|
|
28
|
+
ts.factory.createStringLiteral(key),
|
|
29
|
+
),
|
|
30
|
+
ts.factory.createPropertyAssignment(
|
|
31
|
+
ts.factory.createIdentifier(key),
|
|
32
|
+
programmer({
|
|
33
|
+
...project,
|
|
34
|
+
options: {
|
|
35
|
+
numeric: false,
|
|
36
|
+
finite: false,
|
|
37
|
+
functional: false,
|
|
38
|
+
},
|
|
39
|
+
})(modulo)(type),
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// RETURNS
|
|
44
|
+
const category = project.options.validate;
|
|
45
|
+
if (category === "is" || category === "equals")
|
|
46
|
+
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
47
|
+
else if (
|
|
48
|
+
category === "validate" ||
|
|
49
|
+
category === "validateEquals" ||
|
|
50
|
+
category === "validateClone" ||
|
|
51
|
+
category === "validatePrune"
|
|
52
|
+
)
|
|
53
|
+
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
54
|
+
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
|
|
3
|
-
import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
|
|
4
|
-
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
|
|
5
|
-
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedQueryProgrammer {
|
|
11
|
-
export const generate =
|
|
12
|
-
(project: INestiaTransformProject) =>
|
|
13
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
-
(type: ts.Type): ts.Expression => {
|
|
15
|
-
// GENERATE VALIDATION PLAN
|
|
16
|
-
const parameter =
|
|
17
|
-
(key: IRequestQueryValidator<any>["type"]) =>
|
|
18
|
-
(
|
|
19
|
-
programmer: (
|
|
20
|
-
project: IProject,
|
|
21
|
-
) => (
|
|
22
|
-
modulo: ts.LeftHandSideExpression,
|
|
23
|
-
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
-
) =>
|
|
25
|
-
ts.factory.createObjectLiteralExpression([
|
|
26
|
-
ts.factory.createPropertyAssignment(
|
|
27
|
-
ts.factory.createIdentifier("type"),
|
|
28
|
-
ts.factory.createStringLiteral(key),
|
|
29
|
-
),
|
|
30
|
-
ts.factory.createPropertyAssignment(
|
|
31
|
-
ts.factory.createIdentifier(key),
|
|
32
|
-
programmer({
|
|
33
|
-
...project,
|
|
34
|
-
options: {
|
|
35
|
-
numeric: false,
|
|
36
|
-
finite: false,
|
|
37
|
-
functional: false,
|
|
38
|
-
},
|
|
39
|
-
})(modulo)(type),
|
|
40
|
-
),
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
// RETURNS
|
|
44
|
-
const category = project.options.validate;
|
|
45
|
-
if (category === "is" || category === "equals")
|
|
46
|
-
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
47
|
-
else if (
|
|
48
|
-
category === "validate" ||
|
|
49
|
-
category === "validateEquals" ||
|
|
50
|
-
category === "validateClone" ||
|
|
51
|
-
category === "validatePrune"
|
|
52
|
-
)
|
|
53
|
-
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
54
|
-
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
|
|
3
|
+
import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
|
|
4
|
+
import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
|
|
5
|
+
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedQueryProgrammer {
|
|
11
|
+
export const generate =
|
|
12
|
+
(project: INestiaTransformProject) =>
|
|
13
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type): ts.Expression => {
|
|
15
|
+
// GENERATE VALIDATION PLAN
|
|
16
|
+
const parameter =
|
|
17
|
+
(key: IRequestQueryValidator<any>["type"]) =>
|
|
18
|
+
(
|
|
19
|
+
programmer: (
|
|
20
|
+
project: IProject,
|
|
21
|
+
) => (
|
|
22
|
+
modulo: ts.LeftHandSideExpression,
|
|
23
|
+
) => (type: ts.Type) => ts.ArrowFunction,
|
|
24
|
+
) =>
|
|
25
|
+
ts.factory.createObjectLiteralExpression([
|
|
26
|
+
ts.factory.createPropertyAssignment(
|
|
27
|
+
ts.factory.createIdentifier("type"),
|
|
28
|
+
ts.factory.createStringLiteral(key),
|
|
29
|
+
),
|
|
30
|
+
ts.factory.createPropertyAssignment(
|
|
31
|
+
ts.factory.createIdentifier(key),
|
|
32
|
+
programmer({
|
|
33
|
+
...project,
|
|
34
|
+
options: {
|
|
35
|
+
numeric: false,
|
|
36
|
+
finite: false,
|
|
37
|
+
functional: false,
|
|
38
|
+
},
|
|
39
|
+
})(modulo)(type),
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// RETURNS
|
|
44
|
+
const category = project.options.validate;
|
|
45
|
+
if (category === "is" || category === "equals")
|
|
46
|
+
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
47
|
+
else if (
|
|
48
|
+
category === "validate" ||
|
|
49
|
+
category === "validateEquals" ||
|
|
50
|
+
category === "validateClone" ||
|
|
51
|
+
category === "validatePrune"
|
|
52
|
+
)
|
|
53
|
+
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
54
|
+
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IProject } from "typia/lib/transformers/IProject";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
5
|
-
import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
|
|
6
|
-
import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
|
|
8
|
-
import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
|
|
9
|
-
|
|
10
|
-
export namespace TypedQueryRouteProgrammer {
|
|
11
|
-
export const generate =
|
|
12
|
-
(project: INestiaTransformProject) =>
|
|
13
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
-
(type: ts.Type): ts.Expression => {
|
|
15
|
-
// GENERATE STRINGIFY PLAN
|
|
16
|
-
const parameter = (
|
|
17
|
-
key: string,
|
|
18
|
-
programmer: (
|
|
19
|
-
project: IProject,
|
|
20
|
-
) => (
|
|
21
|
-
modulo: ts.LeftHandSideExpression,
|
|
22
|
-
) => (type: ts.Type) => ts.ArrowFunction,
|
|
23
|
-
) =>
|
|
24
|
-
ts.factory.createObjectLiteralExpression([
|
|
25
|
-
ts.factory.createPropertyAssignment(
|
|
26
|
-
ts.factory.createIdentifier("type"),
|
|
27
|
-
ts.factory.createStringLiteral(key),
|
|
28
|
-
),
|
|
29
|
-
ts.factory.createPropertyAssignment(
|
|
30
|
-
ts.factory.createIdentifier(key),
|
|
31
|
-
programmer({
|
|
32
|
-
...project,
|
|
33
|
-
options: {}, // use default option
|
|
34
|
-
})(modulo)(type),
|
|
35
|
-
),
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
// RETURNS
|
|
39
|
-
if (project.options.stringify === "is")
|
|
40
|
-
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
41
|
-
else if (project.options.stringify === "validate")
|
|
42
|
-
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
43
|
-
else if (project.options.stringify === "stringify")
|
|
44
|
-
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
45
|
-
else if (project.options.stringify === null)
|
|
46
|
-
return ts.factory.createNull();
|
|
47
|
-
|
|
48
|
-
// ASSERT IS DEFAULT
|
|
49
|
-
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IProject } from "typia/lib/transformers/IProject";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformProject } from "../options/INestiaTransformProject";
|
|
5
|
+
import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
|
|
6
|
+
import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
|
|
8
|
+
import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
|
|
9
|
+
|
|
10
|
+
export namespace TypedQueryRouteProgrammer {
|
|
11
|
+
export const generate =
|
|
12
|
+
(project: INestiaTransformProject) =>
|
|
13
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
14
|
+
(type: ts.Type): ts.Expression => {
|
|
15
|
+
// GENERATE STRINGIFY PLAN
|
|
16
|
+
const parameter = (
|
|
17
|
+
key: string,
|
|
18
|
+
programmer: (
|
|
19
|
+
project: IProject,
|
|
20
|
+
) => (
|
|
21
|
+
modulo: ts.LeftHandSideExpression,
|
|
22
|
+
) => (type: ts.Type) => ts.ArrowFunction,
|
|
23
|
+
) =>
|
|
24
|
+
ts.factory.createObjectLiteralExpression([
|
|
25
|
+
ts.factory.createPropertyAssignment(
|
|
26
|
+
ts.factory.createIdentifier("type"),
|
|
27
|
+
ts.factory.createStringLiteral(key),
|
|
28
|
+
),
|
|
29
|
+
ts.factory.createPropertyAssignment(
|
|
30
|
+
ts.factory.createIdentifier(key),
|
|
31
|
+
programmer({
|
|
32
|
+
...project,
|
|
33
|
+
options: {}, // use default option
|
|
34
|
+
})(modulo)(type),
|
|
35
|
+
),
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
// RETURNS
|
|
39
|
+
if (project.options.stringify === "is")
|
|
40
|
+
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
41
|
+
else if (project.options.stringify === "validate")
|
|
42
|
+
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
43
|
+
else if (project.options.stringify === "stringify")
|
|
44
|
+
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
45
|
+
else if (project.options.stringify === null)
|
|
46
|
+
return ts.factory.createNull();
|
|
47
|
+
|
|
48
|
+
// ASSERT IS DEFAULT
|
|
49
|
+
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
50
|
+
};
|
|
51
|
+
}
|