@nestia/core 7.0.0-dev.20250607 → 7.0.0
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 +92 -92
- package/package.json +3 -3
- package/src/adaptors/WebSocketAdaptor.ts +429 -429
- 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/HumanRoute.ts +22 -22
- 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 +166 -166
- package/src/decorators/TypedFormData.ts +195 -195
- package/src/decorators/TypedHeaders.ts +64 -64
- package/src/decorators/TypedParam.ts +77 -77
- 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 +22 -22
- package/src/options/INestiaTransformOptions.ts +38 -38
- 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 +142 -142
- package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
- package/src/programmers/TypedHeadersProgrammer.ts +63 -63
- package/src/programmers/TypedParamProgrammer.ts +33 -33
- package/src/programmers/TypedQueryBodyProgrammer.ts +112 -112
- package/src/programmers/TypedQueryProgrammer.ts +114 -114
- package/src/programmers/TypedQueryRouteProgrammer.ts +105 -105
- package/src/programmers/TypedRouteProgrammer.ts +94 -94
- 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,105 +1,105 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
-
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
-
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
|
|
6
|
-
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
|
|
7
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
8
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
9
|
-
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
10
|
-
import { ValidationPipe } from "typia/lib/typings/ValidationPipe";
|
|
11
|
-
|
|
12
|
-
import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
|
|
13
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
14
|
-
import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
|
|
15
|
-
import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
|
|
16
|
-
import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
|
|
17
|
-
import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
|
|
18
|
-
|
|
19
|
-
export namespace TypedQueryRouteProgrammer {
|
|
20
|
-
export const generate = (props: {
|
|
21
|
-
context: INestiaTransformContext;
|
|
22
|
-
modulo: ts.LeftHandSideExpression;
|
|
23
|
-
type: ts.Type;
|
|
24
|
-
}): ts.Expression => {
|
|
25
|
-
// VALIDATE TYPE
|
|
26
|
-
if (props.context.options.llm) {
|
|
27
|
-
const llm: INestiaTransformOptions.ILlm<ILlmSchema.Model> =
|
|
28
|
-
props.context.options.llm;
|
|
29
|
-
const result: ValidationPipe<Metadata, MetadataFactory.IError> =
|
|
30
|
-
MetadataFactory.analyze({
|
|
31
|
-
checker: props.context.checker,
|
|
32
|
-
transformer: props.context.transformer,
|
|
33
|
-
options: {
|
|
34
|
-
escape: false,
|
|
35
|
-
constant: true,
|
|
36
|
-
absorb: true,
|
|
37
|
-
validate: (meta, explore) => {
|
|
38
|
-
const errors: string[] = HttpQueryProgrammer.validate(
|
|
39
|
-
meta,
|
|
40
|
-
explore,
|
|
41
|
-
true,
|
|
42
|
-
);
|
|
43
|
-
errors.push(
|
|
44
|
-
...LlmSchemaProgrammer.validate({
|
|
45
|
-
model: llm.model,
|
|
46
|
-
config: {
|
|
47
|
-
strict: llm.strict,
|
|
48
|
-
recursive: llm.recursive,
|
|
49
|
-
},
|
|
50
|
-
})(meta),
|
|
51
|
-
);
|
|
52
|
-
return errors;
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
collection: new MetadataCollection(),
|
|
56
|
-
type: props.type,
|
|
57
|
-
});
|
|
58
|
-
if (result.success === false)
|
|
59
|
-
throw TransformerError.from({
|
|
60
|
-
code: props.modulo.getText(),
|
|
61
|
-
errors: result.errors,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// GENERATE STRINGIFY PLAN
|
|
66
|
-
const parameter = (
|
|
67
|
-
key: string,
|
|
68
|
-
programmer: (next: {
|
|
69
|
-
context: ITypiaContext;
|
|
70
|
-
modulo: ts.LeftHandSideExpression;
|
|
71
|
-
type: ts.Type;
|
|
72
|
-
}) => ts.ArrowFunction,
|
|
73
|
-
) =>
|
|
74
|
-
ts.factory.createObjectLiteralExpression([
|
|
75
|
-
ts.factory.createPropertyAssignment(
|
|
76
|
-
ts.factory.createIdentifier("type"),
|
|
77
|
-
ts.factory.createStringLiteral(key),
|
|
78
|
-
),
|
|
79
|
-
ts.factory.createPropertyAssignment(
|
|
80
|
-
ts.factory.createIdentifier(key),
|
|
81
|
-
programmer({
|
|
82
|
-
context: {
|
|
83
|
-
...props.context,
|
|
84
|
-
options: {}, // use default option
|
|
85
|
-
},
|
|
86
|
-
modulo: props.modulo,
|
|
87
|
-
type: props.type,
|
|
88
|
-
}),
|
|
89
|
-
),
|
|
90
|
-
]);
|
|
91
|
-
|
|
92
|
-
// RETURNS
|
|
93
|
-
if (props.context.options.stringify === "is")
|
|
94
|
-
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
95
|
-
else if (props.context.options.stringify === "validate")
|
|
96
|
-
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
97
|
-
else if (props.context.options.stringify === "stringify")
|
|
98
|
-
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
99
|
-
else if (props.context.options.stringify === null)
|
|
100
|
-
return ts.factory.createNull();
|
|
101
|
-
|
|
102
|
-
// ASSERT IS DEFAULT
|
|
103
|
-
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
+
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
+
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
|
|
6
|
+
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
|
|
7
|
+
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
8
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
9
|
+
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
10
|
+
import { ValidationPipe } from "typia/lib/typings/ValidationPipe";
|
|
11
|
+
|
|
12
|
+
import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
|
|
13
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
14
|
+
import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
|
|
15
|
+
import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
|
|
16
|
+
import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
|
|
17
|
+
import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
|
|
18
|
+
|
|
19
|
+
export namespace TypedQueryRouteProgrammer {
|
|
20
|
+
export const generate = (props: {
|
|
21
|
+
context: INestiaTransformContext;
|
|
22
|
+
modulo: ts.LeftHandSideExpression;
|
|
23
|
+
type: ts.Type;
|
|
24
|
+
}): ts.Expression => {
|
|
25
|
+
// VALIDATE TYPE
|
|
26
|
+
if (props.context.options.llm) {
|
|
27
|
+
const llm: INestiaTransformOptions.ILlm<ILlmSchema.Model> =
|
|
28
|
+
props.context.options.llm;
|
|
29
|
+
const result: ValidationPipe<Metadata, MetadataFactory.IError> =
|
|
30
|
+
MetadataFactory.analyze({
|
|
31
|
+
checker: props.context.checker,
|
|
32
|
+
transformer: props.context.transformer,
|
|
33
|
+
options: {
|
|
34
|
+
escape: false,
|
|
35
|
+
constant: true,
|
|
36
|
+
absorb: true,
|
|
37
|
+
validate: (meta, explore) => {
|
|
38
|
+
const errors: string[] = HttpQueryProgrammer.validate(
|
|
39
|
+
meta,
|
|
40
|
+
explore,
|
|
41
|
+
true,
|
|
42
|
+
);
|
|
43
|
+
errors.push(
|
|
44
|
+
...LlmSchemaProgrammer.validate({
|
|
45
|
+
model: llm.model,
|
|
46
|
+
config: {
|
|
47
|
+
strict: llm.strict,
|
|
48
|
+
recursive: llm.recursive,
|
|
49
|
+
},
|
|
50
|
+
})(meta),
|
|
51
|
+
);
|
|
52
|
+
return errors;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
collection: new MetadataCollection(),
|
|
56
|
+
type: props.type,
|
|
57
|
+
});
|
|
58
|
+
if (result.success === false)
|
|
59
|
+
throw TransformerError.from({
|
|
60
|
+
code: props.modulo.getText(),
|
|
61
|
+
errors: result.errors,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// GENERATE STRINGIFY PLAN
|
|
66
|
+
const parameter = (
|
|
67
|
+
key: string,
|
|
68
|
+
programmer: (next: {
|
|
69
|
+
context: ITypiaContext;
|
|
70
|
+
modulo: ts.LeftHandSideExpression;
|
|
71
|
+
type: ts.Type;
|
|
72
|
+
}) => ts.ArrowFunction,
|
|
73
|
+
) =>
|
|
74
|
+
ts.factory.createObjectLiteralExpression([
|
|
75
|
+
ts.factory.createPropertyAssignment(
|
|
76
|
+
ts.factory.createIdentifier("type"),
|
|
77
|
+
ts.factory.createStringLiteral(key),
|
|
78
|
+
),
|
|
79
|
+
ts.factory.createPropertyAssignment(
|
|
80
|
+
ts.factory.createIdentifier(key),
|
|
81
|
+
programmer({
|
|
82
|
+
context: {
|
|
83
|
+
...props.context,
|
|
84
|
+
options: {}, // use default option
|
|
85
|
+
},
|
|
86
|
+
modulo: props.modulo,
|
|
87
|
+
type: props.type,
|
|
88
|
+
}),
|
|
89
|
+
),
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
// RETURNS
|
|
93
|
+
if (props.context.options.stringify === "is")
|
|
94
|
+
return parameter("is", HttpIsQuerifyProgrammer.write);
|
|
95
|
+
else if (props.context.options.stringify === "validate")
|
|
96
|
+
return parameter("validate", HttpValidateQuerifyProgrammer.write);
|
|
97
|
+
else if (props.context.options.stringify === "stringify")
|
|
98
|
+
return parameter("stringify", HttpQuerifyProgrammer.write);
|
|
99
|
+
else if (props.context.options.stringify === null)
|
|
100
|
+
return ts.factory.createNull();
|
|
101
|
+
|
|
102
|
+
// ASSERT IS DEFAULT
|
|
103
|
+
return parameter("assert", HttpAssertQuerifyProgrammer.write);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { JsonMetadataFactory } from "typia/lib/factories/JsonMetadataFactory";
|
|
3
|
-
import { JsonAssertStringifyProgrammer } from "typia/lib/programmers/json/JsonAssertStringifyProgrammer";
|
|
4
|
-
import { JsonIsStringifyProgrammer } from "typia/lib/programmers/json/JsonIsStringifyProgrammer";
|
|
5
|
-
import { JsonStringifyProgrammer } from "typia/lib/programmers/json/JsonStringifyProgrammer";
|
|
6
|
-
import { JsonValidateStringifyProgrammer } from "typia/lib/programmers/json/JsonValidateStringifyProgrammer";
|
|
7
|
-
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
|
|
8
|
-
import { IProgrammerProps } from "typia/lib/transformers/IProgrammerProps";
|
|
9
|
-
|
|
10
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
11
|
-
|
|
12
|
-
export namespace TypedRouteProgrammer {
|
|
13
|
-
export const generate = (props: {
|
|
14
|
-
context: INestiaTransformContext;
|
|
15
|
-
modulo: ts.LeftHandSideExpression;
|
|
16
|
-
type: ts.Type;
|
|
17
|
-
}): ts.Expression => {
|
|
18
|
-
// VALIDATE TYPE
|
|
19
|
-
if (props.context.options.llm)
|
|
20
|
-
JsonMetadataFactory.analyze({
|
|
21
|
-
method: "@nestia.core.TypedBody",
|
|
22
|
-
checker: props.context.checker,
|
|
23
|
-
transformer: props.context.transformer,
|
|
24
|
-
type: props.type,
|
|
25
|
-
validate: LlmSchemaProgrammer.validate({
|
|
26
|
-
model: props.context.options.llm.model,
|
|
27
|
-
config: {
|
|
28
|
-
strict: props.context.options.llm.strict,
|
|
29
|
-
recursive: props.context.options.llm.recursive,
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// GENERATE STRINGIFY PLAN
|
|
35
|
-
const parameter = (next: {
|
|
36
|
-
type: string;
|
|
37
|
-
key: string;
|
|
38
|
-
programmer: (next: IProgrammerProps) => ts.Expression;
|
|
39
|
-
}) =>
|
|
40
|
-
ts.factory.createObjectLiteralExpression([
|
|
41
|
-
ts.factory.createPropertyAssignment(
|
|
42
|
-
ts.factory.createIdentifier("type"),
|
|
43
|
-
ts.factory.createStringLiteral(next.type),
|
|
44
|
-
),
|
|
45
|
-
ts.factory.createPropertyAssignment(
|
|
46
|
-
ts.factory.createIdentifier(next.key),
|
|
47
|
-
next.programmer({
|
|
48
|
-
context: {
|
|
49
|
-
...props.context,
|
|
50
|
-
options: {}, // use default option
|
|
51
|
-
},
|
|
52
|
-
modulo: props.modulo,
|
|
53
|
-
type: props.type,
|
|
54
|
-
name: undefined,
|
|
55
|
-
}),
|
|
56
|
-
),
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
// RETURNS
|
|
60
|
-
if (props.context.options.stringify === "is")
|
|
61
|
-
return parameter({
|
|
62
|
-
type: "is",
|
|
63
|
-
key: "is",
|
|
64
|
-
programmer: JsonIsStringifyProgrammer.write,
|
|
65
|
-
});
|
|
66
|
-
else if (props.context.options.stringify === "validate")
|
|
67
|
-
return parameter({
|
|
68
|
-
type: "validate",
|
|
69
|
-
key: "validate",
|
|
70
|
-
programmer: JsonValidateStringifyProgrammer.write,
|
|
71
|
-
});
|
|
72
|
-
else if (props.context.options.stringify === "stringify")
|
|
73
|
-
return parameter({
|
|
74
|
-
type: "stringify",
|
|
75
|
-
key: "stringify",
|
|
76
|
-
programmer: JsonStringifyProgrammer.write,
|
|
77
|
-
});
|
|
78
|
-
else if (props.context.options.stringify === "validate.log")
|
|
79
|
-
return parameter({
|
|
80
|
-
type: "validate.log",
|
|
81
|
-
key: "validate",
|
|
82
|
-
programmer: JsonValidateStringifyProgrammer.write,
|
|
83
|
-
});
|
|
84
|
-
else if (props.context.options.stringify === null)
|
|
85
|
-
return ts.factory.createNull();
|
|
86
|
-
|
|
87
|
-
// ASSERT IS DEFAULT
|
|
88
|
-
return parameter({
|
|
89
|
-
type: "assert",
|
|
90
|
-
key: "assert",
|
|
91
|
-
programmer: JsonAssertStringifyProgrammer.write,
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { JsonMetadataFactory } from "typia/lib/factories/JsonMetadataFactory";
|
|
3
|
+
import { JsonAssertStringifyProgrammer } from "typia/lib/programmers/json/JsonAssertStringifyProgrammer";
|
|
4
|
+
import { JsonIsStringifyProgrammer } from "typia/lib/programmers/json/JsonIsStringifyProgrammer";
|
|
5
|
+
import { JsonStringifyProgrammer } from "typia/lib/programmers/json/JsonStringifyProgrammer";
|
|
6
|
+
import { JsonValidateStringifyProgrammer } from "typia/lib/programmers/json/JsonValidateStringifyProgrammer";
|
|
7
|
+
import { LlmSchemaProgrammer } from "typia/lib/programmers/llm/LlmSchemaProgrammer";
|
|
8
|
+
import { IProgrammerProps } from "typia/lib/transformers/IProgrammerProps";
|
|
9
|
+
|
|
10
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
11
|
+
|
|
12
|
+
export namespace TypedRouteProgrammer {
|
|
13
|
+
export const generate = (props: {
|
|
14
|
+
context: INestiaTransformContext;
|
|
15
|
+
modulo: ts.LeftHandSideExpression;
|
|
16
|
+
type: ts.Type;
|
|
17
|
+
}): ts.Expression => {
|
|
18
|
+
// VALIDATE TYPE
|
|
19
|
+
if (props.context.options.llm)
|
|
20
|
+
JsonMetadataFactory.analyze({
|
|
21
|
+
method: "@nestia.core.TypedBody",
|
|
22
|
+
checker: props.context.checker,
|
|
23
|
+
transformer: props.context.transformer,
|
|
24
|
+
type: props.type,
|
|
25
|
+
validate: LlmSchemaProgrammer.validate({
|
|
26
|
+
model: props.context.options.llm.model,
|
|
27
|
+
config: {
|
|
28
|
+
strict: props.context.options.llm.strict,
|
|
29
|
+
recursive: props.context.options.llm.recursive,
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// GENERATE STRINGIFY PLAN
|
|
35
|
+
const parameter = (next: {
|
|
36
|
+
type: string;
|
|
37
|
+
key: string;
|
|
38
|
+
programmer: (next: IProgrammerProps) => ts.Expression;
|
|
39
|
+
}) =>
|
|
40
|
+
ts.factory.createObjectLiteralExpression([
|
|
41
|
+
ts.factory.createPropertyAssignment(
|
|
42
|
+
ts.factory.createIdentifier("type"),
|
|
43
|
+
ts.factory.createStringLiteral(next.type),
|
|
44
|
+
),
|
|
45
|
+
ts.factory.createPropertyAssignment(
|
|
46
|
+
ts.factory.createIdentifier(next.key),
|
|
47
|
+
next.programmer({
|
|
48
|
+
context: {
|
|
49
|
+
...props.context,
|
|
50
|
+
options: {}, // use default option
|
|
51
|
+
},
|
|
52
|
+
modulo: props.modulo,
|
|
53
|
+
type: props.type,
|
|
54
|
+
name: undefined,
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
// RETURNS
|
|
60
|
+
if (props.context.options.stringify === "is")
|
|
61
|
+
return parameter({
|
|
62
|
+
type: "is",
|
|
63
|
+
key: "is",
|
|
64
|
+
programmer: JsonIsStringifyProgrammer.write,
|
|
65
|
+
});
|
|
66
|
+
else if (props.context.options.stringify === "validate")
|
|
67
|
+
return parameter({
|
|
68
|
+
type: "validate",
|
|
69
|
+
key: "validate",
|
|
70
|
+
programmer: JsonValidateStringifyProgrammer.write,
|
|
71
|
+
});
|
|
72
|
+
else if (props.context.options.stringify === "stringify")
|
|
73
|
+
return parameter({
|
|
74
|
+
type: "stringify",
|
|
75
|
+
key: "stringify",
|
|
76
|
+
programmer: JsonStringifyProgrammer.write,
|
|
77
|
+
});
|
|
78
|
+
else if (props.context.options.stringify === "validate.log")
|
|
79
|
+
return parameter({
|
|
80
|
+
type: "validate.log",
|
|
81
|
+
key: "validate",
|
|
82
|
+
programmer: JsonValidateStringifyProgrammer.write,
|
|
83
|
+
});
|
|
84
|
+
else if (props.context.options.stringify === null)
|
|
85
|
+
return ts.factory.createNull();
|
|
86
|
+
|
|
87
|
+
// ASSERT IS DEFAULT
|
|
88
|
+
return parameter({
|
|
89
|
+
type: "assert",
|
|
90
|
+
key: "assert",
|
|
91
|
+
programmer: JsonAssertStringifyProgrammer.write,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
-
import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
|
|
5
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpAssertQuerifyProgrammer {
|
|
10
|
-
export const write = (props: {
|
|
11
|
-
context: ITypiaContext;
|
|
12
|
-
modulo: ts.LeftHandSideExpression;
|
|
13
|
-
type: ts.Type;
|
|
14
|
-
}): ts.ArrowFunction =>
|
|
15
|
-
ts.factory.createArrowFunction(
|
|
16
|
-
undefined,
|
|
17
|
-
undefined,
|
|
18
|
-
[IdentifierFactory.parameter("input")],
|
|
19
|
-
undefined,
|
|
20
|
-
undefined,
|
|
21
|
-
ts.factory.createBlock([
|
|
22
|
-
StatementFactory.constant({
|
|
23
|
-
name: "assert",
|
|
24
|
-
value: AssertProgrammer.write({
|
|
25
|
-
context: {
|
|
26
|
-
...props.context,
|
|
27
|
-
options: {
|
|
28
|
-
...props.context.options,
|
|
29
|
-
functional: false,
|
|
30
|
-
numeric: false,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
modulo: props.modulo,
|
|
34
|
-
config: {
|
|
35
|
-
equals: false,
|
|
36
|
-
guard: false,
|
|
37
|
-
},
|
|
38
|
-
type: props.type,
|
|
39
|
-
name: undefined,
|
|
40
|
-
}),
|
|
41
|
-
}),
|
|
42
|
-
StatementFactory.constant({
|
|
43
|
-
name: "stringify",
|
|
44
|
-
value: HttpQuerifyProgrammer.write({
|
|
45
|
-
context: {
|
|
46
|
-
...props.context,
|
|
47
|
-
options: {
|
|
48
|
-
...props.context.options,
|
|
49
|
-
functional: false,
|
|
50
|
-
numeric: false,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
modulo: props.modulo,
|
|
54
|
-
type: props.type,
|
|
55
|
-
}),
|
|
56
|
-
}),
|
|
57
|
-
ts.factory.createReturnStatement(
|
|
58
|
-
ts.factory.createCallExpression(
|
|
59
|
-
ts.factory.createIdentifier("stringify"),
|
|
60
|
-
undefined,
|
|
61
|
-
[
|
|
62
|
-
ts.factory.createCallExpression(
|
|
63
|
-
ts.factory.createIdentifier("assert"),
|
|
64
|
-
undefined,
|
|
65
|
-
[ts.factory.createIdentifier("input")],
|
|
66
|
-
),
|
|
67
|
-
],
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
|
-
]),
|
|
71
|
-
);
|
|
72
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
+
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
+
import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
|
|
5
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpAssertQuerifyProgrammer {
|
|
10
|
+
export const write = (props: {
|
|
11
|
+
context: ITypiaContext;
|
|
12
|
+
modulo: ts.LeftHandSideExpression;
|
|
13
|
+
type: ts.Type;
|
|
14
|
+
}): ts.ArrowFunction =>
|
|
15
|
+
ts.factory.createArrowFunction(
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
[IdentifierFactory.parameter("input")],
|
|
19
|
+
undefined,
|
|
20
|
+
undefined,
|
|
21
|
+
ts.factory.createBlock([
|
|
22
|
+
StatementFactory.constant({
|
|
23
|
+
name: "assert",
|
|
24
|
+
value: AssertProgrammer.write({
|
|
25
|
+
context: {
|
|
26
|
+
...props.context,
|
|
27
|
+
options: {
|
|
28
|
+
...props.context.options,
|
|
29
|
+
functional: false,
|
|
30
|
+
numeric: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
modulo: props.modulo,
|
|
34
|
+
config: {
|
|
35
|
+
equals: false,
|
|
36
|
+
guard: false,
|
|
37
|
+
},
|
|
38
|
+
type: props.type,
|
|
39
|
+
name: undefined,
|
|
40
|
+
}),
|
|
41
|
+
}),
|
|
42
|
+
StatementFactory.constant({
|
|
43
|
+
name: "stringify",
|
|
44
|
+
value: HttpQuerifyProgrammer.write({
|
|
45
|
+
context: {
|
|
46
|
+
...props.context,
|
|
47
|
+
options: {
|
|
48
|
+
...props.context.options,
|
|
49
|
+
functional: false,
|
|
50
|
+
numeric: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
modulo: props.modulo,
|
|
54
|
+
type: props.type,
|
|
55
|
+
}),
|
|
56
|
+
}),
|
|
57
|
+
ts.factory.createReturnStatement(
|
|
58
|
+
ts.factory.createCallExpression(
|
|
59
|
+
ts.factory.createIdentifier("stringify"),
|
|
60
|
+
undefined,
|
|
61
|
+
[
|
|
62
|
+
ts.factory.createCallExpression(
|
|
63
|
+
ts.factory.createIdentifier("assert"),
|
|
64
|
+
undefined,
|
|
65
|
+
[ts.factory.createIdentifier("input")],
|
|
66
|
+
),
|
|
67
|
+
],
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
]),
|
|
71
|
+
);
|
|
72
|
+
}
|