@navios/core 0.1.13 → 0.1.15

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 (36) hide show
  1. package/dist/_tsup-dts-rollup.d.mts +133 -49
  2. package/dist/_tsup-dts-rollup.d.ts +133 -49
  3. package/dist/index.d.mts +8 -2
  4. package/dist/index.d.ts +8 -2
  5. package/dist/index.js +1184 -1090
  6. package/dist/index.mjs +1179 -1090
  7. package/package.json +1 -1
  8. package/src/adapters/endpoint-adapter.service.mts +75 -0
  9. package/src/adapters/handler-adapter.interface.mts +21 -0
  10. package/src/adapters/index.mts +4 -0
  11. package/src/adapters/multipart-adapter.service.mts +130 -0
  12. package/src/adapters/stream-adapter.service.mts +95 -0
  13. package/src/attribute.factory.mts +13 -13
  14. package/src/config/config.provider.mts +8 -2
  15. package/src/decorators/controller.decorator.mts +0 -2
  16. package/src/decorators/endpoint.decorator.mts +7 -3
  17. package/src/decorators/header.decorator.mts +1 -6
  18. package/src/decorators/http-code.decorator.mts +1 -6
  19. package/src/decorators/module.decorator.mts +13 -15
  20. package/src/decorators/multipart.decorator.mts +7 -3
  21. package/src/decorators/stream.decorator.mts +7 -3
  22. package/src/index.mts +1 -0
  23. package/src/logger/console-logger.service.mts +41 -3
  24. package/src/logger/logger.service.mts +0 -1
  25. package/src/metadata/controller.metadata.mts +3 -3
  26. package/src/metadata/{endpoint.metadata.mts → handler.metadata.mts} +17 -24
  27. package/src/metadata/index.mts +1 -1
  28. package/src/navios.application.mts +3 -4
  29. package/src/service-locator/__tests__/injection-token.spec.mts +10 -5
  30. package/src/service-locator/decorators/injectable.decorator.mts +53 -4
  31. package/src/service-locator/inject.mts +14 -0
  32. package/src/service-locator/interfaces/factory.interface.mts +9 -1
  33. package/src/service-locator/service-locator.mts +1 -0
  34. package/src/service-locator/sync-injector.mts +14 -0
  35. package/src/services/controller-adapter.service.mts +59 -240
  36. package/src/services/execution-context.mts +4 -3
@@ -41,14 +41,14 @@ export { Application as Application_alias_2 }
41
41
  declare class AttributeFactory {
42
42
  static createAttribute(token: symbol): ClassAttribute;
43
43
  static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
44
- static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): true | null;
45
- static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): z.output<T> | null;
46
- static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): Array<true> | null;
47
- static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): Array<z.output<T>> | null;
48
- static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | EndpointMetadata)[]): true | null;
49
- static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | EndpointMetadata)[]): z.output<T> | null;
50
- static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
51
- static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
44
+ static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
45
+ static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z.output<T> | null;
46
+ static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
47
+ static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z.output<T>> | null;
48
+ static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
49
+ static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z.output<T> | null;
50
+ static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
51
+ static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
52
52
  }
53
53
  export { AttributeFactory }
54
54
  export { AttributeFactory as AttributeFactory_alias_1 }
@@ -132,7 +132,7 @@ export { ConfigProvider as ConfigProvider_alias_2 }
132
132
 
133
133
  declare class ConfigProviderFactory {
134
134
  logger: LoggerInstance_2;
135
- create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
135
+ create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigService>;
136
136
  }
137
137
  export { ConfigProviderFactory }
138
138
  export { ConfigProviderFactory as ConfigProviderFactory_alias_1 }
