@xeno-js/core 1.1.1 → 1.2.0

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.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ExtendedRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
1
+ import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, ExtendedRequest, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
2
2
  export * from '@xeno-js/shared';
3
3
  export { Query as BaseQuery } from '@xeno-js/shared';
4
4
  import { SupabaseClientOptions } from '@supabase/supabase-js';
@@ -135,6 +135,14 @@ interface ApplicationRegistry<T = unknown, Ttx = unknown> {
135
135
  * @link https://github.com/xeno-js/xeno-js
136
136
  */
137
137
  readonly DB_CONTEXT: T;
138
+ /** @description Token used to register and resolve the HTTP Adapter instance in the dependency injection container.
139
+ *
140
+ * @author Xeno
141
+ * @version 1.2.1
142
+ * @since 2025-09-30
143
+ * @link https://github.com/xeno-js/xeno-js
144
+ */
145
+ readonly HTTP_ADAPTER: IHttpAdapter<unknown, unknown>;
138
146
  /** @description Token used to register and resolve the Logger instance in the dependency injection container.
139
147
  *
140
148
  * @author Xeno
@@ -592,6 +600,42 @@ interface ICryptoService {
592
600
  timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
593
601
  }
594
602
 
603
+ /**
604
+ * @description Interface for a WebTransport.
605
+ * @author Xeno
606
+ * @version 1.2.1
607
+ * @since 2025-09-30
608
+ * @link https://github.com/xeno-js/xeno-js
609
+ */
610
+ interface XenoWebTransport {
611
+ /**
612
+ * @description The Extendend native request.
613
+ * @type ExtendedRequest
614
+ */
615
+ request: ExtendedRequest;
616
+ /**
617
+ * @description The native response.
618
+ * @type Response
619
+ */
620
+ response: Response;
621
+ }
622
+ /**
623
+ * @description Interface for an HTTP adapter.
624
+ * @author Xeno
625
+ * @version 1.2.1
626
+ * @since 2025-09-30
627
+ * @link https://github.com/xeno-js/xeno-js
628
+ */
629
+ interface IHttpAdapter<TReq = Request, TRes = Response> {
630
+ /**
631
+ * @description Adapts an HTTP request and response to an ExtendedRequest and Response.
632
+ * @param req - The HTTP request.
633
+ * @param res - The HTTP response.
634
+ * @returns An object containing the adapted ExtendedRequest and Response.
635
+ */
636
+ adapt(req: TReq, res: TRes): XenoWebTransport;
637
+ }
638
+
595
639
  /**
596
640
  * @description Represents a module that can be registered with the service container.
597
641
  *
@@ -880,6 +924,51 @@ interface HttpConfig<TRegistry extends ApplicationRegistry<unknown> = Applicatio
880
924
  */
881
925
  client: HttpClientConfig;
882
926
  }
927
+ /**
928
+ * @description The configuration options for the HTTP client, including default headers, base URL, and timeout settings.
929
+ * @author Xeno
930
+ * @version 1.2.1
931
+ * @since 2025-09-30
932
+ * @link https://github.com/xeno-js/xeno-js
933
+ */
934
+ interface HttpAdapterConfig {
935
+ /**
936
+ * @description Boolean for Native node js adapter (default true).
937
+ * @type boolean
938
+ * @author Xeno
939
+ * @version 1.2.1
940
+ * @since 2025-09-30
941
+ * @link https://github.com/xeno-js/xeno-js
942
+ */
943
+ native: boolean;
944
+ /**
945
+ * @description Boolean for Vercel adapter.
946
+ * @type boolean
947
+ * @author Xeno
948
+ * @version 1.2.1
949
+ * @since 2025-09-30
950
+ * @link https://github.com/xeno-js/xeno-js
951
+ */
952
+ vercel: boolean;
953
+ /**
954
+ * @description Boolean for Fastify adapter.
955
+ * @type boolean
956
+ * @author Xeno
957
+ * @version 1.2.1
958
+ * @since 2025-09-30
959
+ * @link https://github.com/xeno-js/xeno-js
960
+ */
961
+ fastify: boolean;
962
+ /**
963
+ * @description Optional function for custom adapter.
964
+ * @type Optional<() => IHttpAdapter>
965
+ * @author Xeno
966
+ * @version 1.2.1
967
+ * @since 2025-09-30
968
+ * @link https://github.com/xeno-js/xeno-js
969
+ */
970
+ custom: Optional<() => IHttpAdapter>;
971
+ }
883
972
 
