@avleon/core 0.0.45 → 0.0.48

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