@xeno-js/core 1.2.6 → 1.2.7

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
@@ -1950,6 +1950,57 @@ declare class SupabaseServerAuthFactory<TRegistry extends XenoRegistry = XenoReg
1950
1950
  private _getCookieSsr;
1951
1951
  }
1952
1952
 
1953
+ /**
1954
+ * @description Base HTTP adapter.
1955
+ * @author Xeno
1956
+ * @version 1.2.1
1957
+ * @since 2025-09-30
1958
+ * @link https://github.com/xeno-js/xeno-js
1959
+ */
1960
+ declare abstract class BaseHttpAdapter<TReq = ExtendedRequest, TRes = Response> implements IHttpAdapter<TReq, TRes> {
1961
+ abstract adapt(req: TReq, res: TRes): XenoWebTransport;
1962
+ /**
1963
+ * @description Parse the URL from the request.
1964
+ * @param rawUrl The raw URL.
1965
+ * @param headers The headers.
1966
+ * @param queryParams The query parameters.
1967
+ * @returns The parsed URL.
1968
+ */
1969
+ protected parseUrl(rawUrl: string | undefined, headers: Dictionary<Optional<string | string[]>>, queryParams: Optional<Dictionary>): URL;
1970
+ /**
1971
+ * @description Parses the headers.
1972
+ * @param rawHeaders The raw headers.
1973
+ * @returns The parsed headers.
1974
+ */
1975
+ protected parseHeaders(rawHeaders: Dictionary<Optional<string | string[]>>): Headers;
1976
+ /**
1977
+ * @description Parses the body.
1978
+ * @param method The method.
1979
+ * @param rawBody The raw body.
1980
+ * @returns The parsed body.
1981
+ */
1982
+ protected parseBody(method: Optional<string>, rawBody: unknown): Optional<RequestInit['body']>;
1983
+ /**
1984
+ * @description Handles the header change.
1985
+ * @param res The response.
1986
+ * @param name The name.
1987
+ * @param value The value.
1988
+ * @param action The action.
1989
+ * @param action The action.
1990
+ * @returns void
1991
+ */
1992
+ protected abstract handleHeaderChange(_res: TRes, _name: string, _value: string, _action: 'set' | 'append' | 'delete'): void;
1993
+ /**
1994
+ * @description Creates the XenoWebTransport.
1995
+ * @param url The url.
1996
+ * @param method The method.
1997
+ * @param headers The headers.
1998
+ * @param body The body.
1999
+ * @returns The XenoWebTransport.
2000
+ */
2001
+ protected createXenoWebTransport(url: URL, method: string | undefined, headers: Headers, body?: Optional<unknown>, res?: Optional<TRes>): XenoWebTransport;
2002
+ }
2003
+
1953
2004
  /**
1954
2005
  * An abstract generic read-only DAO that provides basic read operations for entities of type T, using a Data Transfer Object (DTO) of type TDto for data access. This class relies on an IReadDataSource to perform database operations and an IMapper to convert between entities and DTOs.
1955
2006
  * @template T - The type of the entity that the DAO will manage.
@@ -2093,4 +2144,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2093
2144
  protected getContext(): Optional<RequestContext>;
2094
2145
  }
2095
2146
 
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 };
2147
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BaseHttpAdapter, 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
@@ -1950,6 +1950,57 @@ declare class SupabaseServerAuthFactory<TRegistry extends XenoRegistry = XenoReg
1950
1950
  private _getCookieSsr;
1951
1951
  }
1952
1952
 
1953
+ /**
1954
+ * @description Base HTTP adapter.
1955
+ * @author Xeno
1956
+ * @version 1.2.1
1957
+ * @since 2025-09-30
1958
+ * @link https://github.com/xeno-js/xeno-js
1959
+ */
1960
+ declare abstract class BaseHttpAdapter<TReq = ExtendedRequest, TRes = Response> implements IHttpAdapter<TReq, TRes> {
1961
+ abstract adapt(req: TReq, res: TRes): XenoWebTransport;
1962
+ /**
1963
+ * @description Parse the URL from the request.
1964
+ * @param rawUrl The raw URL.
1965
+ * @param headers The headers.
1966
+ * @param queryParams The query parameters.
1967
+ * @returns The parsed URL.
1968
+ */
1969
+ protected parseUrl(rawUrl: string | undefined, headers: Dictionary<Optional<string | string[]>>, queryParams: Optional<Dictionary>): URL;
1970
+ /**
1971
+ * @description Parses the headers.
1972
+ * @param rawHeaders The raw headers.
1973
+ * @returns The parsed headers.
1974
+ */
1975
+ protected parseHeaders(rawHeaders: Dictionary<Optional<string | string[]>>): Headers;
1976
+ /**
1977
+ * @description Parses the body.
1978
+ * @param method The method.
1979
+ * @param rawBody The raw body.
1980
+ * @returns The parsed body.
1981
+ */
1982
+ protected parseBody(method: Optional<string>, rawBody: unknown): Optional<RequestInit['body']>;
1983
+ /**
1984
+ * @description Handles the header change.
1985
+ * @param res The response.
1986
+ * @param name The name.
1987
+ * @param value The value.
1988
+ * @param action The action.
1989
+ * @param action The action.
1990
+ * @returns void
1991
+ */
1992
+ protected abstract handleHeaderChange(_res: TRes, _name: string, _value: string, _action: 'set' | 'append' | 'delete'): void;
1993
+ /**
1994
+ * @description Creates the XenoWebTransport.
1995
+ * @param url The url.
1996
+ * @param method The method.
1997
+ * @param headers The headers.
1998
+ * @param body The body.
1999
+ * @returns The XenoWebTransport.
2000
+ */
2001
+ protected createXenoWebTransport(url: URL, method: string | undefined, headers: Headers, body?: Optional<unknown>, res?: Optional<TRes>): XenoWebTransport;
2002
+ }
2003
+
1953
2004
  /**
1954
2005
  * An abstract generic read-only DAO that provides basic read operations for entities of type T, using a Data Transfer Object (DTO) of type TDto for data access. This class relies on an IReadDataSource to perform database operations and an IMapper to convert between entities and DTOs.
1955
2006
  * @template T - The type of the entity that the DAO will manage.
@@ -2093,4 +2144,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2093
2144
  protected getContext(): Optional<RequestContext>;
2094
2145
  }
2095
2146
 
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 };
2147
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, BaseHttpAdapter, 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.js CHANGED
@@ -3335,11 +3335,11 @@ var init_fastify_http_adapter = __esm({
3335
3335
  "use strict";
3336
3336
  init_base_http_adapter();
3337
3337
  FastifyHttpAdapter = class extends BaseHttpAdapter {
3338
- adapt(req, _res) {
3338
+ adapt(req, res) {
3339
3339
  const headers = this.parseHeaders(req.headers);
3340
3340
  const url = this.parseUrl(req.url, req.headers, req.query);
3341
3341
  const body = req.body;
3342
- return this.createXenoWebTransport(url, req.method, headers, body);
3342
+ return this.createXenoWebTransport(url, req.method, headers, body, res);
3343
3343
  }
3344
3344
  handleHeaderChange(res, name, value, action) {
3345
3345
  if (action === "delete") {
@@ -3398,10 +3398,10 @@ var init_vercel_http_adapter = __esm({
3398
3398
  "use strict";
3399
3399
  init_base_http_adapter();
3400
3400
  VercelHttpAdapter = class extends BaseHttpAdapter {
3401
- adapt(req, _res) {
3401
+ adapt(req, res) {
3402
3402
  const headers = this.parseHeaders(req.headers);
3403
3403
  const url = this.parseUrl(req.url, req.headers, req.query);
3404
- return this.createXenoWebTransport(url, req.method, headers, req.body);
3404
+ return this.createXenoWebTransport(url, req.method, headers, req.body, res);
3405
3405
  }
3406
3406
  handleHeaderChange(res, name, value, action) {
3407
3407
  if (action === "delete") {
@@ -4744,6 +4744,7 @@ __export(index_exports, {
4744
4744
  BaseAuthorizationStrategy: () => BaseAuthorizationStrategy,
4745
4745
  BaseController: () => BaseController,
4746
4746
  BaseHandler: () => BaseHandler,
4747
+ BaseHttpAdapter: () => BaseHttpAdapter,
4747
4748
  BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
4748
4749
  BaseQuery: () => Query,
4749
4750
  BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
@@ -5575,6 +5576,7 @@ import { AppError as AppError15, Result as Result16 } from "@xeno-js/shared";
5575
5576
 
5576
5577
  // src/infrastructure/index.ts
5577
5578
  init_factories();
5579
+ init_http();
5578
5580
  init_idempotency();
5579
5581
 
5580
5582
  // src/infrastructure/loggers/index.ts
@@ -5696,6 +5698,7 @@ export {
5696
5698
  BaseAuthorizationStrategy,
5697
5699
  BaseController,
5698
5700
  BaseHandler,
5701
+ BaseHttpAdapter,
5699
5702
  BasePostgresSqlDataSource,
5700
5703
  Query as BaseQuery,
5701
5704
  BaseSqliteSqlDataSource,