raiton 5.4.0-beta.2 → 5.6.0-beta.4

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 CHANGED
@@ -94,7 +94,7 @@ Raiton détecte automatiquement l'environnement d'exécution et adapte son serve
94
94
 
95
95
  Example
96
96
  ```typescript
97
- import { Controllable, Get, ApiOkResponse, ApiResponse } from '@protorians/framework';
97
+ import { Controllable, Get, ApiOkResponse, ApiResponse } from 'raiton/framework';
98
98
 
99
99
  @Controllable('/users')
100
100
  export class UserController {
@@ -125,6 +125,23 @@ Example
125
125
  }
126
126
  ```
127
127
 
128
+ ```typescript
129
+ import { Controllable, Get, ApiQuery } from "raiton/framework";
130
+
131
+ @Controllable("/users")
132
+ export class UserController {
133
+ @Get()
134
+ @ApiQuery("name", { description: "Filter by name", required: false, type:
135
+ String })
136
+ @ApiQuery("limit", { description: "Max results", required: false, type:
137
+ Number })
138
+ async getUsers(ctx) {
139
+ const { name, limit } = ctx.query;
140
+ // …
141
+ }
142
+ }
143
+ ```
144
+
128
145
  ## Licence
129
146
 
130
147
  Ce projet est sous licence MIT. Voir le fichier [LICENSE](LICENSE) pour plus de détails.
@@ -4817,7 +4817,7 @@ var {
4817
4817
  Help
4818
4818
  } = import__.default;
4819
4819
  // package.json
4820
- var version = "5.4.0-beta.2";
4820
+ var version = "5.6.0-beta.4";
4821
4821
 
4822
4822
  // source/bin/cli.ts
4823
4823
  var CLI = new Command;