@@ -191,6 +191,10 @@ declare class ConsoleLogger implements LoggerService {
191
191
  * The context of the logger (can be set manually or automatically inferred).
192
192
  */
193
193
  protected context?: string;
194
+ /**
195
+ * Request ID (if enabled).
196
+ */
197
+ protected requestId: string | null;
194
198
  /**
195
199
  * The original context of the logger (set in the constructor).
196
200
  */
@@ -270,6 +274,7 @@ declare class ConsoleLogger implements LoggerService {
270
274
  protected formatPid(pid: number): string;
271
275
  protected formatContext(context: string): string;
272
276
  protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
277
+ protected getRequestId(): string;
273
278
  protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
274
279
  protected colorize(message: string, logLevel: LogLevel): string;
275
280
  protected printStackTrace(stack: string): void;
@@ -304,6 +309,10 @@ declare interface ConsoleLoggerOptions {
304
309
  * Note: This option is not used when `json` is enabled.
305
310
  */
306
311
  prefix?: string;
312
+ /**
313
+ * If enabled, will add a request ID to the log message.
314
+ */
315
+ requestId?: boolean;
307
316
  /**
308
317
  * If enabled, will print the log message in JSON format.
309
318
  */
@@ -368,7 +377,7 @@ export { ConsoleLoggerOptions }
368
377
  export { ConsoleLoggerOptions as ConsoleLoggerOptions_alias_1 }
369
378
  export { ConsoleLoggerOptions as ConsoleLoggerOptions_alias_2 }
370
379
 
371
- declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
380
+ declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => any;
372
381
  export { Controller }
373
382
  export { Controller as Controller_alias_1 }
374
383
  export { Controller as Controller_alias_2 }
@@ -376,20 +385,16 @@ export { Controller as Controller_alias_2 }
376
385
  declare class ControllerAdapterService {
377
386
  guardRunner: GuardRunnerService;
378
387
  private logger;
379
- setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
380
- providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<undefined>) | undefined;
381
- private provideSchemaForConfig;
382
- private provideHandler;
383
- private provideHandlerForConfig;
384
- private provideHandlerForStream;
385
- private provideHandlerForMultipart;
388
+ setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): Promise<void>;
389
+ providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<void>) | undefined;
390
+ private wrapHandler;
386
391
  }
387
392
  export { ControllerAdapterService }
388
393
  export { ControllerAdapterService as ControllerAdapterService_alias_1 }
389
394
  export { ControllerAdapterService as ControllerAdapterService_alias_2 }
390
395
 
391
396
  declare interface ControllerMetadata {
392
- endpoints: Set<EndpointMetadata>;
397
+ endpoints: Set<HandlerMetadata>;
393
398
  guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
394
399
  customAttributes: Map<string | symbol, any>;
395
400
  }
@@ -416,20 +421,19 @@ export { Endpoint }
416
421
  export { Endpoint as Endpoint_alias_1 }
417
422
  export { Endpoint as Endpoint_alias_2 }
418
423
 
419
- declare interface EndpointMetadata {
420
- classMethod: string;
421
- url: string;
422
- successStatusCode: number;
423
- type: EndpointType;
424
- headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
425
- httpMethod: HttpMethod;
426
- config: BaseEndpointConfig | BaseStreamConfig | null;
427
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
428
- customAttributes: Map<string | symbol, any>;
424
+ declare class EndpointAdapterService extends StreamAdapterService {
425
+ hasSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): boolean;
426
+ provideSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): Record<string, any>;
427
+ provideHandler(controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<BaseEndpointConfig>): (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
429
428
  }
430
- export { EndpointMetadata }
431
- export { EndpointMetadata as EndpointMetadata_alias_1 }
432
- export { EndpointMetadata as EndpointMetadata_alias_2 }
429
+ export { EndpointAdapterService }
430
+ export { EndpointAdapterService as EndpointAdapterService_alias_1 }
431
+ export { EndpointAdapterService as EndpointAdapterService_alias_2 }
432
+
433
+ declare const EndpointAdapterToken: InjectionToken<EndpointAdapterService, undefined>;
434
+ export { EndpointAdapterToken }
435
+ export { EndpointAdapterToken as EndpointAdapterToken_alias_1 }
436
+ export { EndpointAdapterToken as EndpointAdapterToken_alias_2 }
433
437
 
434
438
  declare const EndpointMetadataKey: unique symbol;
435
439
  export { EndpointMetadataKey }
@@ -450,17 +454,6 @@ export { EndpointResult }
450
454
  export { EndpointResult as EndpointResult_alias_1 }
451
455
  export { EndpointResult as EndpointResult_alias_2 }
452
456
 
453
- declare enum EndpointType {
454
- Unknown = "unknown",
455
- Endpoint = "endpoint",
456
- Stream = "stream",
457
- Multipart = "multipart",
458
- Handler = "handler"
459
- }
460
- export { EndpointType }
461
- export { EndpointType as EndpointType_alias_1 }
462
- export { EndpointType as EndpointType_alias_2 }
463
-
464
457
  declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
465
458
  export { envInt }
466
459
  export { envInt as envInt_alias_1 }
@@ -534,10 +527,10 @@ declare class ExecutionContext {
534
527
  private readonly handler;
535
528
  private request;
536
529
  private reply;
537
- constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
530
+ constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: HandlerMetadata);
538
531
  getModule(): ModuleMetadata;