884
973
  /**
885
974
  * @description Interface defining the structure of a logger configuration object. This includes properties such as the minimum log level that should be captured by the logger. The log level determines the severity of log messages that will be processed and forwarded to the logging clients, allowing developers to control the verbosity of logs based on the needs of the application and its operational context.
@@ -1426,7 +1515,7 @@ declare const ContainerUtils: Readonly<{
1426
1515
  * @throws Error If the service is not found in the container.
1427
1516
  * @throws Error If the service is not a scoped service.
1428
1517
  */
1429
- runExecute<TResponse, T extends ApplicationRegistry, TRes extends Response, TReq extends ExtendedRequest>(res: TRes, req: TReq, container: IServiceContainer<T>, action: () => Promise<ResponseDto<TResponse>>): Promise<ResponseDto<TResponse>>;
1518
+ runExecute<TResponse, T extends ApplicationRegistry, TRes, TReq>(res: TRes, req: TReq, container: IServiceContainer<T>, action: () => Promise<ResponseDto<TResponse>>): Promise<ResponseDto<TResponse>>;
1430
1519
  }>;
1431
1520
 
1432
1521
  /**
@@ -1616,6 +1705,7 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1616
1705
  private _isBuilded;
1617
1706
  constructor(container?: IServiceContainer<TRegistry>);
1618
1707
  private readonly _modules;
1708
+ private _adapterConfig;
1619
1709
  private _pipelineConfig;
1620
1710
  private _config;
1621
1711
  private _middlewareConfig;
@@ -1630,6 +1720,8 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1630
1720
  private _isDbContextModuleQueued;
1631
1721
  private _isConcurrencyServiceQueued;
1632
1722
  private _isCacheModuleQueued;
1723
+ private _isAdapterModuleQueued;
1724
+ addAdapter(setupAction: SetupAction<HttpAdapterConfig, IConfigurationService>): this;
1633
1725
  /**
1634
1726
  * @description Enables the use of middlewares in the application. Middlewares can be used for cross-cutting concerns such as logging, authentication, and request/response manipulation.
1635
1727
  * @returns The current instance of AppBuilder for method chaining.
@@ -2001,4 +2093,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2001
2093
  protected getContext(): Optional<RequestContext>;
2002
2094
  }
2003
2095
 
2004
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, type CookieHandlerOptions, type DbContext, type DbTransaction, type ExecutionContext, type HttpConfig, type HttpCoreConfig, type IAllowMethod, type IAllowOrigin, type IAtomicCache, type ICryptoService, type ICsrfTokenService, type IIPResolver, type IModule, type IRateLimitKeyBuilder, type IRequestContext, type IServiceContainer, type IServiceProvider, type IServiceScope, type IServiceScopeAccessor, type ISsrCookie, type ISsrCookieHandler, type ISsrCookieToSet, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, SupabaseServerAuthFactory, type XenoRegistry };
2096
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, type CookieHandlerOptions, type DbContext, type DbTransaction, type ExecutionContext, type HttpAdapterConfig, type HttpConfig, type HttpCoreConfig, type IAllowMethod, type IAllowOrigin, type IAtomicCache, type ICryptoService, type ICsrfTokenService, type IHttpAdapter, type IIPResolver, type IModule, type IRateLimitKeyBuilder, type IRequestContext, type IServiceContainer, type IServiceProvider, type IServiceScope, type IServiceScopeAccessor, type ISsrCookie, type ISsrCookieHandler, type ISsrCookieToSet, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, SupabaseServerAuthFactory, type XenoRegistry, type XenoWebTransport };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ExtendedRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
1
+ import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, ExtendedRequest, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
2
2
  export * from '@xeno-js/shared';
3
3
  export { Query as BaseQuery } from '@xeno-js/shared';
4
4
  import { SupabaseClientOptions } from '@supabase/supabase-js';
@@ -135,6 +135,14 @@ interface ApplicationRegistry<T = unknown, Ttx = unknown> {
135
135
  * @link https://github.com/xeno-js/xeno-js
136
136
  */
