@navios/core 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -7,6 +7,152 @@ import * as http from 'http';
7
7
  import * as fastify_types_type_provider_js from 'fastify/types/type-provider.js';
8
8
  import { FastifyCorsOptions } from '@fastify/cors';
9
9
 
10
+ declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
11
+ declare function envString<DefaultValue extends string | undefined, Ensured = DefaultValue extends string ? true : false>(key: keyof NodeJS.ProcessEnv, defaultValue?: DefaultValue): Ensured extends true ? string : string | undefined;
12
+
13
+ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
14
+ /**
15
+ * @publicApi
16
+ */
17
+ type LogLevel = (typeof LOG_LEVELS)[number];
18
+
19
+ /**
20
+ * @publicApi
21
+ */
22
+ interface LoggerService {
23
+ /**
24
+ * Write a 'log' level log.
25
+ */
26
+ log(message: any, ...optionalParams: any[]): any;
27
+ /**
28
+ * Write an 'error' level log.
29
+ */
30
+ error(message: any, ...optionalParams: any[]): any;
31
+ /**
32
+ * Write a 'warn' level log.
33
+ */
34
+ warn(message: any, ...optionalParams: any[]): any;
35
+ /**
36
+ * Write a 'debug' level log.
37
+ */
38
+ debug?(message: any, ...optionalParams: any[]): any;
39
+ /**
40
+ * Write a 'verbose' level log.
41
+ */
42
+ verbose?(message: any, ...optionalParams: any[]): any;
43
+ /**
44
+ * Write a 'fatal' level log.
45
+ */
46
+ fatal?(message: any, ...optionalParams: any[]): any;
47
+ /**
48
+ * Set log levels.
49
+ * @param levels log levels
50
+ */
51
+ setLogLevels?(levels: LogLevel[]): any;
52
+ }
53
+
54
+ declare class LoggerInstance implements LoggerService {
55
+ protected context?: string | undefined;
56
+ protected options: {
57
+ timestamp?: boolean;
58
+ };
59
+ protected static staticInstanceRef?: LoggerService;
60
+ protected static logLevels?: LogLevel[];
61
+ protected localInstanceRef?: LoggerService;
62
+ constructor();
63
+ constructor(context: string);
64
+ constructor(context: string, options?: {
65
+ timestamp?: boolean;
66
+ });
67
+ get localInstance(): LoggerService;
68
+ /**
69
+ * Write an 'error' level log.
70
+ */
71
+ error(message: any, stack?: string, context?: string): void;
72
+ error(message: any, ...optionalParams: [...any, string?, string?]): void;
73
+ /**
74
+ * Write a 'log' level log.
75
+ */
76
+ log(message: any, context?: string): void;
77
+ log(message: any, ...optionalParams: [...any, string?]): void;
78
+ /**
79
+ * Write a 'warn' level log.
80
+ */
81
+ warn(message: any, context?: string): void;
82
+ warn(message: any, ...optionalParams: [...any, string?]): void;
83
+ /**
84
+ * Write a 'debug' level log.
85
+ */
86
+ debug(message: any, context?: string): void;
87
+ debug(message: any, ...optionalParams: [...any, string?]): void;
88
+ /**
89
+ * Write a 'verbose' level log.
90
+ */
91
+ verbose(message: any, context?: string): void;
92
+ verbose(message: any, ...optionalParams: [...any, string?]): void;
93
+ /**
94
+ * Write a 'fatal' level log.
95
+ */
96
+ fatal(message: any, context?: string): void;
97
+ fatal(message: any, ...optionalParams: [...any, string?]): void;
98
+ /**
99
+ * Write an 'error' level log.
100
+ */
101
+ static error(message: any, stackOrContext?: string): void;
102
+ static error(message: any, context?: string): void;
103
+ static error(message: any, stack?: string, context?: string): void;
104
+ static error(message: any, ...optionalParams: [...any, string?, string?]): void;
105
+ /**
106
+ * Write a 'log' level log.
107
+ */
108
+ static log(message: any, context?: string): void;
109
+ static log(message: any, ...optionalParams: [...any, string?]): void;
110
+ /**
111
+ * Write a 'warn' level log.
112
+ */
113
+ static warn(message: any, context?: string): void;
114
+ static warn(message: any, ...optionalParams: [...any, string?]): void;
115
+ /**
116
+ * Write a 'debug' level log, if the configured level allows for it.
117
+ * Prints to `stdout` with newline.
118
+ */
119
+ static debug(message: any, context?: string): void;
120
+ static debug(message: any, ...optionalParams: [...any, string?]): void;
121
+ /**
122
+ * Write a 'verbose' level log.
123
+ */
124
+ static verbose(message: any, context?: string): void;
125
+ static verbose(message: any, ...optionalParams: [...any, string?]): void;
126
+ /**
127
+ * Write a 'fatal' level log.
128
+ */
129
+ static fatal(message: any, context?: string): void;
130
+ static fatal(message: any, ...optionalParams: [...any, string?]): void;
131
+ static getTimestamp(): string;
132
+ static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
133
+ static isLevelEnabled(level: LogLevel): boolean;
134
+ private registerLocalInstanceRef;
135
+ }
136
+
137
+ /**
138
+ * Evaluates to `true` if `T` is `any`. `false` otherwise.
139
+ * (c) https://stackoverflow.com/a/68633327/5290447
140
+ */
141
+ type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
142
+ type ExcludedParts = 'services' | 'mailer' | 'aws' | 'computedTimeRates' | 'aiModelsRates';
143
+ type ExcludedKeys = 'computedTimeRates' | 'aiModelsRates' | 'aiModel';
144
+ type PathImpl<T, Key extends keyof T> = Key extends string ? Key extends ExcludedKeys ? never : IsAny<T[Key]> extends true ? never : T[Key] extends string ? never : T[Key] extends any[] ? never : T[Key] extends Record<string, any> ? Key extends ExcludedParts ? `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
145
+ type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
146
+ type Path<T> = keyof T extends string ? PathImpl2<T> extends infer P ? P extends string | keyof T ? P : keyof T : keyof T : never;
147
+ type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
148
+
149
+ interface ConfigService<Config = Record<string, unknown>> {
150
+ getConfig: () => Config;
151
+ get: <Key extends Path<Config>>(key: Key) => PathValue<Config, Key> | null;
152
+ getOrDefault: <Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>) => PathValue<Config, Key>;
153
+ getOrThrow: <Key extends Path<Config>>(key: Key, errorMessage?: string) => PathValue<Config, Key>;
154
+ }
155
+
10
156
  type ClassType = new (...args: any[]) => any;
11
157
  type ClassTypeWithInstance<T> = new (...args: any[]) => T;
12
158
  declare class InjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject> | unknown = unknown> {
@@ -237,145 +383,6 @@ declare function syncInject<T, S extends ZodOptional<AnyZodObject>>(token: Injec
237
383
  declare function syncInject<T>(token: InjectionToken<T, undefined>): T;
238
384
  declare function setPromiseCollector(collector: null | ((promise: Promise<any>) => void)): typeof promiseCollector;
239
385
 
240
- interface ControllerOptions {
241
- guards?: ClassType[] | Set<ClassType>;
242
- }
243
- declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
244
-
245
- type EndpointParams<EndpointDeclaration extends {
246
- config: BaseEndpointConfig<any, any, any, any, any>;
247
- }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends AnyZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, QuerySchema, undefined> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, undefined, undefined>;
248
- declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
249
- config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
250
- }): (target: (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>;
251
-
252
- interface ModuleOptions {
253
- controllers?: ClassType[] | Set<ClassType>;
254
- imports?: ClassType[] | Set<ClassType>;
255
- guards?: ClassType[] | Set<ClassType>;
256
- }
257
- declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
258
-
259
- declare const EndpointMetadataKey: unique symbol;
260
- interface EndpointMetadata {
261
- classMethod: string;
262
- url: string;
263
- httpMethod: HttpMethod;
264
- config: BaseEndpointConfig | null;
265
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
266
- customAttributes: Map<string | symbol, any>;
267
- }
268
- declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
269
- declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
270
-
271
- declare const ControllerMetadataKey: unique symbol;
272
- interface ControllerMetadata {
273
- endpoints: Set<EndpointMetadata>;
274
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
275
- customAttributes: Map<string | symbol, any>;
276
- }
277
- declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
278
- declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
279
- declare function hasControllerMetadata(target: ClassType): boolean;
280
-
281
- interface InjectableMetadata<Instance = any, Schema = any> {
282
- type: InjectableType;
283
- scope: InjectableScope;
284
- token: InjectionToken<Instance, Schema>;
285
- }
286
-
287
- declare const ModuleMetadataKey: unique symbol;
288
- interface ModuleMetadata {
289
- controllers: Set<ClassType>;
290
- imports: Set<ClassType>;
291
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
292
- customAttributes: Map<string | symbol, any>;
293
- }
294
- declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
295
- declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
296
- declare function hasModuleMetadata(target: ClassType): boolean;
297
-
298
- declare class ExecutionContext {
299
- private readonly module;
300
- private readonly controller;
301
- private readonly handler;
302
- private request;
303
- private reply;
304
- constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
305
- getModule(): ModuleMetadata;
306
- getController(): ControllerMetadata;
307
- getHandler(): EndpointMetadata;
308
- getRequest(): FastifyRequest;
309
- getReply(): FastifyReply;
310
- provideRequest(request: FastifyRequest): void;
311
- provideReply(reply: FastifyReply): void;
312
- }
313
-
314
- declare class GuardRunnerService {
315
- runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: ExecutionContext): Promise<boolean>;
316
- makeContext(executionContext: ExecutionContext): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
317
- }
318
-
319
- declare class ControllerAdapterService {
320
- guardRunner: GuardRunnerService;
321
- private logger;
322
- setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
323
- }
324
-
325
- declare class ModuleLoaderService {
326
- private logger;
327
- private modulesMetadata;
328
- private loadedModules;
329
- private initialized;
330
- loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
331
- private traverseModules;
332
- private mergeMetadata;
333
- getAllModules(): Map<string, ModuleMetadata>;
334
- }
335
-
336
- interface CanActivate {
337
- canActivate(executionContext: ExecutionContext): Promise<boolean> | boolean;
338
- }
339
-
340
- interface NaviosModule {
341
- onModuleInit?: () => Promise<void> | void;
342
- }
343
-
344
- declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
345
-
346
- declare class HttpException {
347
- readonly statusCode: number;
348
- readonly response: string | object;
349
- readonly error?: Error | undefined;
350
- constructor(statusCode: number, response: string | object, error?: Error | undefined);
351
- }
352
-
353
- declare class BadRequestException extends HttpException {
354
- constructor(message: string | object);
355
- }
356
-
357
- declare class ForbiddenException extends HttpException {
358
- constructor(message: string);
359
- }
360
-
361
- declare class InternalServerErrorException extends HttpException {
362
- constructor(message: string | object, error?: Error);
363
- }
364
-
365
- declare class NotFoundException extends HttpException {
366
- readonly response: string | object;
367
- readonly error?: Error | undefined;
368
- constructor(response: string | object, error?: Error | undefined);
369
- }
370
-
371
- declare class UnauthorizedException extends HttpException {
372
- constructor(message: string | object, error?: Error);
373
- }
374
-
375
- declare class ConflictException extends HttpException {
376
- constructor(message: string | object, error?: Error);
377
- }
378
-
379
386
  declare const clc: {
380
387
  bold: (text: string) => string;
381
388
  green: (text: string) => string;
@@ -386,77 +393,36 @@ declare const clc: {
386
393
  };
387
394
  declare const yellow: (text: string) => string;
388
395
 
389
- declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
390
- /**
391
- * @publicApi
392
- */
393
- type LogLevel = (typeof LOG_LEVELS)[number];
394
-
395
396
  /**
396
397
  * @publicApi
397
398
  */
398
399
  declare function filterLogLevels(parseableString?: string): LogLevel[];
399
400
 
400
401
  /**
401
- * @publicApi
402
- */
403
- declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
404
-
405
- /**
406
- * Checks if target level is enabled.
407
- * @param targetLevel target level
408
- * @param logLevels array of enabled log levels
409
- */
410
- declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
411
-
412
- declare const isUndefined: (obj: any) => obj is undefined;
413
- declare const isObject: (fn: any) => fn is object;
414
- declare const isPlainObject: (fn: any) => fn is object;
415
- declare const addLeadingSlash: (path?: string) => string;
416
- declare const normalizePath: (path?: string) => string;
417
- declare const stripEndSlash: (path: string) => string;
418
- declare const isFunction: (val: any) => val is Function;
419
- declare const isString: (val: any) => val is string;
420
- declare const isNumber: (val: any) => val is number;
421
- declare const isConstructor: (val: any) => boolean;
422
- declare const isNil: (val: any) => val is null | undefined;
423
- declare const isEmpty: (array: any) => boolean;
424
- declare const isSymbol: (val: any) => val is symbol;
425
-
426
- /**
427
- * @publicApi
428
- */
429
- interface LoggerService {
430
- /**
431
- * Write a 'log' level log.
432
- */
433
- log(message: any, ...optionalParams: any[]): any;
434
- /**
435
- * Write an 'error' level log.
436
- */
437
- error(message: any, ...optionalParams: any[]): any;
438
- /**
439
- * Write a 'warn' level log.
440
- */
441
- warn(message: any, ...optionalParams: any[]): any;
442
- /**
443
- * Write a 'debug' level log.
444
- */
445
- debug?(message: any, ...optionalParams: any[]): any;
446
- /**
447
- * Write a 'verbose' level log.
448
- */
449
- verbose?(message: any, ...optionalParams: any[]): any;
450
- /**
451
- * Write a 'fatal' level log.
452
- */
453
- fatal?(message: any, ...optionalParams: any[]): any;
454
- /**
455
- * Set log levels.
456
- * @param levels log levels
457
- */
458
- setLogLevels?(levels: LogLevel[]): any;
459
- }
402
+ * @publicApi
403
+ */
404
+ declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
405
+
406
+ /**
407
+ * Checks if target level is enabled.
408
+ * @param targetLevel target level
409
+ * @param logLevels array of enabled log levels
410
+ */
411
+ declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
412
+
413
+ declare const isUndefined: (obj: any) => obj is undefined;
414
+ declare const isObject: (fn: any) => fn is object;
415
+ declare const isPlainObject: (fn: any) => fn is object;
416
+ declare const addLeadingSlash: (path?: string) => string;
417
+ declare const normalizePath: (path?: string) => string;
418
+ declare const stripEndSlash: (path: string) => string;
419
+ declare const isFunction: (val: any) => val is Function;
420
+ declare const isString: (val: any) => val is string;
421
+ declare const isNumber: (val: any) => val is number;
422
+ declare const isConstructor: (val: any) => boolean;
423
+ declare const isNil: (val: any) => val is null | undefined;
424
+ declare const isEmpty: (array: any) => boolean;
425
+ declare const isSymbol: (val: any) => val is symbol;
460
426
 
461
427
  /**
462
428
  * @publicApi
@@ -640,89 +606,6 @@ declare class ConsoleLogger implements LoggerService {
640
606
  private getColorByLogLevel;
641
607
  }
642
608
 
643
- declare class LoggerInstance implements LoggerService {
644
- protected context?: string | undefined;
645
- protected options: {
646
- timestamp?: boolean;
647
- };
648
- protected static staticInstanceRef?: LoggerService;
649
- protected static logLevels?: LogLevel[];
650
- protected localInstanceRef?: LoggerService;
651
- constructor();
652
- constructor(context: string);
653
- constructor(context: string, options?: {
654
- timestamp?: boolean;
655
- });
656
- get localInstance(): LoggerService;
657
- /**
658
- * Write an 'error' level log.
659
- */
660
- error(message: any, stack?: string, context?: string): void;
661
- error(message: any, ...optionalParams: [...any, string?, string?]): void;
662
- /**
663
- * Write a 'log' level log.
664
- */
665
- log(message: any, context?: string): void;
666
- log(message: any, ...optionalParams: [...any, string?]): void;
667
- /**
668
- * Write a 'warn' level log.
669
- */
670
- warn(message: any, context?: string): void;
671
- warn(message: any, ...optionalParams: [...any, string?]): void;
672
- /**
673
- * Write a 'debug' level log.
674
- */
675
- debug(message: any, context?: string): void;
676
- debug(message: any, ...optionalParams: [...any, string?]): void;
677
- /**
678
- * Write a 'verbose' level log.
679
- */
680
- verbose(message: any, context?: string): void;
681
- verbose(message: any, ...optionalParams: [...any, string?]): void;
682
- /**
683
- * Write a 'fatal' level log.
684
- */
685
- fatal(message: any, context?: string): void;
686
- fatal(message: any, ...optionalParams: [...any, string?]): void;
687
- /**
688
- * Write an 'error' level log.
689
- */
690
- static error(message: any, stackOrContext?: string): void;
691
- static error(message: any, context?: string): void;
692
- static error(message: any, stack?: string, context?: string): void;
693
- static error(message: any, ...optionalParams: [...any, string?, string?]): void;
694
- /**
695
- * Write a 'log' level log.
696
- */
697
- static log(message: any, context?: string): void;
698
- static log(message: any, ...optionalParams: [...any, string?]): void;
699
- /**
700
- * Write a 'warn' level log.
701
- */
702
- static warn(message: any, context?: string): void;
703
- static warn(message: any, ...optionalParams: [...any, string?]): void;
704
- /**
705
- * Write a 'debug' level log, if the configured level allows for it.
706
- * Prints to `stdout` with newline.
707
- */
708
- static debug(message: any, context?: string): void;
709
- static debug(message: any, ...optionalParams: [...any, string?]): void;
710
- /**
711
- * Write a 'verbose' level log.
712
- */
713
- static verbose(message: any, context?: string): void;
714
- static verbose(message: any, ...optionalParams: [...any, string?]): void;
715
- /**
716
- * Write a 'fatal' level log.
717
- */
718
- static fatal(message: any, context?: string): void;
719
- static fatal(message: any, ...optionalParams: [...any, string?]): void;
720
- static getTimestamp(): string;
721
- static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
722
- static isLevelEnabled(level: LogLevel): boolean;
723
- private registerLocalInstanceRef;
724
- }
725
-
726
609
  declare const LoggerInjectionToken = "LoggerInjectionToken";
727
610
  declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
728
611
  context: z.ZodOptional<z.ZodString>;
@@ -782,6 +665,176 @@ declare class PinoWrapper {
782
665
  get level(): any;
783
666
  }
784
667
 
668
+ declare class ConfigServiceInstance<Config = Record<string, unknown>> implements ConfigService<Config> {
669
+ private config;
670
+ private logger;
671
+ constructor(config: Config | undefined, logger: LoggerService);
672
+ getConfig(): Config;
673
+ get<Key extends Path<Config>>(key: Key): PathValue<Config, Key> | null;
674
+ getOrDefault<Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>): PathValue<Config, Key>;
675
+ getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
676
+ }
677
+
678
+ declare const ConfigProviderInjectionToken = "ConfigProvider";
679
+ declare const ConfigProviderOptions: z.ZodObject<{
680
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
681
+ }, "strip", z.ZodTypeAny, {
682
+ load: (...args: unknown[]) => unknown;
683
+ }, {
684
+ load: (...args: unknown[]) => unknown;
685
+ }>;
686
+ declare const ConfigProvider: InjectionToken<ConfigService<Record<string, unknown>>, z.ZodObject<{
687
+ load: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
688
+ }, "strip", z.ZodTypeAny, {
689
+ load: (...args: unknown[]) => unknown;
690
+ }, {
691
+ load: (...args: unknown[]) => unknown;
692
+ }>>;
693
+ declare class ConfigProviderFactory {
694
+ logger: Promise<LoggerInstance>;
695
+ create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
696
+ }
697
+ declare function makeConfigToken<Config extends Record<string, unknown>>(options: z.input<typeof ConfigProviderOptions>): InjectionToken<ConfigService<Config>>;
698
+
699
+ interface ControllerOptions {
700
+ guards?: ClassType[] | Set<ClassType>;
701
+ }
702
+ declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
703
+
704
+ type EndpointParams<EndpointDeclaration extends {
705
+ config: BaseEndpointConfig<any, any, any, any, any>;
706
+ }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends AnyZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, QuerySchema, undefined> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema']> : EndpointFunctionArgs<Url, undefined, undefined>;
707
+ declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
708
+ config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
709
+ }): (target: (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends AnyZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => z.input<ResponseSchema>;
710
+
711
+ interface ModuleOptions {
712
+ controllers?: ClassType[] | Set<ClassType>;
713
+ imports?: ClassType[] | Set<ClassType>;
714
+ guards?: ClassType[] | Set<ClassType>;
715
+ }
716
+ declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
717
+
718
+ declare const EndpointMetadataKey: unique symbol;
719
+ interface EndpointMetadata {
720
+ classMethod: string;
721
+ url: string;
722
+ httpMethod: HttpMethod;
723
+ config: BaseEndpointConfig | null;
724
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
725
+ customAttributes: Map<string | symbol, any>;
726
+ }
727
+ declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
728
+ declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
729
+
730
+ declare const ControllerMetadataKey: unique symbol;
731
+ interface ControllerMetadata {
732
+ endpoints: Set<EndpointMetadata>;
733
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
734
+ customAttributes: Map<string | symbol, any>;
735
+ }
736
+ declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
737
+ declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
738
+ declare function hasControllerMetadata(target: ClassType): boolean;
739
+
740
+ interface InjectableMetadata<Instance = any, Schema = any> {
741
+ type: InjectableType;
742
+ scope: InjectableScope;
743
+ token: InjectionToken<Instance, Schema>;
744
+ }
745
+
746
+ declare const ModuleMetadataKey: unique symbol;
747
+ interface ModuleMetadata {
748
+ controllers: Set<ClassType>;
749
+ imports: Set<ClassType>;
750
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
751
+ customAttributes: Map<string | symbol, any>;
752
+ }
753
+ declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
754
+ declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
755
+ declare function hasModuleMetadata(target: ClassType): boolean;
756
+
757
+ declare class ExecutionContext {
758
+ private readonly module;
759
+ private readonly controller;
760
+ private readonly handler;
761
+ private request;
762
+ private reply;
763
+ constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
764
+ getModule(): ModuleMetadata;
765
+ getController(): ControllerMetadata;
766
+ getHandler(): EndpointMetadata;
767
+ getRequest(): FastifyRequest;
768
+ getReply(): FastifyReply;
769
+ provideRequest(request: FastifyRequest): void;
770
+ provideReply(reply: FastifyReply): void;
771
+ }
772
+
773
+ declare class GuardRunnerService {
774
+ runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: ExecutionContext): Promise<boolean>;
775
+ makeContext(executionContext: ExecutionContext): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
776
+ }
777
+
778
+ declare class ControllerAdapterService {
779
+ guardRunner: GuardRunnerService;
780
+ private logger;
781
+ setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
782
+ }
783
+
784
+ declare class ModuleLoaderService {
785
+ private logger;
786
+ private modulesMetadata;
787
+ private loadedModules;
788
+ private initialized;
789
+ loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
790
+ private traverseModules;
791
+ private mergeMetadata;
792
+ getAllModules(): Map<string, ModuleMetadata>;
793
+ }
794
+
795
+ interface CanActivate {
796
+ canActivate(executionContext: ExecutionContext): Promise<boolean> | boolean;
797
+ }
798
+
799
+ interface NaviosModule {
800
+ onModuleInit?: () => Promise<void> | void;
801
+ }
802
+
803
+ declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
804
+
805
+ declare class HttpException {
806
+ readonly statusCode: number;
807
+ readonly response: string | object;
808
+ readonly error?: Error | undefined;
809
+ constructor(statusCode: number, response: string | object, error?: Error | undefined);
810
+ }
811
+
812
+ declare class BadRequestException extends HttpException {
813
+ constructor(message: string | object);
814
+ }
815
+
816
+ declare class ForbiddenException extends HttpException {
817
+ constructor(message: string);
818
+ }
819
+
820
+ declare class InternalServerErrorException extends HttpException {
821
+ constructor(message: string | object, error?: Error);
822
+ }
823
+
824
+ declare class NotFoundException extends HttpException {
825
+ readonly response: string | object;
826
+ readonly error?: Error | undefined;
827
+ constructor(response: string | object, error?: Error | undefined);
828
+ }
829
+
830
+ declare class UnauthorizedException extends HttpException {
831
+ constructor(message: string | object, error?: Error);
832
+ }
833
+
834
+ declare class ConflictException extends HttpException {
835
+ constructor(message: string | object, error?: Error);
836
+ }
837
+
785
838
  declare const Application: InjectionToken<FastifyInstance<fastify.RawServerDefault, http.IncomingMessage, http.ServerResponse<http.IncomingMessage>, fastify.FastifyBaseLogger, fastify.FastifyTypeProviderDefault>, undefined>;
786
839
 
787
840
  declare const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
@@ -843,4 +896,4 @@ declare class NaviosFactory {
843
896
  private static registerLoggerConfiguration;
844
897
  }
845
898
 
846
- export { Application, AttributeFactory, BadRequestException, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConflictException, ConsoleLogger, type ConsoleLoggerOptions, Controller, ControllerAdapterService, type ControllerMetadata, ControllerMetadataKey, type ControllerOptions, Endpoint, type EndpointMetadata, EndpointMetadataKey, type EndpointParams, ErrorsEnum, EventEmitter, type EventEmitterInterface, type EventsArgs, type EventsConfig, type EventsNames, ExecutionContext, ExecutionContextInjectionToken, ExecutionContextToken, FactoryNotFound, ForbiddenException, GuardRunnerService, HttpException, Injectable, type InjectableMetadata, type InjectableOptions, InjectableScope, InjectableTokenMeta, InjectableType, InjectionToken, InstanceDestroying, InstanceExpired, InstanceNotFound, InternalServerErrorException, LOG_LEVELS, type LogLevel, Logger, LoggerFactory, LoggerInjectionToken, LoggerInstance, LoggerOptions, type LoggerService, Module, ModuleLoaderService, type ModuleMetadata, ModuleMetadataKey, type ModuleOptions, NaviosApplication, type NaviosApplicationContextOptions, type NaviosApplicationOptions, NaviosFactory, type NaviosModule, NotFoundException, PinoWrapper, Reply, Request, ServiceLocator, type ServiceLocatorAbstractFactoryContext, ServiceLocatorEventBus, type ServiceLocatorInstanceDestroyListener, type ServiceLocatorInstanceEffect, type ServiceLocatorInstanceHolder, type ServiceLocatorInstanceHolderCreated, type ServiceLocatorInstanceHolderCreating, type ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnauthorizedException, UnknownError, UseGuards, addLeadingSlash, clc, extractControllerMetadata, extractModuleMetadata, filterLogLevels, getAllEndpointMetadata, getControllerMetadata, getEndpointMetadata, getInjectableToken, getModuleMetadata, getServiceLocator, hasControllerMetadata, hasModuleMetadata, inject, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, normalizePath, override, provideServiceLocator, setPromiseCollector, stripEndSlash, syncInject, yellow };
899
+ export { Application, AttributeFactory, BadRequestException, type CanActivate, type ChannelEmitter, type ClassAttribute, type ClassSchemaAttribute, type ClassType, type ClassTypeWithInstance, ConfigProvider, ConfigProviderFactory, ConfigProviderInjectionToken, ConfigProviderOptions, type ConfigService, ConfigServiceInstance, ConflictException, ConsoleLogger, type ConsoleLoggerOptions, Controller, ControllerAdapterService, type ControllerMetadata, ControllerMetadataKey, type ControllerOptions, Endpoint, type EndpointMetadata, EndpointMetadataKey, type EndpointParams, ErrorsEnum, EventEmitter, type EventEmitterInterface, type EventsArgs, type EventsConfig, type EventsNames, ExecutionContext, ExecutionContextInjectionToken, ExecutionContextToken, FactoryNotFound, ForbiddenException, GuardRunnerService, HttpException, Injectable, type InjectableMetadata, type InjectableOptions, InjectableScope, InjectableTokenMeta, InjectableType, InjectionToken, InstanceDestroying, InstanceExpired, InstanceNotFound, InternalServerErrorException, LOG_LEVELS, type LogLevel, Logger, LoggerFactory, LoggerInjectionToken, LoggerInstance, LoggerOptions, type LoggerService, Module, ModuleLoaderService, type ModuleMetadata, ModuleMetadataKey, type ModuleOptions, NaviosApplication, type NaviosApplicationContextOptions, type NaviosApplicationOptions, NaviosFactory, type NaviosModule, NotFoundException, type Path, type PathImpl, type PathImpl2, type PathValue, PinoWrapper, Reply, Request, ServiceLocator, type ServiceLocatorAbstractFactoryContext, ServiceLocatorEventBus, type ServiceLocatorInstanceDestroyListener, type ServiceLocatorInstanceEffect, type ServiceLocatorInstanceHolder, type ServiceLocatorInstanceHolderCreated, type ServiceLocatorInstanceHolderCreating, type ServiceLocatorInstanceHolderDestroying, ServiceLocatorInstanceHolderKind, ServiceLocatorInstanceHolderStatus, ServiceLocatorManager, UnauthorizedException, UnknownError, UseGuards, addLeadingSlash, clc, envInt, envString, extractControllerMetadata, extractModuleMetadata, filterLogLevels, getAllEndpointMetadata, getControllerMetadata, getEndpointMetadata, getInjectableToken, getModuleMetadata, getServiceLocator, hasControllerMetadata, hasModuleMetadata, inject, isConstructor, isEmpty, isFunction, isLogLevel, isLogLevelEnabled, isNil, isNumber, isObject, isPlainObject, isString, isSymbol, isUndefined, makeConfigToken, normalizePath, override, provideServiceLocator, setPromiseCollector, stripEndSlash, syncInject, yellow };