539
532
  getController(): ControllerMetadata;
540
- getHandler(): EndpointMetadata;
533
+ getHandler(): HandlerMetadata;
541
534
  getRequest(): FastifyRequest;
542
535
  getReply(): FastifyReply;
543
536
  provideRequest(request: FastifyRequest): void;
@@ -568,7 +561,7 @@ export { extractModuleMetadata as extractModuleMetadata_alias_1 }
568
561
  export { extractModuleMetadata as extractModuleMetadata_alias_2 }
569
562
 
570
563
  export declare interface Factory<T> {
571
- create(ctx: any): Promise<T>;
564
+ create(ctx?: any): Promise<T> | T;
572
565
  }
573
566
 
574
567
  declare class FactoryInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, S> {
@@ -602,6 +595,10 @@ export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_1 }
602
595
  export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_2 }
603
596
  export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_3 }
604
597
 
598
+ export declare interface FactoryWithArgs<T, A extends AnyZodObject> {
599
+ create(ctx: any, args: z.output<A>): Promise<T> | T;
600
+ }
601
+
605
602
  /**
606
603
  * @publicApi
607
604
  */
@@ -618,7 +615,7 @@ export { ForbiddenException }
618
615
  export { ForbiddenException as ForbiddenException_alias_1 }
619
616
  export { ForbiddenException as ForbiddenException_alias_2 }
620
617
 
621
- declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
618
+ declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<HandlerMetadata<any>>;
622
619
  export { getAllEndpointMetadata }
623
620
  export { getAllEndpointMetadata as getAllEndpointMetadata_alias_1 }
624
621
  export { getAllEndpointMetadata as getAllEndpointMetadata_alias_2 }
@@ -628,7 +625,7 @@ export { getControllerMetadata }
628
625
  export { getControllerMetadata as getControllerMetadata_alias_1 }
629
626
  export { getControllerMetadata as getControllerMetadata_alias_2 }
630
627
 
631
- declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
628
+ declare function getEndpointMetadata<Config = any>(target: Function, context: ClassMethodDecoratorContext): HandlerMetadata<Config>;
632
629
  export { getEndpointMetadata }
633
630
  export { getEndpointMetadata as getEndpointMetadata_alias_1 }
634
631
  export { getEndpointMetadata as getEndpointMetadata_alias_2 }
@@ -659,6 +656,31 @@ export { GuardRunnerService }
659
656
  export { GuardRunnerService as GuardRunnerService_alias_1 }
660
657
  export { GuardRunnerService as GuardRunnerService_alias_2 }
661
658
 
