@riktajs/swagger 0.1.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/README.md +258 -0
- package/dist/constants.d.ts +56 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +61 -0
- package/dist/constants.js.map +1 -0
- package/dist/decorators/api-body.decorator.d.ts +33 -0
- package/dist/decorators/api-body.decorator.d.ts.map +1 -0
- package/dist/decorators/api-body.decorator.js +40 -0
- package/dist/decorators/api-body.decorator.js.map +1 -0
- package/dist/decorators/api-exclude.decorator.d.ts +71 -0
- package/dist/decorators/api-exclude.decorator.d.ts.map +1 -0
- package/dist/decorators/api-exclude.decorator.js +95 -0
- package/dist/decorators/api-exclude.decorator.js.map +1 -0
- package/dist/decorators/api-header.decorator.d.ts +25 -0
- package/dist/decorators/api-header.decorator.d.ts.map +1 -0
- package/dist/decorators/api-header.decorator.js +33 -0
- package/dist/decorators/api-header.decorator.js.map +1 -0
- package/dist/decorators/api-operation.decorator.d.ts +32 -0
- package/dist/decorators/api-operation.decorator.d.ts.map +1 -0
- package/dist/decorators/api-operation.decorator.js +39 -0
- package/dist/decorators/api-operation.decorator.js.map +1 -0
- package/dist/decorators/api-param.decorator.d.ts +28 -0
- package/dist/decorators/api-param.decorator.d.ts.map +1 -0
- package/dist/decorators/api-param.decorator.js +36 -0
- package/dist/decorators/api-param.decorator.js.map +1 -0
- package/dist/decorators/api-property.decorator.d.ts +69 -0
- package/dist/decorators/api-property.decorator.d.ts.map +1 -0
- package/dist/decorators/api-property.decorator.js +76 -0
- package/dist/decorators/api-property.decorator.js.map +1 -0
- package/dist/decorators/api-query.decorator.d.ts +30 -0
- package/dist/decorators/api-query.decorator.d.ts.map +1 -0
- package/dist/decorators/api-query.decorator.js +38 -0
- package/dist/decorators/api-query.decorator.js.map +1 -0
- package/dist/decorators/api-response.decorator.d.ts +70 -0
- package/dist/decorators/api-response.decorator.d.ts.map +1 -0
- package/dist/decorators/api-response.decorator.js +100 -0
- package/dist/decorators/api-response.decorator.js.map +1 -0
- package/dist/decorators/api-security.decorator.d.ts +88 -0
- package/dist/decorators/api-security.decorator.d.ts.map +1 -0
- package/dist/decorators/api-security.decorator.js +119 -0
- package/dist/decorators/api-security.decorator.js.map +1 -0
- package/dist/decorators/api-tags.decorator.d.ts +31 -0
- package/dist/decorators/api-tags.decorator.d.ts.map +1 -0
- package/dist/decorators/api-tags.decorator.js +52 -0
- package/dist/decorators/api-tags.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +16 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +24 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi/generator.d.ts +98 -0
- package/dist/openapi/generator.d.ts.map +1 -0
- package/dist/openapi/generator.js +493 -0
- package/dist/openapi/generator.js.map +1 -0
- package/dist/openapi/index.d.ts +8 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +11 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/openapi/zod-to-openapi.d.ts +52 -0
- package/dist/openapi/zod-to-openapi.d.ts.map +1 -0
- package/dist/openapi/zod-to-openapi.js +172 -0
- package/dist/openapi/zod-to-openapi.js.map +1 -0
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +7 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/swagger.plugin.d.ts +157 -0
- package/dist/plugin/swagger.plugin.d.ts.map +1 -0
- package/dist/plugin/swagger.plugin.js +235 -0
- package/dist/plugin/swagger.plugin.js.map +1 -0
- package/dist/types.d.ts +511 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_HEADER_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiHeader() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a header parameter for an API operation.
|
|
7
|
+
* Multiple @ApiHeader decorators can be applied for routes with multiple headers.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Header options including name, description, and required flag
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/')
|
|
14
|
+
* @ApiHeader({ name: 'X-Request-ID', description: 'Unique request identifier', required: true })
|
|
15
|
+
* @ApiHeader({ name: 'X-Correlation-ID', description: 'Correlation ID for tracing' })
|
|
16
|
+
* listUsers() { }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function ApiHeader(options) {
|
|
20
|
+
return (target, propertyKey, descriptor) => {
|
|
21
|
+
const existingHeaders = Reflect.getMetadata(API_HEADER_METADATA, target, propertyKey) ?? [];
|
|
22
|
+
Reflect.defineMetadata(API_HEADER_METADATA, [...existingHeaders, options], target, propertyKey);
|
|
23
|
+
return descriptor;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get all header parameter metadata from a method
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export function getApiHeaders(target, propertyKey) {
|
|
31
|
+
return Reflect.getMetadata(API_HEADER_METADATA, target.prototype, propertyKey) ?? [];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=api-header.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-header.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-header.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EACV,EAAE;QACtB,MAAM,eAAe,GACnB,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAEtE,OAAO,CAAC,cAAc,CACpB,mBAAmB,EACnB,CAAC,GAAG,eAAe,EAAE,OAAO,CAAC,EAC7B,MAAM,EACN,WAAW,CACZ,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAgB,EAChB,WAA4B;IAE5B,OAAO,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ApiOperationOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiOperation() decorator
|
|
5
|
+
*
|
|
6
|
+
* Describes a single API operation (endpoint) with summary, description,
|
|
7
|
+
* and other OpenAPI operation metadata.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Operation options
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Controller('/users')
|
|
14
|
+
* class UserController {
|
|
15
|
+
* @Get('/:id')
|
|
16
|
+
* @ApiOperation({
|
|
17
|
+
* summary: 'Get user by ID',
|
|
18
|
+
* description: 'Retrieves a single user by their unique identifier',
|
|
19
|
+
* operationId: 'getUserById',
|
|
20
|
+
* deprecated: false,
|
|
21
|
+
* })
|
|
22
|
+
* getUser(@Param('id') id: string) { }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function ApiOperation(options: ApiOperationOptions): MethodDecorator;
|
|
27
|
+
/**
|
|
28
|
+
* Get operation metadata from a method
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function getApiOperation(target: Function, propertyKey: string | symbol): ApiOperationOptions | undefined;
|
|
32
|
+
//# sourceMappingURL=api-operation.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-operation.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/api-operation.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,eAAe,CAc1E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,mBAAmB,GAAG,SAAS,CAEjC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_OPERATION_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiOperation() decorator
|
|
5
|
+
*
|
|
6
|
+
* Describes a single API operation (endpoint) with summary, description,
|
|
7
|
+
* and other OpenAPI operation metadata.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Operation options
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Controller('/users')
|
|
14
|
+
* class UserController {
|
|
15
|
+
* @Get('/:id')
|
|
16
|
+
* @ApiOperation({
|
|
17
|
+
* summary: 'Get user by ID',
|
|
18
|
+
* description: 'Retrieves a single user by their unique identifier',
|
|
19
|
+
* operationId: 'getUserById',
|
|
20
|
+
* deprecated: false,
|
|
21
|
+
* })
|
|
22
|
+
* getUser(@Param('id') id: string) { }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function ApiOperation(options) {
|
|
27
|
+
return (target, propertyKey, descriptor) => {
|
|
28
|
+
Reflect.defineMetadata(API_OPERATION_METADATA, options, target, propertyKey);
|
|
29
|
+
return descriptor;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get operation metadata from a method
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export function getApiOperation(target, propertyKey) {
|
|
37
|
+
return Reflect.getMetadata(API_OPERATION_METADATA, target.prototype, propertyKey);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=api-operation.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-operation.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-operation.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EACV,EAAE;QACtB,OAAO,CAAC,cAAc,CACpB,sBAAsB,EACtB,OAAO,EACP,MAAM,EACN,WAAW,CACZ,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAgB,EAChB,WAA4B;IAE5B,OAAO,OAAO,CAAC,WAAW,CAAC,sBAAsB,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ApiParamOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiParam() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a path parameter for an API operation.
|
|
7
|
+
* Multiple @ApiParam decorators can be applied for routes with multiple parameters.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Parameter options including name, description, and type
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/:userId/posts/:postId')
|
|
14
|
+
* @ApiParam({ name: 'userId', description: 'User ID', type: 'string', format: 'uuid' })
|
|
15
|
+
* @ApiParam({ name: 'postId', description: 'Post ID', type: 'integer' })
|
|
16
|
+
* getUserPost(
|
|
17
|
+
* @Param('userId') userId: string,
|
|
18
|
+
* @Param('postId') postId: number
|
|
19
|
+
* ) { }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function ApiParam(options: ApiParamOptions): MethodDecorator;
|
|
23
|
+
/**
|
|
24
|
+
* Get all path parameter metadata from a method
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function getApiParams(target: Function, propertyKey: string | symbol): ApiParamOptions[];
|
|
28
|
+
//# sourceMappingURL=api-param.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-param.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/api-param.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CAiBlE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,eAAe,EAAE,CAEnB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_PARAM_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiParam() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a path parameter for an API operation.
|
|
7
|
+
* Multiple @ApiParam decorators can be applied for routes with multiple parameters.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Parameter options including name, description, and type
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/:userId/posts/:postId')
|
|
14
|
+
* @ApiParam({ name: 'userId', description: 'User ID', type: 'string', format: 'uuid' })
|
|
15
|
+
* @ApiParam({ name: 'postId', description: 'Post ID', type: 'integer' })
|
|
16
|
+
* getUserPost(
|
|
17
|
+
* @Param('userId') userId: string,
|
|
18
|
+
* @Param('postId') postId: number
|
|
19
|
+
* ) { }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function ApiParam(options) {
|
|
23
|
+
return (target, propertyKey, descriptor) => {
|
|
24
|
+
const existingParams = Reflect.getMetadata(API_PARAM_METADATA, target, propertyKey) ?? [];
|
|
25
|
+
Reflect.defineMetadata(API_PARAM_METADATA, [...existingParams, { ...options, required: options.required ?? true }], target, propertyKey);
|
|
26
|
+
return descriptor;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get all path parameter metadata from a method
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export function getApiParams(target, propertyKey) {
|
|
34
|
+
return Reflect.getMetadata(API_PARAM_METADATA, target.prototype, propertyKey) ?? [];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=api-param.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-param.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-param.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EACV,EAAE;QACtB,MAAM,cAAc,GAClB,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAErE,OAAO,CAAC,cAAc,CACpB,kBAAkB,EAClB,CAAC,GAAG,cAAc,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,EACvE,MAAM,EACN,WAAW,CACZ,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAgB,EAChB,WAA4B;IAE5B,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ApiPropertyOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stored property metadata structure
|
|
5
|
+
*/
|
|
6
|
+
interface StoredPropertyMetadata {
|
|
7
|
+
propertyKey: string | symbol;
|
|
8
|
+
options: ApiPropertyOptions;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @ApiProperty() decorator
|
|
12
|
+
*
|
|
13
|
+
* Documents a property of a DTO class for schema generation.
|
|
14
|
+
* Used when you want to manually define schema properties instead of using Zod.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Property options including type, description, and validation rules
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class CreateUserDto {
|
|
21
|
+
* @ApiProperty({
|
|
22
|
+
* description: 'User email address',
|
|
23
|
+
* type: 'string',
|
|
24
|
+
* format: 'email',
|
|
25
|
+
* example: 'user@example.com',
|
|
26
|
+
* required: true,
|
|
27
|
+
* })
|
|
28
|
+
* email!: string;
|
|
29
|
+
*
|
|
30
|
+
* @ApiProperty({
|
|
31
|
+
* description: 'User age',
|
|
32
|
+
* type: 'integer',
|
|
33
|
+
* minimum: 0,
|
|
34
|
+
* maximum: 150,
|
|
35
|
+
* required: false,
|
|
36
|
+
* })
|
|
37
|
+
* age?: number;
|
|
38
|
+
*
|
|
39
|
+
* @ApiProperty({
|
|
40
|
+
* description: 'User role',
|
|
41
|
+
* enum: ['admin', 'user', 'guest'],
|
|
42
|
+
* default: 'user',
|
|
43
|
+
* })
|
|
44
|
+
* role!: string;
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function ApiProperty(options?: ApiPropertyOptions): PropertyDecorator;
|
|
49
|
+
/**
|
|
50
|
+
* @ApiPropertyOptional() decorator
|
|
51
|
+
*
|
|
52
|
+
* Shorthand for @ApiProperty({ required: false }).
|
|
53
|
+
* Marks a property as optional in the schema.
|
|
54
|
+
*/
|
|
55
|
+
export declare function ApiPropertyOptional(options?: Omit<ApiPropertyOptions, 'required'>): PropertyDecorator;
|
|
56
|
+
/**
|
|
57
|
+
* @ApiHideProperty() decorator
|
|
58
|
+
*
|
|
59
|
+
* Excludes a property from the generated schema.
|
|
60
|
+
* Useful for internal properties that shouldn't be documented.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ApiHideProperty(): PropertyDecorator;
|
|
63
|
+
/**
|
|
64
|
+
* Get all property metadata from a class
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export declare function getApiProperties(target: Function): StoredPropertyMetadata[];
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=api-property.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-property.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/api-property.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CAW/E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAM,GACjD,iBAAiB,CAEnB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAYnD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAE3E"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_PROPERTY_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiProperty() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a property of a DTO class for schema generation.
|
|
7
|
+
* Used when you want to manually define schema properties instead of using Zod.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Property options including type, description, and validation rules
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* class CreateUserDto {
|
|
14
|
+
* @ApiProperty({
|
|
15
|
+
* description: 'User email address',
|
|
16
|
+
* type: 'string',
|
|
17
|
+
* format: 'email',
|
|
18
|
+
* example: 'user@example.com',
|
|
19
|
+
* required: true,
|
|
20
|
+
* })
|
|
21
|
+
* email!: string;
|
|
22
|
+
*
|
|
23
|
+
* @ApiProperty({
|
|
24
|
+
* description: 'User age',
|
|
25
|
+
* type: 'integer',
|
|
26
|
+
* minimum: 0,
|
|
27
|
+
* maximum: 150,
|
|
28
|
+
* required: false,
|
|
29
|
+
* })
|
|
30
|
+
* age?: number;
|
|
31
|
+
*
|
|
32
|
+
* @ApiProperty({
|
|
33
|
+
* description: 'User role',
|
|
34
|
+
* enum: ['admin', 'user', 'guest'],
|
|
35
|
+
* default: 'user',
|
|
36
|
+
* })
|
|
37
|
+
* role!: string;
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function ApiProperty(options = {}) {
|
|
42
|
+
return (target, propertyKey) => {
|
|
43
|
+
const existingProperties = Reflect.getMetadata(API_PROPERTY_METADATA, target.constructor) ?? [];
|
|
44
|
+
Reflect.defineMetadata(API_PROPERTY_METADATA, [...existingProperties, { propertyKey, options }], target.constructor);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @ApiPropertyOptional() decorator
|
|
49
|
+
*
|
|
50
|
+
* Shorthand for @ApiProperty({ required: false }).
|
|
51
|
+
* Marks a property as optional in the schema.
|
|
52
|
+
*/
|
|
53
|
+
export function ApiPropertyOptional(options = {}) {
|
|
54
|
+
return ApiProperty({ ...options, required: false });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @ApiHideProperty() decorator
|
|
58
|
+
*
|
|
59
|
+
* Excludes a property from the generated schema.
|
|
60
|
+
* Useful for internal properties that shouldn't be documented.
|
|
61
|
+
*/
|
|
62
|
+
export function ApiHideProperty() {
|
|
63
|
+
return (target, propertyKey) => {
|
|
64
|
+
const existingProperties = Reflect.getMetadata(API_PROPERTY_METADATA, target.constructor) ?? [];
|
|
65
|
+
// Add property with special flag to hide it
|
|
66
|
+
Reflect.defineMetadata(API_PROPERTY_METADATA, [...existingProperties, { propertyKey, options: { _hidden: true } }], target.constructor);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get all property metadata from a class
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export function getApiProperties(target) {
|
|
74
|
+
return Reflect.getMetadata(API_PROPERTY_METADATA, target) ?? [];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=api-property.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-property.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AAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ApiQueryOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiQuery() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a query parameter for an API operation.
|
|
7
|
+
* Multiple @ApiQuery decorators can be applied for routes with multiple query parameters.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Query parameter options including name, description, and type
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/')
|
|
14
|
+
* @ApiQuery({ name: 'page', description: 'Page number', type: 'integer', required: false })
|
|
15
|
+
* @ApiQuery({ name: 'limit', description: 'Items per page', type: 'integer', required: false })
|
|
16
|
+
* @ApiQuery({ name: 'sort', description: 'Sort order', enum: ['asc', 'desc'] })
|
|
17
|
+
* listUsers(
|
|
18
|
+
* @Query('page') page?: number,
|
|
19
|
+
* @Query('limit') limit?: number,
|
|
20
|
+
* @Query('sort') sort?: string
|
|
21
|
+
* ) { }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function ApiQuery(options: ApiQueryOptions): MethodDecorator;
|
|
25
|
+
/**
|
|
26
|
+
* Get all query parameter metadata from a method
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function getApiQueries(target: Function, propertyKey: string | symbol): ApiQueryOptions[];
|
|
30
|
+
//# sourceMappingURL=api-query.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-query.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/api-query.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CAiBlE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,eAAe,EAAE,CAEnB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_QUERY_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiQuery() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a query parameter for an API operation.
|
|
7
|
+
* Multiple @ApiQuery decorators can be applied for routes with multiple query parameters.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Query parameter options including name, description, and type
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/')
|
|
14
|
+
* @ApiQuery({ name: 'page', description: 'Page number', type: 'integer', required: false })
|
|
15
|
+
* @ApiQuery({ name: 'limit', description: 'Items per page', type: 'integer', required: false })
|
|
16
|
+
* @ApiQuery({ name: 'sort', description: 'Sort order', enum: ['asc', 'desc'] })
|
|
17
|
+
* listUsers(
|
|
18
|
+
* @Query('page') page?: number,
|
|
19
|
+
* @Query('limit') limit?: number,
|
|
20
|
+
* @Query('sort') sort?: string
|
|
21
|
+
* ) { }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function ApiQuery(options) {
|
|
25
|
+
return (target, propertyKey, descriptor) => {
|
|
26
|
+
const existingQueries = Reflect.getMetadata(API_QUERY_METADATA, target, propertyKey) ?? [];
|
|
27
|
+
Reflect.defineMetadata(API_QUERY_METADATA, [...existingQueries, { ...options, required: options.required ?? false }], target, propertyKey);
|
|
28
|
+
return descriptor;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get all query parameter metadata from a method
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export function getApiQueries(target, propertyKey) {
|
|
36
|
+
return Reflect.getMetadata(API_QUERY_METADATA, target.prototype, propertyKey) ?? [];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=api-query.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-query.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-query.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EACV,EAAE;QACtB,MAAM,eAAe,GACnB,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAErE,OAAO,CAAC,cAAc,CACpB,kBAAkB,EAClB,CAAC,GAAG,eAAe,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK,EAAE,CAAC,EACzE,MAAM,EACN,WAAW,CACZ,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAgB,EAChB,WAA4B;IAE5B,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import type { ApiResponseOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiResponse() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a possible response for an API operation.
|
|
7
|
+
* Multiple @ApiResponse decorators can be applied to document different response scenarios.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Response options including status code, description, and schema
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/:id')
|
|
14
|
+
* @ApiResponse({ status: 200, description: 'User found', schema: UserSchema })
|
|
15
|
+
* @ApiResponse({ status: 404, description: 'User not found' })
|
|
16
|
+
* @ApiResponse({ status: 500, description: 'Internal server error' })
|
|
17
|
+
* getUser(@Param('id') id: string) { }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function ApiResponse(options: ApiResponseOptions): MethodDecorator;
|
|
21
|
+
/**
|
|
22
|
+
* @ApiOkResponse() - Shorthand for 200 OK response
|
|
23
|
+
*/
|
|
24
|
+
export declare function ApiOkResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
25
|
+
/**
|
|
26
|
+
* @ApiCreatedResponse() - Shorthand for 201 Created response
|
|
27
|
+
*/
|
|
28
|
+
export declare function ApiCreatedResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
29
|
+
/**
|
|
30
|
+
* @ApiAcceptedResponse() - Shorthand for 202 Accepted response
|
|
31
|
+
*/
|
|
32
|
+
export declare function ApiAcceptedResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
33
|
+
/**
|
|
34
|
+
* @ApiNoContentResponse() - Shorthand for 204 No Content response
|
|
35
|
+
*/
|
|
36
|
+
export declare function ApiNoContentResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
37
|
+
/**
|
|
38
|
+
* @ApiBadRequestResponse() - Shorthand for 400 Bad Request response
|
|
39
|
+
*/
|
|
40
|
+
export declare function ApiBadRequestResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* @ApiUnauthorizedResponse() - Shorthand for 401 Unauthorized response
|
|
43
|
+
*/
|
|
44
|
+
export declare function ApiUnauthorizedResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
45
|
+
/**
|
|
46
|
+
* @ApiForbiddenResponse() - Shorthand for 403 Forbidden response
|
|
47
|
+
*/
|
|
48
|
+
export declare function ApiForbiddenResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
49
|
+
/**
|
|
50
|
+
* @ApiNotFoundResponse() - Shorthand for 404 Not Found response
|
|
51
|
+
*/
|
|
52
|
+
export declare function ApiNotFoundResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
53
|
+
/**
|
|
54
|
+
* @ApiConflictResponse() - Shorthand for 409 Conflict response
|
|
55
|
+
*/
|
|
56
|
+
export declare function ApiConflictResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
57
|
+
/**
|
|
58
|
+
* @ApiUnprocessableEntityResponse() - Shorthand for 422 Unprocessable Entity response
|
|
59
|
+
*/
|
|
60
|
+
export declare function ApiUnprocessableEntityResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
61
|
+
/**
|
|
62
|
+
* @ApiInternalServerErrorResponse() - Shorthand for 500 Internal Server Error response
|
|
63
|
+
*/
|
|
64
|
+
export declare function ApiInternalServerErrorResponse(options?: Omit<ApiResponseOptions, 'status'>): MethodDecorator;
|
|
65
|
+
/**
|
|
66
|
+
* Get all response metadata from a method
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export declare function getApiResponses(target: Function, propertyKey: string | symbol): ApiResponseOptions[];
|
|
70
|
+
//# sourceMappingURL=api-response.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/api-response.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,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,CAAM,GAC/C,eAAe,CAEjB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,kBAAkB,EAAE,CAEtB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { API_RESPONSE_METADATA } from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @ApiResponse() decorator
|
|
5
|
+
*
|
|
6
|
+
* Documents a possible response for an API operation.
|
|
7
|
+
* Multiple @ApiResponse decorators can be applied to document different response scenarios.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Response options including status code, description, and schema
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Get('/:id')
|
|
14
|
+
* @ApiResponse({ status: 200, description: 'User found', schema: UserSchema })
|
|
15
|
+
* @ApiResponse({ status: 404, description: 'User not found' })
|
|
16
|
+
* @ApiResponse({ status: 500, description: 'Internal server error' })
|
|
17
|
+
* getUser(@Param('id') id: string) { }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function ApiResponse(options) {
|
|
21
|
+
return (target, propertyKey, descriptor) => {
|
|
22
|
+
const existingResponses = Reflect.getMetadata(API_RESPONSE_METADATA, target, propertyKey) ?? [];
|
|
23
|
+
Reflect.defineMetadata(API_RESPONSE_METADATA, [...existingResponses, options], target, propertyKey);
|
|
24
|
+
return descriptor;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @ApiOkResponse() - Shorthand for 200 OK response
|
|
29
|
+
*/
|
|
30
|
+
export function ApiOkResponse(options = {}) {
|
|
31
|
+
return ApiResponse({ ...options, status: 200 });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @ApiCreatedResponse() - Shorthand for 201 Created response
|
|
35
|
+
*/
|
|
36
|
+
export function ApiCreatedResponse(options = {}) {
|
|
37
|
+
return ApiResponse({ ...options, status: 201 });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @ApiAcceptedResponse() - Shorthand for 202 Accepted response
|
|
41
|
+
*/
|
|
42
|
+
export function ApiAcceptedResponse(options = {}) {
|
|
43
|
+
return ApiResponse({ ...options, status: 202 });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @ApiNoContentResponse() - Shorthand for 204 No Content response
|
|
47
|
+
*/
|
|
48
|
+
export function ApiNoContentResponse(options = {}) {
|
|
49
|
+
return ApiResponse({ ...options, status: 204 });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @ApiBadRequestResponse() - Shorthand for 400 Bad Request response
|
|
53
|
+
*/
|
|
54
|
+
export function ApiBadRequestResponse(options = {}) {
|
|
55
|
+
return ApiResponse({ ...options, status: 400, description: options.description ?? 'Bad Request' });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @ApiUnauthorizedResponse() - Shorthand for 401 Unauthorized response
|
|
59
|
+
*/
|
|
60
|
+
export function ApiUnauthorizedResponse(options = {}) {
|
|
61
|
+
return ApiResponse({ ...options, status: 401, description: options.description ?? 'Unauthorized' });
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @ApiForbiddenResponse() - Shorthand for 403 Forbidden response
|
|
65
|
+
*/
|
|
66
|
+
export function ApiForbiddenResponse(options = {}) {
|
|
67
|
+
return ApiResponse({ ...options, status: 403, description: options.description ?? 'Forbidden' });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @ApiNotFoundResponse() - Shorthand for 404 Not Found response
|
|
71
|
+
*/
|
|
72
|
+
export function ApiNotFoundResponse(options = {}) {
|
|
73
|
+
return ApiResponse({ ...options, status: 404, description: options.description ?? 'Not Found' });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @ApiConflictResponse() - Shorthand for 409 Conflict response
|
|
77
|
+
*/
|
|
78
|
+
export function ApiConflictResponse(options = {}) {
|
|
79
|
+
return ApiResponse({ ...options, status: 409, description: options.description ?? 'Conflict' });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @ApiUnprocessableEntityResponse() - Shorthand for 422 Unprocessable Entity response
|
|
83
|
+
*/
|
|
84
|
+
export function ApiUnprocessableEntityResponse(options = {}) {
|
|
85
|
+
return ApiResponse({ ...options, status: 422, description: options.description ?? 'Unprocessable Entity' });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @ApiInternalServerErrorResponse() - Shorthand for 500 Internal Server Error response
|
|
89
|
+
*/
|
|
90
|
+
export function ApiInternalServerErrorResponse(options = {}) {
|
|
91
|
+
return ApiResponse({ ...options, status: 500, description: options.description ?? 'Internal Server Error' });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all response metadata from a method
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
export function getApiResponses(target, propertyKey) {
|
|
98
|
+
return Reflect.getMetadata(API_RESPONSE_METADATA, target.prototype, propertyKey) ?? [];
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=api-response.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.decorator.js","sourceRoot":"","sources":["../../src/decorators/api-response.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,OAAO,CACL,MAAc,EACd,WAA4B,EAC5B,UAA8B,EACV,EAAE;QACtB,MAAM,iBAAiB,GACrB,OAAO,CAAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAExE,OAAO,CAAC,cAAc,CACpB,qBAAqB,EACrB,CAAC,GAAG,iBAAiB,EAAE,OAAO,CAAC,EAC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