@nestia/core 12.0.0-rc.2 → 12.0.0-rc.3
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/MIGRATION.md +138 -169
- package/lib/decorators/NoTransformConfigurationError.js +5 -5
- package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
- package/native/cmd/ttsc-nestia/main.go +11 -11
- package/native/go.mod +32 -32
- package/native/go.sum +54 -54
- package/native/plugin/plan.go +102 -102
- package/native/transform/ast.go +32 -32
- package/native/transform/build.go +388 -380
- package/native/transform/cleanup.go +408 -408
- package/native/transform/contributor.go +97 -97
- package/native/transform/core_querify.go +231 -231
- package/native/transform/core_transform.go +1996 -1996
- package/native/transform/core_websocket.go +115 -115
- package/native/transform/exports.go +13 -13
- package/native/transform/mcp_transform.go +414 -414
- package/native/transform/node_transform.go +357 -357
- package/native/transform/path_rewrite.go +285 -285
- package/native/transform/printer.go +244 -244
- package/native/transform/rewrite.go +668 -668
- package/native/transform/run.go +73 -73
- package/native/transform/transform.go +336 -336
- package/native/transform/typia_fast.go +375 -352
- package/native/transform/typia_replacement.go +24 -24
- package/native/transform.cjs +43 -43
- package/package.json +9 -9
- package/src/adaptors/McpAdaptor.ts +276 -276
- package/src/adaptors/WebSocketAdaptor.ts +429 -429
- package/src/decorators/DynamicModule.ts +44 -44
- package/src/decorators/EncryptedBody.ts +97 -97
- package/src/decorators/EncryptedController.ts +40 -40
- package/src/decorators/EncryptedModule.ts +98 -98
- package/src/decorators/EncryptedRoute.ts +213 -213
- package/src/decorators/HumanRoute.ts +21 -21
- package/src/decorators/McpRoute.ts +154 -154
- package/src/decorators/NoTransformConfigurationError.ts +40 -40
- package/src/decorators/PlainBody.ts +76 -76
- package/src/decorators/SwaggerCustomizer.ts +97 -97
- package/src/decorators/SwaggerExample.ts +180 -180
- package/src/decorators/TypedBody.ts +57 -57
- package/src/decorators/TypedException.ts +147 -147
- package/src/decorators/TypedFormData.ts +187 -187
- package/src/decorators/TypedHeaders.ts +66 -66
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +234 -234
- package/src/decorators/TypedRoute.ts +198 -198
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/doNotThrowTransformError.ts +5 -5
- package/src/decorators/internal/EncryptedConstant.ts +2 -2
- package/src/decorators/internal/IMcpRouteReflect.ts +40 -40
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/get_path_and_querify.ts +94 -94
- package/src/decorators/internal/get_path_and_stringify.ts +110 -110
- package/src/decorators/internal/get_text_body.ts +16 -16
- package/src/decorators/internal/headers_to_object.ts +11 -11
- package/src/decorators/internal/is_request_body_undefined.ts +12 -12
- package/src/decorators/internal/load_controller.ts +94 -94
- package/src/decorators/internal/route_error.ts +43 -43
- package/src/decorators/internal/validate_request_body.ts +64 -64
- package/src/decorators/internal/validate_request_form_data.ts +67 -67
- package/src/decorators/internal/validate_request_headers.ts +76 -76
- package/src/decorators/internal/validate_request_query.ts +83 -83
- package/src/index.ts +5 -5
- package/src/module.ts +25 -25
- 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/transform.ts +26 -26
- 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 +115 -115
- package/src/utils/Singleton.ts +16 -16
- package/src/utils/SourceFinder.ts +54 -54
- package/src/utils/VersioningStrategy.ts +27 -27
- package/README.md +0 -93
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
import { IEncryptionPassword } from "@nestia/fetcher";
|
|
2
|
-
import { AesPkcs5 } from "@nestia/fetcher/lib/AesPkcs5";
|
|
3
|
-
import {
|
|
4
|
-
CallHandler,
|
|
5
|
-
Delete,
|
|
6
|
-
ExecutionContext,
|
|
7
|
-
Get,
|
|
8
|
-
NestInterceptor,
|
|
9
|
-
Patch,
|
|
10
|
-
Post,
|
|
11
|
-
Put,
|
|
12
|
-
UseInterceptors,
|
|
13
|
-
applyDecorators,
|
|
14
|
-
} from "@nestjs/common";
|
|
15
|
-
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
16
|
-
import express from "express";
|
|
17
|
-
import { catchError, map } from "rxjs/operators";
|
|
18
|
-
import typia from "typia";
|
|
19
|
-
|
|
20
|
-
import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
|
|
21
|
-
import { Singleton } from "../utils/Singleton";
|
|
22
|
-
import { TypedRoute } from "./TypedRoute";
|
|
23
|
-
import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
|
|
24
|
-
import { get_path_and_stringify } from "./internal/get_path_and_stringify";
|
|
25
|
-
import { headers_to_object } from "./internal/headers_to_object";
|
|
26
|
-
import { route_error } from "./internal/route_error";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Encrypted router decorator functions.
|
|
30
|
-
*
|
|
31
|
-
* `EncryptedRoute` is a module containing router decorator functions which
|
|
32
|
-
* encrypts response body data through AES-128/256 encryption. Furthermore, they
|
|
33
|
-
* can boost up JSON string conversion speed about 50x times faster than
|
|
34
|
-
* `class-transformer`, even type safe through
|
|
35
|
-
* [typia](https://github.com/samchon/typia).
|
|
36
|
-
*
|
|
37
|
-
* For reference, if you try to invalid data that is not following the promised
|
|
38
|
-
* type `T`, 500 internal server error would be thrown. Also, as
|
|
39
|
-
* `EncryptedRoute` composes JSON string through `typia.assertStringify<T>()`
|
|
40
|
-
* function, it is not possible to modify response data through interceptors.
|
|
41
|
-
*
|
|
42
|
-
* - AES-128/256
|
|
43
|
-
* - CBC mode
|
|
44
|
-
* - PKCS #5 Padding
|
|
45
|
-
* - Base64 Encoding
|
|
46
|
-
*
|
|
47
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
48
|
-
*/
|
|
49
|
-
export namespace EncryptedRoute {
|
|
50
|
-
/**
|
|
51
|
-
* Encrypted router decorator function for the GET method.
|
|
52
|
-
*
|
|
53
|
-
* @param paths Path(s) of the HTTP request
|
|
54
|
-
* @returns Method decorator
|
|
55
|
-
*/
|
|
56
|
-
export const Get = Generator("Get");
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Encrypted router decorator function for the GET method.
|
|
60
|
-
*
|
|
61
|
-
* @param paths Path(s) of the HTTP request
|
|
62
|
-
* @returns Method decorator
|
|
63
|
-
*/
|
|
64
|
-
export const Post = Generator("Post");
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Encrypted router decorator function for the PATCH method.
|
|
68
|
-
*
|
|
69
|
-
* @param path Path of the HTTP request
|
|
70
|
-
* @returns Method decorator
|
|
71
|
-
*/
|
|
72
|
-
export const Patch = Generator("Patch");
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Encrypted router decorator function for the PUT method.
|
|
76
|
-
*
|
|
77
|
-
* @param path Path of the HTTP request
|
|
78
|
-
* @returns Method decorator
|
|
79
|
-
*/
|
|
80
|
-
export const Put = Generator("Put");
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Encrypted router decorator function for the DELETE method.
|
|
84
|
-
*
|
|
85
|
-
* @param path Path of the HTTP request
|
|
86
|
-
* @returns Method decorator
|
|
87
|
-
*/
|
|
88
|
-
export const Delete = Generator("Delete");
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Set the logger function for the response validation failure.
|
|
92
|
-
*
|
|
93
|
-
* If you've configured the transformation option to `validate.log` in the
|
|
94
|
-
* `tsconfig.json` file, then the error log information of the response
|
|
95
|
-
* validation failure would be logged through this function instead of
|
|
96
|
-
* throwing the 400 bad request error.
|
|
97
|
-
*
|
|
98
|
-
* By the way, be careful. If you've configured the response transformation
|
|
99
|
-
* option to be `validate.log`, client may get wrong response data. Therefore,
|
|
100
|
-
* this way is not recommended in the common backend server case.
|
|
101
|
-
*
|
|
102
|
-
* @default console.log
|
|
103
|
-
* @param func Logger function
|
|
104
|
-
*/
|
|
105
|
-
export function setValidateErrorLogger(
|
|
106
|
-
func: (log: IValidateErrorLog) => void,
|
|
107
|
-
): void {
|
|
108
|
-
TypedRoute.setValidateErrorLogger(func);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
|
|
112
|
-
|
|
113
|
-
/** @internal */
|
|
114
|
-
function Generator(method: "Get" | "Post" | "Put" | "Patch" | "Delete") {
|
|
115
|
-
function route(path?: string | string[]): MethodDecorator;
|
|
116
|
-
function route<T>(
|
|
117
|
-
stringify?: IResponseBodyStringifier<T> | null,
|
|
118
|
-
): MethodDecorator;
|
|
119
|
-
function route<T>(
|
|
120
|
-
path: string | string[],
|
|
121
|
-
stringify?: IResponseBodyStringifier<T> | null,
|
|
122
|
-
): MethodDecorator;
|
|
123
|
-
|
|
124
|
-
function route(...args: any[]): MethodDecorator {
|
|
125
|
-
const [path, stringify] = get_path_and_stringify(
|
|
126
|
-
() => TypedRoute.__logger,
|
|
127
|
-
)(`EncryptedRoute.${method}`)(...args);
|
|
128
|
-
return applyDecorators(
|
|
129
|
-
ROUTERS[method](path),
|
|
130
|
-
UseInterceptors(new EncryptedRouteInterceptor(method, stringify)),
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
return route;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
for (const method of [
|
|
138
|
-
typia.json.isStringify,
|
|
139
|
-
typia.json.assertStringify,
|
|
140
|
-
typia.json.validateStringify,
|
|
141
|
-
typia.json.stringify,
|
|
142
|
-
])
|
|
143
|
-
for (const [key, value] of Object.entries(method))
|
|
144
|
-
for (const deco of [
|
|
145
|
-
EncryptedRoute.Get,
|
|
146
|
-
EncryptedRoute.Delete,
|
|
147
|
-
EncryptedRoute.Post,
|
|
148
|
-
EncryptedRoute.Put,
|
|
149
|
-
EncryptedRoute.Patch,
|
|
150
|
-
])
|
|
151
|
-
(deco as any)[key] = value;
|
|
152
|
-
|
|
153
|
-
/** @internal */
|
|
154
|
-
class EncryptedRouteInterceptor implements NestInterceptor {
|
|
155
|
-
public constructor(
|
|
156
|
-
private readonly method: string,
|
|
157
|
-
private readonly stringify: (
|
|
158
|
-
input: any,
|
|
159
|
-
method: string,
|
|
160
|
-
path: string,
|
|
161
|
-
) => string,
|
|
162
|
-
) {}
|
|
163
|
-
|
|
164
|
-
public intercept(context: ExecutionContext, next: CallHandler) {
|
|
165
|
-
const http: HttpArgumentsHost = context.switchToHttp();
|
|
166
|
-
return next.handle().pipe(
|
|
167
|
-
map((value) => {
|
|
168
|
-
const param:
|
|
169
|
-
| IEncryptionPassword
|
|
170
|
-
| IEncryptionPassword.Closure
|
|
171
|
-
| undefined = Reflect.getMetadata(
|
|
172
|
-
ENCRYPTION_METADATA_KEY,
|
|
173
|
-
context.getClass(),
|
|
174
|
-
);
|
|
175
|
-
if (!param)
|
|
176
|
-
return Error(
|
|
177
|
-
`Error on EncryptedRoute.${this.method}(): no password found.`,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
const request: express.Request = http.getRequest();
|
|
181
|
-
const headers: Singleton<Record<string, string>> = new Singleton(() =>
|
|
182
|
-
headers_to_object(request.headers),
|
|
183
|
-
);
|
|
184
|
-
const body: string | undefined = this.stringify(
|
|
185
|
-
value,
|
|
186
|
-
request.method,
|
|
187
|
-
request.url,
|
|
188
|
-
);
|
|
189
|
-
const password: IEncryptionPassword =
|
|
190
|
-
typeof param === "function"
|
|
191
|
-
? param({
|
|
192
|
-
headers: headers.get(),
|
|
193
|
-
body,
|
|
194
|
-
direction: "encode",
|
|
195
|
-
})
|
|
196
|
-
: param;
|
|
197
|
-
|
|
198
|
-
if (body === undefined) return body;
|
|
199
|
-
return AesPkcs5.encrypt(body, password.key, password.iv);
|
|
200
|
-
}),
|
|
201
|
-
catchError((err) => route_error(http.getRequest(), err)),
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/** @internal */
|
|
207
|
-
const ROUTERS = {
|
|
208
|
-
Get,
|
|
209
|
-
Post,
|
|
210
|
-
Put,
|
|
211
|
-
Patch,
|
|
212
|
-
Delete,
|
|
213
|
-
};
|
|
1
|
+
import { IEncryptionPassword } from "@nestia/fetcher";
|
|
2
|
+
import { AesPkcs5 } from "@nestia/fetcher/lib/AesPkcs5";
|
|
3
|
+
import {
|
|
4
|
+
CallHandler,
|
|
5
|
+
Delete,
|
|
6
|
+
ExecutionContext,
|
|
7
|
+
Get,
|
|
8
|
+
NestInterceptor,
|
|
9
|
+
Patch,
|
|
10
|
+
Post,
|
|
11
|
+
Put,
|
|
12
|
+
UseInterceptors,
|
|
13
|
+
applyDecorators,
|
|
14
|
+
} from "@nestjs/common";
|
|
15
|
+
import { HttpArgumentsHost } from "@nestjs/common/interfaces";
|
|
16
|
+
import express from "express";
|
|
17
|
+
import { catchError, map } from "rxjs/operators";
|
|
18
|
+
import typia from "typia";
|
|
19
|
+
|
|
20
|
+
import { IResponseBodyStringifier } from "../options/IResponseBodyStringifier";
|
|
21
|
+
import { Singleton } from "../utils/Singleton";
|
|
22
|
+
import { TypedRoute } from "./TypedRoute";
|
|
23
|
+
import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
|
|
24
|
+
import { get_path_and_stringify } from "./internal/get_path_and_stringify";
|
|
25
|
+
import { headers_to_object } from "./internal/headers_to_object";
|
|
26
|
+
import { route_error } from "./internal/route_error";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Encrypted router decorator functions.
|
|
30
|
+
*
|
|
31
|
+
* `EncryptedRoute` is a module containing router decorator functions which
|
|
32
|
+
* encrypts response body data through AES-128/256 encryption. Furthermore, they
|
|
33
|
+
* can boost up JSON string conversion speed about 50x times faster than
|
|
34
|
+
* `class-transformer`, even type safe through
|
|
35
|
+
* [typia](https://github.com/samchon/typia).
|
|
36
|
+
*
|
|
37
|
+
* For reference, if you try to invalid data that is not following the promised
|
|
38
|
+
* type `T`, 500 internal server error would be thrown. Also, as
|
|
39
|
+
* `EncryptedRoute` composes JSON string through `typia.assertStringify<T>()`
|
|
40
|
+
* function, it is not possible to modify response data through interceptors.
|
|
41
|
+
*
|
|
42
|
+
* - AES-128/256
|
|
43
|
+
* - CBC mode
|
|
44
|
+
* - PKCS #5 Padding
|
|
45
|
+
* - Base64 Encoding
|
|
46
|
+
*
|
|
47
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
48
|
+
*/
|
|
49
|
+
export namespace EncryptedRoute {
|
|
50
|
+
/**
|
|
51
|
+
* Encrypted router decorator function for the GET method.
|
|
52
|
+
*
|
|
53
|
+
* @param paths Path(s) of the HTTP request
|
|
54
|
+
* @returns Method decorator
|
|
55
|
+
*/
|
|
56
|
+
export const Get = Generator("Get");
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Encrypted router decorator function for the GET method.
|
|
60
|
+
*
|
|
61
|
+
* @param paths Path(s) of the HTTP request
|
|
62
|
+
* @returns Method decorator
|
|
63
|
+
*/
|
|
64
|
+
export const Post = Generator("Post");
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Encrypted router decorator function for the PATCH method.
|
|
68
|
+
*
|
|
69
|
+
* @param path Path of the HTTP request
|
|
70
|
+
* @returns Method decorator
|
|
71
|
+
*/
|
|
72
|
+
export const Patch = Generator("Patch");
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Encrypted router decorator function for the PUT method.
|
|
76
|
+
*
|
|
77
|
+
* @param path Path of the HTTP request
|
|
78
|
+
* @returns Method decorator
|
|
79
|
+
*/
|
|
80
|
+
export const Put = Generator("Put");
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Encrypted router decorator function for the DELETE method.
|
|
84
|
+
*
|
|
85
|
+
* @param path Path of the HTTP request
|
|
86
|
+
* @returns Method decorator
|
|
87
|
+
*/
|
|
88
|
+
export const Delete = Generator("Delete");
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Set the logger function for the response validation failure.
|
|
92
|
+
*
|
|
93
|
+
* If you've configured the transformation option to `validate.log` in the
|
|
94
|
+
* `tsconfig.json` file, then the error log information of the response
|
|
95
|
+
* validation failure would be logged through this function instead of
|
|
96
|
+
* throwing the 400 bad request error.
|
|
97
|
+
*
|
|
98
|
+
* By the way, be careful. If you've configured the response transformation
|
|
99
|
+
* option to be `validate.log`, client may get wrong response data. Therefore,
|
|
100
|
+
* this way is not recommended in the common backend server case.
|
|
101
|
+
*
|
|
102
|
+
* @default console.log
|
|
103
|
+
* @param func Logger function
|
|
104
|
+
*/
|
|
105
|
+
export function setValidateErrorLogger(
|
|
106
|
+
func: (log: IValidateErrorLog) => void,
|
|
107
|
+
): void {
|
|
108
|
+
TypedRoute.setValidateErrorLogger(func);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export import IValidateErrorLog = TypedRoute.IValidateErrorLog;
|
|
112
|
+
|
|
113
|
+
/** @internal */
|
|
114
|
+
function Generator(method: "Get" | "Post" | "Put" | "Patch" | "Delete") {
|
|
115
|
+
function route(path?: string | string[]): MethodDecorator;
|
|
116
|
+
function route<T>(
|
|
117
|
+
stringify?: IResponseBodyStringifier<T> | null,
|
|
118
|
+
): MethodDecorator;
|
|
119
|
+
function route<T>(
|
|
120
|
+
path: string | string[],
|
|
121
|
+
stringify?: IResponseBodyStringifier<T> | null,
|
|
122
|
+
): MethodDecorator;
|
|
123
|
+
|
|
124
|
+
function route(...args: any[]): MethodDecorator {
|
|
125
|
+
const [path, stringify] = get_path_and_stringify(
|
|
126
|
+
() => TypedRoute.__logger,
|
|
127
|
+
)(`EncryptedRoute.${method}`)(...args);
|
|
128
|
+
return applyDecorators(
|
|
129
|
+
ROUTERS[method](path),
|
|
130
|
+
UseInterceptors(new EncryptedRouteInterceptor(method, stringify)),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return route;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const method of [
|
|
138
|
+
typia.json.isStringify,
|
|
139
|
+
typia.json.assertStringify,
|
|
140
|
+
typia.json.validateStringify,
|
|
141
|
+
typia.json.stringify,
|
|
142
|
+
])
|
|
143
|
+
for (const [key, value] of Object.entries(method))
|
|
144
|
+
for (const deco of [
|
|
145
|
+
EncryptedRoute.Get,
|
|
146
|
+
EncryptedRoute.Delete,
|
|
147
|
+
EncryptedRoute.Post,
|
|
148
|
+
EncryptedRoute.Put,
|
|
149
|
+
EncryptedRoute.Patch,
|
|
150
|
+
])
|
|
151
|
+
(deco as any)[key] = value;
|
|
152
|
+
|
|
153
|
+
/** @internal */
|
|
154
|
+
class EncryptedRouteInterceptor implements NestInterceptor {
|
|
155
|
+
public constructor(
|
|
156
|
+
private readonly method: string,
|
|
157
|
+
private readonly stringify: (
|
|
158
|
+
input: any,
|
|
159
|
+
method: string,
|
|
160
|
+
path: string,
|
|
161
|
+
) => string,
|
|
162
|
+
) {}
|
|
163
|
+
|
|
164
|
+
public intercept(context: ExecutionContext, next: CallHandler) {
|
|
165
|
+
const http: HttpArgumentsHost = context.switchToHttp();
|
|
166
|
+
return next.handle().pipe(
|
|
167
|
+
map((value) => {
|
|
168
|
+
const param:
|
|
169
|
+
| IEncryptionPassword
|
|
170
|
+
| IEncryptionPassword.Closure
|
|
171
|
+
| undefined = Reflect.getMetadata(
|
|
172
|
+
ENCRYPTION_METADATA_KEY,
|
|
173
|
+
context.getClass(),
|
|
174
|
+
);
|
|
175
|
+
if (!param)
|
|
176
|
+
return Error(
|
|
177
|
+
`Error on EncryptedRoute.${this.method}(): no password found.`,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const request: express.Request = http.getRequest();
|
|
181
|
+
const headers: Singleton<Record<string, string>> = new Singleton(() =>
|
|
182
|
+
headers_to_object(request.headers),
|
|
183
|
+
);
|
|
184
|
+
const body: string | undefined = this.stringify(
|
|
185
|
+
value,
|
|
186
|
+
request.method,
|
|
187
|
+
request.url,
|
|
188
|
+
);
|
|
189
|
+
const password: IEncryptionPassword =
|
|
190
|
+
typeof param === "function"
|
|
191
|
+
? param({
|
|
192
|
+
headers: headers.get(),
|
|
193
|
+
body,
|
|
194
|
+
direction: "encode",
|
|
195
|
+
})
|
|
196
|
+
: param;
|
|
197
|
+
|
|
198
|
+
if (body === undefined) return body;
|
|
199
|
+
return AesPkcs5.encrypt(body, password.key, password.iv);
|
|
200
|
+
}),
|
|
201
|
+
catchError((err) => route_error(http.getRequest(), err)),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** @internal */
|
|
207
|
+
const ROUTERS = {
|
|
208
|
+
Get,
|
|
209
|
+
Post,
|
|
210
|
+
Put,
|
|
211
|
+
Patch,
|
|
212
|
+
Delete,
|
|
213
|
+
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { SwaggerCustomizer } from "./SwaggerCustomizer";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Human only API marking.
|
|
5
|
-
*
|
|
6
|
-
* This decorator marks the API for human only, so that LLM function calling
|
|
7
|
-
* schema composer excludes the API.
|
|
8
|
-
*
|
|
9
|
-
* In other words, if you adjust the `@HumanRoute()` decorator to the API, the
|
|
10
|
-
* API never participates in the LLM function calling. When calling the
|
|
11
|
-
* {@link HttpLlm.application} function, matched {@link IHttpLlmFunction} data
|
|
12
|
-
* never be composed.
|
|
13
|
-
*
|
|
14
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
15
|
-
* @returns Method decorator
|
|
16
|
-
*/
|
|
17
|
-
export function HumanRoute(): MethodDecorator {
|
|
18
|
-
return SwaggerCustomizer((props) => {
|
|
19
|
-
props.route["x-samchon-human"] = true;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
1
|
+
import { SwaggerCustomizer } from "./SwaggerCustomizer";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Human only API marking.
|
|
5
|
+
*
|
|
6
|
+
* This decorator marks the API for human only, so that LLM function calling
|
|
7
|
+
* schema composer excludes the API.
|
|
8
|
+
*
|
|
9
|
+
* In other words, if you adjust the `@HumanRoute()` decorator to the API, the
|
|
10
|
+
* API never participates in the LLM function calling. When calling the
|
|
11
|
+
* {@link HttpLlm.application} function, matched {@link IHttpLlmFunction} data
|
|
12
|
+
* never be composed.
|
|
13
|
+
*
|
|
14
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
15
|
+
* @returns Method decorator
|
|
16
|
+
*/
|
|
17
|
+
export function HumanRoute(): MethodDecorator {
|
|
18
|
+
return SwaggerCustomizer((props) => {
|
|
19
|
+
props.route["x-samchon-human"] = true;
|
|
20
|
+
});
|
|
21
|
+
}
|