@nestia/core 4.3.0 → 4.4.0-dev.20241216
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/LICENSE +21 -21
- package/README.md +87 -87
- package/package.json +5 -5
- package/src/adaptors/WebSocketAdaptor.ts +426 -426
- package/src/decorators/DynamicModule.ts +43 -43
- package/src/decorators/EncryptedBody.ts +101 -101
- package/src/decorators/EncryptedController.ts +38 -38
- package/src/decorators/EncryptedModule.ts +100 -100
- package/src/decorators/EncryptedRoute.ts +219 -219
- package/src/decorators/NoTransformConfigurationError.ts +32 -32
- package/src/decorators/PlainBody.ts +79 -79
- package/src/decorators/SwaggerCustomizer.ts +115 -115
- package/src/decorators/SwaggerExample.ts +100 -100
- package/src/decorators/TypedBody.ts +59 -59
- package/src/decorators/TypedException.ts +128 -128
- package/src/decorators/TypedFormData.ts +195 -195
- package/src/decorators/TypedHeaders.ts +64 -64
- package/src/decorators/TypedParam.ts +66 -66
- package/src/decorators/TypedQuery.ts +245 -245
- package/src/decorators/TypedRoute.ts +214 -214
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/internal/EncryptedConstant.ts +4 -4
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
- package/src/decorators/internal/get_path_and_querify.ts +108 -108
- package/src/decorators/internal/get_path_and_stringify.ts +122 -122
- package/src/decorators/internal/get_text_body.ts +20 -20
- package/src/decorators/internal/headers_to_object.ts +13 -13
- package/src/decorators/internal/is_request_body_undefined.ts +14 -14
- package/src/decorators/internal/load_controller.ts +49 -49
- package/src/decorators/internal/route_error.ts +45 -45
- package/src/decorators/internal/validate_request_body.ts +74 -74
- package/src/decorators/internal/validate_request_form_data.ts +77 -77
- package/src/decorators/internal/validate_request_headers.ts +86 -86
- package/src/decorators/internal/validate_request_query.ts +74 -74
- package/src/index.ts +5 -5
- package/src/module.ts +21 -21
- package/src/options/INestiaTransformOptions.ts +24 -24
- package/src/options/INestiaTransformProject.ts +8 -8
- 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 +30 -30
- package/src/programmers/PlainBodyProgrammer.ts +70 -70
- package/src/programmers/TypedBodyProgrammer.ts +132 -132
- package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
- package/src/programmers/TypedHeadersProgrammer.ts +63 -63
- package/src/programmers/TypedParamProgrammer.ts +30 -30
- package/src/programmers/TypedQueryBodyProgrammer.ts +63 -63
- package/src/programmers/TypedQueryProgrammer.ts +65 -65
- package/src/programmers/TypedQueryRouteProgrammer.ts +56 -56
- package/src/programmers/TypedRouteProgrammer.ts +76 -76
- package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +72 -72
- package/src/programmers/http/HttpIsQuerifyProgrammer.ts +75 -75
- package/src/programmers/http/HttpQuerifyProgrammer.ts +108 -108
- package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +76 -76
- package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
- package/src/transform.ts +35 -35
- package/src/transformers/FileTransformer.ts +110 -110
- package/src/transformers/MethodTransformer.ts +103 -103
- package/src/transformers/NodeTransformer.ts +23 -23
- package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
- package/src/transformers/ParameterTransformer.ts +57 -57
- package/src/transformers/TypedRouteTransformer.ts +85 -85
- package/src/transformers/WebSocketRouteTransformer.ts +120 -120
- package/src/typings/Creator.ts +3 -3
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +7 -7
- package/src/utils/ExceptionManager.ts +112 -112
- package/src/utils/Singleton.ts +20 -20
- package/src/utils/SourceFinder.ts +57 -57
- package/src/utils/VersioningStrategy.ts +27 -27
|
@@ -1,63 +1,63 @@
|
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedHeadersProgrammer {
|
|
11
|
-
export const generate = (props: {
|
|
12
|
-
context: INestiaTransformContext;
|
|
13
|
-
modulo: ts.LeftHandSideExpression;
|
|
14
|
-
type: ts.Type;
|
|
15
|
-
}): ts.Expression => {
|
|
16
|
-
// GENERATE VALIDATION PLAN
|
|
17
|
-
const parameter =
|
|
18
|
-
(key: IRequestHeadersValidator<any>["type"]) =>
|
|
19
|
-
(
|
|
20
|
-
programmer: (next: {
|
|
21
|
-
context: ITypiaContext;
|
|
22
|
-
modulo: ts.LeftHandSideExpression;
|
|
23
|
-
type: ts.Type;
|
|
24
|
-
name: string | undefined;
|
|
25
|
-
}) => ts.Expression,
|
|
26
|
-
) =>
|
|
27
|
-
ts.factory.createObjectLiteralExpression([
|
|
28
|
-
ts.factory.createPropertyAssignment(
|
|
29
|
-
ts.factory.createIdentifier("type"),
|
|
30
|
-
ts.factory.createStringLiteral(key),
|
|
31
|
-
),
|
|
32
|
-
ts.factory.createPropertyAssignment(
|
|
33
|
-
ts.factory.createIdentifier(key),
|
|
34
|
-
programmer({
|
|
35
|
-
context: {
|
|
36
|
-
...props.context,
|
|
37
|
-
options: {
|
|
38
|
-
numeric: false,
|
|
39
|
-
finite: false,
|
|
40
|
-
functional: false,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
modulo: props.modulo,
|
|
44
|
-
type: props.type,
|
|
45
|
-
name: undefined,
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
// RETURNS
|
|
51
|
-
const category = props.context.options.validate;
|
|
52
|
-
if (category === "is" || category === "equals")
|
|
53
|
-
return parameter("is")(HttpIsHeadersProgrammer.write);
|
|
54
|
-
else if (
|
|
55
|
-
category === "validate" ||
|
|
56
|
-
category === "validateEquals" ||
|
|
57
|
-
category === "validateClone" ||
|
|
58
|
-
category === "validatePrune"
|
|
59
|
-
)
|
|
60
|
-
return parameter("validate")(HttpValidateHeadersProgrammer.write);
|
|
61
|
-
return parameter("assert")(HttpAssertHeadersProgrammer.write);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedHeadersProgrammer {
|
|
11
|
+
export const generate = (props: {
|
|
12
|
+
context: INestiaTransformContext;
|
|
13
|
+
modulo: ts.LeftHandSideExpression;
|
|
14
|
+
type: ts.Type;
|
|
15
|
+
}): ts.Expression => {
|
|
16
|
+
// GENERATE VALIDATION PLAN
|
|
17
|
+
const parameter =
|
|
18
|
+
(key: IRequestHeadersValidator<any>["type"]) =>
|
|
19
|
+
(
|
|
20
|
+
programmer: (next: {
|
|
21
|
+
context: ITypiaContext;
|
|
22
|
+
modulo: ts.LeftHandSideExpression;
|
|
23
|
+
type: ts.Type;
|
|
24
|
+
name: string | undefined;
|
|
25
|
+
}) => ts.Expression,
|
|
26
|
+
) =>
|
|
27
|
+
ts.factory.createObjectLiteralExpression([
|
|
28
|
+
ts.factory.createPropertyAssignment(
|
|
29
|
+
ts.factory.createIdentifier("type"),
|
|
30
|
+
ts.factory.createStringLiteral(key),
|
|
31
|
+
),
|
|
32
|
+
ts.factory.createPropertyAssignment(
|
|
33
|
+
ts.factory.createIdentifier(key),
|
|
34
|
+
programmer({
|
|
35
|
+
context: {
|
|
36
|
+
...props.context,
|
|
37
|
+
options: {
|
|
38
|
+
numeric: false,
|
|
39
|
+
finite: false,
|
|
40
|
+
functional: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
modulo: props.modulo,
|
|
44
|
+
type: props.type,
|
|
45
|
+
name: undefined,
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// RETURNS
|
|
51
|
+
const category = props.context.options.validate;
|
|
52
|
+
if (category === "is" || category === "equals")
|
|
53
|
+
return parameter("is")(HttpIsHeadersProgrammer.write);
|
|
54
|
+
else if (
|
|
55
|
+
category === "validate" ||
|
|
56
|
+
category === "validateEquals" ||
|
|
57
|
+
category === "validateClone" ||
|
|
58
|
+
category === "validatePrune"
|
|
59
|
+
)
|
|
60
|
+
return parameter("validate")(HttpValidateHeadersProgrammer.write);
|
|
61
|
+
return parameter("assert")(HttpAssertHeadersProgrammer.write);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
5
|
-
|
|
6
|
-
export namespace TypedParamProgrammer {
|
|
7
|
-
export const generate = (props: {
|
|
8
|
-
context: INestiaTransformContext;
|
|
9
|
-
modulo: ts.LeftHandSideExpression;
|
|
10
|
-
arguments: readonly ts.Expression[];
|
|
11
|
-
type: ts.Type;
|
|
12
|
-
}): readonly ts.Expression[] => {
|
|
13
|
-
// ALREADY BEING TRANSFORMED
|
|
14
|
-
if (props.arguments.length !== 1) return props.arguments;
|
|
15
|
-
return [
|
|
16
|
-
props.arguments[0],
|
|
17
|
-
HttpParameterProgrammer.write({
|
|
18
|
-
context: {
|
|
19
|
-
...props.context,
|
|
20
|
-
options: {
|
|
21
|
-
numeric: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
modulo: props.modulo,
|
|
25
|
-
type: props.type,
|
|
26
|
-
name: undefined,
|
|
27
|
-
}),
|
|
28
|
-
];
|
|
29
|
-
};
|
|
30
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
5
|
+
|
|
6
|
+
export namespace TypedParamProgrammer {
|
|
7
|
+
export const generate = (props: {
|
|
8
|
+
context: INestiaTransformContext;
|
|
9
|
+
modulo: ts.LeftHandSideExpression;
|
|
10
|
+
arguments: readonly ts.Expression[];
|
|
11
|
+
type: ts.Type;
|
|
12
|
+
}): readonly ts.Expression[] => {
|
|
13
|
+
// ALREADY BEING TRANSFORMED
|
|
14
|
+
if (props.arguments.length !== 1) return props.arguments;
|
|
15
|
+
return [
|
|
16
|
+
props.arguments[0],
|
|
17
|
+
HttpParameterProgrammer.write({
|
|
18
|
+
context: {
|
|
19
|
+
...props.context,
|
|
20
|
+
options: {
|
|
21
|
+
numeric: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
modulo: props.modulo,
|
|
25
|
+
type: props.type,
|
|
26
|
+
name: undefined,
|
|
27
|
+
}),
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedQueryBodyProgrammer {
|
|
11
|
-
export const generate = (props: {
|
|
12
|
-
context: INestiaTransformContext;
|
|
13
|
-
modulo: ts.LeftHandSideExpression;
|
|
14
|
-
type: ts.Type;
|
|
15
|
-
}): ts.ObjectLiteralExpression => {
|
|
16
|
-
// GENERATE VALIDATION PLAN
|
|
17
|
-
const parameter =
|
|
18
|
-
(key: IRequestQueryValidator<any>["type"]) =>
|
|
19
|
-
(
|
|
20
|
-
programmer: (next: {
|
|
21
|
-
context: ITypiaContext;
|
|
22
|
-
modulo: ts.LeftHandSideExpression;
|
|
23
|
-
type: ts.Type;
|
|
24
|
-
name: string | undefined;
|
|
25
|
-
}) => ts.Expression,
|
|
26
|
-
) =>
|
|
27
|
-
ts.factory.createObjectLiteralExpression([
|
|
28
|
-
ts.factory.createPropertyAssignment(
|
|
29
|
-
ts.factory.createIdentifier("type"),
|
|
30
|
-
ts.factory.createStringLiteral(key),
|
|
31
|
-
),
|
|
32
|
-
ts.factory.createPropertyAssignment(
|
|
33
|
-
ts.factory.createIdentifier(key),
|
|
34
|
-
programmer({
|
|
35
|
-
context: {
|
|
36
|
-
...props.context,
|
|
37
|
-
options: {
|
|
38
|
-
numeric: false,
|
|
39
|
-
finite: false,
|
|
40
|
-
functional: false,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
modulo: props.modulo,
|
|
44
|
-
type: props.type,
|
|
45
|
-
name: undefined,
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
// RETURNS
|
|
51
|
-
const category = props.context.options.validate;
|
|
52
|
-
if (category === "is" || category === "equals")
|
|
53
|
-
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
54
|
-
else if (
|
|
55
|
-
category === "validate" ||
|
|
56
|
-
category === "validateEquals" ||
|
|
57
|
-
category === "validateClone" ||
|
|
58
|
-
category === "validatePrune"
|
|
59
|
-
)
|
|
60
|
-
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
61
|
-
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
62
|
-
};
|
|
63
|
-
}
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedQueryBodyProgrammer {
|
|
11
|
+
export const generate = (props: {
|
|
12
|
+
context: INestiaTransformContext;
|
|
13
|
+
modulo: ts.LeftHandSideExpression;
|
|
14
|
+
type: ts.Type;
|
|
15
|
+
}): ts.ObjectLiteralExpression => {
|
|
16
|
+
// GENERATE VALIDATION PLAN
|
|
17
|
+
const parameter =
|
|
18
|
+
(key: IRequestQueryValidator<any>["type"]) =>
|
|
19
|
+
(
|
|
20
|
+
programmer: (next: {
|
|
21
|
+
context: ITypiaContext;
|
|
22
|
+
modulo: ts.LeftHandSideExpression;
|
|
23
|
+
type: ts.Type;
|
|
24
|
+
name: string | undefined;
|
|
25
|
+
}) => ts.Expression,
|
|
26
|
+
) =>
|
|
27
|
+
ts.factory.createObjectLiteralExpression([
|
|
28
|
+
ts.factory.createPropertyAssignment(
|
|
29
|
+
ts.factory.createIdentifier("type"),
|
|
30
|
+
ts.factory.createStringLiteral(key),
|
|
31
|
+
),
|
|
32
|
+
ts.factory.createPropertyAssignment(
|
|
33
|
+
ts.factory.createIdentifier(key),
|
|
34
|
+
programmer({
|
|
35
|
+
context: {
|
|
36
|
+
...props.context,
|
|
37
|
+
options: {
|
|
38
|
+
numeric: false,
|
|
39
|
+
finite: false,
|
|
40
|
+
functional: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
modulo: props.modulo,
|
|
44
|
+
type: props.type,
|
|
45
|
+
name: undefined,
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// RETURNS
|
|
51
|
+
const category = props.context.options.validate;
|
|
52
|
+
if (category === "is" || category === "equals")
|
|
53
|
+
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
54
|
+
else if (
|
|
55
|
+
category === "validate" ||
|
|
56
|
+
category === "validateEquals" ||
|
|
57
|
+
category === "validateClone" ||
|
|
58
|
+
category === "validatePrune"
|
|
59
|
+
)
|
|
60
|
+
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
61
|
+
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -1,65 +1,65 @@
|
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
-
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
-
|
|
10
|
-
export namespace TypedQueryProgrammer {
|
|
11
|
-
export const generate = (props: {
|
|
12
|
-
context: INestiaTransformContext;
|
|
13
|
-
modulo: ts.LeftHandSideExpression;
|
|
14
|
-
type: ts.Type;
|
|
15
|
-
}): ts.Expression => {
|
|
16
|
-
// GENERATE VALIDATION PLAN
|
|
17
|
-
const parameter =
|
|
18
|
-
(key: IRequestQueryValidator<any>["type"]) =>
|
|
19
|
-
(
|
|
20
|
-
programmer: (next: {
|
|
21
|
-
context: ITypiaContext;
|
|
22
|
-
modulo: ts.LeftHandSideExpression;
|
|
23
|
-
type: ts.Type;
|
|
24
|
-
name: string | undefined;
|
|
25
|
-
allowOptional: boolean;
|
|
26
|
-
}) => ts.Expression,
|
|
27
|
-
) =>
|
|
28
|
-
ts.factory.createObjectLiteralExpression([
|
|
29
|
-
ts.factory.createPropertyAssignment(
|
|
30
|
-
ts.factory.createIdentifier("type"),
|
|
31
|
-
ts.factory.createStringLiteral(key),
|
|
32
|
-
),
|
|
33
|
-
ts.factory.createPropertyAssignment(
|
|
34
|
-
ts.factory.createIdentifier(key),
|
|
35
|
-
programmer({
|
|
36
|
-
context: {
|
|
37
|
-
...props.context,
|
|
38
|
-
options: {
|
|
39
|
-
numeric: false,
|
|
40
|
-
finite: false,
|
|
41
|
-
functional: false,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
modulo: props.modulo,
|
|
45
|
-
type: props.type,
|
|
46
|
-
name: undefined,
|
|
47
|
-
allowOptional: true,
|
|
48
|
-
}),
|
|
49
|
-
),
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
// RETURNS
|
|
53
|
-
const category = props.context.options.validate;
|
|
54
|
-
if (category === "is" || category === "equals")
|
|
55
|
-
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
56
|
-
else if (
|
|
57
|
-
category === "validate" ||
|
|
58
|
-
category === "validateEquals" ||
|
|
59
|
-
category === "validateClone" ||
|
|
60
|
-
category === "validatePrune"
|
|
61
|
-
)
|
|
62
|
-
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
63
|
-
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
8
|
+
import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
|
|
9
|
+
|
|
10
|
+
export namespace TypedQueryProgrammer {
|
|
11
|
+
export const generate = (props: {
|
|
12
|
+
context: INestiaTransformContext;
|
|
13
|
+
modulo: ts.LeftHandSideExpression;
|
|
14
|
+
type: ts.Type;
|
|
15
|
+
}): ts.Expression => {
|
|
16
|
+
// GENERATE VALIDATION PLAN
|
|
17
|
+
const parameter =
|
|
18
|
+
(key: IRequestQueryValidator<any>["type"]) =>
|
|
19
|
+
(
|
|
20
|
+
programmer: (next: {
|
|
21
|
+
context: ITypiaContext;
|
|
22
|
+
modulo: ts.LeftHandSideExpression;
|
|
23
|
+
type: ts.Type;
|
|
24
|
+
name: string | undefined;
|
|
25
|
+
allowOptional: boolean;
|
|
26
|
+
}) => ts.Expression,
|
|
27
|
+
) =>
|
|
28
|
+
ts.factory.createObjectLiteralExpression([
|
|
29
|
+
ts.factory.createPropertyAssignment(
|
|
30
|
+
ts.factory.createIdentifier("type"),
|
|
31
|
+
ts.factory.createStringLiteral(key),
|
|
32
|
+
),
|
|
33
|
+
ts.factory.createPropertyAssignment(
|
|
34
|
+
ts.factory.createIdentifier(key),
|
|
35
|
+
programmer({
|
|
36
|
+
context: {
|
|
37
|
+
...props.context,
|
|
38
|
+
options: {
|
|
39
|
+
numeric: false,
|
|
40
|
+
finite: false,
|
|
41
|
+
functional: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
modulo: props.modulo,
|
|
45
|
+
type: props.type,
|
|
46
|
+
name: undefined,
|
|
47
|
+
allowOptional: true,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
// RETURNS
|
|
53
|
+
const category = props.context.options.validate;
|
|
54
|
+
if (category === "is" || category === "equals")
|
|
55
|
+
return parameter("is")(HttpIsQueryProgrammer.write);
|
|
56
|
+
else if (
|
|
57
|
+
category === "validate" ||
|
|
58
|
+
category === "validateEquals" ||
|
|
59
|
+
category === "validateClone" ||
|
|
60
|
+
category === "validatePrune"
|
|
61
|
+
)
|
|
62
|
+
return parameter("validate")(HttpValidateQueryProgrammer.write);
|
|
63
|
+
return parameter("assert")(HttpAssertQueryProgrammer.write);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformContext } 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 = (props: {
|
|
12
|
-
context: INestiaTransformContext;
|
|
13
|
-
modulo: ts.LeftHandSideExpression;
|
|
14
|
-
type: ts.Type;
|
|
15
|
-
}): ts.Expression => {
|
|
16
|
-
// GENERATE STRINGIFY PLAN
|
|
17
|
-
const parameter = (
|
|
18
|
-
key: string,
|
|
19
|
-
programmer: (next: {
|
|
20
|
-
context: ITypiaContext;
|
|
21
|
-
modulo: ts.LeftHandSideExpression;
|
|
22
|
-
type: ts.Type;
|
|
23
|
-
}) => 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
|
-
context: {
|
|
34
|
-
...props.context,
|
|
35
|
-
options: {}, // use default option
|
|
36
|
-
},
|
|
37
|
-
modulo: props.modulo,
|
|
38
|
-
type: props.type,
|
|
39
|
-
}),
|
|
40
|
-
),
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
// RETURNS
|
|
44
|
-
if (props.context.options.stringify === "is")
|
|
45
|
-
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
46
|
-
else if (props.context.options.stringify === "validate")
|
|
47
|
-
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
48
|
-
else if (props.context.options.stringify === "stringify")
|
|
49
|
-
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
50
|
-
else if (props.context.options.stringify === null)
|
|
51
|
-
return ts.factory.createNull();
|
|
52
|
-
|
|
53
|
-
// ASSERT IS DEFAULT
|
|
54
|
-
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformContext } 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 = (props: {
|
|
12
|
+
context: INestiaTransformContext;
|
|
13
|
+
modulo: ts.LeftHandSideExpression;
|
|
14
|
+
type: ts.Type;
|
|
15
|
+
}): ts.Expression => {
|
|
16
|
+
// GENERATE STRINGIFY PLAN
|
|
17
|
+
const parameter = (
|
|
18
|
+
key: string,
|
|
19
|
+
programmer: (next: {
|
|
20
|
+
context: ITypiaContext;
|
|
21
|
+
modulo: ts.LeftHandSideExpression;
|
|
22
|
+
type: ts.Type;
|
|
23
|
+
}) => 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
|
+
context: {
|
|
34
|
+
...props.context,
|
|
35
|
+
options: {}, // use default option
|
|
36
|
+
},
|
|
37
|
+
modulo: props.modulo,
|
|
38
|
+
type: props.type,
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// RETURNS
|
|
44
|
+
if (props.context.options.stringify === "is")
|
|
45
|
+
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
46
|
+
else if (props.context.options.stringify === "validate")
|
|
47
|
+
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
48
|
+
else if (props.context.options.stringify === "stringify")
|
|
49
|
+
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
50
|
+
else if (props.context.options.stringify === null)
|
|
51
|
+
return ts.factory.createNull();
|
|
52
|
+
|
|
53
|
+
// ASSERT IS DEFAULT
|
|
54
|
+
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
55
|
+
};
|
|
56
|
+
}
|