@avleon/core 0.0.46 → 0.0.49

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 (142) hide show
  1. package/License +21 -21
  2. package/README.md +666 -666
  3. package/dist/chunk-9hOWP6kD.cjs +64 -0
  4. package/dist/chunk-DORXReHP.js +37 -0
  5. package/dist/index-CWUcfHYp.d.ts +1283 -0
  6. package/dist/index-CzAzauXZ.d.cts +1282 -0
  7. package/dist/index.cjs +3194 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.js +3022 -79
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib-Bk8hUm06.cjs +7847 -0
  12. package/dist/lib-Bk8hUm06.cjs.map +1 -0
  13. package/dist/lib-CvDxBMkR.js +7843 -0
  14. package/dist/lib-CvDxBMkR.js.map +1 -0
  15. package/package.json +41 -103
  16. package/dist/application.test.d.ts +0 -1
  17. package/dist/application.test.js +0 -15
  18. package/dist/authentication.d.ts +0 -13
  19. package/dist/authentication.js +0 -16
  20. package/dist/cache.d.ts +0 -12
  21. package/dist/cache.js +0 -78
  22. package/dist/cache.test.d.ts +0 -1
  23. package/dist/cache.test.js +0 -36
  24. package/dist/collection.d.ts +0 -43
  25. package/dist/collection.js +0 -231
  26. package/dist/collection.test.d.ts +0 -1
  27. package/dist/collection.test.js +0 -59
  28. package/dist/config.d.ts +0 -18
  29. package/dist/config.js +0 -58
  30. package/dist/config.test.d.ts +0 -1
  31. package/dist/config.test.js +0 -40
  32. package/dist/constants.d.ts +0 -1
  33. package/dist/constants.js +0 -4
  34. package/dist/container.d.ts +0 -30
  35. package/dist/container.js +0 -55
  36. package/dist/controller.d.ts +0 -50
  37. package/dist/controller.js +0 -71
  38. package/dist/controller.test.d.ts +0 -1
  39. package/dist/controller.test.js +0 -97
  40. package/dist/core/application.d.ts +0 -74
  41. package/dist/core/application.js +0 -424
  42. package/dist/core/router.d.ts +0 -44
  43. package/dist/core/router.js +0 -520
  44. package/dist/core/testing.d.ts +0 -21
  45. package/dist/core/testing.js +0 -104
  46. package/dist/core/types.d.ts +0 -67
  47. package/dist/core/types.js +0 -2
  48. package/dist/decorators.d.ts +0 -15
  49. package/dist/decorators.js +0 -41
  50. package/dist/environment-variables.d.ts +0 -49
  51. package/dist/environment-variables.js +0 -130
  52. package/dist/environment-variables.test.d.ts +0 -1
  53. package/dist/environment-variables.test.js +0 -70
  54. package/dist/event-dispatcher.d.ts +0 -22
  55. package/dist/event-dispatcher.js +0 -97
  56. package/dist/event-subscriber.d.ts +0 -14
  57. package/dist/event-subscriber.js +0 -87
  58. package/dist/exceptions/http-exceptions.d.ts +0 -50
  59. package/dist/exceptions/http-exceptions.js +0 -85
  60. package/dist/exceptions/index.d.ts +0 -1
  61. package/dist/exceptions/index.js +0 -17
  62. package/dist/exceptions/system-exception.d.ts +0 -22
  63. package/dist/exceptions/system-exception.js +0 -26
  64. package/dist/file-storage.d.ts +0 -69
  65. package/dist/file-storage.js +0 -323
  66. package/dist/file-storage.test.d.ts +0 -1
  67. package/dist/file-storage.test.js +0 -117
  68. package/dist/helpers.d.ts +0 -11
  69. package/dist/helpers.js +0 -27
  70. package/dist/helpers.test.d.ts +0 -1
  71. package/dist/helpers.test.js +0 -95
  72. package/dist/index.d.ts +0 -57
  73. package/dist/interfaces/avleon-application.d.ts +0 -75
  74. package/dist/interfaces/avleon-application.js +0 -2
  75. package/dist/kenx-provider.d.ts +0 -7
  76. package/dist/kenx-provider.js +0 -44
  77. package/dist/kenx-provider.test.d.ts +0 -1
  78. package/dist/kenx-provider.test.js +0 -36
  79. package/dist/logger.d.ts +0 -12
  80. package/dist/logger.js +0 -87
  81. package/dist/logger.test.d.ts +0 -1
  82. package/dist/logger.test.js +0 -42
  83. package/dist/map-types.d.ts +0 -17
  84. package/dist/map-types.js +0 -89
  85. package/dist/middleware.d.ts +0 -34
  86. package/dist/middleware.js +0 -73
  87. package/dist/middleware.test.d.ts +0 -1
  88. package/dist/middleware.test.js +0 -121
  89. package/dist/multipart.d.ts +0 -17
  90. package/dist/multipart.js +0 -70
  91. package/dist/multipart.test.d.ts +0 -1
  92. package/dist/multipart.test.js +0 -87
  93. package/dist/openapi.d.ts +0 -410
  94. package/dist/openapi.js +0 -59
  95. package/dist/openapi.test.d.ts +0 -1
  96. package/dist/openapi.test.js +0 -111
  97. package/dist/params.d.ts +0 -17
  98. package/dist/params.js +0 -64
  99. package/dist/params.test.d.ts +0 -1
  100. package/dist/params.test.js +0 -83
  101. package/dist/queue.d.ts +0 -29
  102. package/dist/queue.js +0 -84
  103. package/dist/response.d.ts +0 -16
  104. package/dist/response.js +0 -56
  105. package/dist/results.d.ts +0 -20
  106. package/dist/results.js +0 -32
  107. package/dist/route-methods.d.ts +0 -25
  108. package/dist/route-methods.js +0 -60
  109. package/dist/route-methods.test.d.ts +0 -1
  110. package/dist/route-methods.test.js +0 -129
  111. package/dist/swagger-schema.d.ts +0 -37
  112. package/dist/swagger-schema.js +0 -454
  113. package/dist/swagger-schema.test.d.ts +0 -1
  114. package/dist/swagger-schema.test.js +0 -125
  115. package/dist/types/app-builder.interface.d.ts +0 -15
  116. package/dist/types/app-builder.interface.js +0 -8
  117. package/dist/types/application.interface.d.ts +0 -8
  118. package/dist/types/application.interface.js +0 -2
  119. package/dist/utils/common-utils.d.ts +0 -17
  120. package/dist/utils/common-utils.js +0 -108
  121. package/dist/utils/di-utils.d.ts +0 -1
  122. package/dist/utils/di-utils.js +0 -22
  123. package/dist/utils/hash.d.ts +0 -2
  124. package/dist/utils/hash.js +0 -11
  125. package/dist/utils/index.d.ts +0 -2
  126. package/dist/utils/index.js +0 -18
  127. package/dist/utils/object-utils.d.ts +0 -11
  128. package/dist/utils/object-utils.js +0 -198
  129. package/dist/utils/optional-require.d.ts +0 -8
  130. package/dist/utils/optional-require.js +0 -70
  131. package/dist/utils/validation-utils.d.ts +0 -13
  132. package/dist/utils/validation-utils.js +0 -119
  133. package/dist/validation.d.ts +0 -39
  134. package/dist/validation.js +0 -108
  135. package/dist/validation.test.d.ts +0 -1
  136. package/dist/validation.test.js +0 -61
  137. package/dist/validator-extend.d.ts +0 -7
  138. package/dist/validator-extend.js +0 -28
  139. package/dist/websocket.d.ts +0 -10
  140. package/dist/websocket.js +0 -21
  141. package/dist/websocket.test.d.ts +0 -1
  142. package/dist/websocket.test.js +0 -27
