@xeno-js/core 1.0.0 → 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
  *
@@ -715,8 +759,12 @@ interface ISsrCookieHandler {
715
759
  getAll(): ISsrCookie[];
716
760
  setAll(cookies: ISsrCookieToSet[]): void;
717
761
  }
762
+ interface CookieHandlerOptions extends CookieOptions {
763
+ httpOnly: boolean;
764
+ }
718
765
  interface AuthSsrConfig<TOption, TRegistry extends ApplicationRegistry = ApplicationRegistry> extends AuthConfig<TOption> {
719
766
  ssrOpts: Optional<(container: IServiceContainer<TRegistry>) => ISsrCookieHandler>;
767
+ cookieOpts: CookieHandlerOptions;
720
768
  customAuth: Optional<{
721
769
  authHeaderExtractor: () => IServiceExtractor<Request['headers'], Optional<string>>;
722
770
  authExtendedService: () => IExtendendAuthService;
@@ -876,6 +924,51 @@ interface HttpConfig<TRegistry extends ApplicationRegistry<unknown> = Applicatio
876
924
  */
877
925
  client: HttpClientConfig;
878
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
+ }
879
972
 
880
973
  /**
881
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.
@@ -1422,7 +1515,7 @@ declare const ContainerUtils: Readonly<{
1422
1515
  * @throws Error If the service is not found in the container.
1423
1516
  * @throws Error If the service is not a scoped service.
1424
1517
  */
1425
- 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>>;
1426
1519
  }>;
1427
1520
 
1428
1521
  /**
@@ -1612,6 +1705,7 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1612
1705
  private _isBuilded;
1613
1706
  constructor(container?: IServiceContainer<TRegistry>);
1614
1707
  private readonly _modules;
1708
+ private _adapterConfig;
1615
1709
  private _pipelineConfig;
1616
1710
  private _config;
1617
1711
  private _middlewareConfig;
@@ -1626,6 +1720,8 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1626
1720
  private _isDbContextModuleQueued;
1627
1721
  private _isConcurrencyServiceQueued;
1628
1722
  private _isCacheModuleQueued;
1723
+ private _isAdapterModuleQueued;
1724
+ addAdapter(setupAction: SetupAction<HttpAdapterConfig, IConfigurationService>): this;
1629
1725
  /**
1630
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.
1631
1727
  * @returns The current instance of AppBuilder for method chaining.
@@ -1851,6 +1947,7 @@ interface SupabaseServerAuthFactoryInput<TRegistry extends XenoRegistry> {
1851
1947
  }
1852
1948
  declare class SupabaseServerAuthFactory<TRegistry extends XenoRegistry = XenoRegistry> implements IFactory<SupabaseServerAuthFactoryInput<TRegistry>, IExtendendAuthService> {
1853
1949
  create({ config, container, }: SupabaseServerAuthFactoryInput<TRegistry>): IExtendendAuthService;
1950
+ private _getCookieSsr;
1854
1951
  }
1855
1952
 
1856
1953
  /**
@@ -1996,4 +2093,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
1996
2093
  protected getContext(): Optional<RequestContext>;
1997
2094
  }
1998
2095
 
1999
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, 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
  *
@@ -715,8 +759,12 @@ interface ISsrCookieHandler {
715
759
  getAll(): ISsrCookie[];
716
760
  setAll(cookies: ISsrCookieToSet[]): void;
717
761
  }
762
+ interface CookieHandlerOptions extends CookieOptions {
763
+ httpOnly: boolean;
764
+ }
718
765
  interface AuthSsrConfig<TOption, TRegistry extends ApplicationRegistry = ApplicationRegistry> extends AuthConfig<TOption> {
719
766
  ssrOpts: Optional<(container: IServiceContainer<TRegistry>) => ISsrCookieHandler>;
767
+ cookieOpts: CookieHandlerOptions;
720
768
  customAuth: Optional<{
721
769
  authHeaderExtractor: () => IServiceExtractor<Request['headers'], Optional<string>>;
722
770
  authExtendedService: () => IExtendendAuthService;
@@ -876,6 +924,51 @@ interface HttpConfig<TRegistry extends ApplicationRegistry<unknown> = Applicatio
876
924
  */
877
925
  client: HttpClientConfig;
878
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
+ }
879
972
 
880
973
  /**
881
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.
@@ -1422,7 +1515,7 @@ declare const ContainerUtils: Readonly<{
1422
1515
  * @throws Error If the service is not found in the container.
1423
1516
  * @throws Error If the service is not a scoped service.
1424
1517
  */
1425
- 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>>;
1426
1519
  }>;
1427
1520
 
1428
1521
  /**
@@ -1612,6 +1705,7 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1612
1705
  private _isBuilded;
1613
1706
  constructor(container?: IServiceContainer<TRegistry>);
1614
1707
  private readonly _modules;
1708
+ private _adapterConfig;
1615
1709
  private _pipelineConfig;
1616
1710
  private _config;
1617
1711
  private _middlewareConfig;
@@ -1626,6 +1720,8 @@ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1626
1720
  private _isDbContextModuleQueued;
1627
1721
  private _isConcurrencyServiceQueued;
1628
1722
  private _isCacheModuleQueued;
1723
+ private _isAdapterModuleQueued;
1724
+ addAdapter(setupAction: SetupAction<HttpAdapterConfig, IConfigurationService>): this;
1629
1725
  /**
1630
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.
1631
1727
  * @returns The current instance of AppBuilder for method chaining.
@@ -1851,6 +1947,7 @@ interface SupabaseServerAuthFactoryInput<TRegistry extends XenoRegistry> {
1851
1947
  }
1852
1948
  declare class SupabaseServerAuthFactory<TRegistry extends XenoRegistry = XenoRegistry> implements IFactory<SupabaseServerAuthFactoryInput<TRegistry>, IExtendendAuthService> {
1853
1949
  create({ config, container, }: SupabaseServerAuthFactoryInput<TRegistry>): IExtendendAuthService;
1950
+ private _getCookieSsr;
1854
1951
  }
1855
1952
 
1856
1953
  /**
@@ -1996,4 +2093,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
1996
2093
  protected getContext(): Optional<RequestContext>;
1997
2094
  }
1998
2095
 
1999
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BasePostgresSqlDataSource, BaseSqliteSqlDataSource, ContainerUtils, 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 };