@digitaldefiance/node-express-suite 3.11.32 → 3.12.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.
Files changed (146) hide show
  1. package/README.md +858 -0
  2. package/package.json +1 -1
  3. package/src/controllers/openapi.d.ts +67 -0
  4. package/src/controllers/openapi.d.ts.map +1 -0
  5. package/src/controllers/openapi.js +89 -0
  6. package/src/controllers/openapi.js.map +1 -0
  7. package/src/decorators/auth.d.ts +128 -0
  8. package/src/decorators/auth.d.ts.map +1 -0
  9. package/src/decorators/auth.js +230 -0
  10. package/src/decorators/auth.js.map +1 -0
  11. package/src/decorators/base-controller.d.ts +144 -6
  12. package/src/decorators/base-controller.d.ts.map +1 -1
  13. package/src/decorators/base-controller.js +487 -31
  14. package/src/decorators/base-controller.js.map +1 -1
  15. package/src/decorators/controller.d.ts +63 -7
  16. package/src/decorators/controller.d.ts.map +1 -1
  17. package/src/decorators/controller.js +70 -39
  18. package/src/decorators/controller.js.map +1 -1
  19. package/src/decorators/handler-args.d.ts +68 -0
  20. package/src/decorators/handler-args.d.ts.map +1 -0
  21. package/src/decorators/handler-args.js +83 -0
  22. package/src/decorators/handler-args.js.map +1 -0
  23. package/src/decorators/http-methods.d.ts +143 -0
  24. package/src/decorators/http-methods.d.ts.map +1 -0
  25. package/src/decorators/http-methods.js +265 -0
  26. package/src/decorators/http-methods.js.map +1 -0
  27. package/src/decorators/index.d.ts +22 -0
  28. package/src/decorators/index.d.ts.map +1 -1
  29. package/src/decorators/index.js +56 -0
  30. package/src/decorators/index.js.map +1 -1
  31. package/src/decorators/lifecycle.d.ts +248 -0
  32. package/src/decorators/lifecycle.d.ts.map +1 -0
  33. package/src/decorators/lifecycle.js +301 -0
  34. package/src/decorators/lifecycle.js.map +1 -0
  35. package/src/decorators/metadata-collector.d.ts +175 -0
  36. package/src/decorators/metadata-collector.d.ts.map +1 -0
  37. package/src/decorators/metadata-collector.js +272 -0
  38. package/src/decorators/metadata-collector.js.map +1 -0
  39. package/src/decorators/metadata-keys.d.ts +121 -0
  40. package/src/decorators/metadata-keys.d.ts.map +1 -0
  41. package/src/decorators/metadata-keys.js +116 -0
  42. package/src/decorators/metadata-keys.js.map +1 -0
  43. package/src/decorators/middleware.d.ts +181 -0
  44. package/src/decorators/middleware.d.ts.map +1 -0
  45. package/src/decorators/middleware.js +400 -0
  46. package/src/decorators/middleware.js.map +1 -0
  47. package/src/decorators/openapi-params.d.ts +192 -0
  48. package/src/decorators/openapi-params.d.ts.map +1 -0
  49. package/src/decorators/openapi-params.js +332 -0
  50. package/src/decorators/openapi-params.js.map +1 -0
  51. package/src/decorators/openapi.d.ts +201 -0
  52. package/src/decorators/openapi.d.ts.map +1 -0
  53. package/src/decorators/openapi.js +334 -0
  54. package/src/decorators/openapi.js.map +1 -0
  55. package/src/decorators/params.d.ts +217 -0
  56. package/src/decorators/params.d.ts.map +1 -0
  57. package/src/decorators/params.js +323 -0
  58. package/src/decorators/params.js.map +1 -0
  59. package/src/decorators/response.d.ts +200 -0
  60. package/src/decorators/response.d.ts.map +1 -0
  61. package/src/decorators/response.js +315 -0
  62. package/src/decorators/response.js.map +1 -0
  63. package/src/decorators/schema.d.ts +99 -0
  64. package/src/decorators/schema.d.ts.map +1 -0
  65. package/src/decorators/schema.js +329 -0
  66. package/src/decorators/schema.js.map +1 -0
  67. package/src/decorators/transaction.d.ts +69 -0
  68. package/src/decorators/transaction.d.ts.map +1 -0
  69. package/src/decorators/transaction.js +80 -0
  70. package/src/decorators/transaction.js.map +1 -0
  71. package/src/decorators/validation.d.ts +188 -0
  72. package/src/decorators/validation.d.ts.map +1 -0
  73. package/src/decorators/validation.js +269 -0
  74. package/src/decorators/validation.js.map +1 -0
  75. package/src/decorators/zod-validation.d.ts +164 -4
  76. package/src/decorators/zod-validation.d.ts.map +1 -1
  77. package/src/decorators/zod-validation.js +692 -13
  78. package/src/decorators/zod-validation.js.map +1 -1
  79. package/src/index.d.ts +1 -0
  80. package/src/index.d.ts.map +1 -1
  81. package/src/index.js +1 -0
  82. package/src/index.js.map +1 -1
  83. package/src/interfaces/openApi/decoratorOptions.d.ts +760 -0
  84. package/src/interfaces/openApi/decoratorOptions.d.ts.map +1 -0
  85. package/src/interfaces/openApi/decoratorOptions.js +734 -0
  86. package/src/interfaces/openApi/decoratorOptions.js.map +1 -0
  87. package/src/interfaces/openApi/index.d.ts +1 -0
  88. package/src/interfaces/openApi/index.d.ts.map +1 -1
  89. package/src/interfaces/openApi/index.js +23 -0
  90. package/src/interfaces/openApi/index.js.map +1 -1
  91. package/src/interfaces/openApi/parameter.d.ts +2 -0
  92. package/src/interfaces/openApi/parameter.d.ts.map +1 -1
  93. package/src/interfaces/openApi/parameter.js +3 -1
  94. package/src/interfaces/openApi/parameter.js.map +1 -1
  95. package/src/interfaces/openApi/parameterSchema.d.ts +2 -0
  96. package/src/interfaces/openApi/parameterSchema.d.ts.map +1 -1
  97. package/src/interfaces/openApi/parameterSchema.js +3 -0
  98. package/src/interfaces/openApi/parameterSchema.js.map +1 -1
  99. package/src/openapi/builder.d.ts +249 -0
  100. package/src/openapi/builder.d.ts.map +1 -0
  101. package/src/openapi/builder.js +352 -0
  102. package/src/openapi/builder.js.map +1 -0
  103. package/src/openapi/controller.d.ts +153 -0
  104. package/src/openapi/controller.d.ts.map +1 -0
  105. package/src/openapi/controller.js +331 -0
  106. package/src/openapi/controller.js.map +1 -0
  107. package/src/openapi/index.d.ts +12 -0
  108. package/src/openapi/index.d.ts.map +1 -0
  109. package/src/openapi/index.js +20 -0
  110. package/src/openapi/index.js.map +1 -0
  111. package/src/openapi/markdown-generator.d.ts +52 -0
  112. package/src/openapi/markdown-generator.d.ts.map +1 -0
  113. package/src/openapi/markdown-generator.js +569 -0
  114. package/src/openapi/markdown-generator.js.map +1 -0
  115. package/src/openapi/middleware/index.d.ts +9 -0
  116. package/src/openapi/middleware/index.d.ts.map +1 -0
  117. package/src/openapi/middleware/index.js +15 -0
  118. package/src/openapi/middleware/index.js.map +1 -0
  119. package/src/openapi/middleware/redoc.d.ts +314 -0
  120. package/src/openapi/middleware/redoc.d.ts.map +1 -0
  121. package/src/openapi/middleware/redoc.js +181 -0
  122. package/src/openapi/middleware/redoc.js.map +1 -0
  123. package/src/openapi/middleware/swagger-ui.d.ts +123 -0
  124. package/src/openapi/middleware/swagger-ui.d.ts.map +1 -0
  125. package/src/openapi/middleware/swagger-ui.js +227 -0
  126. package/src/openapi/middleware/swagger-ui.js.map +1 -0
  127. package/src/openapi/schemas.d.ts +170 -0
  128. package/src/openapi/schemas.d.ts.map +1 -0
  129. package/src/openapi/schemas.js +340 -0
  130. package/src/openapi/schemas.js.map +1 -0
  131. package/src/registry/controller-registry.d.ts +78 -0
  132. package/src/registry/controller-registry.d.ts.map +1 -0
  133. package/src/registry/controller-registry.js +86 -0
  134. package/src/registry/controller-registry.js.map +1 -0
  135. package/src/registry/index.d.ts +2 -0
  136. package/src/registry/index.d.ts.map +1 -1
  137. package/src/registry/index.js +3 -1
  138. package/src/registry/index.js.map +1 -1
  139. package/src/routers/api.d.ts +2 -1
  140. package/src/routers/api.d.ts.map +1 -1
  141. package/src/routers/api.js +7 -1
  142. package/src/routers/api.js.map +1 -1
  143. package/src/types.d.ts +1 -0
  144. package/src/types.d.ts.map +1 -1
  145. package/src/types.js +1 -0
  146. package/src/types.js.map +1 -1