@@ -0,0 +1,1282 @@
1
+ import { Constructable, Container, Service } from "typedi";
2
+ import { FastifyInstance, FastifyReply, FastifyRequest, FastifyServerOptions, InjectOptions, LightMyRequestResponse } from "fastify";
3
+ import { MultipartFile, SavedMultipartFile } from "@fastify/multipart";
4
+ import { DataSource, DataSourceOptions, EntityTarget, ObjectLiteral, Repository } from "typeorm";
5
+ import { ClassConstructor } from "class-transformer";
6
+ import { Knex } from "knex";
7
+ import { Socket } from "socket.io";
8
+ import Bull, { Job, JobOptions, Queue as Queue$1 } from "bull";
9
+ import fs, { PathLike } from "node:fs";
10
+ import pino from "pino";
11
+ import { Redis } from "ioredis";
12
+
13
+ //#region src/openapi.d.ts
14
+ /**
15
+ * @copyright 2024
16
+ * @author Tareq Hossain
17
+ * @email xtrinsic96@gmail.com
18
+ * @url https://github.com/xtareq
19
+ */
20
+ interface InfoObject {
21
+ title: string;
22
+ description?: string;
23
+ termsOfService?: string;
24
+ contact?: ContactObject;
25
+ license?: LicenseObject;
26
+ version: string;
27
+ }
28
+ interface ContactObject {
29
+ name?: string;
30
+ url?: string;
31
+ email?: string;
32
+ }
33
+ interface LicenseObject {
34
+ name: string;
35
+ url?: string;
36
+ }
37
+ interface ServerObject {
38
+ url: string;
39
+ description?: string;
40
+ variables?: {
41
+ [variable: string]: ServerVariableObject;
42
+ };
43
+ }
44
+ interface ServerVariableObject {
45
+ enum?: string[];
46
+ default: string;
47
+ description?: string;
48
+ }
49
+ type OpenApiUiOptions = {
50
+ logo?: any;
51
+ theme?: any;
52
+ provider?: "default" | "scalar";
53
+ ui?: "default" | "scalar";
54
+ openapi?: string;
55
+ uiConfig?: any;
56
+ configuration?: any;
57
+ routePrefix?: string;
58
+ info?: InfoObject;
59
+ servers?: ServerObject[];
60
+ paths?: PathsObject<any>;
61
+ components?: ComponentsObject;
62
+ security?: SecurityRequirementObject[];
63
+ tags?: TagObject[];
64
+ externalDocs?: any;
65
+ "x-express-openapi-additional-middleware"?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
66
+ "x-express-openapi-validation-strict"?: boolean;
67
+ };
68
+ interface PathsObject<T extends {} = {}, P extends {} = {}> {
69
+ [pattern: string]: (PathItemObject<T> & P) | undefined;
70
+ }
71
+ declare enum HttpMethods {
72
+ GET = "get",
73
+ PUT = "put",
74
+ POST = "post",
75
+ DELETE = "delete",
76
+ OPTIONS = "options",
77
+ HEAD = "head",
78
+ PATCH = "patch",
79
+ TRACE = "trace",
80
+ }
81
+ type PathItemObject<T extends {} = {}> = {
82
+ $ref?: string;
83
+ summary?: string;
84
+ description?: string;
85
+ servers?: ServerObject[];
86
+ parameters?: (ReferenceObject | ParameterObject)[];
87
+ } & { [method in HttpMethods]?: OperationObject<T> };
88
+ type OperationObject<T extends {} = {}> = {
89
+ tags?: string[];
90
+ summary?: string;
91
+ description?: string;
92
+ externalDocs?: ExternalDocumentationObject;
93
+ operationId?: string;
94
+ parameters?: (ReferenceObject | ParameterObject)[];
95
+ requestBody?: ReferenceObject | RequestBodyObject;
96
+ responses: ResponsesObject;
97
+ callbacks?: {
98
+ [callback: string]: ReferenceObject | CallbackObject;
99
+ };
100
+ deprecated?: boolean;
101
+ security?: SecurityRequirementObject[];
102
+ servers?: ServerObject[];
103
+ } & T;
104
+ interface ExternalDocumentationObject {
105
+ description?: string;
106
+ url: string;
107
+ }
108
+ interface ParameterObject extends ParameterBaseObject {
109
+ name: string;
110
+ in: string;
111
+ }
112
+ interface HeaderObject extends ParameterBaseObject {}
113
+ interface ParameterBaseObject {
114
+ description?: string;
115
+ required?: boolean;
116
+ deprecated?: boolean;
117
+ allowEmptyValue?: boolean;
118
+ style?: string;
119
+ explode?: boolean;
120
+ allowReserved?: boolean;
121
+ schema?: ReferenceObject | SchemaObject;
122
+ example?: any;
123
+ examples?: {
124
+ [media: string]: ReferenceObject | ExampleObject;
125
+ };
126
+ content?: {
127
+ [media: string]: MediaTypeObject;
128
+ };
129
+ }
130
+ type NonArraySchemaObjectType = "boolean" | "object" | "number" | "string" | "integer";
131
+ type ArraySchemaObjectType = "array";
132
+ type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
133
+ interface ArraySchemaObject extends BaseSchemaObject {
134
+ type: ArraySchemaObjectType;
135
+ items: ReferenceObject | SchemaObject;
136
+ }
137
+ interface NonArraySchemaObject extends BaseSchemaObject {
138
+ type?: NonArraySchemaObjectType;
139
+ }
140
+ interface BaseSchemaObject {
141
+ title?: string;
142
+ description?: string;
143
+ format?: string;
144
+ default?: any;
145
+ multipleOf?: number;
146
+ maximum?: number;
147
+ exclusiveMaximum?: boolean;
148
+ minimum?: number;
149
+ exclusiveMinimum?: boolean;
150
+ maxLength?: number;
151
+ minLength?: number;
152
+ pattern?: string;
153
+ additionalProperties?: boolean | ReferenceObject | SchemaObject;
154
+ maxItems?: number;
155
+ minItems?: number;
156
+ uniqueItems?: boolean;
157
+ maxProperties?: number;
158
+ minProperties?: number;
159
+ required?: string[];
160
+ enum?: any[];
161
+ properties?: {
162
+ [name: string]: ReferenceObject | SchemaObject;
163
+ };
164
+ allOf?: (ReferenceObject | SchemaObject)[];
165
+ oneOf?: (ReferenceObject | SchemaObject)[];
166
+ anyOf?: (ReferenceObject | SchemaObject)[];
167
+ not?: ReferenceObject | SchemaObject;
168
+ nullable?: boolean;
169
+ discriminator?: DiscriminatorObject;
170
+ readOnly?: boolean;
171
+ writeOnly?: boolean;
172
+ xml?: XMLObject;
173
+ externalDocs?: ExternalDocumentationObject;
174
+ example?: any;
175
+ deprecated?: boolean;
176
+ }
177
+ interface DiscriminatorObject {
178
+ propertyName: string;
179
+ mapping?: {
180
+ [value: string]: string;
181
+ };
182
+ }
183
+ interface XMLObject {
184
+ name?: string;
185
+ namespace?: string;
186
+ prefix?: string;
187
+ attribute?: boolean;
188
+ wrapped?: boolean;
189
+ }
190
+ interface ReferenceObject {
191
+ $ref: string;
192
+ }
193
+ interface ExampleObject {
194
+ summary?: string;
195
+ description?: string;
196
+ value?: any;
197
+ externalValue?: string;
198
+ }
199
+ interface MediaTypeObject {
200
+ schema?: ReferenceObject | SchemaObject;
201
+ example?: any;
202
+ examples?: {
203
+ [media: string]: ReferenceObject | ExampleObject;
204
+ };
205
+ encoding?: {
206
+ [media: string]: EncodingObject;
207
+ };
208
+ }
209
+ interface EncodingObject {
210
+ contentType?: string;
211
+ headers?: {
212
+ [header: string]: ReferenceObject | HeaderObject;
213
+ };
214
+ style?: string;
215
+ explode?: boolean;
216
+ allowReserved?: boolean;
217
+ }
218
+ interface RequestBodyObject {
219
+ description?: string;
220
+ content: {
221
+ [media: string]: MediaTypeObject;
222
+ };
223
+ required?: boolean;
224
+ }
225
+ interface ResponsesObject {
226
+ [code: string]: ReferenceObject | ResponseObject;
227
+ }
228
+ interface ResponseObject {
229
+ description: string;
230
+ headers?: {
231
+ [header: string]: ReferenceObject | HeaderObject;
232
+ };
233
+ content?: {
234
+ [media: string]: MediaTypeObject;
235
+ };
236
+ links?: {
237
+ [link: string]: ReferenceObject | LinkObject;
238
+ };
239
+ }
240
+ interface LinkObject {
241
+ operationRef?: string;
242
+ operationId?: string;
243
+ parameters?: {
244
+ [parameter: string]: any;
245
+ };
246
+ requestBody?: any;
247
+ description?: string;
248
+ server?: ServerObject;
249
+ }
250
+ interface CallbackObject {
251
+ [url: string]: PathItemObject;
252
+ }
253
+ interface SecurityRequirementObject {
254
+ [name: string]: string[];
255
+ }
256
+ interface ComponentsObject {
257
+ schemas?: {
258
+ [key: string]: ReferenceObject | SchemaObject;
259
+ };
260
+ responses?: {
261
+ [key: string]: ReferenceObject | ResponseObject;
262
+ };
263
+ parameters?: {
264
+ [key: string]: ReferenceObject | ParameterObject;
265
+ };
266
+ examples?: {
267
+ [key: string]: ReferenceObject | ExampleObject;
268
+ };
269
+ requestBodies?: {
270
+ [key: string]: ReferenceObject | RequestBodyObject;
271
+ };
272
+ headers?: {
273
+ [key: string]: ReferenceObject | HeaderObject;
274
+ };
275
+ securitySchemes?: {
276
+ [key: string]: ReferenceObject | SecuritySchemeObject;
277
+ };
278
+ links?: {
279
+ [key: string]: ReferenceObject | LinkObject;
280
+ };
281
+ callbacks?: {
282
+ [key: string]: ReferenceObject | CallbackObject;
283
+ };
284
+ }
285
+ type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
286
+ interface HttpSecurityScheme {
287
+ type: "http";
288
+ description?: string;
289
+ scheme: string;
290
+ bearerFormat?: string;
291
+ }
292
+ interface ApiKeySecurityScheme {
293
+ type: "apiKey";
294
+ description?: string;
295
+ name: string;
296
+ in: string;
297
+ }
298
+ 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
+ interface OpenIdSecurityScheme {
334
+ type: "openIdConnect";
335
+ description?: string;
336
+ openIdConnectUrl: string;
337
+ }
338
+ interface TagObject {
339
+ name: string;
340
+ description?: string;
341
+ externalDocs?: ExternalDocumentationObject;
342
+ }
343
+ type ParamSchema = {
344
+ type?: "string" | "number" | "integer" | "boolean" | "array";
345
+ description?: string;
346
+ example?: any;
347
+ required?: boolean;
348
+ deprecated?: boolean;
349
+ enum?: any[];
350
+ format?: string;
351
+ default?: any;
352
+ minimum?: number;
353
+ maximum?: number;
354
+ minLength?: number;
355
+ maxLength?: number;
356
+ pattern?: string;
357
+ };
358
+ type ParamsSchemaMap = Record<string, ParamSchema>;
359
+ type RequestBodyOptions = {
360
+ description?: string;
361
+ required?: boolean;
362
+ content?: {
363
+ [media: string]: MediaTypeObject;
364
+ };
365
+ schema?: SchemaObject | ReferenceObject;
366
+ example?: any;
367
+ examples?: Record<string, ExampleObject>;
368
+ };
369
+ type ResponseBodyOptions = {
370
+ description?: string;
371
+ type?: NonArraySchemaObjectType | ArraySchemaObjectType;
372
+ properties?: {
373
+ [name: string]: ReferenceObject | SchemaObject;
374
+ };
375
+ items?: ReferenceObject | SchemaObject;
376
+ required?: string[];
377
+ schema?: SchemaObject | ReferenceObject;
378
+ example?: any;
379
+ examples?: Record<string, ExampleObject>;
380
+ content?: {
381
+ [media: string]: MediaTypeObject;
382
+ };
383
+ } & Partial<BaseSchemaObject>;
384
+ type ResponsesOptions = {
385
+ [statusCode: number]: ResponseBodyOptions | ResponseObject;
386
+ };
387
+ type OpenApiOptions = {
388
+ exclude?: boolean;
389
+ deprecated?: boolean;
390
+ tags?: readonly string[];
391
+ description?: string;
392
+ summary?: string;
393
+ operationId?: string;
394
+ security?: SecurityRequirementObject[];
395
+ externalDocs?: ExternalDocumentationObject;
396
+ components?: ComponentsObject;
397
+ /** Path parameters e.g. /:id → { id: { type: "string", example: "abc-123" } } */
398
+ params?: ParamsSchemaMap;
399
+ /** Query string parameters e.g. ?page=1 → { page: { type: "integer", example: 1 } } */
400
+ query?: ParamsSchemaMap;
401
+ /** Request headers */
402
+ headers?: ParamsSchemaMap;
403
+ /** Request body */
404
+ requestBody?: RequestBodyOptions;
405
+ /** Responses keyed by HTTP status code */
406
+ response?: ResponsesOptions;
407
+ /** @deprecated use requestBody instead */
408
+ responseBody?: any;
409
+ };
410
+ /**
411
+ * Normalize a flat ParamsSchemaMap into a valid JSON Schema object
412
+ * that Fastify/AJV can validate against.
413
+ *
414
+ * Input: { id: { type: "string", example: "abc-123" } }
415
+ * Output: { type: "object", properties: { id: { type: "string", example: "abc-123" } } }
416
+ */
417
+ declare function normalizeParamsToJsonSchema(params: ParamsSchemaMap, requiredKeys?: string[]): SchemaObject;
418
+ declare function OpenApiSchema(): ClassDecorator;
419
+ declare function OpenApi(options: OpenApiOptions): MethodDecorator & ClassDecorator & PropertyDecorator;
420
+ //#endregion
421
+ //#region src/swagger-schema.d.ts
422
+ declare function OpenApiProperty$1(options?: ParamSchema & {
423
+ exclude?: boolean;
424
+ isArray?: boolean;
425
+ items?: Record<string, any>;
426
+ oneOf?: any[];
427
+ allOf?: any[];
428
+ anyOf?: any[];
429
+ readOnly?: boolean;
430
+ writeOnly?: boolean;
431
+ nullable?: boolean;
432
+ title?: string;
433
+ }): (target: any, propertyKey: string) => void;
434
+ declare function CreateSwaggerObjectSchema(classType: any): any;
435
+ declare function generateClassSchema(classType: any): any;
436
+ declare function generateSwaggerSchema(controllers: any[]): any;
437
+ declare function OpenApiResponse$1(code: number | undefined, model: any, description?: string): {
438
+ description: string;
439
+ content: {
440
+ "application/json": {
441
+ schema: {
442
+ type: string;
443
+ properties: {
444
+ code: {
445
+ type: string;
446
+ example: number;
447
+ };
448
+ status: {
449
+ type: string;
450
+ example: string;
451
+ };
452
+ data: any;
453
+ };
454
+ };
455
+ };
456
+ };
457
+ };
458
+ //#endregion
459
+ //#region src/controller.d.ts
460
+ /**
461
+ * @copyright 2024
462
+ * @author Tareq Hossain
463
+ * @email xtrinsic96@gmail.com
464
+ * @url https://github.com/xtareq
465
+ */
466
+ declare const REQUEST_METADATA_KEY: unique symbol;
467
+ declare function AvleonRequest(): ParameterDecorator;
468
+ /**
469
+ * Options for configuring a controller.
470
+ * @remarks
471
+ * Controller default options
472
+ * @type {Object} ControllerOptions
473
+ * @property {string} [name] - The name of the controller.
474
+ * @property {string} [path] - The base path for the controller's routes.
475
+ * @property {string} [version] - The version of the controller. If not provided, it will default to the version from `package.json`.
476
+ * @property {string} [since] - The date or version since the controller was introduced.
477
+ * @property {any} [meta] - Additional metadata associated with the controller.
478
+ */
479
+ type ControllerOptions = {
480
+ /**
481
+ *@property {string} name
482
+ *@description Name of the controller. If specified it'll used as swagger tags
483
+ *@default Contorller class name
484
+ * */
485
+ name?: string;
486
+ path?: string;
487
+ version?: string;
488
+ since?: string;
489
+ meta?: any;
490
+ };
491
+ declare function createControllerDecorator(type?: "api" | "web"): (pathOrOptions?: string | ControllerOptions, maybeOptions?: ControllerOptions) => ClassDecorator;
492
+ /**
493
+ *@description Api controller's are used for rest . It will populate
494
+ * json on return and all it http methods {get} {post} etc must return
495
+ *Results.*
496
+ * @param path {string} this will used as route prefix
497
+ *
498
+ **/
499
+ declare function ApiController(target: Function): void;
500
+ declare function ApiController(path: string): ClassDecorator;
501
+ /**
502
+ *@description Api controller's are used for rest . It will populate
503
+ * json on return and all it http methods {get} {post} etc must return
504
+ * Results.*
505
+ * @param {ControllerOptions} options this will used as route prefix
506
+ *
507
+ **/
508
+ declare function ApiController(options: ControllerOptions): ClassDecorator;
509
+ declare function ApiController(path: string, options?: ControllerOptions): ClassDecorator;
510
+ //#endregion
511
+ //#region src/route-methods.d.ts
512
+ type RouteMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "ALL";
513
+ type RouteMethodOptions = {
514
+ method?: RouteMethods;
515
+ path?: string;
516
+ openapi?: OpenApiOptions;
517
+ name?: string;
518
+ };
519
+ /**
520
+ * Generic Route decorator factory
521
+ */
522
+ declare function Route(method: RouteMethods, pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions): MethodDecorator;
523
+ declare const Get: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
524
+ declare const Post: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
525
+ declare const Put: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
526
+ declare const Delete: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
527
+ declare const Patch: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
528
+ declare const Options: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
529
+ declare const All: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
530
+ //#endregion
531
+ //#region src/params.d.ts
532
+ /**
533
+ * @copyright 2024
534
+ * @author Tareq Hossain
535
+ * @email xtrinsic96@gmail.com
536
+ * @url https://github.com/xtareq
537
+ */
538
+ type ParameterOptions = {
539
+ required?: boolean;
540
+ validate?: boolean;
541
+ type?: any;
542
+ };
543
+ declare const Param: (key?: string | ParameterOptions, options?: ParameterOptions) => ParameterDecorator;
544
+ declare const Query: (key?: string | ParameterOptions, options?: ParameterOptions) => ParameterDecorator;
545
+ declare const Body: (key?: string | ParameterOptions, options?: ParameterOptions) => ParameterDecorator;
546
+ declare const Header: (key?: string | ParameterOptions, options?: ParameterOptions) => ParameterDecorator;
547
+ declare const AuthUser: (key?: string | ParameterOptions, options?: ParameterOptions) => ParameterDecorator;
548
+ //#endregion
549
+ //#region src/decorators.d.ts
550
+ declare function AppService(target: any): void;
551
+ declare function AppService(): any;
552
+ declare const Utility: typeof Service;
553
+ declare const Helper: typeof Service;
554
+ //#endregion
555
+ //#region src/utils/common-utils.d.ts
556
+ declare const uuid: `${string}-${string}-${string}-${string}-${string}`;
557
+ type Constructor<T = any> = new (...args: any[]) => T;
558
+ declare function isConstructor(func: any): boolean;
559
+ declare function formatUrl(path: string): string;
560
+ declare function parsedPath(ipath: string): string;
561
+ interface MatchLocation {
562
+ line: number;
563
+ column: number;
564
+ }
565
+ declare const getLineNumber: (filePath: string, rpath: string | RegExp) => MatchLocation[] | null;
566
+ declare function normalizePath(base?: string, subPath?: string): string;
567
+ declare function extrctParamFromUrl(url: string): {
568
+ key: string;
569
+ required: boolean;
570
+ }[];
571
+ declare function findDuplicates(arr: string[]): string[];
572
+ declare function sleep(ms: number): Promise<unknown>;
573
+ //#endregion
574
+ //#region src/utils/object-utils.d.ts
575
+ declare function pick<T extends object>(obj: T, paths: string[]): Partial<T>;
576
+ declare function exclude<T extends object>(obj: T | T[], paths: string[]): Partial<T> | Partial<T>[];
577
+ declare function autoCast(value: any, typeHint?: any, schema?: any): any;
578
+ /**
579
+ * Deeply normalizes query strings into nested JS objects.
580
+ */
581
+ declare function normalizeQueryDeep(query: Record<string, any>): Record<string, any>;
582
+ declare function transformObjectByInstanceToObject(instance: Constructor, value: object): Record<string, any>;
583
+ declare function jsonToJs(value: string): any;
584
+ declare function jsonToInstance(value: string, instance: Constructor): any;
585
+ //#endregion
586
+ //#region src/utils/validation-utils.d.ts
587
+ declare const isClassValidator: (target: Constructor) => boolean;
588
+ declare function getDataType(expectedType: any): any;
589
+ declare function isValidType(value: any, expectedType: any): boolean;
590
+ declare function isValidJsonString(value: string): object | boolean;
591
+ declare const isClassValidatorClass: (target: Constructor) => boolean;
592
+ declare function validateObjectByInstance(target: Constructor, value?: object, options?: "object" | "array"): Promise<any>;
593
+ type ValidationError = {
594
+ count: number;
595
+ errors: any;
596
+ };
597
+ declare function validateRequestBody(target: Constructor, value: object, options?: "object" | "array"): ValidationError;
598
+ //#endregion
599
+ //#region src/utils/di-utils.d.ts
600
+ declare function inject<T>(cls: new (...args: any[]) => T): T;
601
+ //#endregion
602
+ //#region src/validation.d.ts
603
+ /**
604
+ * @copyright 2024
605
+ * @author Tareq Hossain
606
+ * @email xtrinsic96@gmail.com
607
+ * @url https://github.com/xtareq
608
+ */
609
+ type BaseRule = {
610
+ required?: boolean;
611
+ optional?: boolean;
612
+ message?: string;
613
+ };
614
+ type StringRule = BaseRule & {
615
+ type: "string";
616
+ };
617
+ type NumberRule = BaseRule & {
618
+ type: "number";
619
+ min?: number;
620
+ max?: number;
621
+ exact?: number;
622
+ };
623
+ type BooleanRule = BaseRule & {
624
+ type: "boolean";
625
+ };
626
+ type ValidationRule = StringRule | NumberRule | BooleanRule;
627
+ type ValidationProps = {
628
+ [key: string]: ValidationRule;
629
+ };
630
+ type ValidateOptons = {
631
+ location?: "header" | "queryparam" | "param" | "body" | "custom";
632
+ };
633
+ declare class Validator {
634
+ private rules;
635
+ private options;
636
+ constructor(obj: ValidationProps, options?: ValidateOptons);
637
+ private init;
638
+ validate(obj: any | Array<any>, options?: ValidateOptons): any[];
639
+ }
640
+ declare function validateOrThrow<T extends {}>(obj: T, rules: ValidationProps, options?: ValidateOptons): any;
641
+ //#endregion
642
+ //#region src/multipart.d.ts
643
+ type MultipartFile$1 = MultipartFile | SavedMultipartFile;
644
+ //#endregion
645
+ //#region src/core/types.d.ts
646
+ interface IRequest extends Omit<FastifyRequest, "files" | "formData" | "file" | "saveRequestFiles"> {
647
+ params: any;
648
+ query: any;
649
+ body: any;
650
+ headers: any;
651
+ user?: any;
652
+ formData?: any;
653
+ file?: MultipartFile$1;
654
+ files?: MultipartFile$1[];
655
+ saveRequestFiles?: (options?: any) => Promise<MultipartFile$1[]>;
656
+ _argsCache?: Map<string, any[]>;
657
+ }
658
+ interface IResponse extends FastifyReply {}
659
+ interface ParamMetaOptions {
660
+ index: number;
661
+ key: string;
662
+ name: string;
663
+ required: boolean;
664
+ validate: boolean;
665
+ dataType: any;
666
+ validatorClass: boolean;
667
+ schema?: any;
668
+ type: "route:param" | "route:query" | "route:body" | "route:header" | "route:user" | "route:file" | "route:files";
669
+ }
670
+ interface ParamMetaFilesOptions {
671
+ index: number;
672
+ type: "route:files";
673
+ files: MultipartFile$1[];
674
+ fieldName: string;
675
+ }
676
+ interface MethodParamMeta {
677
+ request: any[];
678
+ params: ParamMetaOptions[];
679
+ query: ParamMetaOptions[];
680
+ body: ParamMetaOptions[];
681
+ headers: ParamMetaOptions[];
682
+ currentUser: ParamMetaOptions[];
683
+ swagger?: OpenApiUiOptions;
684
+ file?: any[];
685
+ files?: ParamMetaFilesOptions[];
686
+ }
687
+ interface IRoute {
688
+ url: string;
689
+ method: string;
690
+ controller: string;
691
+ }
692
+ type FuncRoute = {
693
+ handler: Function;
694
+ middlewares: any[];
695
+ schema: any;
696
+ };
697
+ type StaticFileOptions = {
698
+ path?: string;
699
+ prefix?: string;
700
+ };
701
+ //#endregion
702
+ //#region src/exceptions/http-exceptions.d.ts
703
+ /**
704
+ * @copyright 2024
705
+ * @author Tareq Hossain
706
+ * @email xtrinsic96@gmail.com
707
+ * @url https://github.com/xtareq
708
+ */
709
+ declare abstract class BaseHttpException extends Error {
710
+ code: number;
711
+ name: string;
712
+ payload: any;
713
+ constructor(message: any);
714
+ isCustomException(): boolean;
715
+ }
716
+ declare class BadRequestException extends BaseHttpException {
717
+ name: string;
718
+ code: number;
719
+ constructor(message: any);
720
+ }
721
+ declare class ValidationErrorException extends BadRequestException {
722
+ name: string;
723
+ }
724
+ declare class InternalErrorException extends BaseHttpException {
725
+ name: string;
726
+ code: number;
727
+ constructor(message?: any);
728
+ }
729
+ declare class NotFoundException extends BaseHttpException {
730
+ name: string;
731
+ code: number;
732
+ constructor(message: any);
733
+ }
734
+ declare class UnauthorizedException extends BaseHttpException {
735
+ name: string;
736
+ code: number;
737
+ constructor(message: any);
738
+ }
739
+ declare class ForbiddenException extends BaseHttpException {
740
+ name: string;
741
+ code: number;
742
+ constructor(message: any);
743
+ }
744
+ type HttpExceptionTypes = NotFoundException | BadRequestException | UnauthorizedException | InternalErrorException | ForbiddenException;
745
+ declare const HttpExceptions: {
746
+ notFound: (message?: any) => NotFoundException;
747
+ validationError: (message?: any) => ValidationErrorException;
748
+ badRequest: (message?: any) => BadRequestException;
749
+ unauthorized: (message?: any) => UnauthorizedException;
750
+ forbidden: (message?: any) => ForbiddenException;
751
+ internalError: (message?: any) => InternalErrorException;
752
+ };
753
+ //#endregion
754
+ //#region src/middleware.d.ts
755
+ declare abstract class AvleonMiddleware {
756
+ abstract invoke(req: IRequest, res?: IResponse): Promise<IRequest | HttpExceptionTypes>;
757
+ }
758
+ type AuthHandler = (req: IRequest, roles?: string[]) => Promise<IRequest | HttpExceptionTypes>;
759
+ declare abstract class AuthorizeMiddleware {
760
+ abstract authorize(roles: string[]): (req: IRequest, res?: IResponse) => IRequest | Promise<IRequest>;
761
+ }
762
+ type AuthReturnTypes = IRequest | Promise<IRequest>;
763
+ interface AuthorizeClass {
764
+ authorize(req: IRequest, options?: any): AuthReturnTypes;
765
+ }
766
+ declare function CanAuthorize(target: {
767
+ new (...args: any[]): AuthorizeClass;
768
+ }): void;
769
+ declare function AppAuthorization(target: {
770
+ new (...args: any[]): AuthorizeClass;
771
+ }): void;
772
+ declare function Authorized(): ClassDecorator & MethodDecorator;
773
+ declare function Authorized(options?: any): ClassDecorator & MethodDecorator;
774
+ declare function AppMiddleware(target: Constructor<AvleonMiddleware>): void;
775
+ /**
776
+ * A decorator function that applies one or more middleware to a class or a method.
777
+ *
778
+ * When applied to a class, the middleware are registered for the entire controller.
779
+ * When applied to a method, the middleware are registered for that specific route.
780
+ *
781
+ * @param options - A single middleware instance/class or an array of middleware instances/classes to be applied.
782
+ * @returns A decorator that registers the middleware metadata.
783
+ */
784
+ declare function UseMiddleware<T extends AvleonMiddleware | (new (...args: any[]) => AvleonMiddleware)>(options: T | T[]): MethodDecorator & ClassDecorator;
785
+ //#endregion
786
+ //#region src/interfaces/avleon-application.d.ts
787
+ type CorsOptions = {
788
+ origin?: boolean | string | RegExp | (string | RegExp)[] | ((origin: string, cb: (err: Error | null, allow?: boolean) => void) => void);
789
+ methods?: string | string[];
790
+ allowedHeaders?: string | string[];
791
+ exposedHeaders?: string | string[];
792
+ credentials?: boolean;
793
+ maxAge?: number;
794
+ preflight?: boolean;
795
+ strictPreflight?: boolean;
796
+ hideOptionsRoute?: boolean;
797
+ optionsSuccessStatus?: number;
798
+ };
799
+ type GlobalOptions = {
800
+ cors?: CorsOptions;
801
+ openApi?: OpenApiUiOptions;
802
+ controllers?: any;
803
+ middlewares?: any;
804
+ authorization?: any;
805
+ multipart?: any;
806
+ staticFiles?: any;
807
+ };
808
+ type AvleonApplicationOptions = {
809
+ server?: FastifyServerOptions;
810
+ dataSourceOptions?: DataSourceOptions;
811
+ };
812
+ type AutoControllerOptions = {
813
+ auto: true;
814
+ path?: string;
815
+ };
816
+ interface IAvleonApplication {
817
+ useCors: (options: CorsOptions) => this;
818
+ useDatasource: (dataSource: DataSource) => this;
819
+ useMultipart: (options?: any) => this;
820
+ useOpenApi: (options: OpenApiUiOptions) => this;
821
+ useMiddlewares: (middlewares: Constructor<AvleonMiddleware>[]) => this;
822
+ useAuthorization: (authorization: Constructor<any>) => this;
823
+ useSerialization: () => this;
824
+ useControllers: (controllers: Constructor[] | AutoControllerOptions) => this;
825
+ useStaticFiles: (options: any) => this;
826
+ useHttps: (options?: any) => this;
827
+ useGlobal: (options: GlobalOptions) => this;
828
+ useSocketIo: (options?: any) => this;
829
+ useKnex: (options: any) => this;
830
+ mapFeatures: () => this;
831
+ mapGet: <T extends (...args: any[]) => any>(path: string, fn: T) => any;
832
+ mapPost: <T extends (...args: any[]) => any>(path: string, fn: T) => any;
833
+ mapPut: <T extends (...args: any[]) => any>(path: string, fn: T) => any;
834
+ mapDelete: <T extends (...args: any[]) => any>(path: string, fn: T) => any;
835
+ run: (port?: number, fn?: CallableFunction) => Promise<void>;
836
+ }
837
+ type TestResponse = LightMyRequestResponse | Promise<LightMyRequestResponse>;
838
+ interface TestApplication {
839
+ get: (url: string, options?: InjectOptions) => TestResponse;
840
+ post: (url: string, options?: InjectOptions) => TestResponse;
841
+ put: (url: string, options?: InjectOptions) => TestResponse;
842
+ patch: (url: string, options?: InjectOptions) => TestResponse;
843
+ delete: (url: string, options?: InjectOptions) => TestResponse;
844
+ options: (url: string, options?: InjectOptions) => TestResponse;
845
+ getController: <T>(controller: Constructor<T>, deps?: any[]) => T;
846
+ }
847
+ type TestAppOptions = {
848
+ controllers: Constructor[] | unknown[];
849
+ dataSource?: DataSourceOptions;
850
+ };
851
+ //#endregion
852
+ //#region src/core/application.d.ts
853
+ declare class AvleonApplication implements IAvleonApplication {
854
+ app: FastifyInstance;
855
+ private router;
856
+ private static instance;
857
+ private alreadyRun;
858
+ private hasSwagger;
859
+ private globalSwaggerOptions;
860
+ private dataSourceOptions;
861
+ private dataSource;
862
+ private isMapFeatures;
863
+ private registerControllerAuto;
864
+ private registerControllerPath;
865
+ private controllers;
866
+ private _hasWebsocket;
867
+ private io;
868
+ private constructor();
869
+ static getApp(options?: AvleonApplicationOptions): AvleonApplication;
870
+ /** @deprecated Use `getApp` instead. This is internal. */
871
+ static getInternalApp(options?: AvleonApplicationOptions): AvleonApplication;
872
+ useCors(options: CorsOptions): this;
873
+ useDatasource(dataSource: any): this;
874
+ useMultipart(options?: any): this;
875
+ useOpenApi(options: OpenApiUiOptions): this;
876
+ private initSwagger;
877
+ useMiddlewares(middlewares: Constructor<AvleonMiddleware>[]): this;
878
+ useAuthorization(authorization: Constructor<any>): this;
879
+ useSerialization(): this;
880
+ useControllers(controllers: Constructor[] | AutoControllerOptions): this;
881
+ useStaticFiles(options?: any): this;
882
+ useHttps(options?: any): this;
883
+ useGlobal(options: GlobalOptions): this;
884
+ useSocketIo(options?: any): this;
885
+ useKnex(options: any): this;
886
+ mapFeatures(): this;
887
+ isDevelopment(): boolean;
888
+ private _mapControllers;
889
+ private _resolveControllerDir;
890
+ private autoControllers;
891
+ private _mapFeatures;
892
+ initializeDatabase(): Promise<void>;
893
+ handleSocket(socket: any): void;
894
+ mapGet<T extends (...args: any[]) => any>(path: string | undefined, fn: T): {
895
+ useMiddleware: <M extends AvleonMiddleware>(middlewares: Constructor<AvleonMiddleware>[]) => /*elided*/any;
896
+ useOpenApi: (options: OpenApiOptions) => /*elided*/any;
897
+ };
898
+ mapPost<T extends (...args: any[]) => any>(path: string | undefined, fn: T): {
899
+ useMiddleware: <M extends AvleonMiddleware>(middlewares: Constructor<AvleonMiddleware>[]) => /*elided*/any;
900
+ useOpenApi: (options: OpenApiOptions) => /*elided*/any;
901
+ };
902
+ mapPut<T extends (...args: any[]) => any>(path: string | undefined, fn: T): {
903
+ useMiddleware: <M extends AvleonMiddleware>(middlewares: Constructor<AvleonMiddleware>[]) => /*elided*/any;
904
+ useOpenApi: (options: OpenApiOptions) => /*elided*/any;
905
+ };
906
+ mapDelete<T extends (...args: any[]) => any>(path: string | undefined, fn: T): {
907
+ useMiddleware: <M extends AvleonMiddleware>(middlewares: Constructor<AvleonMiddleware>[]) => /*elided*/any;
908
+ useOpenApi: (options: OpenApiOptions) => /*elided*/any;
909
+ };
910
+ run(port?: number, fn?: CallableFunction): Promise<void>;
911
+ }
912
+ //#endregion
913
+ //#region src/core/testing.d.ts
914
+ declare class AvleonTest {
915
+ private constructor();
916
+ static getController<T>(controller: Constructor<T>, deps?: any[]): T;
917
+ static getProvider<T>(service: Constructor<T>, deps?: any[]): T;
918
+ static createTestApplication(options: TestAppOptions): TestApplication;
919
+ static from(app: AvleonApplication): TestApplication;
920
+ static clean(): void;
921
+ }
922
+ declare class Avleon {
923
+ static createApplication(): AvleonApplication;
924
+ static createTestApplication(options: TestAppOptions): TestApplication;
925
+ }
926
+ //#endregion
927
+ //#region src/response.d.ts
928
+ interface IHttpResponse<T extends any> {
929
+ message: string;
930
+ data: T | null;
931
+ }
932
+ declare class HttpResponse {
933
+ static Ok<T>(obj: any, s?: ClassConstructor<T>): IHttpResponse<T>;
934
+ static Created<T>(obj: any, s?: ClassConstructor<T>): IHttpResponse<T>;
935
+ static NoContent(): IHttpResponse<null>;
936
+ }
937
+ //#endregion
938
+ //#region src/container.d.ts
939
+ declare const FEATURE_KEY: unique symbol;
940
+ declare const ROUTE_META_KEY: unique symbol;
941
+ declare const CONTROLLER_META_KEY: unique symbol;
942
+ declare const PARAM_META_KEY: unique symbol;
943
+ declare const QUERY_META_KEY: unique symbol;
944
+ declare const REQUEST_BODY_META_KEY: unique symbol;
945
+ declare const REQUEST_BODY_FILE_KEY: unique symbol;
946
+ declare const REQUEST_BODY_FILES_KEY: unique symbol;
947
+ declare const REQUEST_USER_META_KEY: unique symbol;
948
+ declare const REQUEST_HEADER_META_KEY: unique symbol;
949
+ declare const DATASOURCE_META_KEY: unique symbol;
950
+ declare const AUTHORIZATION_META_KEY: unique symbol;
951
+ declare function registerController(controller: Function): void;
952
+ declare function registerService(service: Function): void;
953
+ declare function getRegisteredServices(): Function[];
954
+ declare function getRegisteredControllers(): Function[];
955
+ declare const API_CONTROLLER_METADATA_KEY: unique symbol;
956
+ declare function isApiController(target: Function): boolean;
957
+ declare function registerDataSource(dataSource: any): void;
958
+ declare function registerKnex(dataSource: Knex.Config): void;
959
+ //#endregion
960
+ //#region src/kenx-provider.d.ts
961
+ declare class DB {
962
+ private connection;
963
+ constructor();
964
+ init(config: Knex.Config): Knex<any, any[]>;
965
+ get client(): Knex;
966
+ }
967
+ //#endregion
968
+ //#region src/collection.d.ts
969
+ type Predicate<T> = (item: T) => boolean;
970
+ type ValueOperator<T> = {
971
+ $in?: T[];
972
+ };
973
+ type FieldCondition<T> = T | ValueOperator<T>;
974
+ type WhereCondition<T> = { [K in keyof T]?: FieldCondition<T[K]> };
975
+ type LogicalOperators<T> = {
976
+ $and: Where<T>[];
977
+ } | {
978
+ $or: Where<T>[];
979
+ } | {
980
+ $not: Where<T>;
981
+ };
982
+ type Where<T> = WhereCondition<T> | LogicalOperators<T>;
983
+ interface IFindOneOptions<T = any> {
984
+ where: Where<T>;
985
+ }
986
+ type PaginationResult<T> = {
987
+ total: number;
988
+ data: T[];
989
+ next?: number | null;
990
+ prev?: number | null;
991
+ first?: number | null;
992
+ last?: number | null;
993
+ totalPage?: number;
994
+ };
995
+ interface BasicCollection<T> {
996
+ clear(): void;
997
+ find(predicate?: Predicate<T>): T[];
998
+ findAsync(predicate?: Predicate<T>): Promise<T[]>;
999
+ findOne(predicate: Predicate<T> | IFindOneOptions<T>): T | undefined;
1000
+ findOneAsync(predicate: Predicate<T> | IFindOneOptions<T>): Promise<T | undefined>;
1001
+ }
1002
+ declare class Collection {
1003
+ private constructor();
1004
+ static from<T>(items: T[]): BasicCollection<T>;
1005
+ static fromRepository<T extends ObjectLiteral>(entity: EntityTarget<T>): Repository<T>;
1006
+ }
1007
+ declare function InjectRepository<T extends Repository<T>>(model: EntityTarget<T>): (object: any, propertyName: string | undefined, index?: number) => void;
1008
+ //#endregion
1009
+ //#region src/event-dispatcher.d.ts
1010
+ declare class SocketContextService {
1011
+ private readonly storage;
1012
+ run(socket: Socket, fn: () => void | Promise<void>): void;
1013
+ getSocket(): Socket | undefined;
1014
+ }
1015
+ type DispatchOptions = {
1016
+ room?: string;
1017
+ broadcast?: boolean;
1018
+ transports?: ("socket" | "kafka" | "rabbitmq")[];
1019
+ retry?: number;
1020
+ retryDelay?: number;
1021
+ };
1022
+ declare class EventDispatcher {
1023
+ private readonly _context;
1024
+ constructor(_context: SocketContextService);
1025
+ dispatch<T = any>(event: string, data: T, options?: DispatchOptions): Promise<void>;
1026
+ private dispatchToTransports;
1027
+ }
1028
+ declare function Dispatch(event: string, options?: Omit<DispatchOptions, "transports"> & {
1029
+ transports?: DispatchOptions["transports"];
1030
+ }): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
1031
+ //#endregion
1032
+ //#region src/event-subscriber.d.ts
1033
+ declare function Private(channelResolver?: (socket: any) => string): (target: any, propertyKey: string) => void;
1034
+ declare function isPrivate(target: any, propertyKey: string): boolean;
1035
+ declare function getPrivateChannelResolver(target: any, propertyKey: string): ((socket: any) => string) | undefined;
1036
+ declare function registerSocketSubscriber(target: Function): void;
1037
+ declare function getSocketSubscribers(): Function[];
1038
+ declare function Subscribe(event: string): MethodDecorator;
1039
+ declare class EventSubscriberRegistry {
1040
+ private readonly socketContext;
1041
+ constructor(socketContext: SocketContextService);
1042
+ register(socket: Socket): void;
1043
+ }
1044
+ //#endregion
1045
+ //#region src/queue.d.ts
1046
+ interface QueueConfig {
1047
+ name: string;
1048
+ adapter?: any;
1049
+ handler?: (job: Job) => Promise<any>;
1050
+ options?: Bull.QueueOptions;
1051
+ }
1052
+ declare class AvleonQueue<T = any> {
1053
+ protected name?: string | undefined;
1054
+ protected adapter?: any | undefined;
1055
+ protected queue: Queue$1<T>;
1056
+ protected handlerFn?: (job: Job<T>) => Promise<any>;
1057
+ constructor(name?: string | undefined, adapter?: any | undefined, handler?: (job: Job<T>) => Promise<any>);
1058
+ handler?(job: Job<T>): Promise<any> | any;
1059
+ add(data: T, options?: JobOptions): Promise<Bull.Job<T>>;
1060
+ delay(data: T, delayMs: number, options?: JobOptions): Promise<Bull.Job<T>>;
1061
+ process(handler: (job: Job<T>) => Promise<any>): void;
1062
+ processConcurrent(concurrency: number, handler: (job: Job<T>) => Promise<any>): void;
1063
+ getQueue(): Queue$1<T>;
1064
+ clean(grace: number, status?: 'completed' | 'wait' | 'active' | 'delayed' | 'failed'): Promise<Job[]>;
1065
+ close(): Promise<void>;
1066
+ pause(): Promise<void>;
1067
+ resume(): Promise<void>;
1068
+ getJob(jobId: string): Promise<Job<T> | null>;
1069
+ getJobs(types: Array<'completed' | 'waiting' | 'active' | 'delayed' | 'failed' | 'paused'>, start?: number, end?: number): Promise<Job<T>[]>;
1070
+ }
1071
+ declare function Queue(config: QueueConfig): <T extends {
1072
+ new (...args: any[]): AvleonQueue;
1073
+ }>(target: T) => T;
1074
+ //#endregion
1075
+ //#region src/file-storage.d.ts
1076
+ interface TransformOptions {
1077
+ resize?: {
1078
+ width: number;
1079
+ height: number;
1080
+ };
1081
+ format?: "jpeg" | "png" | "webp" | "avif";
1082
+ quality?: number;
1083
+ }
1084
+ interface FileStorageInterface {
1085
+ transform(options: TransformOptions): FileStorage;
1086
+ save(file: MultipartFile$1, options?: SaveOptionsSingle): Promise<MultipartFile$1>;
1087
+ saveAll(files: MultipartFile$1[], options?: SaveOptions): Promise<MultipartFile$1[]>;
1088
+ remove(filepath: string): Promise<void>;
1089
+ }
1090
+ interface SaveOptions {
1091
+ overwrite?: boolean;
1092
+ to?: string;
1093
+ }
1094
+ interface SaveOptionsSingle extends SaveOptions {
1095
+ saveAs?: string;
1096
+ }
1097
+ declare class FileStorage implements FileStorageInterface {
1098
+ private transformOptions;
1099
+ private readonly baseDir;
1100
+ private readonly maxFileSize;
1101
+ constructor();
1102
+ /**
1103
+ * Set transformation options for the next save operation
1104
+ */
1105
+ transform(options: TransformOptions): FileStorage;
1106
+ getUploadFile(fliePath: string): Promise<NonSharedBuffer>;
1107
+ download(filepath: PathLike): Promise<{
1108
+ download: boolean;
1109
+ stream: fs.ReadStream;
1110
+ filename: string;
1111
+ }>;
1112
+ downloadAs(filepath: PathLike, filename: string): Promise<{
1113
+ download: boolean;
1114
+ stream: fs.ReadStream;
1115
+ filename: string;
1116
+ }>;
1117
+ /**
1118
+ * Save a single file with optional transformations
1119
+ */
1120
+ save(f: MultipartFile$1, options?: SaveOptionsSingle): Promise<any>;
1121
+ /**
1122
+ * Save multiple files
1123
+ */
1124
+ saveAll(files: MultipartFile$1[], options?: SaveOptions): Promise<any[]>;
1125
+ /**
1126
+ * Remove a file from storage
1127
+ */
1128
+ remove(filepath: string): Promise<void>;
1129
+ /**
1130
+ * Process image with transformations using sharp
1131
+ */
1132
+ private processImage;
1133
+ /**
1134
+ * Helper methods
1135
+ */
1136
+ private isFileExists;
1137
+ private ensureDirectoryExists;
1138
+ private removeFileSync;
1139
+ private isImageFile;
1140
+ private validateFilename;
1141
+ }
1142
+ //#endregion
1143
+ //#region src/environment-variables.d.ts
1144
+ /**
1145
+ * @copyright 2024
1146
+ * @author Tareq Hossain
1147
+ * @email xtrinsic96@gmail.com
1148
+ * @url https://github.com/xtareq
1149
+ */
1150
+ /**
1151
+ * @class Environment
1152
+ * @description A service class to manage access to environment variables.
1153
+ * It loads variables from `.env` file and merges them with `process.env`,
1154
+ * giving precedence to `process.env` values.
1155
+ */
1156
+ declare class Environment {
1157
+ /**
1158
+ * Parses the given `.env` file and merges it with `process.env`.
1159
+ * Values from `process.env` take precedence.
1160
+ *
1161
+ * @private
1162
+ * @param filePath - Absolute path to the `.env` file.
1163
+ * @returns A dictionary of merged environment variables.
1164
+ */
1165
+ private parseEnvFile;
1166
+ /**
1167
+ * Retrieves the value of the specified environment variable.
1168
+ *
1169
+ * @template T
1170
+ * @param key - The name of the environment variable.
1171
+ * @returns The value of the variable, or `undefined` if not found.
1172
+ */
1173
+ get<T = any>(key: string): T;
1174
+ /**
1175
+ * Retrieves the value of the specified environment variable.
1176
+ * Throws an error if the variable is not found.
1177
+ *
1178
+ * @template T
1179
+ * @param key - The name of the environment variable.
1180
+ * @throws {EnvironmentVariableNotFound} If the variable does not exist.
1181
+ * @returns The value of the variable.
1182
+ */
1183
+ getOrThrow<T = any>(key: string): T;
1184
+ /**
1185
+ * Retrieves all available environment variables,
1186
+ * with `process.env` values taking precedence over `.env` values.
1187
+ *
1188
+ * @template T
1189
+ * @returns An object containing all environment variables.
1190
+ */
1191
+ getAll<T = any>(): T;
1192
+ }
1193
+ //#endregion
1194
+ //#region src/config.d.ts
1195
+ interface IConfig<T = any> {
1196
+ config(env: Environment): T;
1197
+ }
1198
+ declare function AppConfig<T extends IConfig>(target: Constructable<T>): void;
1199
+ declare class AvleonConfig {
1200
+ get<T extends IConfig<R>, R>(configClass: Constructable<T>): R;
1201
+ }
1202
+ declare function GetConfig<T extends IConfig<R>, R = ReturnType<InstanceType<Constructable<T>>["config"]>>(ConfigClass: Constructable<T>): R;
1203
+ declare function GetConfig<T = any>(config: string | symbol): T;
1204
+ declare function CreateConfig<T>(token: string | symbol, callback: (env: Environment) => T): void;
1205
+ //#endregion
1206
+ //#region src/logger.d.ts
1207
+ declare class LoggerService {
1208
+ private logger;
1209
+ constructor();
1210
+ getLogger(): pino.Logger;
1211
+ info(message: string, obj?: any): void;
1212
+ error(message: string, obj?: any): void;
1213
+ warn(message: string, obj?: any): void;
1214
+ debug(message: string, obj?: any): void;
1215
+ fatal(message: string, obj?: any): void;
1216
+ trace(message: string, obj?: any): void;
1217
+ }
1218
+ //#endregion
1219
+ //#region src/cache.d.ts
1220
+ declare class CacheManager {
1221
+ private store;
1222
+ private tagsMap;
1223
+ private redis;
1224
+ constructor(redisInstance?: Redis);
1225
+ private redisTagKey;
1226
+ get<T>(key: string): Promise<T | null>;
1227
+ set<T>(key: string, value: T, tags?: string[], ttl?: number): Promise<void>;
1228
+ delete(key: string): Promise<void>;
1229
+ invalidateTag(tag: string): Promise<void>;
1230
+ }
1231
+ //#endregion
1232
+ //#region src/results.d.ts
1233
+ type OkOptions = {
1234
+ streamable: boolean;
1235
+ };
1236
+ declare class Results {
1237
+ static code: number;
1238
+ message: string;
1239
+ static Ok<T>(data: T): Ok<T>;
1240
+ static NoContent(): void;
1241
+ static OkStream(): void;
1242
+ static NotFound<T>(message: T): NotFound<T>;
1243
+ }
1244
+ declare class Ok<T> {
1245
+ data: T;
1246
+ constructor(data: T);
1247
+ }
1248
+ declare class NotFound<T> {
1249
+ message: T;
1250
+ constructor(message: T);
1251
+ }
1252
+ type RouteResult<T = any> = typeof Results.Ok<T>;
1253
+ //#endregion
1254
+ //#region src/index.d.ts
1255
+ declare const GetSchema: typeof generateSwaggerSchema;
1256
+ declare const GetObjectSchema: typeof CreateSwaggerObjectSchema;
1257
+ declare const OpenApiOk: (args1: any) => {
1258
+ description: string;
1259
+ content: {
1260
+ "application/json": {
1261
+ schema: {
1262
+ type: string;
1263
+ properties: {
1264
+ code: {
1265
+ type: string;
1266
+ example: number;
1267
+ };
1268
+ status: {
1269
+ type: string;
1270
+ example: string;
1271
+ };
1272
+ data: any;
1273
+ };
1274
+ };
1275
+ };
1276
+ };
1277
+ };
1278
+ declare const OpenApiResponse: typeof OpenApiResponse$1;
1279
+ declare const OpenApiProperty: typeof OpenApiProperty$1;
1280
+ //#endregion
1281
+ export { API_CONTROLLER_METADATA_KEY, AUTHORIZATION_META_KEY, All, ApiController, ApiKeySecurityScheme, AppAuthorization, AppConfig, AppMiddleware, AppService, ArraySchemaObject, ArraySchemaObjectType, AuthHandler, AuthReturnTypes, AuthUser, AuthorizeMiddleware, Authorized, AutoControllerOptions, Avleon, AvleonApplication, AvleonApplicationOptions, AvleonConfig, Container as AvleonContainer, AvleonMiddleware, AvleonQueue, AvleonRequest, AvleonTest, BadRequestException, BaseHttpException, BaseSchemaObject, BasicCollection, Body, CONTROLLER_META_KEY, CacheManager, CallbackObject, CanAuthorize, Collection, ComponentsObject, Constructor, ContactObject, ControllerOptions, CorsOptions, CreateConfig, CreateSwaggerObjectSchema, DATASOURCE_META_KEY, DB, Delete, DiscriminatorObject, Dispatch, DispatchOptions, EncodingObject, Environment, EventDispatcher, EventSubscriberRegistry, ExampleObject, ExternalDocumentationObject, FEATURE_KEY, FileStorage, FileStorageInterface, ForbiddenException, FuncRoute, Get, GetConfig, GetObjectSchema, GetSchema, GlobalOptions, Header, HeaderObject, Helper, HttpExceptionTypes, HttpExceptions, HttpResponse, HttpSecurityScheme, IAvleonApplication, IConfig, IFindOneOptions, IHttpResponse, IRequest, IResponse, IRoute, InfoObject, InjectRepository, InternalErrorException, LicenseObject, LinkObject, LoggerService, MatchLocation, MediaTypeObject, MethodParamMeta, NonArraySchemaObject, NonArraySchemaObjectType, NotFound, NotFoundException, OAuth2SecurityScheme, Ok, OkOptions, OpenApi, OpenApiOk, OpenApiOptions, OpenApiProperty, OpenApiResponse, OpenApiSchema, OpenApiUiOptions, OpenIdSecurityScheme, OperationObject, Options, PARAM_META_KEY, PaginationResult, Param, ParamMetaFilesOptions, ParamMetaOptions, ParamSchema, ParameterBaseObject, ParameterObject, ParamsSchemaMap, Patch, PathItemObject, PathsObject, Post, Private, Put, QUERY_META_KEY, Query, Queue, QueueConfig, REQUEST_BODY_FILES_KEY, REQUEST_BODY_FILE_KEY, REQUEST_BODY_META_KEY, REQUEST_HEADER_META_KEY, REQUEST_METADATA_KEY, REQUEST_USER_META_KEY, ROUTE_META_KEY, ReferenceObject, RequestBodyObject, RequestBodyOptions, ResponseBodyOptions, ResponseObject, ResponsesObject, ResponsesOptions, Results, Route, RouteMethodOptions, RouteMethods, RouteResult, SaveOptions, SaveOptionsSingle, SchemaObject, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, SocketContextService, StaticFileOptions, Subscribe, TagObject, TestAppOptions, TestApplication, TestResponse, UnauthorizedException, UseMiddleware, Utility, ValidateOptons, ValidationErrorException, ValidationProps, ValidationRule, Validator, XMLObject, autoCast, createControllerDecorator, exclude, extrctParamFromUrl, findDuplicates, formatUrl, generateClassSchema, generateSwaggerSchema, getDataType, getLineNumber, getPrivateChannelResolver, getRegisteredControllers, getRegisteredServices, getSocketSubscribers, inject, isApiController, isClassValidator, isClassValidatorClass, isConstructor, isPrivate, isValidJsonString, isValidType, jsonToInstance, jsonToJs, normalizeParamsToJsonSchema, normalizePath, normalizeQueryDeep, parsedPath, pick, registerController, registerDataSource, registerKnex, registerService, registerSocketSubscriber, sleep, transformObjectByInstanceToObject, uuid, validateObjectByInstance, validateOrThrow, validateRequestBody };
1282
+ //# sourceMappingURL=index-CzAzauXZ.d.cts.map