adorn-api 1.0.1 → 1.0.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/README.md +4 -1
- package/dist/adapters/express/createApp.d.ts +149 -11
- package/dist/adapters/express/createApp.d.ts.map +1 -1
- package/dist/adapters/express/createApp.js +112 -6
- package/dist/adapters/express/createApp.js.map +1 -1
- package/dist/adapters/express/middleware/errorHandler.d.ts +193 -2
- package/dist/adapters/express/middleware/errorHandler.d.ts.map +1 -1
- package/dist/adapters/express/middleware/errorHandler.js +164 -3
- package/dist/adapters/express/middleware/errorHandler.js.map +1 -1
- package/dist/adapters/express/router.d.ts +1 -1
- package/dist/adapters/express/router.d.ts.map +1 -1
- package/dist/adapters/express/router.js +6 -4
- package/dist/adapters/express/router.js.map +1 -1
- package/dist/adapters/express/transport/request.js.map +1 -1
- package/dist/adapters/express/transport/response.d.ts +1 -1
- package/dist/adapters/express/transport/response.d.ts.map +1 -1
- package/dist/adapters/express/transport/response.js.map +1 -1
- package/dist/contracts/openapi-v3.d.ts +461 -0
- package/dist/contracts/openapi-v3.d.ts.map +1 -1
- package/dist/contracts/reply.d.ts +109 -1
- package/dist/contracts/reply.d.ts.map +1 -1
- package/dist/contracts/reply.js +40 -1
- package/dist/contracts/reply.js.map +1 -1
- package/dist/contracts/response-types.d.ts +5 -5
- package/dist/contracts/response-types.d.ts.map +1 -1
- package/dist/contracts/responses.d.ts +84 -4
- package/dist/contracts/responses.d.ts.map +1 -1
- package/dist/contracts/route-options.d.ts +134 -3
- package/dist/contracts/route-options.d.ts.map +1 -1
- package/dist/contracts/validator.d.ts +121 -0
- package/dist/contracts/validator.d.ts.map +1 -1
- package/dist/core/binding/binder.d.ts +56 -1
- package/dist/core/binding/binder.d.ts.map +1 -1
- package/dist/core/binding/binder.js +33 -0
- package/dist/core/binding/binder.js.map +1 -1
- package/dist/core/binding/coerce/primitives.d.ts +68 -1
- package/dist/core/binding/coerce/primitives.d.ts.map +1 -1
- package/dist/core/binding/coerce/primitives.js +82 -12
- package/dist/core/binding/coerce/primitives.js.map +1 -1
- package/dist/core/errors/http-error.d.ts +54 -0
- package/dist/core/errors/http-error.d.ts.map +1 -1
- package/dist/core/errors/http-error.js +54 -0
- package/dist/core/errors/http-error.js.map +1 -1
- package/dist/core/errors/validation-error.d.ts +65 -0
- package/dist/core/errors/validation-error.d.ts.map +1 -1
- package/dist/core/errors/validation-error.js +65 -0
- package/dist/core/errors/validation-error.js.map +1 -1
- package/dist/core/openapi/buildOpenApi.d.ts +65 -0
- package/dist/core/openapi/buildOpenApi.d.ts.map +1 -1
- package/dist/core/openapi/buildOpenApi.js +66 -4
- package/dist/core/openapi/buildOpenApi.js.map +1 -1
- package/dist/core/openapi/schema/registry.d.ts +1 -1
- package/dist/core/openapi/schema/registry.d.ts.map +1 -1
- package/dist/core/openapi/schema/registry.js.map +1 -1
- package/dist/core/registry/buildRegistry.d.ts.map +1 -1
- package/dist/core/registry/buildRegistry.js +49 -5
- package/dist/core/registry/buildRegistry.js.map +1 -1
- package/dist/core/registry/types.d.ts +194 -1
- package/dist/core/registry/types.d.ts.map +1 -1
- package/dist/core/reply/reply.d.ts +94 -0
- package/dist/core/reply/reply.d.ts.map +1 -1
- package/dist/core/reply/reply.js +87 -0
- package/dist/core/reply/reply.js.map +1 -1
- package/dist/core/reply/typed.d.ts +137 -3
- package/dist/core/reply/typed.d.ts.map +1 -1
- package/dist/core/reply/typed.js +137 -2
- package/dist/core/reply/typed.js.map +1 -1
- package/dist/core/responses/helpers.d.ts +1 -1
- package/dist/core/responses/helpers.d.ts.map +1 -1
- package/dist/core/responses/normalize.d.ts.map +1 -1
- package/dist/core/responses/normalize.js +2 -1
- package/dist/core/responses/normalize.js.map +1 -1
- package/dist/core/route/defineRoute.d.ts +48 -1
- package/dist/core/route/defineRoute.d.ts.map +1 -1
- package/dist/core/route/defineRoute.js +42 -1
- package/dist/core/route/defineRoute.js.map +1 -1
- package/dist/decorators/binding.d.ts +1 -1
- package/dist/decorators/binding.d.ts.map +1 -1
- package/dist/decorators/binding.js.map +1 -1
- package/dist/decorators/controller.d.ts +1 -1
- package/dist/decorators/controller.d.ts.map +1 -1
- package/dist/decorators/controller.js.map +1 -1
- package/dist/decorators/docs.d.ts +6 -0
- package/dist/decorators/docs.d.ts.map +1 -1
- package/dist/decorators/docs.js +45 -2
- package/dist/decorators/docs.js.map +1 -1
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +3 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/methods.d.ts +128 -6
- package/dist/decorators/methods.d.ts.map +1 -1
- package/dist/decorators/methods.js +124 -0
- package/dist/decorators/methods.js.map +1 -1
- package/dist/decorators/responses.d.ts +5 -0
- package/dist/decorators/responses.d.ts.map +1 -1
- package/dist/decorators/responses.js +43 -2
- package/dist/decorators/responses.js.map +1 -1
- package/dist/decorators/security.d.ts +6 -0
- package/dist/decorators/security.d.ts.map +1 -1
- package/dist/decorators/security.js +38 -2
- package/dist/decorators/security.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/integrations/metal-orm/schema/column-map.d.ts +91 -0
- package/dist/integrations/metal-orm/schema/column-map.d.ts.map +1 -1
- package/dist/integrations/metal-orm/schema/column-map.js +129 -2
- package/dist/integrations/metal-orm/schema/column-map.js.map +1 -1
- package/dist/integrations/metal-orm/schema/dto.d.ts +2 -2
- package/dist/integrations/metal-orm/schema/dto.d.ts.map +1 -1
- package/dist/integrations/metal-orm/schema/dto.js.map +1 -1
- package/dist/integrations/metal-orm/schema/entity.d.ts +90 -8
- package/dist/integrations/metal-orm/schema/entity.d.ts.map +1 -1
- package/dist/integrations/metal-orm/schema/entity.js +78 -6
- package/dist/integrations/metal-orm/schema/entity.js.map +1 -1
- package/dist/integrations/metal-orm/schema/filters.d.ts +1 -1
- package/dist/integrations/metal-orm/schema/filters.d.ts.map +1 -1
- package/dist/integrations/metal-orm/schema/filters.js +2 -1
- package/dist/integrations/metal-orm/schema/filters.js.map +1 -1
- package/dist/integrations/metal-orm/schema/tabledef.d.ts +1 -1
- package/dist/integrations/metal-orm/schema/tabledef.d.ts.map +1 -1
- package/dist/metadata/bag.d.ts +2 -1
- package/dist/metadata/bag.d.ts.map +1 -1
- package/dist/metadata/bag.js +2 -1
- package/dist/metadata/bag.js.map +1 -1
- package/dist/metadata/keys.d.ts +203 -1
- package/dist/metadata/keys.d.ts.map +1 -1
- package/dist/metadata/keys.js +3 -9
- package/dist/metadata/keys.js.map +1 -1
- package/dist/metadata/merge.d.ts.map +1 -1
- package/dist/metadata/merge.js +4 -1
- package/dist/metadata/merge.js.map +1 -1
- package/dist/validation/native/schema.d.ts +2 -2
- package/dist/validation/native/schema.d.ts.map +1 -1
- package/dist/validation/native/validator.d.ts +1 -1
- package/dist/validation/native/validator.d.ts.map +1 -1
- package/package.json +6 -2
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
type Stage3ClassContext = ClassDecoratorContext;
|
|
2
|
+
type Stage3MethodContext = ClassMethodDecoratorContext<unknown, (this: unknown, ...args: unknown[]) => unknown>;
|
|
3
|
+
type DecoratorContext = Stage3ClassContext | Stage3MethodContext;
|
|
4
|
+
export declare function Tags(...tags: string[]): (_value: unknown, context: DecoratorContext) => void;
|
|
5
|
+
export declare function OperationId(id: string): (_value: unknown, context: Stage3MethodContext) => void;
|
|
6
|
+
export declare function Deprecated(value?: boolean): (_value: unknown, context: Stage3MethodContext) => void;
|
|
1
7
|
export {};
|
|
2
8
|
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/decorators/docs.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/decorators/docs.ts"],"names":[],"mappings":"AAIA,KAAK,kBAAkB,GAAG,qBAAqB,CAAC;AAChD,KAAK,mBAAmB,GAAG,2BAA2B,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC;AAChH,KAAK,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAkBjE,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,IACnB,QAAQ,OAAO,EAAE,SAAS,gBAAgB,UAc5D;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IACnB,QAAQ,OAAO,EAAE,SAAS,mBAAmB,UAM/D;AAED,wBAAgB,UAAU,CAAC,KAAK,UAAO,IACpB,QAAQ,OAAO,EAAE,SAAS,mBAAmB,UAM/D"}
|
package/dist/decorators/docs.js
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { META } from '../metadata/keys.js';
|
|
2
|
+
import { bagEnsureObject, bagFromContext } from '../metadata/bag.js';
|
|
3
|
+
function ensureDocsMeta(context) {
|
|
4
|
+
const bag = bagFromContext(context);
|
|
5
|
+
return bagEnsureObject(bag, META.docs, () => ({}));
|
|
6
|
+
}
|
|
7
|
+
function ensureMethodDocs(meta, method) {
|
|
8
|
+
meta.byMethod ??= {};
|
|
9
|
+
meta.byMethod[method] ??= {};
|
|
10
|
+
return meta.byMethod[method];
|
|
11
|
+
}
|
|
12
|
+
function mergeTags(existing, next) {
|
|
13
|
+
return [...(existing ?? []), ...next];
|
|
14
|
+
}
|
|
15
|
+
export function Tags(...tags) {
|
|
16
|
+
return function (_value, context) {
|
|
17
|
+
const meta = ensureDocsMeta(context);
|
|
18
|
+
const cleaned = tags.map((t) => t.trim()).filter(Boolean);
|
|
19
|
+
if (!cleaned.length)
|
|
20
|
+
return;
|
|
21
|
+
if (context.kind === 'class') {
|
|
22
|
+
meta.tags = mergeTags(meta.tags, cleaned);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const method = String(context.name);
|
|
26
|
+
const methodDocs = ensureMethodDocs(meta, method);
|
|
27
|
+
methodDocs.tags = mergeTags(methodDocs.tags, cleaned);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function OperationId(id) {
|
|
31
|
+
return function (_value, context) {
|
|
32
|
+
const meta = ensureDocsMeta(context);
|
|
33
|
+
const method = String(context.name);
|
|
34
|
+
const methodDocs = ensureMethodDocs(meta, method);
|
|
35
|
+
methodDocs.operationId = id;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function Deprecated(value = true) {
|
|
39
|
+
return function (_value, context) {
|
|
40
|
+
const meta = ensureDocsMeta(context);
|
|
41
|
+
const method = String(context.name);
|
|
42
|
+
const methodDocs = ensureMethodDocs(meta, method);
|
|
43
|
+
methodDocs.deprecated = value;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
3
46
|
//# sourceMappingURL=docs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/decorators/docs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/decorators/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQrE,SAAS,cAAc,CAAC,OAAyB;IAC/C,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,eAAe,CAAW,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAc,EAAE,MAAc;IACtD,IAAI,CAAC,QAAQ,KAAK,EAAE,CAAC;IACrB,IAAI,CAAC,QAAQ,CAAC,MA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,CAAC;QAClD,UAAU,CAAC,WAAW,GAAG,EAAE,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAK,GAAG,IAAI;IACrC,OAAO,UAAU,MAAe,EAAE,OAA4B;QAC5D,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClD,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/dist/decorators/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -13,12 +13,134 @@ type SuccessBodyType<O> = BodyTypeFromResponses<ResponsesFromOptions<O>>;
|
|
|
13
13
|
type ReplyWithBodyTypes<R extends ResponsesSpec | undefined> = R extends ResponsesSpec ? SuccessStatusesWithBody<R> extends never ? never : Reply<BodySchemaFromResponses<R> extends Schema<infer T> ? T : unknown, SuccessStatusesWithBody<R>> : never;
|
|
14
14
|
type ReplyNoBodyTypes<R extends ResponsesSpec | undefined> = R extends ResponsesSpec ? SuccessStatusesNoBody<R> extends never ? never : Reply<undefined, SuccessStatusesNoBody<R>> : never;
|
|
15
15
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
16
|
-
type HandlerReply<R extends ResponsesSpec | undefined> = R extends ResponsesSpec ? (IsNever<ReplyWithBodyTypes<R>> extends true ? never : ReplyWithBodyTypes<R>) | (IsNever<ReplyNoBodyTypes<R>> extends true ? never : ReplyNoBodyTypes<R>) : Reply<
|
|
16
|
+
type HandlerReply<R extends ResponsesSpec | undefined> = R extends ResponsesSpec ? (IsNever<ReplyWithBodyTypes<R>> extends true ? never : ReplyWithBodyTypes<R>) | (IsNever<ReplyNoBodyTypes<R>> extends true ? never : ReplyNoBodyTypes<R>) : Reply<unknown, number>;
|
|
17
17
|
type HandlerReturn<O extends RouteOptions<string> | undefined> = MaybePromise<SuccessBodyType<O> | HandlerReply<ResponsesFromOptions<O>>>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Decorator for HTTP GET method endpoints.
|
|
20
|
+
*
|
|
21
|
+
* @template Path - The route path as a string literal
|
|
22
|
+
* @template O - Route options extending RouteOptions for the path
|
|
23
|
+
* @param path - The route path (e.g., '/users', '/users/:id')
|
|
24
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
25
|
+
* @returns Method decorator for class methods
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class UserController {
|
|
30
|
+
* @Get('/users')
|
|
31
|
+
* async listUsers() {
|
|
32
|
+
* return await userService.findAll();
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* @Get('/users/:id')
|
|
36
|
+
* async getUser(id: string) {
|
|
37
|
+
* return await userService.findById(id);
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see RouteOptions for available configuration options
|
|
43
|
+
*/
|
|
44
|
+
export declare function Get<Path extends string, const O extends RouteOptions<Path> | undefined>(path: Path, options?: O): <This, Args extends unknown[], Ret extends HandlerReturn<O>>(value: (this: This, ...args: Args) => Ret, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Ret>) => (this: This, ...args: Args) => Ret;
|
|
45
|
+
/**
|
|
46
|
+
* Decorator for HTTP POST method endpoints.
|
|
47
|
+
*
|
|
48
|
+
* @template Path - The route path as a string literal
|
|
49
|
+
* @template O - Route options extending RouteOptions for the path
|
|
50
|
+
* @param path - The route path (e.g., '/users', '/users/:id/comments')
|
|
51
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
52
|
+
* @returns Method decorator for class methods
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* class UserController {
|
|
57
|
+
* @Post('/users')
|
|
58
|
+
* async createUser(@Body() userData: CreateUserDto) {
|
|
59
|
+
* return await userService.create(userData);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* @Post('/users/:id/activate')
|
|
63
|
+
* async activateUser(id: string) {
|
|
64
|
+
* return await userService.activate(id);
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @see RouteOptions for available configuration options
|
|
70
|
+
*/
|
|
71
|
+
export declare function Post<Path extends string, const O extends RouteOptions<Path> | undefined>(path: Path, options?: O): <This, Args extends unknown[], Ret extends HandlerReturn<O>>(value: (this: This, ...args: Args) => Ret, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Ret>) => (this: This, ...args: Args) => Ret;
|
|
72
|
+
/**
|
|
73
|
+
* Decorator for HTTP PUT method endpoints.
|
|
74
|
+
*
|
|
75
|
+
* @template Path - The route path as a string literal
|
|
76
|
+
* @template O - Route options extending RouteOptions for the path
|
|
77
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
78
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
79
|
+
* @returns Method decorator for class methods
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* class UserController {
|
|
84
|
+
* @Put('/users/:id')
|
|
85
|
+
* async updateUser(id: string, @Body() userData: UpdateUserDto) {
|
|
86
|
+
* return await userService.update(id, userData);
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see RouteOptions for available configuration options
|
|
92
|
+
*/
|
|
93
|
+
export declare function Put<Path extends string, const O extends RouteOptions<Path> | undefined>(path: Path, options?: O): <This, Args extends unknown[], Ret extends HandlerReturn<O>>(value: (this: This, ...args: Args) => Ret, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Ret>) => (this: This, ...args: Args) => Ret;
|
|
94
|
+
/**
|
|
95
|
+
* Decorator for HTTP PATCH method endpoints.
|
|
96
|
+
*
|
|
97
|
+
* @template Path - The route path as a string literal
|
|
98
|
+
* @template O - Route options extending RouteOptions for the path
|
|
99
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
100
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
101
|
+
* @returns Method decorator for class methods
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* class UserController {
|
|
106
|
+
* @Patch('/users/:id')
|
|
107
|
+
* async partialUpdate(id: string, @Body() partialData: Partial<User>) {
|
|
108
|
+
* return await userService.patch(id, partialData);
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @see RouteOptions for available configuration options
|
|
114
|
+
*/
|
|
115
|
+
export declare function Patch<Path extends string, const O extends RouteOptions<Path> | undefined>(path: Path, options?: O): <This, Args extends unknown[], Ret extends HandlerReturn<O>>(value: (this: This, ...args: Args) => Ret, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Ret>) => (this: This, ...args: Args) => Ret;
|
|
116
|
+
/**
|
|
117
|
+
* Decorator for HTTP DELETE method endpoints.
|
|
118
|
+
*
|
|
119
|
+
* @template Path - The route path as a string literal
|
|
120
|
+
* @template O - Route options extending RouteOptions for the path
|
|
121
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
122
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
123
|
+
* @returns Method decorator for class methods
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* class UserController {
|
|
128
|
+
* @Delete('/users/:id')
|
|
129
|
+
* async deleteUser(id: string) {
|
|
130
|
+
* await userService.delete(id);
|
|
131
|
+
* return { success: true };
|
|
132
|
+
* }
|
|
133
|
+
*
|
|
134
|
+
* @Delete('/users')
|
|
135
|
+
* async deleteAllUsers() {
|
|
136
|
+
* await userService.deleteAll();
|
|
137
|
+
* return { deletedCount: await userService.count() };
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @see RouteOptions for available configuration options
|
|
143
|
+
*/
|
|
144
|
+
export declare function Delete<Path extends string, const O extends RouteOptions<Path> | undefined>(path: Path, options?: O): <This, Args extends unknown[], Ret extends HandlerReturn<O>>(value: (this: This, ...args: Args) => Ret, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Ret>) => (this: This, ...args: Args) => Ret;
|
|
23
145
|
export {};
|
|
24
146
|
//# sourceMappingURL=methods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/decorators/methods.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/decorators/methods.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAIxC,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC,KAAK,oBAAoB,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAC,SAAS,aAAa,CAAA;CAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AAEtG,KAAK,uBAAuB,CAAC,CAAC,SAAS,aAAa,IAClD,uBAAuB,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,aAAa,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG,KAAK,qBAAqB,CAAC,CAAC,SAAS,aAAa,GAAG,SAAS,IAC5D,CAAC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;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,YAAY,CAAC,IAAI,CAAC,GAAG,SAAS,EACxF,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,CAAC,IAjKM,IAAI,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,GAAG,4LAoKnD"}
|
|
@@ -2,6 +2,8 @@ import { META } from '../metadata/keys.js';
|
|
|
2
2
|
import { bagFromContext, bagPush } from '../metadata/bag.js';
|
|
3
3
|
/**
|
|
4
4
|
* Internal helper: store route metadata for a method.
|
|
5
|
+
* @param context - The decorator context
|
|
6
|
+
* @param route - Route metadata without the name property
|
|
5
7
|
*/
|
|
6
8
|
function addRoute(context, route) {
|
|
7
9
|
const bag = bagFromContext(context);
|
|
@@ -28,18 +30,140 @@ function createMethodDecorator(method, path, options) {
|
|
|
28
30
|
return value;
|
|
29
31
|
};
|
|
30
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Decorator for HTTP GET method endpoints.
|
|
35
|
+
*
|
|
36
|
+
* @template Path - The route path as a string literal
|
|
37
|
+
* @template O - Route options extending RouteOptions for the path
|
|
38
|
+
* @param path - The route path (e.g., '/users', '/users/:id')
|
|
39
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
40
|
+
* @returns Method decorator for class methods
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* class UserController {
|
|
45
|
+
* @Get('/users')
|
|
46
|
+
* async listUsers() {
|
|
47
|
+
* return await userService.findAll();
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* @Get('/users/:id')
|
|
51
|
+
* async getUser(id: string) {
|
|
52
|
+
* return await userService.findById(id);
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @see RouteOptions for available configuration options
|
|
58
|
+
*/
|
|
31
59
|
export function Get(path, options) {
|
|
32
60
|
return createMethodDecorator('GET', path, options);
|
|
33
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Decorator for HTTP POST method endpoints.
|
|
64
|
+
*
|
|
65
|
+
* @template Path - The route path as a string literal
|
|
66
|
+
* @template O - Route options extending RouteOptions for the path
|
|
67
|
+
* @param path - The route path (e.g., '/users', '/users/:id/comments')
|
|
68
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
69
|
+
* @returns Method decorator for class methods
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* class UserController {
|
|
74
|
+
* @Post('/users')
|
|
75
|
+
* async createUser(@Body() userData: CreateUserDto) {
|
|
76
|
+
* return await userService.create(userData);
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* @Post('/users/:id/activate')
|
|
80
|
+
* async activateUser(id: string) {
|
|
81
|
+
* return await userService.activate(id);
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @see RouteOptions for available configuration options
|
|
87
|
+
*/
|
|
34
88
|
export function Post(path, options) {
|
|
35
89
|
return createMethodDecorator('POST', path, options);
|
|
36
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Decorator for HTTP PUT method endpoints.
|
|
93
|
+
*
|
|
94
|
+
* @template Path - The route path as a string literal
|
|
95
|
+
* @template O - Route options extending RouteOptions for the path
|
|
96
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
97
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
98
|
+
* @returns Method decorator for class methods
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* class UserController {
|
|
103
|
+
* @Put('/users/:id')
|
|
104
|
+
* async updateUser(id: string, @Body() userData: UpdateUserDto) {
|
|
105
|
+
* return await userService.update(id, userData);
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see RouteOptions for available configuration options
|
|
111
|
+
*/
|
|
37
112
|
export function Put(path, options) {
|
|
38
113
|
return createMethodDecorator('PUT', path, options);
|
|
39
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Decorator for HTTP PATCH method endpoints.
|
|
117
|
+
*
|
|
118
|
+
* @template Path - The route path as a string literal
|
|
119
|
+
* @template O - Route options extending RouteOptions for the path
|
|
120
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
121
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
122
|
+
* @returns Method decorator for class methods
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* class UserController {
|
|
127
|
+
* @Patch('/users/:id')
|
|
128
|
+
* async partialUpdate(id: string, @Body() partialData: Partial<User>) {
|
|
129
|
+
* return await userService.patch(id, partialData);
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @see RouteOptions for available configuration options
|
|
135
|
+
*/
|
|
40
136
|
export function Patch(path, options) {
|
|
41
137
|
return createMethodDecorator('PATCH', path, options);
|
|
42
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Decorator for HTTP DELETE method endpoints.
|
|
141
|
+
*
|
|
142
|
+
* @template Path - The route path as a string literal
|
|
143
|
+
* @template O - Route options extending RouteOptions for the path
|
|
144
|
+
* @param path - The route path (e.g., '/users/:id')
|
|
145
|
+
* @param options - Optional route configuration including responses, validation, etc.
|
|
146
|
+
* @returns Method decorator for class methods
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* class UserController {
|
|
151
|
+
* @Delete('/users/:id')
|
|
152
|
+
* async deleteUser(id: string) {
|
|
153
|
+
* await userService.delete(id);
|
|
154
|
+
* return { success: true };
|
|
155
|
+
* }
|
|
156
|
+
*
|
|
157
|
+
* @Delete('/users')
|
|
158
|
+
* async deleteAllUsers() {
|
|
159
|
+
* await userService.deleteAll();
|
|
160
|
+
* return { deletedCount: await userService.count() };
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @see RouteOptions for available configuration options
|
|
166
|
+
*/
|
|
43
167
|
export function Delete(path, options) {
|
|
44
168
|
return createMethodDecorator('DELETE', path, options);
|
|
45
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/decorators/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/decorators/methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAuD7D;;;;GAIG;AACH,SAAS,QAAQ,CACf,OAA6C,EAC7C,KAA8B;IAE9B,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC,MAAM,IAAI,GAAc;QACtB,GAAG,KAAK;QACR,IAAI;KACL,CAAC;IAEF,OAAO,CAAY,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAS;IACnC,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAClB,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1C,IAAI,GA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EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import type { ResponseSpec, ResponsesSpec } from '../contracts/responses.js';
|
|
2
|
+
import type { Schema } from '../validation/native/schema.js';
|
|
3
|
+
type Stage3MethodContext = ClassMethodDecoratorContext<unknown, (this: unknown, ...args: unknown[]) => unknown>;
|
|
4
|
+
export declare function Responses(spec: ResponsesSpec): (_value: unknown, context: Stage3MethodContext) => void;
|
|
5
|
+
export declare function Response(status: number | string, spec?: ResponseSpec | Schema<unknown> | string): (_value: unknown, context: Stage3MethodContext) => void;
|
|
1
6
|
export {};
|
|
2
7
|
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/decorators/responses.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/decorators/responses.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAE7D,KAAK,mBAAmB,GAAG,2BAA2B,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC;AAmBhH,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,IAC1B,QAAQ,OAAO,EAAE,SAAS,mBAAmB,UAO/D;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,IAE7B,QAAQ,OAAO,EAAE,SAAS,mBAAmB,UAgB/D"}
|
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { META } from '../metadata/keys.js';
|
|
2
|
+
import { bagEnsureObject, bagFromContext } from '../metadata/bag.js';
|
|
3
|
+
function ensureDocsMeta(context) {
|
|
4
|
+
const bag = bagFromContext(context);
|
|
5
|
+
return bagEnsureObject(bag, META.docs, () => ({}));
|
|
6
|
+
}
|
|
7
|
+
function ensureResponses(meta, method) {
|
|
8
|
+
meta.byMethod ??= {};
|
|
9
|
+
meta.byMethod[method] ??= {};
|
|
10
|
+
const existing = meta.byMethod[method];
|
|
11
|
+
if (!existing.responses)
|
|
12
|
+
existing.responses = {};
|
|
13
|
+
return existing.responses;
|
|
14
|
+
}
|
|
15
|
+
function isSchema(value) {
|
|
16
|
+
return !!value && typeof value === 'object' && typeof value.parse === 'function';
|
|
17
|
+
}
|
|
18
|
+
export function Responses(spec) {
|
|
19
|
+
return function (_value, context) {
|
|
20
|
+
const meta = ensureDocsMeta(context);
|
|
21
|
+
const method = String(context.name);
|
|
22
|
+
const responses = ensureResponses(meta, method);
|
|
23
|
+
Object.assign(responses, spec);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function Response(status, spec) {
|
|
27
|
+
return function (_value, context) {
|
|
28
|
+
const meta = ensureDocsMeta(context);
|
|
29
|
+
const method = String(context.name);
|
|
30
|
+
const responses = ensureResponses(meta, method);
|
|
31
|
+
let value;
|
|
32
|
+
if (typeof spec === 'string') {
|
|
33
|
+
value = { description: spec };
|
|
34
|
+
}
|
|
35
|
+
else if (spec && isSchema(spec)) {
|
|
36
|
+
value = spec;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
value = spec ?? {};
|
|
40
|
+
}
|
|
41
|
+
responses[String(status)] = value;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
3
44
|
//# sourceMappingURL=responses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/decorators/responses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":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AAQ,CACtB,MAAuB,EACvB,IAA8C;IAE9C,OAAO,UAAU,MAAe,EAAE,OAA4B;QAC5D,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEhD,IAAI,KAAqC,CAAC;QAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,KAAK,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;aAAM,IAAI,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,CAAC;QAED,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import type { SecurityRequirementObject, SecuritySchemeObject } from '../contracts/openapi-v3.js';
|
|
2
|
+
type Stage3ClassContext = ClassDecoratorContext;
|
|
3
|
+
type Stage3MethodContext = ClassMethodDecoratorContext<unknown, (this: unknown, ...args: unknown[]) => unknown>;
|
|
4
|
+
type DecoratorContext = Stage3ClassContext | Stage3MethodContext;
|
|
5
|
+
export declare function Security(nameOrReq: string | SecurityRequirementObject | SecurityRequirementObject[], scopes?: string[]): (_value: unknown, context: DecoratorContext) => void;
|
|
6
|
+
export declare function SecurityScheme(name: string, scheme: SecuritySchemeObject): (_value: unknown, context: Stage3ClassContext) => void;
|
|
1
7
|
export {};
|
|
2
8
|
//# sourceMappingURL=security.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/decorators/security.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/decorators/security.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlG,KAAK,kBAAkB,GAAG,qBAAqB,CAAC;AAChD,KAAK,mBAAmB,GAAG,2BAA2B,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAAC;AAChH,KAAK,gBAAgB,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AA4BjE,wBAAgB,QAAQ,CACtB,SAAS,EAAE,MAAM,GAAG,yBAAyB,GAAG,yBAAyB,EAAE,EAC3E,MAAM,CAAC,EAAE,MAAM,EAAE,IAEA,QAAQ,OAAO,EAAE,SAAS,gBAAgB,UAO5D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,IACtD,QAAQ,OAAO,EAAE,SAAS,kBAAkB,UAO9D"}
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { META } from '../metadata/keys.js';
|
|
2
|
+
import { bagEnsureObject, bagFromContext } from '../metadata/bag.js';
|
|
3
|
+
function ensureDocsMeta(context) {
|
|
4
|
+
const bag = bagFromContext(context);
|
|
5
|
+
return bagEnsureObject(bag, META.docs, () => ({}));
|
|
6
|
+
}
|
|
7
|
+
function ensureSecurityTarget(meta, context) {
|
|
8
|
+
if (context.kind === 'class')
|
|
9
|
+
return meta;
|
|
10
|
+
const method = String(context.name);
|
|
11
|
+
meta.byMethod ??= {};
|
|
12
|
+
meta.byMethod[method] ??= {};
|
|
13
|
+
return meta.byMethod[method];
|
|
14
|
+
}
|
|
15
|
+
function normalizeRequirements(nameOrReq, scopes) {
|
|
16
|
+
if (typeof nameOrReq === 'string') {
|
|
17
|
+
return [{ [nameOrReq]: scopes ?? [] }];
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(nameOrReq))
|
|
20
|
+
return nameOrReq;
|
|
21
|
+
return [nameOrReq];
|
|
22
|
+
}
|
|
23
|
+
export function Security(nameOrReq, scopes) {
|
|
24
|
+
return function (_value, context) {
|
|
25
|
+
const meta = ensureDocsMeta(context);
|
|
26
|
+
const target = ensureSecurityTarget(meta, context);
|
|
27
|
+
const next = normalizeRequirements(nameOrReq, scopes);
|
|
28
|
+
target.security = [...(target.security ?? []), ...next];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function SecurityScheme(name, scheme) {
|
|
32
|
+
return function (_value, context) {
|
|
33
|
+
const bag = bagFromContext(context);
|
|
34
|
+
const meta = bagEnsureObject(bag, META.security, () => ({}));
|
|
35
|
+
meta.schemes ??= {};
|
|
36
|
+
meta.schemes[name] = scheme;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
3
39
|
//# sourceMappingURL=security.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/decorators/security.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/decorators/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoC,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQrE,SAAS,cAAc,CAAC,OAAyB;IAC/C,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,eAAe,CAAW,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAc,EAAE,OAAyB;IACrE,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1C,MAA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,CAAC;QAE3E,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export
|
|
1
|
+
export * from './decorators/index.js';
|
|
2
|
+
export { HttpError, ValidationError } from './core/errors/index.js';
|
|
3
|
+
export { toProblemDetails } from './core/errors/index.js';
|
|
3
4
|
export * from './validation/native/index.js';
|
|
4
5
|
export * from './core/openapi/index.js';
|
|
5
6
|
export * from './contracts/openapi.js';
|
|
@@ -7,6 +8,8 @@ export * from './contracts/responses.js';
|
|
|
7
8
|
export * from './contracts/reply.js';
|
|
8
9
|
export * from './core/reply/index.js';
|
|
9
10
|
export * from './core/route/index.js';
|
|
11
|
+
export * from './core/registry/index.js';
|
|
10
12
|
export * from './contracts/route-options.js';
|
|
11
13
|
export * from './contracts/route-typing.js';
|
|
14
|
+
export * from './contracts/validator.js';
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,cAAc,8BAA8B,CAAC;AAG7C,cAAc,yBAAyB,CAAC;AAGxC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAG5C,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Public API exports for adorn-api
|
|
2
|
+
// This file defines the stable public API surface that users can rely on
|
|
3
|
+
// Core decorators - these are the main public API
|
|
4
|
+
export * from './decorators/index.js';
|
|
5
|
+
// Error types - public error classes
|
|
6
|
+
export { HttpError, ValidationError } from './core/errors/index.js';
|
|
7
|
+
export { toProblemDetails } from './core/errors/index.js';
|
|
8
|
+
// Validation - public validation API
|
|
3
9
|
export * from './validation/native/index.js';
|
|
10
|
+
// OpenAPI generation - public API for generating OpenAPI docs
|
|
4
11
|
export * from './core/openapi/index.js';
|
|
12
|
+
// OpenAPI contracts - public types for OpenAPI
|
|
5
13
|
export * from './contracts/openapi.js';
|
|
14
|
+
// Response handling - public API for responses
|
|
6
15
|
export * from './contracts/responses.js';
|
|
7
16
|
export * from './contracts/reply.js';
|
|
8
17
|
export * from './core/reply/index.js';
|
|
18
|
+
// Route definitions - public API for route configuration
|
|
9
19
|
export * from './core/route/index.js';
|
|
20
|
+
// Registry types - public types for the registry system
|
|
21
|
+
export * from './core/registry/index.js';
|
|
22
|
+
// Route options and typing - public API for route configuration
|
|
10
23
|
export * from './contracts/route-options.js';
|
|
11
24
|
export * from './contracts/route-typing.js';
|
|
25
|
+
// Validator contracts - public validation types
|
|
26
|
+
export * from './contracts/validator.js';
|
|
12
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,yEAAyE;AAEzE,kDAAkD;AAClD,cAAc,uBAAuB,CAAC;AAEtC,qCAAqC;AACrC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,qCAAqC;AACrC,cAAc,8BAA8B,CAAC;AAE7C,8DAA8D;AAC9D,cAAc,yBAAyB,CAAC;AAExC,+CAA+C;AAC/C,cAAc,wBAAwB,CAAC;AAEvC,+CAA+C;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAEtC,yDAAyD;AACzD,cAAc,uBAAuB,CAAC;AAEtC,wDAAwD;AACxD,cAAc,0BAA0B,CAAC;AAEzC,gEAAgE;AAChE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAE5C,gDAAgD;AAChD,cAAc,0BAA0B,CAAC"}
|