659
+ declare interface HandlerAdapterInterface {
660
+ provideSchema?: (handlerMetadata: HandlerMetadata<any>) => Record<string, any>;
661
+ hasSchema?: (handlerMetadata: HandlerMetadata<any>) => boolean;
662
+ prepareArguments?: (handlerMetadata: HandlerMetadata<any>) => ((target: Record<string, any>, request: FastifyRequest) => Promise<void> | void)[];
663
+ provideHandler: (controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<any>) => (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
664
+ }
665
+ export { HandlerAdapterInterface }
666
+ export { HandlerAdapterInterface as HandlerAdapterInterface_alias_1 }
667
+ export { HandlerAdapterInterface as HandlerAdapterInterface_alias_2 }
668
+
669
+ declare interface HandlerMetadata<Config = null> {
670
+ classMethod: string;
671
+ url: string;
672
+ successStatusCode: number;
673
+ adapterToken: InjectionToken<HandlerAdapterInterface, undefined> | ClassTypeWithInstance<HandlerAdapterInterface> | null;
674
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
675
+ httpMethod: HttpMethod;
676
+ config: Config;
677
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
678
+ customAttributes: Map<string | symbol, any>;
679
+ }
680
+ export { HandlerMetadata }
681
+ export { HandlerMetadata as HandlerMetadata_alias_1 }
682
+ export { HandlerMetadata as HandlerMetadata_alias_2 }
683
+
662
684
  declare function hasControllerMetadata(target: ClassType): boolean;
663
685
  export { hasControllerMetadata }
664
686
  export { hasControllerMetadata as hasControllerMetadata_alias_1 }
@@ -700,7 +722,39 @@ export { inject }
700
722
  export { inject as inject_alias_1 }
701
723
  export { inject as inject_alias_2 }
702
724
 
703
- declare function Injectable({ scope, type, token, }?: InjectableOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
725
+ declare function Injectable(): <T extends ClassType>(target: T, context: ClassDecoratorContext) => T & {
726
+ [InjectableTokenMeta]: InjectionToken<InstanceType<T>, undefined>;
727
+ };
728
+
729
+ declare function Injectable<T extends ClassType>(options: {
730
+ scope?: InjectableScope;
731
+ token: InjectionToken<T, undefined>;
732
+ }): (target: T, context: ClassDecoratorContext) => T & {
733
+ [InjectableTokenMeta]: InjectionToken<InstanceType<T>, undefined>;
734
+ };
735
+
736
+ declare function Injectable<R>(options: {
737
+ scope?: InjectableScope;
738
+ type: InjectableType.Factory;
739
+ }): <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T & {
740
+ [InjectableTokenMeta]: InjectionToken<R, undefined>;
741
+ };
742
+
743
+ declare function Injectable<R, S extends AnyZodObject>(options: {
744
+ scope?: InjectableScope;
745
+ type: InjectableType.Factory;
746
+ token: InjectionToken<R, S>;
747
+ }): <T extends ClassTypeWithInstance<FactoryWithArgs<R, S>>>(target: T, context: ClassDecoratorContext) => T & {
748
+ [InjectableTokenMeta]: InjectionToken<R, S>;
749
+ };
750
+
751
+ declare function Injectable<R>(options: {
752
+ scope?: InjectableScope;
753
+ type: InjectableType.Factory;
754
+ token: InjectionToken<R, undefined>;
755
+ }): <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T & {
756
+ [InjectableTokenMeta]: InjectionToken<R, undefined>;
757
+ };
704
758
  export { Injectable }
705
759
  export { Injectable as Injectable_alias_1 }
706
760
  export { Injectable as Injectable_alias_2 }
@@ -1094,7 +1148,7 @@ export { LogLevel as LogLevel_alias_2 }
1094
1148
 
1095
1149
  export declare function makeProxyServiceLocator(serviceLocator: ServiceLocator, ctx: ServiceLocatorAbstractFactoryContext): ServiceLocator;
1096
1150
 
1097
- declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
1151
+ declare function Module({ controllers, imports, guards }?: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => any;
1098
1152
  export { Module }
1099
1153
  export { Module as Module_alias_1 }
1100
1154
  export { Module as Module_alias_2 }
@@ -1145,6 +1199,21 @@ export { Multipart }
1145
1199
  export { Multipart as Multipart_alias_1 }
1146
1200
  export { Multipart as Multipart_alias_2 }
1147
1201
 
1202
+ declare class MultipartAdapterService extends EndpointAdapterService {
1203
+ prepareArguments(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): ((target: Record<string, any>, request: FastifyRequest) => void)[];
1204
+ private populateRequest;
1205
+ private analyzeSchema;
1206
+ provideSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): Record<string, any>;
1207
+ }
1208
+ export { MultipartAdapterService }
1209
+ export { MultipartAdapterService as MultipartAdapterService_alias_1 }
1210
+ export { MultipartAdapterService as MultipartAdapterService_alias_2 }
1211
+
1212
+ declare const MultipartAdapterToken: InjectionToken<MultipartAdapterService, undefined>;
1213
+ export { MultipartAdapterToken }
1214
+ export { MultipartAdapterToken as MultipartAdapterToken_alias_1 }
1215
+ export { MultipartAdapterToken as MultipartAdapterToken_alias_2 }
1216
+
1148
1217
  declare type MultipartParams<EndpointDeclaration extends {
1149
1218
  config: BaseEndpointConfig<any, any, any, any, any>;
1150
1219
  }, 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>;
@@ -1482,6 +1551,21 @@ export { Stream }
1482
1551
  export { Stream as Stream_alias_1 }
1483
1552
  export { Stream as Stream_alias_2 }
1484
1553
 
1554
+ declare class StreamAdapterService implements HandlerAdapterInterface {
1555
+ hasSchema(handlerMetadata: HandlerMetadata<BaseStreamConfig>): boolean;
1556
+ prepareArguments(handlerMetadata: HandlerMetadata<BaseStreamConfig>): ((target: Record<string, any>, request: FastifyRequest) => void | Promise<void>)[];
1557
+ provideHandler(controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<BaseStreamConfig>): (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
1558
+ provideSchema(handlerMetadata: HandlerMetadata<BaseStreamConfig>): Record<string, any>;
1559
+ }
1560
+ export { StreamAdapterService }
1561
+ export { StreamAdapterService as StreamAdapterService_alias_1 }
1562
+ export { StreamAdapterService as StreamAdapterService_alias_2 }
1563
+
1564
+ declare const StreamAdapterToken: InjectionToken<StreamAdapterService, undefined>;
1565
+ export { StreamAdapterToken }
1566
+ export { StreamAdapterToken as StreamAdapterToken_alias_1 }
1567
+ export { StreamAdapterToken as StreamAdapterToken_alias_2 }
1568
+
1485
1569
  declare type StreamParams<EndpointDeclaration extends {
1486
1570
  config: BaseStreamConfig<any, any, any, any>;
1487
1571
  }, 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>;
@@ -41,14 +41,14 @@ export { Application as Application_alias_2 }
41
41
  declare class AttributeFactory {
42
42
  static createAttribute(token: symbol): ClassAttribute;
43
43
  static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
44
- static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): true | null;
45
- static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): z.output<T> | null;
46
- static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): Array<true> | null;
47
- static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): Array<z.output<T>> | null;
48
- static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | EndpointMetadata)[]): true | null;
49
- static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | EndpointMetadata)[]): z.output<T> | null;
50
- static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
51
- static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | EndpointMetadata): boolean;
44
+ static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
45
+ static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z.output<T> | null;
46
+ static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
47
+ static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z.output<T>> | null;
48
+ static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
49
+ static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z.output<T> | null;
50
+ static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
51
+ static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
52
52
  }
