@avleon/core 0.0.27 → 0.0.29

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 (77) hide show
  1. package/README.md +601 -561
  2. package/dist/application.js +1 -1
  3. package/dist/cache.d.ts +1 -1
  4. package/dist/cache.js +2 -2
  5. package/dist/collection.d.ts +25 -32
  6. package/dist/collection.js +50 -6
  7. package/dist/collection.test.d.ts +1 -0
  8. package/dist/collection.test.js +59 -0
  9. package/dist/config.d.ts +2 -0
  10. package/dist/config.js +30 -5
  11. package/dist/config.test.d.ts +1 -0
  12. package/dist/config.test.js +40 -0
  13. package/dist/controller.js +2 -2
  14. package/dist/environment-variables.js +42 -5
  15. package/dist/event-dispatcher.d.ts +23 -0
  16. package/dist/event-dispatcher.js +102 -0
  17. package/dist/event-subscriber.d.ts +15 -0
  18. package/dist/event-subscriber.js +96 -0
  19. package/dist/exceptions/http-exceptions.js +1 -1
  20. package/dist/exceptions/index.d.ts +1 -1
  21. package/dist/exceptions/system-exception.js +3 -1
  22. package/dist/file-storage.js +1 -1
  23. package/dist/helpers.js +1 -1
  24. package/dist/icore.d.ts +5 -0
  25. package/dist/icore.js +53 -18
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.js +6 -1
  28. package/dist/utils/index.d.ts +2 -2
  29. package/dist/utils/optional-require.js +2 -2
  30. package/dist/validation.d.ts +1 -1
  31. package/dist/websocket.d.ts +7 -0
  32. package/dist/websocket.js +20 -0
  33. package/dist/websocket.test.d.ts +0 -0
  34. package/dist/websocket.test.js +1 -0
  35. package/package.json +37 -6
  36. package/src/application.ts +104 -125
  37. package/src/authentication.ts +16 -16
  38. package/src/cache.ts +91 -91
  39. package/src/collection.test.ts +71 -0
  40. package/src/collection.ts +344 -254
  41. package/src/config.test.ts +35 -0
  42. package/src/config.ts +85 -42
  43. package/src/constants.ts +1 -1
  44. package/src/container.ts +54 -54
  45. package/src/controller.ts +125 -127
  46. package/src/decorators.ts +27 -27
  47. package/src/environment-variables.ts +53 -46
  48. package/src/event-dispatcher.ts +100 -0
  49. package/src/event-subscriber.ts +79 -0
  50. package/src/exceptions/http-exceptions.ts +86 -86
  51. package/src/exceptions/index.ts +1 -1
  52. package/src/exceptions/system-exception.ts +35 -34
  53. package/src/file-storage.ts +206 -206
  54. package/src/helpers.ts +324 -328
  55. package/src/icore.ts +1106 -1084
  56. package/src/index.ts +32 -30
  57. package/src/interfaces/avleon-application.ts +32 -40
  58. package/src/logger.ts +72 -72
  59. package/src/map-types.ts +159 -159
  60. package/src/middleware.ts +121 -98
  61. package/src/multipart.ts +116 -116
  62. package/src/openapi.ts +372 -372
  63. package/src/params.ts +111 -111
  64. package/src/queue.ts +126 -126
  65. package/src/response.ts +74 -74
  66. package/src/results.ts +30 -30
  67. package/src/route-methods.ts +186 -186
  68. package/src/swagger-schema.ts +213 -213
  69. package/src/testing.ts +220 -220
  70. package/src/types/app-builder.interface.ts +18 -19
  71. package/src/types/application.interface.ts +7 -9
  72. package/src/utils/hash.ts +8 -5
  73. package/src/utils/index.ts +2 -2
  74. package/src/utils/optional-require.ts +50 -50
  75. package/src/validation.ts +160 -156
  76. package/src/validator-extend.ts +25 -25
  77. package/src/websocket.ts +47 -0