@@ -6257,6 +6257,7 @@ var METADATA_KEYS = {
6257
6257
  API_RESPONSES: Symbol("api:responses"),
6258
6258
  API_REQUEST_BODY: Symbol("api:requestBody"),
6259
6259
  API_PARAMETERS: Symbol("api:parameters"),
6260
+ API_ENUMS: Symbol("api:enums"),
6260
6261
  API_TAGS: Symbol("api:tags"),
6261
6262
  API_OPERATION: Symbol("api:operation"),
6262
6263
  API_SECURITY: Symbol("api:security")
@@ -6695,7 +6696,7 @@ class Injection {
6695
6696
  const name = metadata?.name || ("constructor" in construct ? construct.constructor.name || false : false) || construct.name;
6696
6697
  if (!metadata) {
6697
6698
  if (typeof name === "undefined")
6698
- Logger.debug("Cannot resolve", construct);
6699
+ Logger.debug("Cannot resolve", name, ":", construct);
6699
6700
  throw new Throwable(`Cannot resolve ${name} as dependency`);
6700
6701
  }
6701
6702
  return this.get(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiton",
3
- "version": "5.4.0-beta.2",
3
+ "version": "5.6.0-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading.",
@@ -214,7 +214,7 @@ export class Injection {
214
214
  const name = metadata?.name || ('constructor' in construct ? construct.constructor.name || false : false) || construct.name;
215
215
 
216
216
  if (!metadata) {
217
- if (typeof name === 'undefined') Logger.debug('Cannot resolve', construct);
217
+ if (typeof name === 'undefined') Logger.debug('Cannot resolve', name, ':', construct);
218
218
  throw new Throwable(`Cannot resolve ${name} as dependency`);
219
219
  }
220
220
 
@@ -11,6 +11,7 @@ export const METADATA_KEYS = {
11
11
  API_RESPONSES: Symbol('api:responses'),
12
12
  API_REQUEST_BODY: Symbol('api:requestBody'),
13
13
  API_PARAMETERS: Symbol('api:parameters'),
14
+ API_ENUMS: Symbol('api:enums'),
14
15
  API_TAGS: Symbol('api:tags'),
15
16
  API_OPERATION: Symbol('api:operation'),
16
17
  API_SECURITY: Symbol('api:security'),
@@ -8,7 +8,7 @@ export interface ApiResponseOptions {
8
8
  /**
9
9
  * HTTP status code
10
10
  */
11
- statusCode: number;
11
+ status: number;
12
12
 
13
13
  /**
14
14
  * Description of the response
@@ -49,7 +49,7 @@ export function ApiResponse(options: ApiResponseOptions) {
49
49
  */
50
50
  export function ApiOkResponse(description?: string, type?: any, isArray?: boolean) {
51
51
  return ApiResponse({
52
- statusCode: 200,
52
+ status: 200,
53
53
  description,
54
54
  type,
55
55
  isArray
@@ -64,7 +64,7 @@ export function ApiOkResponse(description?: string, type?: any, isArray?: boolea
64
64
  */
65
65
  export function ApiCreatedResponse(description?: string, type?: any, isArray?: boolean) {
66
66
  return ApiResponse({
67
- statusCode: 201,
67
+ status: 201,
68
68
  description,
69
69
  type,
70
70
  isArray
@@ -77,7 +77,7 @@ export function ApiCreatedResponse(description?: string, type?: any, isArray?: b
77
77
  */
78
78
  export function ApiBadRequestResponse(description?: string) {
79
79
  return ApiResponse({
80
- statusCode: 400,
80
+ status: 400,
81
81
  description
82
82
  });
83
83
  }
@@ -88,7 +88,7 @@ export function ApiBadRequestResponse(description?: string) {
88
88
  */
89
89
  export function ApiUnauthorizedResponse(description?: string) {
90
90
  return ApiResponse({
91
- statusCode: 401,
91
+ status: 401,
92
92
  description
93
93
  });
94
94
  }
@@ -99,7 +99,7 @@ export function ApiUnauthorizedResponse(description?: string) {
99
99
  */
100
100
  export function ApiForbiddenResponse(description?: string) {
101
101
  return ApiResponse({
102
- statusCode: 403,
102
+ status: 403,
103
103
  description
104
104
  });
105
105
  }
@@ -110,7 +110,7 @@ export function ApiForbiddenResponse(description?: string) {
110
110
  */
111
111
  export function ApiNotFoundResponse(description?: string) {
112
112
  return ApiResponse({
113
- statusCode: 404,
113
+ status: 404,
114
114
  description
115
115
  });
116
116
  }
@@ -121,7 +121,7 @@ export function ApiNotFoundResponse(description?: string) {
121
121
  */
122
122
  export function ApiInternalServerErrorResponse(description?: string) {
123
123
  return ApiResponse({
124
- statusCode: 500,
124
+ status: 500,
125
125
  description
126
126
  });
127
127
  }
@@ -34,7 +34,7 @@ export function ApiTags(...tags: (string | ApiTagOptions)[]) {
34
34
 
35
35
  // Convert string tags to objects
36
36
  const processedTags = tags.map(tag =>
37
- typeof tag === 'string' ? { name: tag } : tag
37
+ typeof tag === 'string' ? {name: tag} : tag
38
38
  );
39
39
 
40
40
  if (propertyKey) {
@@ -173,6 +173,11 @@ export function ApiParam(name: string, options: {
173
173
  * @deprecated
174
174
  */
175
175
  deprecated?: boolean;
176
+
177
+ /**
178
+ * enums values (optional)
179
+ */
180
+ enum?: any[]
176
181
  }) {
177
182
  return function (target: any, propertyKey: string | symbol) {
178
183
  const params = Reflect.getMetadata(METADATA_KEYS.API_PARAMETERS, target) || {};
@@ -180,6 +185,56 @@ export function ApiParam(name: string, options: {
180
185
  params[propertyKey] = [];
181
186
  }
182
187
  params[propertyKey].push({name, ...options});
188
+
189
+ if (options.enum) {
190
+ Reflect.defineMetadata(
191
+ METADATA_KEYS.API_ENUMS,
192
+ {
193
+ [propertyKey]: options.enum
194
+ },
195
+ target
196
+ );
197
+ }
183
198
  Reflect.defineMetadata(METADATA_KEYS.API_PARAMETERS, params, target, propertyKey);
184
199
  };
185
- }
200
+ }
201
+
202
+ /**
203
+ * Decorator to add query parameter metadata (shortcut for ApiParam with in: 'query')
204
+ * @param name Parameter name
205
+ * @param options Parameter options (description, required, type, default, deprecated)
206
+ */
207
+ export function ApiQuery(name: string, options: {
208
+ /**
209
+ * Parameter description
210
+ */
211
+ description?: string;
212
+
213
+ /**
214
+ * Whether the parameter is required
215
+ */
216
+ required?: boolean;
217
+
218
+ /**
219
+ * Parameter type (for schema generation)
220
+ */
221
+ type?: any;
222
+
223
+ /**
224
+ * Default value (optional)
225
+ */
226
+ default?: any;
227
+
228
+ /**
229
+ * Whether this parameter should be excluded from documentation (deprecated)
230
+ * @deprecated
231
+ */
232
+ deprecated?: boolean;
233
+
234
+ /**
235
+ * enums values (optional)
236
+ */
237
+ enum?: any[]
238
+ }) {
239
+ return ApiParam(name, {...options, in: 'query'});
240
+ }