137
137
  readonly DB_CONTEXT: T;
138
+ /** @description Token used to register and resolve the HTTP Adapter instance in the dependency injection container.
139
+ *
140
+ * @author Xeno
141
+ * @version 1.2.1
142
+ * @since 2025-09-30
143
+ * @link https://github.com/xeno-js/xeno-js
144
+ */
145
+ readonly HTTP_ADAPTER: IHttpAdapter<unknown, unknown>;
138
146
  /** @description Token used to register and resolve the Logger instance in the dependency injection container.
139
147
  *
140
148
  * @author Xeno
@@ -592,6 +600,42 @@ interface ICryptoService {
592
600
  timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
593
601
  }
594
602
 
603
+ /**
604
+ * @description Interface for a WebTransport.
605
+ * @author Xeno
606
+ * @version 1.2.1
607
+ * @since 2025-09-30
608
+ * @link https://github.com/xeno-js/xeno-js
609
+ */
610
+ interface XenoWebTransport {
611
+ /**
612
+ * @description The Extendend native request.
613
+ * @type ExtendedRequest
614
+ */
615
+ request: ExtendedRequest;
616
+ /**
617
+ * @description The native response.
618
+ * @type Response
619
+ */
620
+ response: Response;
621
+ }
622
+ /**
623
+ * @description Interface for an HTTP adapter.
624
+ * @author Xeno
625
+ * @version 1.2.1
626
+ * @since 2025-09-30
627
+ * @link https://github.com/xeno-js/xeno-js
628
+ */
629
+ interface IHttpAdapter<TReq = Request, TRes = Response> {
630
+ /**
631
+ * @description Adapts an HTTP request and response to an ExtendedRequest and Response.
632
+ * @param req - The HTTP request.
633
+ * @param res - The HTTP response.
634
+ * @returns An object containing the adapted ExtendedRequest and Response.
635
+ */
636
+ adapt(req: TReq, res: TRes): XenoWebTransport;
637
+ }
638
+
595
639
  /**
596
640
  * @description Represents a module that can be registered with the service container.
597
641
  *
@@ -880,6 +924,51 @@ interface HttpConfig<TRegistry extends ApplicationRegistry<unknown> = Applicatio
880
924
  */
881
925
  client: HttpClientConfig;
882
926
  }
927
+ /**
928
+ * @description The configuration options for the HTTP client, including default headers, base URL, and timeout settings.
929
+ * @author Xeno
930
+ * @version 1.2.1
931
+ * @since 2025-09-30
932
+ * @link https://github.com/xeno-js/xeno-js
933
+ */
934
+ interface HttpAdapterConfig {
935
+ /**
936
+ * @description Boolean for Native node js adapter (default true).
937
+ * @type boolean
938
+ * @author Xeno
939
+ * @version 1.2.1
940
+ * @since 2025-09-30
941
+ * @link https://github.com/xeno-js/xeno-js
942
+ */
943
+ native: boolean;
944
+ /**
945
+ * @description Boolean for Vercel adapter.
946
+ * @type boolean
947
+ * @author Xeno
948
+ * @version 1.2.1
949
+ * @since 2025-09-30
950
+ * @link https://github.com/xeno-js/xeno-js
951
+ */
952
+ vercel: boolean;
953
+ /**
954
+ * @description Boolean for Fastify adapter.
955
+ * @type boolean
956
+ * @author Xeno
957
+ * @version 1.2.1
958
+ * @since 2025-09-30
959
+ * @link https://github.com/xeno-js/xeno-js
960
+ */
961
+ fastify: boolean;
962
+ /**
963
+ * @description Optional function for custom adapter.
964
+ * @type Optional<() => IHttpAdapter>
965
+ * @author Xeno
966
+ * @version 1.2.1
967
+ * @since 2025-09-30
968
+ * @link https://github.com/xeno-js/xeno-js
969
+ */
970
+ custom: Optional<() => IHttpAdapter>;
971
+ }
883
972
 