package/src/openapi.ts CHANGED
@@ -1,372 +1,372 @@
1
- /**
2
- * @copyright 2024
3
- * @author Tareq Hossain
4
- * @email xtrinsic96@gmail.com
5
- * @url https://github.com/xtareq
6
- */
7
- export interface InfoObject {
8
- title: string;
9
- description?: string;
10
- termsOfService?: string;
11
- contact?: ContactObject;
12
- license?: LicenseObject;
13
- version: string;
14
- }
15
- export interface ContactObject {
16
- name?: string;
17
- url?: string;
18
- email?: string;
19
- }
20
- export interface LicenseObject {
21
- name: string;
22
- url?: string;
23
- }
24
- export interface ServerObject {
25
- url: string;
26
- description?: string;
27
- variables?: {
28
- [variable: string]: ServerVariableObject;
29
- };
30
- }
31
- export interface ServerVariableObject {
32
- enum?: string[];
33
- default: string;
34
- description?: string;
35
- }
36
-
37
- export type OpenApiUiOptions = {
38
- logo?: any;
39
- theme?: any;
40
- ui?: "default" | "scalar";
41
- openapi?: string;
42
- configuration?: any;
43
- routePrefix?: string;
44
- info?: InfoObject;
45
- servers?: ServerObject[];
46
- paths?: PathsObject<any>;
47
- components?: ComponentsObject;
48
- security?: SecurityRequirementObject[];
49
- tags?: TagObject[];
50
- externalDocs?: any;
51
- "x-express-openapi-additional-middleware"?: (
52
- | ((request: any, response: any, next: any) => Promise<void>)
53
- | ((request: any, response: any, next: any) => void)
54
- )[];
55
- "x-express-openapi-validation-strict"?: boolean;
56
- };
57
- export interface PathsObject<T extends {} = {}, P extends {} = {}> {
58
- [pattern: string]: (PathItemObject<T> & P) | undefined;
59
- }
60
- enum HttpMethods {
61
- GET = "get",
62
- PUT = "put",
63
- POST = "post",
64
- DELETE = "delete",
65
- OPTIONS = "options",
66
- HEAD = "head",
67
- PATCH = "patch",
68
- TRACE = "trace",
69
- }
70
- export type PathItemObject<T extends {} = {}> = {
71
- $ref?: string;
72
- summary?: string;
73
- description?: string;
74
- servers?: ServerObject[];
75
- parameters?: (ReferenceObject | ParameterObject)[];
76
- } & {
77
- [method in HttpMethods]?: OperationObject<T>;
78
- };
79
- export type OperationObject<T extends {} = {}> = {
80
- tags?: string[];
81
- summary?: string;
82
- description?: string;
83
- externalDocs?: ExternalDocumentationObject;
84
- operationId?: string;
85
- parameters?: (ReferenceObject | ParameterObject)[];
86
- requestBody?: ReferenceObject | RequestBodyObject;
87
- responses: ResponsesObject;
88
- callbacks?: {
89
- [callback: string]: ReferenceObject | CallbackObject;
90
- };
91
- deprecated?: boolean;
92
- security?: SecurityRequirementObject[];
93
- servers?: ServerObject[];
94
- } & T;
95
- export interface ExternalDocumentationObject {
96
- description?: string;
97
- url: string;
98
- }
99
- export interface ParameterObject extends ParameterBaseObject {
100
- name: string;
101
- in: string;
102
- }
103
- export interface HeaderObject extends ParameterBaseObject {}
104
- export interface ParameterBaseObject {
105
- description?: string;
106
- required?: boolean;
107
- deprecated?: boolean;
108
- allowEmptyValue?: boolean;
109
- style?: string;
110
- explode?: boolean;
111
- allowReserved?: boolean;
112
- schema?: ReferenceObject | SchemaObject;
113
- example?: any;
114
- examples?: {
115
- [media: string]: ReferenceObject | ExampleObject;
116
- };
117
- content?: {
118
- [media: string]: MediaTypeObject;
119
- };
120
- }
121
- export type NonArraySchemaObjectType =
122
- | "boolean"
123
- | "object"
124
- | "number"
125
- | "string"
126
- | "integer";
127
- export type ArraySchemaObjectType = "array";
128
- export type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
129
- export interface ArraySchemaObject extends BaseSchemaObject {
130
- type: ArraySchemaObjectType;
131
- items: ReferenceObject | SchemaObject;
132
- }
133
- export interface NonArraySchemaObject extends BaseSchemaObject {
134
- type?: NonArraySchemaObjectType;
135
- }
136
- export interface BaseSchemaObject {
137
- title?: string;
138
- description?: string;
139
- format?: string;
140
- default?: any;
141
- multipleOf?: number;
142
- maximum?: number;
143
- exclusiveMaximum?: boolean;
144
- minimum?: number;
145
- exclusiveMinimum?: boolean;
146
- maxLength?: number;
147
- minLength?: number;
148
- pattern?: string;
149
- additionalProperties?: boolean | ReferenceObject | SchemaObject;
150
- maxItems?: number;
151
- minItems?: number;
152
- uniqueItems?: boolean;
153
- maxProperties?: number;
154
- minProperties?: number;
155
- required?: string[];
156
- enum?: any[];
157
- properties?: {
158
- [name: string]: ReferenceObject | SchemaObject;
159
- };
160
- allOf?: (ReferenceObject | SchemaObject)[];
161
- oneOf?: (ReferenceObject | SchemaObject)[];
162
- anyOf?: (ReferenceObject | SchemaObject)[];
163
- not?: ReferenceObject | SchemaObject;
164
- nullable?: boolean;
165
- discriminator?: DiscriminatorObject;
166
- readOnly?: boolean;
167
- writeOnly?: boolean;
168
- xml?: XMLObject;
169
- externalDocs?: ExternalDocumentationObject;
170
- example?: any;
171
- deprecated?: boolean;
172
- }
173
- export interface DiscriminatorObject {
174
- propertyName: string;
175
- mapping?: {
176
- [value: string]: string;
177
- };
178
- }
179
- export interface XMLObject {
180
- name?: string;
181
- namespace?: string;
182
- prefix?: string;
183
- attribute?: boolean;
184
- wrapped?: boolean;
185
- }
186
- export interface ReferenceObject {
187
- $ref: string;
188
- }
189
- export interface ExampleObject {
190
- summary?: string;
191
- description?: string;
192
- value?: any;
193
- externalValue?: string;
194
- }
195
- export interface MediaTypeObject {
196
- schema?: ReferenceObject | SchemaObject;
197
- example?: any;
198
- examples?: {
199
- [media: string]: ReferenceObject | ExampleObject;
200
- };
201
- encoding?: {
202
- [media: string]: EncodingObject;
203
- };
204
- }
205
- export interface EncodingObject {
206
- contentType?: string;
207
- headers?: {
208
- [header: string]: ReferenceObject | HeaderObject;
209
- };
210
- style?: string;
211
- explode?: boolean;
212
- allowReserved?: boolean;
213
- }
214
- export interface RequestBodyObject {
215
- description?: string;
216
- content: {
217
- [media: string]: MediaTypeObject;
218
- };
219
- required?: boolean;
220
- }
221
- export interface ResponsesObject {
222
- [code: string]: ReferenceObject | ResponseObject;
223
- }
224
- export interface ResponseObject {
225
- description: string;
226
- headers?: {
227
- [header: string]: ReferenceObject | HeaderObject;
228
- };
229
- content?: {
230
- [media: string]: MediaTypeObject;
231
- };
232
- links?: {
233
- [link: string]: ReferenceObject | LinkObject;
234
- };
235
- }
236
- export interface LinkObject {
237
- operationRef?: string;
238
- operationId?: string;
239
- parameters?: {
240
- [parameter: string]: any;
241
- };
242
- requestBody?: any;
243
- description?: string;
244
- server?: ServerObject;
245
- }
246
- export interface CallbackObject {
247
- [url: string]: PathItemObject;
248
- }
249
- export interface SecurityRequirementObject {
250
- [name: string]: string[];
251
- }
252
- export interface ComponentsObject {
253
- schemas?: {
254
- [key: string]: ReferenceObject | SchemaObject;
255
- };
256
- responses?: {
257
- [key: string]: ReferenceObject | ResponseObject;
258
- };
259
- parameters?: {
260
- [key: string]: ReferenceObject | ParameterObject;
261
- };
262
- examples?: {
263
- [key: string]: ReferenceObject | ExampleObject;
264
- };
265
- requestBodies?: {
266
- [key: string]: ReferenceObject | RequestBodyObject;
267
- };
268
- headers?: {
269
- [key: string]: ReferenceObject | HeaderObject;
270
- };
271
- securitySchemes?: {
272
- [key: string]: ReferenceObject | SecuritySchemeObject;
273
- };
274
- links?: {
275
- [key: string]: ReferenceObject | LinkObject;
276
- };
277
- callbacks?: {
278
- [key: string]: ReferenceObject | CallbackObject;
279
- };
280
- }
281
- export type SecuritySchemeObject =
282
- | HttpSecurityScheme
283
- | ApiKeySecurityScheme
284
- | OAuth2SecurityScheme
285
- | OpenIdSecurityScheme;
286
- export interface HttpSecurityScheme {
287
- type: "http";
288
- description?: string;
289
- scheme: string;
290
- bearerFormat?: string;
291
- }
292
- export interface ApiKeySecurityScheme {
293
- type: "apiKey";
294
- description?: string;
295
- name: string;
296
- in: string;
297
- }
298
- export interface OAuth2SecurityScheme {
299
- type: "oauth2";
300
- description?: string;
301
- flows: {
302
- implicit?: {
303
- authorizationUrl: string;
304
- refreshUrl?: string;
305
- scopes: {
306
- [scope: string]: string;
307
- };
308
- };
309
- password?: {
310
- tokenUrl: string;
311
- refreshUrl?: string;
312
- scopes: {
313
- [scope: string]: string;
314
- };
315
- };
316
- clientCredentials?: {
317
- tokenUrl: string;
318
- refreshUrl?: string;
319
- scopes: {
320
- [scope: string]: string;
321
- };
322
- };
323
- authorizationCode?: {
324
- authorizationUrl: string;
325
- tokenUrl: string;
326
- refreshUrl?: string;
327
- scopes: {
328
- [scope: string]: string;
329
- };
330
- };
331
- };
332
- }
333
- export interface OpenIdSecurityScheme {
334
- type: "openIdConnect";
335
- description?: string;
336
- openIdConnectUrl: string;
337
- }
338
- export interface TagObject {
339
- name: string;
340
- description?: string;
341
- externalDocs?: ExternalDocumentationObject;
342
- }
343
-
344
- export type OpenApiOptions = {
345
- exclude?: boolean;
346
- deprecated?: boolean;
347
- tags?: readonly string[];
348
- description?: string;
349
- summary?: string;
350
- components?: ComponentsObject;
351
- response?: any;
352
- responseBody?: any;
353
- requestBody?: any;
354
- } & any;
355
-
356
- export function OpenApi(
357
- options: OpenApiOptions
358
- ): MethodDecorator & ClassDecorator & PropertyDecorator {
359
- return function (
360
- target: Object | Function,
361
- propertyKey?: string | symbol,
362
- descriptor?: PropertyDescriptor
363
- ) {
364
- if (typeof target === "function" && !propertyKey) {
365
- Reflect.defineMetadata("controller:openapi", options, target);
366
- } else if (descriptor) {
367
- Reflect.defineMetadata("route:openapi", options, target, propertyKey!);
368
- } else if (propertyKey) {
369
- Reflect.defineMetadata("property:openapi", options, target, propertyKey);
370
- }
371
- };
372
- }
1
+ /**
2
+ * @copyright 2024
3
+ * @author Tareq Hossain
4
+ * @email xtrinsic96@gmail.com
5
+ * @url https://github.com/xtareq
6
+ */
7
+ export interface InfoObject {
8
+ title: string;
9
+ description?: string;
10
+ termsOfService?: string;
11
+ contact?: ContactObject;
12
+ license?: LicenseObject;
13
+ version: string;
14
+ }
15
+ export interface ContactObject {
16
+ name?: string;
17
+ url?: string;
18
+ email?: string;
19
+ }
20
+ export interface LicenseObject {
21
+ name: string;
22
+ url?: string;
23
+ }
24
+ export interface ServerObject {
25
+ url: string;
26
+ description?: string;
27
+ variables?: {
28
+ [variable: string]: ServerVariableObject;
29
+ };
30
+ }
31
+ export interface ServerVariableObject {
32
+ enum?: string[];
33
+ default: string;
34
+ description?: string;
35
+ }
36
+
37
+ export type OpenApiUiOptions = {
38
+ logo?: any;
39
+ theme?: any;
40
+ ui?: "default" | "scalar";
41
+ openapi?: string;
42
+ configuration?: any;
43
+ routePrefix?: string;
44
+ info?: InfoObject;
45
+ servers?: ServerObject[];
46
+ paths?: PathsObject<any>;
47
+ components?: ComponentsObject;
48
+ security?: SecurityRequirementObject[];
49
+ tags?: TagObject[];
50
+ externalDocs?: any;
51
+ "x-express-openapi-additional-middleware"?: (
52
+ | ((request: any, response: any, next: any) => Promise<void>)
53
+ | ((request: any, response: any, next: any) => void)
54
+ )[];
55
+ "x-express-openapi-validation-strict"?: boolean;
56
+ };
57
+ export interface PathsObject<T extends {} = {}, P extends {} = {}> {
58
+ [pattern: string]: (PathItemObject<T> & P) | undefined;
59
+ }
60
+ enum HttpMethods {
61
+ GET = "get",
62
+ PUT = "put",
63
+ POST = "post",
64
+ DELETE = "delete",
65
+ OPTIONS = "options",
66
+ HEAD = "head",
67
+ PATCH = "patch",
68
+ TRACE = "trace",
69
+ }
70
+ export type PathItemObject<T extends {} = {}> = {
71
+ $ref?: string;
72
+ summary?: string;
73
+ description?: string;
74
+ servers?: ServerObject[];
75
+ parameters?: (ReferenceObject | ParameterObject)[];
76
+ } & {
77
+ [method in HttpMethods]?: OperationObject<T>;
78
+ };
79
+ export type OperationObject<T extends {} = {}> = {
80
+ tags?: string[];
81
+ summary?: string;
82
+ description?: string;
83
+ externalDocs?: ExternalDocumentationObject;
84
+ operationId?: string;
85
+ parameters?: (ReferenceObject | ParameterObject)[];
86
+ requestBody?: ReferenceObject | RequestBodyObject;
87
+ responses: ResponsesObject;
88
+ callbacks?: {
89
+ [callback: string]: ReferenceObject | CallbackObject;
90
+ };
91
+ deprecated?: boolean;
92
+ security?: SecurityRequirementObject[];
93
+ servers?: ServerObject[];
94
+ } & T;
95
+ export interface ExternalDocumentationObject {
96
+ description?: string;
97
+ url: string;
98
+ }
99
+ export interface ParameterObject extends ParameterBaseObject {
100
+ name: string;
101
+ in: string;
102
+ }
103
+ export interface HeaderObject extends ParameterBaseObject {}
104
+ export interface ParameterBaseObject {
105
+ description?: string;
106
+ required?: boolean;
107
+ deprecated?: boolean;
108
+ allowEmptyValue?: boolean;
109
+ style?: string;
110
+ explode?: boolean;
111
+ allowReserved?: boolean;
112
+ schema?: ReferenceObject | SchemaObject;
113
+ example?: any;
114
+ examples?: {
115
+ [media: string]: ReferenceObject | ExampleObject;
116
+ };
117
+ content?: {
118
+ [media: string]: MediaTypeObject;
119
+ };
120
+ }
121
+ export type NonArraySchemaObjectType =
122
+ | "boolean"
123
+ | "object"
124
+ | "number"
125
+ | "string"
126
+ | "integer";
127
+ export type ArraySchemaObjectType = "array";
128
+ export type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
129
+ export interface ArraySchemaObject extends BaseSchemaObject {
130
+ type: ArraySchemaObjectType;
131
+ items: ReferenceObject | SchemaObject;
132
+ }
133
+ export interface NonArraySchemaObject extends BaseSchemaObject {
134
+ type?: NonArraySchemaObjectType;
135
+ }
136
+ export interface BaseSchemaObject {
137
+ title?: string;
138
+ description?: string;
139
+ format?: string;
140
+ default?: any;
141
+ multipleOf?: number;
142
+ maximum?: number;
143
+ exclusiveMaximum?: boolean;
144
+ minimum?: number;
145
+ exclusiveMinimum?: boolean;
146
+ maxLength?: number;
147
+ minLength?: number;
148
+ pattern?: string;
149
+ additionalProperties?: boolean | ReferenceObject | SchemaObject;
150
+ maxItems?: number;
151
+ minItems?: number;
152
+ uniqueItems?: boolean;
153
+ maxProperties?: number;
154
+ minProperties?: number;
155
+ required?: string[];
156
+ enum?: any[];
157
+ properties?: {
158
+ [name: string]: ReferenceObject | SchemaObject;
159
+ };
160
+ allOf?: (ReferenceObject | SchemaObject)[];
161
+ oneOf?: (ReferenceObject | SchemaObject)[];
162
+ anyOf?: (ReferenceObject | SchemaObject)[];
163
+ not?: ReferenceObject | SchemaObject;
164
+ nullable?: boolean;
165
+ discriminator?: DiscriminatorObject;
166
+ readOnly?: boolean;
167
+ writeOnly?: boolean;
168
+ xml?: XMLObject;
169
+ externalDocs?: ExternalDocumentationObject;
170
+ example?: any;
171
+ deprecated?: boolean;
172
+ }
173
+ export interface DiscriminatorObject {
174
+ propertyName: string;
175
+ mapping?: {
176
+ [value: string]: string;
177
+ };
178
+ }
179
+ export interface XMLObject {
180
+ name?: string;
181
+ namespace?: string;
182
+ prefix?: string;
183
+ attribute?: boolean;
184
+ wrapped?: boolean;
185
+ }
186
+ export interface ReferenceObject {
187
+ $ref: string;
188
+ }
189
+ export interface ExampleObject {
190
+ summary?: string;
191
+ description?: string;
192
+ value?: any;
193
+ externalValue?: string;
194
+ }
195
+ export interface MediaTypeObject {
196
+ schema?: ReferenceObject | SchemaObject;
197
+ example?: any;
198
+ examples?: {
199
+ [media: string]: ReferenceObject | ExampleObject;
200
+ };
201
+ encoding?: {
202
+ [media: string]: EncodingObject;
203
+ };
204
+ }
205
+ export interface EncodingObject {
206
+ contentType?: string;
207
+ headers?: {
208
+ [header: string]: ReferenceObject | HeaderObject;
209
+ };
210
+ style?: string;
211
+ explode?: boolean;
212
+ allowReserved?: boolean;
213
+ }
214
+ export interface RequestBodyObject {
215
+ description?: string;
216
+ content: {
217
+ [media: string]: MediaTypeObject;
218
+ };
219
+ required?: boolean;
220
+ }
221
+ export interface ResponsesObject {
222
+ [code: string]: ReferenceObject | ResponseObject;
223
+ }
224
+ export interface ResponseObject {
225
+ description: string;
226
+ headers?: {
227
+ [header: string]: ReferenceObject | HeaderObject;
228
+ };
229
+ content?: {
230
+ [media: string]: MediaTypeObject;
231
+ };
232
+ links?: {
233
+ [link: string]: ReferenceObject | LinkObject;
234
+ };
235
+ }
236
+ export interface LinkObject {
237
+ operationRef?: string;
238
+ operationId?: string;
239
+ parameters?: {
240
+ [parameter: string]: any;
241
+ };
242
+ requestBody?: any;
243
+ description?: string;
244
+ server?: ServerObject;
245
+ }
246
+ export interface CallbackObject {
247
+ [url: string]: PathItemObject;
248
+ }
249
+ export interface SecurityRequirementObject {
250
+ [name: string]: string[];
251
+ }
252
+ export interface ComponentsObject {
253
+ schemas?: {
254
+ [key: string]: ReferenceObject | SchemaObject;
255
+ };
256
+ responses?: {
257
+ [key: string]: ReferenceObject | ResponseObject;
258
+ };
259
+ parameters?: {
260
+ [key: string]: ReferenceObject | ParameterObject;
261
+ };
262
+ examples?: {
263
+ [key: string]: ReferenceObject | ExampleObject;
264
+ };
265
+ requestBodies?: {
266
+ [key: string]: ReferenceObject | RequestBodyObject;
267
+ };
268
+ headers?: {
269
+ [key: string]: ReferenceObject | HeaderObject;
270
+ };
271
+ securitySchemes?: {
272
+ [key: string]: ReferenceObject | SecuritySchemeObject;
273
+ };
274
+ links?: {
275
+ [key: string]: ReferenceObject | LinkObject;
276
+ };
277
+ callbacks?: {
278
+ [key: string]: ReferenceObject | CallbackObject;
279
+ };
280
+ }
281
+ export type SecuritySchemeObject =
282
+ | HttpSecurityScheme
283
+ | ApiKeySecurityScheme
284
+ | OAuth2SecurityScheme
285
+ | OpenIdSecurityScheme;
286
+ export interface HttpSecurityScheme {
287
+ type: "http";
288
+ description?: string;
289
+ scheme: string;
290
+ bearerFormat?: string;
291
+ }
292
+ export interface ApiKeySecurityScheme {
293
+ type: "apiKey";
294
+ description?: string;
295
+ name: string;
296
+ in: string;
297
+ }
298
+ export interface OAuth2SecurityScheme {
299
+ type: "oauth2";
300
+ description?: string;
301
+ flows: {
302
+ implicit?: {
303
+ authorizationUrl: string;
304
+ refreshUrl?: string;
305
+ scopes: {
306
+ [scope: string]: string;
307
+ };
308
+ };
309
+ password?: {
310
+ tokenUrl: string;
311
+ refreshUrl?: string;
312
+ scopes: {
313
+ [scope: string]: string;
314
+ };
315
+ };
316
+ clientCredentials?: {
317
+ tokenUrl: string;
318
+ refreshUrl?: string;
319
+ scopes: {
320
+ [scope: string]: string;
321
+ };
322
+ };
323
+ authorizationCode?: {
324
+ authorizationUrl: string;
325
+ tokenUrl: string;
326
+ refreshUrl?: string;
327
+ scopes: {
328
+ [scope: string]: string;
329
+ };
330
+ };
331
+ };
332
+ }
333
+ export interface OpenIdSecurityScheme {
334
+ type: "openIdConnect";
335
+ description?: string;
336
+ openIdConnectUrl: string;
337
+ }
338
+ export interface TagObject {
339
+ name: string;
340
+ description?: string;
341
+ externalDocs?: ExternalDocumentationObject;
342
+ }
343
+
344
+ export type OpenApiOptions = {
345
+ exclude?: boolean;
346
+ deprecated?: boolean;
347
+ tags?: readonly string[];
348
+ description?: string;
349
+ summary?: string;
350
+ components?: ComponentsObject;
351
+ response?: any;
352
+ responseBody?: any;
353
+ requestBody?: any;
354
+ } & any;
355
+
356
+ export function OpenApi(
357
+ options: OpenApiOptions,
358
+ ): MethodDecorator & ClassDecorator & PropertyDecorator {
359
+ return function (
360
+ target: Object | Function,
361
+ propertyKey?: string | symbol,
362
+ descriptor?: PropertyDescriptor,
363
+ ) {
364
+ if (typeof target === "function" && !propertyKey) {
365
+ Reflect.defineMetadata("controller:openapi", options, target);
366
+ } else if (descriptor) {
367
+ Reflect.defineMetadata("route:openapi", options, target, propertyKey!);
368
+ } else if (propertyKey) {
369
+ Reflect.defineMetadata("property:openapi", options, target, propertyKey);
370
+ }
371
+ };
372
+ }