53
53
  export { AttributeFactory }
54
54
  export { AttributeFactory as AttributeFactory_alias_1 }
@@ -132,7 +132,7 @@ export { ConfigProvider as ConfigProvider_alias_2 }
132
132
 
133
133
  declare class ConfigProviderFactory {
134
134
  logger: LoggerInstance_2;
135
- create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigServiceInstance<unknown>>;
135
+ create(ctx: any, args: z.infer<typeof ConfigProviderOptions>): Promise<ConfigService>;
136
136
  }
137
137
  export { ConfigProviderFactory }
138
138
  export { ConfigProviderFactory as ConfigProviderFactory_alias_1 }
@@ -191,6 +191,10 @@ declare class ConsoleLogger implements LoggerService {
191
191
  * The context of the logger (can be set manually or automatically inferred).
192
192
  */
193
193
  protected context?: string;
194
+ /**
195
+ * Request ID (if enabled).
196
+ */
197
+ protected requestId: string | null;
194
198
  /**
195
199
  * The original context of the logger (set in the constructor).
196
200
  */
@@ -270,6 +274,7 @@ declare class ConsoleLogger implements LoggerService {
270
274
  protected formatPid(pid: number): string;
271
275
  protected formatContext(context: string): string;
272
276
  protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
277
+ protected getRequestId(): string;
273
278
  protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
274
279
  protected colorize(message: string, logLevel: LogLevel): string;
275
280
  protected printStackTrace(stack: string): void;
@@ -304,6 +309,10 @@ declare interface ConsoleLoggerOptions {
304
309
  * Note: This option is not used when `json` is enabled.
305
310
  */
306
311
  prefix?: string;
312
+ /**
313
+ * If enabled, will add a request ID to the log message.
314
+ */
315
+ requestId?: boolean;
307
316
  /**
308
317
  * If enabled, will print the log message in JSON format.
309
318
  */
@@ -368,7 +377,7 @@ export { ConsoleLoggerOptions }
368
377
  export { ConsoleLoggerOptions as ConsoleLoggerOptions_alias_1 }
369
378
  export { ConsoleLoggerOptions as ConsoleLoggerOptions_alias_2 }
370
379
 
371
- declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
380
+ declare function Controller({ guards }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => any;
372
381
  export { Controller }
373
382
  export { Controller as Controller_alias_1 }
374
383
  export { Controller as Controller_alias_2 }
@@ -376,20 +385,16 @@ export { Controller as Controller_alias_2 }
376
385
  declare class ControllerAdapterService {
377
386
  guardRunner: GuardRunnerService;
378
387
  private logger;
379
- setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): void;
380
- providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<undefined>) | undefined;
381
- private provideSchemaForConfig;
382
- private provideHandler;
383
- private provideHandlerForConfig;
384
- private provideHandlerForStream;
385
- private provideHandlerForMultipart;
388
+ setupController(controller: ClassType, instance: FastifyInstance, moduleMetadata: ModuleMetadata): Promise<void>;
389
+ providePreHandler(executionContext: ExecutionContext): ((request: FastifyRequest, reply: FastifyReply) => Promise<void>) | undefined;
390
+ private wrapHandler;
386
391
  }
387
392
  export { ControllerAdapterService }
388
393
  export { ControllerAdapterService as ControllerAdapterService_alias_1 }
389
394
  export { ControllerAdapterService as ControllerAdapterService_alias_2 }
390
395
 
391
396
  declare interface ControllerMetadata {
392
- endpoints: Set<EndpointMetadata>;
397
+ endpoints: Set<HandlerMetadata>;
393
398
  guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
394
399
  customAttributes: Map<string | symbol, any>;
395
400
  }
@@ -416,20 +421,19 @@ export { Endpoint }
416
421
  export { Endpoint as Endpoint_alias_1 }
417
422
  export { Endpoint as Endpoint_alias_2 }
418
423
 
419
- declare interface EndpointMetadata {
420
- classMethod: string;
421
- url: string;
422
- successStatusCode: number;
423
- type: EndpointType;
424
- headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
425
- httpMethod: HttpMethod;
426
- config: BaseEndpointConfig | BaseStreamConfig | null;
427
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
428
- customAttributes: Map<string | symbol, any>;
424
+ declare class EndpointAdapterService extends StreamAdapterService {
425
+ hasSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): boolean;
426
+ provideSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): Record<string, any>;
427
+ provideHandler(controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<BaseEndpointConfig>): (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
429
428
  }
430
- export { EndpointMetadata }
431
- export { EndpointMetadata as EndpointMetadata_alias_1 }
432
- export { EndpointMetadata as EndpointMetadata_alias_2 }
429
+ export { EndpointAdapterService }
430
+ export { EndpointAdapterService as EndpointAdapterService_alias_1 }
431
+ export { EndpointAdapterService as EndpointAdapterService_alias_2 }
432
+
433
+ declare const EndpointAdapterToken: InjectionToken<EndpointAdapterService, undefined>;
434
+ export { EndpointAdapterToken }
435
+ export { EndpointAdapterToken as EndpointAdapterToken_alias_1 }
436
+ export { EndpointAdapterToken as EndpointAdapterToken_alias_2 }
433
437
 
434
438
  declare const EndpointMetadataKey: unique symbol;
435
439
  export { EndpointMetadataKey }
@@ -450,17 +454,6 @@ export { EndpointResult }
450
454
  export { EndpointResult as EndpointResult_alias_1 }
451
455
  export { EndpointResult as EndpointResult_alias_2 }
452
456
 
453
- declare enum EndpointType {
454
- Unknown = "unknown",
455
- Endpoint = "endpoint",
456
- Stream = "stream",
457
- Multipart = "multipart",
458
- Handler = "handler"
459
- }
460
- export { EndpointType }
461
- export { EndpointType as EndpointType_alias_1 }
462
- export { EndpointType as EndpointType_alias_2 }
463
-
464
457
  declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
465
458
  export { envInt }
466
459
  export { envInt as envInt_alias_1 }
@@ -534,10 +527,10 @@ declare class ExecutionContext {
534
527
  private readonly handler;
535
528
  private request;
536
529
  private reply;
537
- constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: EndpointMetadata);
530
+ constructor(module: ModuleMetadata, controller: ControllerMetadata, handler: HandlerMetadata);
538
531
  getModule(): ModuleMetadata;
539
532
  getController(): ControllerMetadata;
540
- getHandler(): EndpointMetadata;
533
+ getHandler(): HandlerMetadata;
541
534
  getRequest(): FastifyRequest;
542
535
  getReply(): FastifyReply;
543
536
  provideRequest(request: FastifyRequest): void;
@@ -568,7 +561,7 @@ export { extractModuleMetadata as extractModuleMetadata_alias_1 }
568
561
  export { extractModuleMetadata as extractModuleMetadata_alias_2 }
569
562
 
570
563
  export declare interface Factory<T> {
571
- create(ctx: any): Promise<T>;
564
+ create(ctx?: any): Promise<T> | T;
572
565
  }
573
566
 
574
567
  declare class FactoryInjectionToken<T, S extends AnyZodObject | ZodOptional<AnyZodObject>> extends InjectionToken<T, S> {
@@ -602,6 +595,10 @@ export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_1 }
602
595
  export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_2 }
603
596
  export { FactoryTokenNotResolved as FactoryTokenNotResolved_alias_3 }
604
597
 
598
+ export declare interface FactoryWithArgs<T, A extends AnyZodObject> {
599
+ create(ctx: any, args: z.output<A>): Promise<T> | T;
600
+ }
601
+
605
602
  /**
606
603
  * @publicApi
607
604
  */
@@ -618,7 +615,7 @@ export { ForbiddenException }
618
615
  export { ForbiddenException as ForbiddenException_alias_1 }
619
616
  export { ForbiddenException as ForbiddenException_alias_2 }
620
617
 
621
- declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<EndpointMetadata>;
618
+ declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<HandlerMetadata<any>>;
622
619
  export { getAllEndpointMetadata }
623
620
  export { getAllEndpointMetadata as getAllEndpointMetadata_alias_1 }
624
621
  export { getAllEndpointMetadata as getAllEndpointMetadata_alias_2 }
@@ -628,7 +625,7 @@ export { getControllerMetadata }
628
625
  export { getControllerMetadata as getControllerMetadata_alias_1 }
629
626
  export { getControllerMetadata as getControllerMetadata_alias_2 }
630
627
 
631
- declare function getEndpointMetadata(target: Function, context: ClassMethodDecoratorContext): EndpointMetadata;
628
+ declare function getEndpointMetadata<Config = any>(target: Function, context: ClassMethodDecoratorContext): HandlerMetadata<Config>;
632
629
  export { getEndpointMetadata }
633
630
  export { getEndpointMetadata as getEndpointMetadata_alias_1 }
634
631
  export { getEndpointMetadata as getEndpointMetadata_alias_2 }
@@ -659,6 +656,31 @@ export { GuardRunnerService }
659
656
  export { GuardRunnerService as GuardRunnerService_alias_1 }
660
657
  export { GuardRunnerService as GuardRunnerService_alias_2 }
661
658
 
659
+ declare interface HandlerAdapterInterface {
660
+ provideSchema?: (handlerMetadata: HandlerMetadata<any>) => Record<string, any>;
661
+ hasSchema?: (handlerMetadata: HandlerMetadata<any>) => boolean;
662
+ prepareArguments?: (handlerMetadata: HandlerMetadata<any>) => ((target: Record<string, any>, request: FastifyRequest) => Promise<void> | void)[];
663
+ provideHandler: (controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<any>) => (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
664
+ }
665
+ export { HandlerAdapterInterface }
666
+ export { HandlerAdapterInterface as HandlerAdapterInterface_alias_1 }
667
+ export { HandlerAdapterInterface as HandlerAdapterInterface_alias_2 }
668
+
669
+ declare interface HandlerMetadata<Config = null> {
670
+ classMethod: string;
671
+ url: string;
672
+ successStatusCode: number;
673
+ adapterToken: InjectionToken<HandlerAdapterInterface, undefined> | ClassTypeWithInstance<HandlerAdapterInterface> | null;
674
+ headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
675
+ httpMethod: HttpMethod;
676
+ config: Config;
677
+ guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
678
+ customAttributes: Map<string | symbol, any>;
679
+ }
680
+ export { HandlerMetadata }
681
+ export { HandlerMetadata as HandlerMetadata_alias_1 }
682
+ export { HandlerMetadata as HandlerMetadata_alias_2 }
683
+
662
684
  declare function hasControllerMetadata(target: ClassType): boolean;
663
685
  export { hasControllerMetadata }
664
686
  export { hasControllerMetadata as hasControllerMetadata_alias_1 }
@@ -700,7 +722,39 @@ export { inject }
700
722
  export { inject as inject_alias_1 }
701
723
  export { inject as inject_alias_2 }
702
724
 
703
- declare function Injectable({ scope, type, token, }?: InjectableOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
725
+ declare function Injectable(): <T extends ClassType>(target: T, context: ClassDecoratorContext) => T & {
726
+ [InjectableTokenMeta]: InjectionToken<InstanceType<T>, undefined>;
727
+ };
728
+
729
+ declare function Injectable<T extends ClassType>(options: {
730
+ scope?: InjectableScope;
731
+ token: InjectionToken<T, undefined>;
732
+ }): (target: T, context: ClassDecoratorContext) => T & {
733
+ [InjectableTokenMeta]: InjectionToken<InstanceType<T>, undefined>;
734
+ };
735
+
736
+ declare function Injectable<R>(options: {
737
+ scope?: InjectableScope;
738
+ type: InjectableType.Factory;
739
+ }): <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T & {
740
+ [InjectableTokenMeta]: InjectionToken<R, undefined>;
741
+ };
742
+
743
+ declare function Injectable<R, S extends AnyZodObject>(options: {
744
+ scope?: InjectableScope;
745
+ type: InjectableType.Factory;
746
+ token: InjectionToken<R, S>;
747
+ }): <T extends ClassTypeWithInstance<FactoryWithArgs<R, S>>>(target: T, context: ClassDecoratorContext) => T & {
748
+ [InjectableTokenMeta]: InjectionToken<R, S>;
749
+ };
750
+
751
+ declare function Injectable<R>(options: {
752
+ scope?: InjectableScope;
753
+ type: InjectableType.Factory;
754
+ token: InjectionToken<R, undefined>;
755
+ }): <T extends ClassTypeWithInstance<Factory<R>>>(target: T, context: ClassDecoratorContext) => T & {
756
+ [InjectableTokenMeta]: InjectionToken<R, undefined>;
757
+ };
704
758
  export { Injectable }
705
759
  export { Injectable as Injectable_alias_1 }
706
760
  export { Injectable as Injectable_alias_2 }
@@ -1094,7 +1148,7 @@ export { LogLevel as LogLevel_alias_2 }
1094
1148
 
1095
1149
  export declare function makeProxyServiceLocator(serviceLocator: ServiceLocator, ctx: ServiceLocatorAbstractFactoryContext): ServiceLocator;
1096
1150
 
1097
- declare function Module(metadata: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
1151
+ declare function Module({ controllers, imports, guards }?: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => any;
1098
1152
  export { Module }
1099
1153
  export { Module as Module_alias_1 }
1100
1154
  export { Module as Module_alias_2 }
@@ -1145,6 +1199,21 @@ export { Multipart }
1145
1199
  export { Multipart as Multipart_alias_1 }
1146
1200
  export { Multipart as Multipart_alias_2 }
1147
1201
 
1202
+ declare class MultipartAdapterService extends EndpointAdapterService {
1203
+ prepareArguments(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): ((target: Record<string, any>, request: FastifyRequest) => void)[];
1204
+ private populateRequest;
1205
+ private analyzeSchema;
1206
+ provideSchema(handlerMetadata: HandlerMetadata<BaseEndpointConfig>): Record<string, any>;
1207
+ }
1208
+ export { MultipartAdapterService }
1209
+ export { MultipartAdapterService as MultipartAdapterService_alias_1 }
1210
+ export { MultipartAdapterService as MultipartAdapterService_alias_2 }
1211
+
1212
+ declare const MultipartAdapterToken: InjectionToken<MultipartAdapterService, undefined>;
1213
+ export { MultipartAdapterToken }
1214
+ export { MultipartAdapterToken as MultipartAdapterToken_alias_1 }
1215
+ export { MultipartAdapterToken as MultipartAdapterToken_alias_2 }
1216
+
1148
1217
  declare type MultipartParams<EndpointDeclaration extends {
1149
1218
  config: BaseEndpointConfig<any, any, any, any, any>;
1150
1219
  }, 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>;
@@ -1482,6 +1551,21 @@ export { Stream }
1482
1551
  export { Stream as Stream_alias_1 }
1483
1552
  export { Stream as Stream_alias_2 }
1484
1553
 
1554
+ declare class StreamAdapterService implements HandlerAdapterInterface {
1555
+ hasSchema(handlerMetadata: HandlerMetadata<BaseStreamConfig>): boolean;
1556
+ prepareArguments(handlerMetadata: HandlerMetadata<BaseStreamConfig>): ((target: Record<string, any>, request: FastifyRequest) => void | Promise<void>)[];
1557
+ provideHandler(controller: ClassType, executionContext: ExecutionContext, handlerMetadata: HandlerMetadata<BaseStreamConfig>): (request: FastifyRequest, reply: FastifyReply) => Promise<any>;
1558
+ provideSchema(handlerMetadata: HandlerMetadata<BaseStreamConfig>): Record<string, any>;
1559
+ }
1560
+ export { StreamAdapterService }
1561
+ export { StreamAdapterService as StreamAdapterService_alias_1 }
1562
+ export { StreamAdapterService as StreamAdapterService_alias_2 }
1563
+
1564
+ declare const StreamAdapterToken: InjectionToken<StreamAdapterService, undefined>;
1565
+ export { StreamAdapterToken }
1566
+ export { StreamAdapterToken as StreamAdapterToken_alias_1 }
1567
+ export { StreamAdapterToken as StreamAdapterToken_alias_2 }
1568
+
1485
1569
  declare type StreamParams<EndpointDeclaration extends {
1486
1570
  config: BaseStreamConfig<any, any, any, any>;
1487
1571
  }, 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>;