884
973
  /**
885
974
  * @description Interface defining the structure of a logger configuration object. This includes properties such as the minimum log level that should be captured by the logger. The log level determines the severity of log messages that will be processed and forwarded to the logging clients, allowing developers to control the verbosity of logs based on the needs of the application and its operational context.
@@ -1426,7 +1515,7 @@ declare const ContainerUtils: Readonly<{
1426
1515
  * @throws Error If the service is not found in the container.
1427
1516
  * @throws Error If the service is not a scoped service.
1428
1517
  */
1429
- runExecute<TResponse, T extends ApplicationRegistry, TRes extends Response, TReq extends ExtendedRequest>(res: TRes, req: TReq, container: IServiceContainer<T>, action: () => Promise<ResponseDto<TResponse>>): Promise<ResponseDto<TResponse>>;
1518
+ runExecute<TResponse, T extends ApplicationRegistry, TRes, TReq>(res: TRes, req: TReq, container: IServiceContainer<T>, action: () => Promise<ResponseDto<TResponse>>): Promise<ResponseDto<TResponse>>;
1430
1519
  }>;
1431
1520
 
1432
1521
  /**
@@ -1616,6 +1705,7 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1616
1705
  private _isBuilded;
1617
1706
  constructor(container?: IServiceContainer<TRegistry>);
1618
1707
  private readonly _modules;
1708
+ private _adapterConfig;
1619
1709
  private _pipelineConfig;
1620
1710
  private _config;
1621
1711
  private _middlewareConfig;
@@ -1630,6 +1720,8 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1630
1720
  private _isDbContextModuleQueued;
1631
1721
  private _isConcurrencyServiceQueued;
1632
1722
  private _isCacheModuleQueued;
1723
+ private _isAdapterModuleQueued;
1724
+ addAdapter(setupAction: SetupAction<HttpAdapterConfig, IConfigurationService>): this;
1633
1725
  /**
1634
1726
  * @description Enables the use of middlewares in the application. Middlewares can be used for cross-cutting concerns such as logging, authentication, and request/response manipulation.
1635
1727
  * @returns The current instance of AppBuilder for method chaining.
@@ -2001,4 +2093,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2001
2093
  protected getContext(): Optional<RequestContext>;
2002
2094
  }
2003
2095
 
2004
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, type CookieHandlerOptions, type DbContext, type DbTransaction, type ExecutionContext, type HttpConfig, type HttpCoreConfig, type IAllowMethod, type IAllowOrigin, type IAtomicCache, type ICryptoService, type ICsrfTokenService, type IIPResolver, type IModule, type IRateLimitKeyBuilder, type IRequestContext, type IServiceContainer, type IServiceProvider, type IServiceScope, type IServiceScopeAccessor, type ISsrCookie, type ISsrCookieHandler, type ISsrCookieToSet, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, SupabaseServerAuthFactory, type XenoRegistry };
2096
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, type CookieHandlerOptions, type DbContext, type DbTransaction, type ExecutionContext, type HttpAdapterConfig, type HttpConfig, type HttpCoreConfig, type IAllowMethod, type IAllowOrigin, type IAtomicCache, type ICryptoService, type ICsrfTokenService, type IHttpAdapter, type IIPResolver, type IModule, type IRateLimitKeyBuilder, type IRequestContext, type IServiceContainer, type IServiceProvider, type IServiceScope, type IServiceScopeAccessor, type ISsrCookie, type ISsrCookieHandler, type ISsrCookieToSet, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, SupabaseServerAuthFactory, type XenoRegistry, type XenoWebTransport };