@@ -0,0 +1,217 @@
1
+ /**
2
+ * @fileoverview Parameter injection decorators for Express Suite.
3
+ * Provides @Param, @Body, @Query, @Header, @CurrentUser, @EciesUser, @Req, @Res, @Next decorators.
4
+ * Automatically generates OpenAPI parameters for @Param, @Query, @Header.
5
+ * @module decorators/params
6
+ */
7
+ import 'reflect-metadata';
8
+ import { ParamDecoratorOptions, ParamMetadata } from '../interfaces/openApi/decoratorOptions';
9
+ import { OpenAPIParameter } from '../interfaces/openApi/parameter';
10
+ /**
11
+ * Decorator that injects a path parameter value into the method parameter.
12
+ * Automatically adds OpenAPI path parameter documentation.
13
+ *
14
+ * @param name - Name of the path parameter to extract
15
+ * @param options - Optional parameter options (description, example, schema)
16
+ * @returns Parameter decorator
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * @ApiController('/api/users')
21
+ * class UserController {
22
+ * @Get('/:id')
23
+ * async getUser(@Param('id', { description: 'User ID' }) id: string) {
24
+ * return this.userService.findById(id);
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function Param(name: string, options?: ParamDecoratorOptions): ParameterDecorator;
30
+ /**
31
+ * Decorator that injects the request body or a specific field from it.
32
+ * Does not auto-generate OpenAPI parameters (use @ApiRequestBody for that).
33
+ *
34
+ * @param field - Optional field name to extract from the body
35
+ * @returns Parameter decorator
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * @ApiController('/api/users')
40
+ * class UserController {
41
+ * // Inject entire body
42
+ * @Post('/')
43
+ * async createUser(@Body() data: CreateUserDto) {
44
+ * return this.userService.create(data);
45
+ * }
46
+ *
47
+ * // Inject specific field
48
+ * @Post('/login')
49
+ * async login(@Body('email') email: string, @Body('password') password: string) {
50
+ * return this.authService.login(email, password);
51
+ * }
52
+ * }
53
+ * ```
54
+ */
55
+ export declare function Body(field?: string): ParameterDecorator;
56
+ /**
57
+ * Decorator that injects a query parameter value into the method parameter.
58
+ * Automatically adds OpenAPI query parameter documentation.
59
+ *
60
+ * @param name - Name of the query parameter to extract
61
+ * @param options - Optional parameter options (description, example, required, schema)
62
+ * @returns Parameter decorator
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * @ApiController('/api/users')
67
+ * class UserController {
68
+ * @Get('/')
69
+ * async listUsers(
70
+ * @Query('page', { description: 'Page number', schema: { type: 'integer' } }) page: number,
71
+ * @Query('limit', { description: 'Items per page' }) limit: number,
72
+ * ) {
73
+ * return this.userService.findAll({ page, limit });
74
+ * }
75
+ * }
76
+ * ```
77
+ */
78
+ export declare function Query(name: string, options?: ParamDecoratorOptions): ParameterDecorator;
79
+ /**
80
+ * Decorator that injects a header value into the method parameter.
81
+ * Automatically adds OpenAPI header parameter documentation.
82
+ *
83
+ * @param name - Name of the header to extract
84
+ * @param options - Optional parameter options (description, example, required, schema)
85
+ * @returns Parameter decorator
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * @ApiController('/api/data')
90
+ * class DataController {
91
+ * @Get('/')
92
+ * async getData(
93
+ * @Header('X-Request-ID', { description: 'Request tracking ID' }) requestId: string,
94
+ * @Header('Accept-Language') language: string,
95
+ * ) {
96
+ * return this.dataService.get({ requestId, language });
97
+ * }
98
+ * }
99
+ * ```
100
+ */
101
+ export declare function Header(name: string, options?: ParamDecoratorOptions): ParameterDecorator;
102
+ /**
103
+ * Decorator that injects the authenticated user from the request.
104
+ * Injects `req.user` which is populated by JWT authentication middleware.
105
+ *
106
+ * @returns Parameter decorator
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * @RequireAuth()
111
+ * @ApiController('/api/profile')
112
+ * class ProfileController {
113
+ * @Get('/')
114
+ * async getProfile(@CurrentUser() user: AuthenticatedUser) {
115
+ * return this.profileService.getByUserId(user.id);
116
+ * }
117
+ * }
118
+ * ```
119
+ */
120
+ export declare function CurrentUser(): ParameterDecorator;
121
+ /**
122
+ * Decorator that injects the ECIES authenticated member from the request.
123
+ * Injects `req.eciesUser` which is populated by ECIES crypto authentication middleware.
124
+ *
125
+ * @returns Parameter decorator
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * @RequireCryptoAuth()
130
+ * @ApiController('/api/secure')
131
+ * class SecureController {
132
+ * @Get('/data')
133
+ * async getSecureData(@EciesUser() member: EciesMember) {
134
+ * return this.secureService.getDataForMember(member);
135
+ * }
136
+ * }
137
+ * ```
138
+ */
139
+ export declare function EciesUser(): ParameterDecorator;
140
+ /**
141
+ * Decorator that injects the raw Express Request object.
142
+ * Use sparingly - prefer specific parameter decorators when possible.
143
+ *
144
+ * @returns Parameter decorator
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * @ApiController('/api/upload')
149
+ * class UploadController {
150
+ * @Post('/')
151
+ * async upload(@Req() req: Request) {
152
+ * // Access raw request for file uploads, etc.
153
+ * return this.uploadService.handleUpload(req);
154
+ * }
155
+ * }
156
+ * ```
157
+ */
158
+ export declare function Req(): ParameterDecorator;
159
+ /**
160
+ * Decorator that injects the raw Express Response object.
161
+ * Use sparingly - prefer returning values from handlers when possible.
162
+ *
163
+ * @returns Parameter decorator
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * @ApiController('/api/download')
168
+ * class DownloadController {
169
+ * @Get('/:id')
170
+ * async download(@Param('id') id: string, @Res() res: Response) {
171
+ * // Stream file directly to response
172
+ * const stream = await this.fileService.getStream(id);
173
+ * stream.pipe(res);
174
+ * }
175
+ * }
176
+ * ```
177
+ */
178
+ export declare function Res(): ParameterDecorator;
179
+ /**
180
+ * Decorator that injects the Express NextFunction.
181
+ * Useful for middleware-like handlers that need to pass control.
182
+ *
183
+ * @returns Parameter decorator
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * @ApiController('/api/middleware')
188
+ * class MiddlewareController {
189
+ * @Get('/')
190
+ * async handle(@Req() req: Request, @Res() res: Response, @Next() next: NextFunction) {
191
+ * if (someCondition) {
192
+ * return next();
193
+ * }
194
+ * res.json({ handled: true });
195
+ * }
196
+ * }
197
+ * ```
198
+ */
199
+ export declare function Next(): ParameterDecorator;
200
+ /**
201
+ * Gets all parameter metadata for a method.
202
+ * Returns parameters sorted by index for proper injection order.
203
+ *
204
+ * @param target - The class constructor
205
+ * @param propertyKey - The method name
206
+ * @returns Array of parameter metadata sorted by index
207
+ */
208
+ export declare function getParamMetadata(target: object, propertyKey: string | symbol): ParamMetadata[];
209
+ /**
210
+ * Gets OpenAPI parameter definitions for a method.
211
+ *
212
+ * @param target - The class constructor
213
+ * @param propertyKey - The method name
214
+ * @returns Array of OpenAPI parameter definitions
215
+ */
216
+ export declare function getOpenAPIParamMetadata(target: object, propertyKey: string | symbol): OpenAPIParameter[];
217
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/decorators/params.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,aAAa,EACd,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAuHnE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,GAC9B,kBAAkB,CAEpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAEvD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,GAC9B,kBAAkB,CAEpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,GAC9B,kBAAkB,CAEpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,IAAI,kBAAkB,CAEhD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,kBAAkB,CAE9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,IAAI,kBAAkB,CAExC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,IAAI,kBAAkB,CAExC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,IAAI,kBAAkB,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,aAAa,EAAE,CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,gBAAgB,EAAE,CAOpB"}
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Parameter injection decorators for Express Suite.
4
+ * Provides @Param, @Body, @Query, @Header, @CurrentUser, @EciesUser, @Req, @Res, @Next decorators.
5
+ * Automatically generates OpenAPI parameters for @Param, @Query, @Header.
6
+ * @module decorators/params
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Param = Param;
10
+ exports.Body = Body;
11
+ exports.Query = Query;
12
+ exports.Header = Header;
13
+ exports.CurrentUser = CurrentUser;
14
+ exports.EciesUser = EciesUser;
15
+ exports.Req = Req;
16
+ exports.Res = Res;
17
+ exports.Next = Next;
18
+ exports.getParamMetadata = getParamMetadata;
19
+ exports.getOpenAPIParamMetadata = getOpenAPIParamMetadata;
20
+ require("reflect-metadata");
21
+ const metadata_keys_1 = require("./metadata-keys");
22
+ const metadata_collector_1 = require("./metadata-collector");
23
+ /**
24
+ * Creates a parameter decorator that stores metadata for parameter injection.
25
+ * @param type - The type of parameter injection
26
+ * @param name - Optional name of the parameter to extract
27
+ * @param options - Optional parameter options
28
+ * @returns Parameter decorator function
29
+ */
30
+ function createParamDecorator(type, name, options) {
31
+ return function (target, propertyKey, parameterIndex) {
32
+ if (propertyKey === undefined) {
33
+ return;
34
+ }
35
+ const constructor = target.constructor;
36
+ // Get existing params metadata or initialize empty array
37
+ const existingParams = (0, metadata_collector_1.getMetadataOrDefault)(metadata_keys_1.PARAMS_METADATA, constructor, propertyKey, []);
38
+ // Create param metadata
39
+ const paramMetadata = {
40
+ index: parameterIndex,
41
+ type,
42
+ name,
43
+ options,
44
+ };
45
+ // Add to params array
46
+ existingParams.push(paramMetadata);
47
+ (0, metadata_collector_1.setMetadata)(metadata_keys_1.PARAMS_METADATA, existingParams, constructor, propertyKey);
48
+ // Auto-add OpenAPI parameter for param, query, header types
49
+ if (type === 'param' || type === 'query' || type === 'header') {
50
+ addOpenAPIParameter(constructor, propertyKey, type, name, options);
51
+ }
52
+ };
53
+ }
54
+ /**
55
+ * Adds an OpenAPI parameter definition for the decorated parameter.
56
+ * @param target - The class constructor
57
+ * @param propertyKey - The method name
58
+ * @param type - The parameter type (param, query, header)
59
+ * @param name - The parameter name
60
+ * @param options - Optional parameter options
61
+ */
62
+ function addOpenAPIParameter(target, propertyKey, type, name, options) {
63
+ if (!name) {
64
+ return;
65
+ }
66
+ // Map decorator type to OpenAPI 'in' location
67
+ const locationMap = {
68
+ param: 'path',
69
+ query: 'query',
70
+ header: 'header',
71
+ };
72
+ const existingOpenAPIParams = (0, metadata_collector_1.getMetadataOrDefault)(metadata_keys_1.OPENAPI_PARAMS_METADATA, target, propertyKey, []);
73
+ // Check if parameter already exists (avoid duplicates)
74
+ const existingIndex = existingOpenAPIParams.findIndex((p) => p.name === name && p.in === locationMap[type]);
75
+ const openAPIParam = {
76
+ name,
77
+ in: locationMap[type],
78
+ required: type === 'param' ? true : (options?.required ?? false),
79
+ schema: options?.schema ?? { type: 'string' },
80
+ ...(options?.description && { description: options.description }),
81
+ };
82
+ if (existingIndex >= 0) {
83
+ // Update existing parameter
84
+ existingOpenAPIParams[existingIndex] = openAPIParam;
85
+ }
86
+ else {
87
+ // Add new parameter
88
+ existingOpenAPIParams.push(openAPIParam);
89
+ }
90
+ (0, metadata_collector_1.setMetadata)(metadata_keys_1.OPENAPI_PARAMS_METADATA, existingOpenAPIParams, target, propertyKey);
91
+ }
92
+ /**
93
+ * Decorator that injects a path parameter value into the method parameter.
94
+ * Automatically adds OpenAPI path parameter documentation.
95
+ *
96
+ * @param name - Name of the path parameter to extract
97
+ * @param options - Optional parameter options (description, example, schema)
98
+ * @returns Parameter decorator
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * @ApiController('/api/users')
103
+ * class UserController {
104
+ * @Get('/:id')
105
+ * async getUser(@Param('id', { description: 'User ID' }) id: string) {
106
+ * return this.userService.findById(id);
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ function Param(name, options) {
112
+ return createParamDecorator('param', name, options);
113
+ }
114
+ /**
115
+ * Decorator that injects the request body or a specific field from it.
116
+ * Does not auto-generate OpenAPI parameters (use @ApiRequestBody for that).
117
+ *
118
+ * @param field - Optional field name to extract from the body
119
+ * @returns Parameter decorator
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * @ApiController('/api/users')
124
+ * class UserController {
125
+ * // Inject entire body
126
+ * @Post('/')
127
+ * async createUser(@Body() data: CreateUserDto) {
128
+ * return this.userService.create(data);
129
+ * }
130
+ *
131
+ * // Inject specific field
132
+ * @Post('/login')
133
+ * async login(@Body('email') email: string, @Body('password') password: string) {
134
+ * return this.authService.login(email, password);
135
+ * }
136
+ * }
137
+ * ```
138
+ */
139
+ function Body(field) {
140
+ return createParamDecorator('body', field);
141
+ }
142
+ /**
143
+ * Decorator that injects a query parameter value into the method parameter.
144
+ * Automatically adds OpenAPI query parameter documentation.
145
+ *
146
+ * @param name - Name of the query parameter to extract
147
+ * @param options - Optional parameter options (description, example, required, schema)
148
+ * @returns Parameter decorator
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * @ApiController('/api/users')
153
+ * class UserController {
154
+ * @Get('/')
155
+ * async listUsers(
156
+ * @Query('page', { description: 'Page number', schema: { type: 'integer' } }) page: number,
157
+ * @Query('limit', { description: 'Items per page' }) limit: number,
158
+ * ) {
159
+ * return this.userService.findAll({ page, limit });
160
+ * }
161
+ * }
162
+ * ```
163
+ */
164
+ function Query(name, options) {
165
+ return createParamDecorator('query', name, options);
166
+ }
167
+ /**
168
+ * Decorator that injects a header value into the method parameter.
169
+ * Automatically adds OpenAPI header parameter documentation.
170
+ *
171
+ * @param name - Name of the header to extract
172
+ * @param options - Optional parameter options (description, example, required, schema)
173
+ * @returns Parameter decorator
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * @ApiController('/api/data')
178
+ * class DataController {
179
+ * @Get('/')
180
+ * async getData(
181
+ * @Header('X-Request-ID', { description: 'Request tracking ID' }) requestId: string,
182
+ * @Header('Accept-Language') language: string,
183
+ * ) {
184
+ * return this.dataService.get({ requestId, language });
185
+ * }
186
+ * }
187
+ * ```
188
+ */
189
+ function Header(name, options) {
190
+ return createParamDecorator('header', name, options);
191
+ }
192
+ /**
193
+ * Decorator that injects the authenticated user from the request.
194
+ * Injects `req.user` which is populated by JWT authentication middleware.
195
+ *
196
+ * @returns Parameter decorator
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * @RequireAuth()
201
+ * @ApiController('/api/profile')
202
+ * class ProfileController {
203
+ * @Get('/')
204
+ * async getProfile(@CurrentUser() user: AuthenticatedUser) {
205
+ * return this.profileService.getByUserId(user.id);
206
+ * }
207
+ * }
208
+ * ```
209
+ */
210
+ function CurrentUser() {
211
+ return createParamDecorator('user');
212
+ }
213
+ /**
214
+ * Decorator that injects the ECIES authenticated member from the request.
215
+ * Injects `req.eciesUser` which is populated by ECIES crypto authentication middleware.
216
+ *
217
+ * @returns Parameter decorator
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * @RequireCryptoAuth()
222
+ * @ApiController('/api/secure')
223
+ * class SecureController {
224
+ * @Get('/data')
225
+ * async getSecureData(@EciesUser() member: EciesMember) {
226
+ * return this.secureService.getDataForMember(member);
227
+ * }
228
+ * }
229
+ * ```
230
+ */
231
+ function EciesUser() {
232
+ return createParamDecorator('eciesUser');
233
+ }
234
+ /**
235
+ * Decorator that injects the raw Express Request object.
236
+ * Use sparingly - prefer specific parameter decorators when possible.
237
+ *
238
+ * @returns Parameter decorator
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * @ApiController('/api/upload')
243
+ * class UploadController {
244
+ * @Post('/')
245
+ * async upload(@Req() req: Request) {
246
+ * // Access raw request for file uploads, etc.
247
+ * return this.uploadService.handleUpload(req);
248
+ * }
249
+ * }
250
+ * ```
251
+ */
252
+ function Req() {
253
+ return createParamDecorator('req');
254
+ }
255
+ /**
256
+ * Decorator that injects the raw Express Response object.
257
+ * Use sparingly - prefer returning values from handlers when possible.
258
+ *
259
+ * @returns Parameter decorator
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * @ApiController('/api/download')
264
+ * class DownloadController {
265
+ * @Get('/:id')
266
+ * async download(@Param('id') id: string, @Res() res: Response) {
267
+ * // Stream file directly to response
268
+ * const stream = await this.fileService.getStream(id);
269
+ * stream.pipe(res);
270
+ * }
271
+ * }
272
+ * ```
273
+ */
274
+ function Res() {
275
+ return createParamDecorator('res');
276
+ }
277
+ /**
278
+ * Decorator that injects the Express NextFunction.
279
+ * Useful for middleware-like handlers that need to pass control.
280
+ *
281
+ * @returns Parameter decorator
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * @ApiController('/api/middleware')
286
+ * class MiddlewareController {
287
+ * @Get('/')
288
+ * async handle(@Req() req: Request, @Res() res: Response, @Next() next: NextFunction) {
289
+ * if (someCondition) {
290
+ * return next();
291
+ * }
292
+ * res.json({ handled: true });
293
+ * }
294
+ * }
295
+ * ```
296
+ */
297
+ function Next() {
298
+ return createParamDecorator('next');
299
+ }
300
+ /**
301
+ * Gets all parameter metadata for a method.
302
+ * Returns parameters sorted by index for proper injection order.
303
+ *
304
+ * @param target - The class constructor
305
+ * @param propertyKey - The method name
306
+ * @returns Array of parameter metadata sorted by index
307
+ */
308
+ function getParamMetadata(target, propertyKey) {
309
+ const params = (0, metadata_collector_1.getMetadataOrDefault)(metadata_keys_1.PARAMS_METADATA, target, propertyKey, []);
310
+ // Sort by parameter index for proper injection order
311
+ return [...params].sort((a, b) => a.index - b.index);
312
+ }
313
+ /**
314
+ * Gets OpenAPI parameter definitions for a method.
315
+ *
316
+ * @param target - The class constructor
317
+ * @param propertyKey - The method name
318
+ * @returns Array of OpenAPI parameter definitions
319
+ */
320
+ function getOpenAPIParamMetadata(target, propertyKey) {
321
+ return (0, metadata_collector_1.getMetadataOrDefault)(metadata_keys_1.OPENAPI_PARAMS_METADATA, target, propertyKey, []);
322
+ }
323
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-express-suite/src/decorators/params.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAiJH,sBAKC;AA2BD,oBAEC;AAwBD,sBAKC;AAwBD,wBAKC;AAoBD,kCAEC;AAoBD,8BAEC;AAoBD,kBAEC;AAqBD,kBAEC;AAsBD,oBAEC;AAUD,4CAYC;AASD,0DAUC;AArYD,4BAA0B;AAM1B,mDAA2E;AAC3E,6DAAyE;AAEzE;;;;;;GAMG;AACH,SAAS,oBAAoB,CAC3B,IAA2B,EAC3B,IAAa,EACb,OAA+B;IAE/B,OAAO,UACL,MAAc,EACd,WAAwC,EACxC,cAAsB;QAEtB,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QAEvC,yDAAyD;QACzD,MAAM,cAAc,GAAG,IAAA,yCAAoB,EACzC,+BAAe,EACf,WAAW,EACX,WAAW,EACX,EAAE,CACH,CAAC;QAEF,wBAAwB;QACxB,MAAM,aAAa,GAAkB;YACnC,KAAK,EAAE,cAAc;YACrB,IAAI;YACJ,IAAI;YACJ,OAAO;SACR,CAAC;QAEF,sBAAsB;QACtB,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnC,IAAA,gCAAW,EAAC,+BAAe,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;QAEvE,4DAA4D;QAC5D,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9D,mBAAmB,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACrE,CAA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