@xeno-js/core 3.0.2 → 3.0.4

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
@@ -1504,6 +1504,35 @@ interface ConcurrencyConfig {
1504
1504
  };
1505
1505
  }
1506
1506
 
1507
+ declare const TOKENS: Readonly<{
1508
+ USER_CONTEXT_FACTORY: "USER_CONTEXT_FACTORY";
1509
+ AUTH_SERVICE: "AUTH_SERVICE";
1510
+ BASE_AUTH_SERVICE: "BASE_AUTH_SERVICE";
1511
+ CACHE: "CACHE";
1512
+ CACHE_KEY_BUILDER: "CACHE_KEY_BUILDER";
1513
+ COMMAND_PIPELINES_BEHAVIOR: "COMMAND_PIPELINES_BEHAVIOR";
1514
+ CONCURRENCY_SERVICE: "CONCURRENCY_SERVICE";
1515
+ CONFIGURATION_SERVICE: "CONFIGURATION_SERVICE";
1516
+ CONTEXT_ACCESSOR: "CONTEXT_ACCESSOR";
1517
+ CRYPTO_SERVICE: "CRYPTO_SERVICE";
1518
+ CSRF_TOKEN_SERVICE: "CSRF_TOKEN_SERVICE";
1519
+ DB_CONTEXT: "DB_CONTEXT";
1520
+ IDENTITY_ACCESSOR: "IDENTITY_ACCESSOR";
1521
+ LOGGER: "LOGGER";
1522
+ MEDIATOR: "MEDIATOR";
1523
+ NETWORK_CONTEXT_ACCESSOR: "NETWORK_CONTEXT_ACCESSOR";
1524
+ QUERY_PIPELINES_BEHAVIOR: "QUERY_PIPELINES_BEHAVIOR";
1525
+ REQUEST_CONTEXT: "REQUEST_CONTEXT";
1526
+ MIDDLEWARE: "MIDDLEWARE";
1527
+ RESILIENCE_CLIENT: "RESILIENCE_CLIENT";
1528
+ SCHEMA_VALIDATION_STRATEGY: "SCHEMA_VALIDATION_STRATEGY";
1529
+ SERVICE_CONTAINER: "SERVICE_CONTAINER";
1530
+ SERVICE_EXTRACTOR: "SERVICE_EXTRACTOR";
1531
+ SERVICE_SCOPE_ACCESSOR: "SERVICE_SCOPE_ACCESSOR";
1532
+ UNIT_OF_WORK: "UNIT_OF_WORK";
1533
+ VALIDATOR_SERVICE: "VALIDATOR_SERVICE";
1534
+ }>;
1535
+
1507
1536
  /**
1508
1537
  * Utils that provide utility functions for interacting with the service container and managing scoped service resolution.
1509
1538
  */
@@ -1659,7 +1688,7 @@ interface QueuedModule {
1659
1688
  declare class AppBuilder<TRegistry extends ApplicationRegistry = ApplicationRegistry> {
1660
1689
  protected readonly _container: IServiceContainer<TRegistry>;
1661
1690
  protected readonly _configuration: IConfigurationService;
1662
- private _isBuilded;
1691
+ private _buildPromise;
1663
1692
  constructor(container?: IServiceContainer<TRegistry>, configurationService?: IConfigurationService);
1664
1693
  protected readonly _modules: QueuedModule[];
1665
1694
  private _adapterConfig;
@@ -1828,6 +1857,10 @@ declare class AppBuilder<TRegistry extends ApplicationRegistry = ApplicationRegi
1828
1857
  * @link https://github.com/xeno-js/xeno-js
1829
1858
  */
1830
1859
  build(): Promise<IServiceContainer<TRegistry>>;
1860
+ /**
1861
+ * @description Executes the build process by initializing all registered modules in the container.
1862
+ */
1863
+ private _executeBuild;
1831
1864
  /**
1832
1865
  * @description Queues the configuration of the CQRS pipeline module if it has not already been queued. This method ensures that the pipeline module is only added once, even if multiple pipeline-related configurations are made.
1833
1866
  *
@@ -2073,4 +2106,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2073
2106
  protected getContext(): Optional<RequestContext>;
2074
2107
  }
2075
2108
 
2076
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHttpAdapter, ContainerUtils, type CookieHandlerOptions, DbModule, type DbModuleOptions, 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 ITransactionalDb, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, type XenoRegistry, type XenoWebTransport };
2109
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHttpAdapter, ContainerUtils, type CookieHandlerOptions, DbModule, type DbModuleOptions, 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 ITransactionalDb, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, TOKENS, type XenoRegistry, type XenoWebTransport };
package/dist/index.d.ts CHANGED
@@ -1504,6 +1504,35 @@ interface ConcurrencyConfig {
1504
1504
  };
1505
1505
  }
1506
1506
 
1507
+ declare const TOKENS: Readonly<{
1508
+ USER_CONTEXT_FACTORY: "USER_CONTEXT_FACTORY";
1509
+ AUTH_SERVICE: "AUTH_SERVICE";
1510
+ BASE_AUTH_SERVICE: "BASE_AUTH_SERVICE";
1511
+ CACHE: "CACHE";
1512
+ CACHE_KEY_BUILDER: "CACHE_KEY_BUILDER";
1513
+ COMMAND_PIPELINES_BEHAVIOR: "COMMAND_PIPELINES_BEHAVIOR";
1514
+ CONCURRENCY_SERVICE: "CONCURRENCY_SERVICE";
1515
+ CONFIGURATION_SERVICE: "CONFIGURATION_SERVICE";
1516
+ CONTEXT_ACCESSOR: "CONTEXT_ACCESSOR";
1517
+ CRYPTO_SERVICE: "CRYPTO_SERVICE";
1518
+ CSRF_TOKEN_SERVICE: "CSRF_TOKEN_SERVICE";
1519
+ DB_CONTEXT: "DB_CONTEXT";
1520
+ IDENTITY_ACCESSOR: "IDENTITY_ACCESSOR";
1521
+ LOGGER: "LOGGER";
1522
+ MEDIATOR: "MEDIATOR";
1523
+ NETWORK_CONTEXT_ACCESSOR: "NETWORK_CONTEXT_ACCESSOR";
1524
+ QUERY_PIPELINES_BEHAVIOR: "QUERY_PIPELINES_BEHAVIOR";
1525
+ REQUEST_CONTEXT: "REQUEST_CONTEXT";
1526
+ MIDDLEWARE: "MIDDLEWARE";
1527
+ RESILIENCE_CLIENT: "RESILIENCE_CLIENT";
1528
+ SCHEMA_VALIDATION_STRATEGY: "SCHEMA_VALIDATION_STRATEGY";
1529
+ SERVICE_CONTAINER: "SERVICE_CONTAINER";
1530
+ SERVICE_EXTRACTOR: "SERVICE_EXTRACTOR";
1531
+ SERVICE_SCOPE_ACCESSOR: "SERVICE_SCOPE_ACCESSOR";
1532
+ UNIT_OF_WORK: "UNIT_OF_WORK";
1533
+ VALIDATOR_SERVICE: "VALIDATOR_SERVICE";
1534
+ }>;
1535
+
1507
1536
  /**
1508
1537
  * Utils that provide utility functions for interacting with the service container and managing scoped service resolution.
1509
1538
  */
@@ -1659,7 +1688,7 @@ interface QueuedModule {
1659
1688
  declare class AppBuilder<TRegistry extends ApplicationRegistry = ApplicationRegistry> {
1660
1689
  protected readonly _container: IServiceContainer<TRegistry>;
1661
1690
  protected readonly _configuration: IConfigurationService;
1662
- private _isBuilded;
1691
+ private _buildPromise;
1663
1692
  constructor(container?: IServiceContainer<TRegistry>, configurationService?: IConfigurationService);
1664
1693
  protected readonly _modules: QueuedModule[];
1665
1694
  private _adapterConfig;
@@ -1828,6 +1857,10 @@ declare class AppBuilder<TRegistry extends ApplicationRegistry = ApplicationRegi
1828
1857
  * @link https://github.com/xeno-js/xeno-js
1829
1858
  */
1830
1859
  build(): Promise<IServiceContainer<TRegistry>>;
1860
+ /**
1861
+ * @description Executes the build process by initializing all registered modules in the container.
1862
+ */
1863
+ private _executeBuild;
1831
1864
  /**
1832
1865
  * @description Queues the configuration of the CQRS pipeline module if it has not already been queued. This method ensures that the pipeline module is only added once, even if multiple pipeline-related configurations are made.
1833
1866
  *
@@ -2073,4 +2106,4 @@ declare abstract class BaseController<TRequest, TResponse> implements IControlle
2073
2106
  protected getContext(): Optional<RequestContext>;
2074
2107
  }
2075
2108
 
2076
- export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHttpAdapter, ContainerUtils, type CookieHandlerOptions, DbModule, type DbModuleOptions, 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 ITransactionalDb, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, type XenoRegistry, type XenoWebTransport };
2109
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHttpAdapter, ContainerUtils, type CookieHandlerOptions, DbModule, type DbModuleOptions, 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 ITransactionalDb, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, TOKENS, type XenoRegistry, type XenoWebTransport };
package/dist/index.js CHANGED
@@ -1726,7 +1726,7 @@ var init_logger_utils = __esm({
1726
1726
  */
1727
1727
  async addLogger(container, opts) {
1728
1728
  const loggerDependencies = [];
1729
- const { Guards: Guards51, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
1729
+ const { Guards: Guards51, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
1730
1730
  if (!Guards51.isDefined(opts) || opts.console) {
1731
1731
  const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
1732
1732
  loggerDependencies.push(new ConsoleLogger2(opts?.level));
@@ -1748,8 +1748,8 @@ var init_logger_utils = __esm({
1748
1748
  }
1749
1749
  }
1750
1750
  const { BaseLogger } = await import("@xeno-js/shared");
1751
- container.addSingleton(TOKENS5.LOGGER, (c) => {
1752
- const context = c.resolve(TOKENS5.CONTEXT_ACCESSOR);
1751
+ container.addSingleton(TOKENS6.LOGGER, (c) => {
1752
+ const context = c.resolve(TOKENS6.CONTEXT_ACCESSOR);
1753
1753
  return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, loggerDependencies);
1754
1754
  });
1755
1755
  }
@@ -1910,7 +1910,7 @@ var init_cache_utils = __esm({
1910
1910
  * @link https://github.com/xeno-js/xeno-js
1911
1911
  */
1912
1912
  async addCache(container, opts) {
1913
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
1913
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
1914
1914
  if (!opts.inMemory && !Guards51.isDefined(opts.redis)) {
1915
1915
  throw new Error(
1916
1916
  "No cache strategies are configured. Please provide at least one cache strategy."
@@ -1918,17 +1918,17 @@ var init_cache_utils = __esm({
1918
1918
  }
1919
1919
  const { CacheKeyBuilder } = await import("@xeno-js/shared");
1920
1920
  container.addSingleton(
1921
- TOKENS5.CACHE_KEY_BUILDER,
1922
- (c) => new CacheKeyBuilder(c.resolve(TOKENS5.IDENTITY_ACCESSOR))
1921
+ TOKENS6.CACHE_KEY_BUILDER,
1922
+ (c) => new CacheKeyBuilder(c.resolve(TOKENS6.IDENTITY_ACCESSOR))
1923
1923
  );
1924
1924
  if (opts.inMemory || !Guards51.isDefined(opts.redis)) {
1925
1925
  const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
1926
- container.addSingleton(TOKENS5.CACHE, () => new InMemoryCacheExtended2());
1926
+ container.addSingleton(TOKENS6.CACHE, () => new InMemoryCacheExtended2());
1927
1927
  return;
1928
1928
  }
1929
1929
  if (Guards51.isDefined(opts.redis)) {
1930
1930
  const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
1931
- container.addSingleton(TOKENS5.CACHE, () => {
1931
+ container.addSingleton(TOKENS6.CACHE, () => {
1932
1932
  const config = opts.redis;
1933
1933
  return new RedisCacheFactory2().create(config);
1934
1934
  });
@@ -2556,7 +2556,7 @@ __export(supabase_factory_exports, {
2556
2556
  SupabaseServerAuthFactory: () => SupabaseServerAuthFactory
2557
2557
  });
2558
2558
  import { createServerClient } from "@supabase/ssr";
2559
- import { Guards as Guards36, TOKENS as TOKENS3 } from "@xeno-js/shared";
2559
+ import { Guards as Guards36, TOKENS as TOKENS4 } from "@xeno-js/shared";
2560
2560
  import {
2561
2561
  SupabaseAuthService,
2562
2562
  SupabaseClaimsMapper,
@@ -2593,8 +2593,8 @@ var init_supabase_factory = __esm({
2593
2593
  return ssrOpts(container);
2594
2594
  } else {
2595
2595
  return new CookieHandler(
2596
- container.resolve(TOKENS3.NETWORK_CONTEXT_ACCESSOR),
2597
- container.resolve(TOKENS3.CONFIGURATION_SERVICE),
2596
+ container.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR),
2597
+ container.resolve(TOKENS4.CONFIGURATION_SERVICE),
2598
2598
  config
2599
2599
  );
2600
2600
  }
@@ -2625,14 +2625,14 @@ var init_auth_utils = __esm({
2625
2625
  * @link https://github.com/xeno-js/xeno-js
2626
2626
  */
2627
2627
  async addAuthZ(container, opts) {
2628
- const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
2628
+ const { TOKENS: TOKENS6 } = await import("@xeno-js/shared");
2629
2629
  const strategies = [];
2630
2630
  const { Guards: Guards51 } = await import("@xeno-js/shared");
2631
2631
  if (Guards51.isDefined(opts.policies)) {
2632
2632
  const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
2633
2633
  const policyRegistry = opts.policies;
2634
2634
  const registryInstance = new PolicyRegistry2();
2635
- const ctxAccessor = container.resolve(TOKENS5.CONTEXT_ACCESSOR);
2635
+ const ctxAccessor = container.resolve(TOKENS6.CONTEXT_ACCESSOR);
2636
2636
  const Policies = /* @__PURE__ */ new Set();
2637
2637
  for (const [intent, policy] of Object.entries(policyRegistry)) {
2638
2638
  const intentLower = intent.toLowerCase();
@@ -2690,23 +2690,23 @@ var init_auth_utils = __esm({
2690
2690
  * @link https://github.com/xeno-js/xeno-js
2691
2691
  */
2692
2692
  async addAuthN(container, opts) {
2693
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
2693
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
2694
2694
  if (Guards51.isDefined(opts.customAuth)) {
2695
2695
  const authService = opts.customAuth.authExtendedService();
2696
- container.addScoped(TOKENS5.AUTH_SERVICE, () => {
2696
+ container.addScoped(TOKENS6.AUTH_SERVICE, () => {
2697
2697
  return authService;
2698
2698
  });
2699
- container.addSingleton(TOKENS5.BASE_AUTH_SERVICE, () => {
2699
+ container.addSingleton(TOKENS6.BASE_AUTH_SERVICE, () => {
2700
2700
  return authService;
2701
2701
  });
2702
2702
  } else {
2703
2703
  const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_supabase_factory(), supabase_factory_exports));
2704
2704
  const factory = new SupabaseServerAuthFactory2();
2705
2705
  const supabase = factory.create({ config: opts, container });
2706
- container.addScoped(TOKENS5.AUTH_SERVICE, () => {
2706
+ container.addScoped(TOKENS6.AUTH_SERVICE, () => {
2707
2707
  return supabase;
2708
2708
  });
2709
- container.addSingleton(TOKENS5.BASE_AUTH_SERVICE, () => {
2709
+ container.addSingleton(TOKENS6.BASE_AUTH_SERVICE, () => {
2710
2710
  return supabase;
2711
2711
  });
2712
2712
  }
@@ -2950,9 +2950,9 @@ var init_http_utils = __esm({
2950
2950
  * @link https://github.com/xeno-js/xeno-js
2951
2951
  */
2952
2952
  async addResilience(container, opts) {
2953
- const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
2953
+ const { TOKENS: TOKENS6 } = await import("@xeno-js/shared");
2954
2954
  const { CockatielResilienceFactory: CockatielResilienceFactory2 } = await Promise.resolve().then(() => (init_cockatiel_resilience_factory(), cockatiel_resilience_factory_exports));
2955
- container.addSingleton(TOKENS5.RESILIENCE_CLIENT, () => {
2955
+ container.addSingleton(TOKENS6.RESILIENCE_CLIENT, () => {
2956
2956
  const factory = new CockatielResilienceFactory2();
2957
2957
  return factory.create(opts);
2958
2958
  });
@@ -3023,7 +3023,7 @@ var init_validation_utils = __esm({
3023
3023
  * @link https://github.com/xeno-js/xeno-js
3024
3024
  */
3025
3025
  async addValidation(container, opts, logger) {
3026
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
3026
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
3027
3027
  if (!Guards51.isDefined(opts.zod) && Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
3028
3028
  return;
3029
3029
  }
@@ -3033,7 +3033,7 @@ var init_validation_utils = __esm({
3033
3033
  const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_zod_validator_factory(), zod_validator_factory_exports));
3034
3034
  const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
3035
3035
  const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
3036
- container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
3036
+ container.addSingleton(TOKENS6.VALIDATOR_SERVICE, () => validatorService);
3037
3037
  validationStrategies.push(new SchemaValidationStrategy2(validatorService));
3038
3038
  }
3039
3039
  if (!Guards51.isNullOrEmpty(opts.customValidationStrategy)) {
@@ -3138,16 +3138,16 @@ var init_pipeline_utils = __esm({
3138
3138
  * @link https://github.com/xeno-js/xeno-js
3139
3139
  */
3140
3140
  async addCommand(container, opts) {
3141
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
3141
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
3142
3142
  const pipelines = [];
3143
3143
  if (Guards51.isDefined(opts.idempotency)) {
3144
3144
  const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
3145
3145
  const imdStore = new IdempotencyStore2(
3146
- container.resolve(TOKENS5.CACHE),
3147
- container.resolve(TOKENS5.CACHE_KEY_BUILDER)
3146
+ container.resolve(TOKENS6.CACHE),
3147
+ container.resolve(TOKENS6.CACHE_KEY_BUILDER)
3148
3148
  );
3149
3149
  const { IdempotencyPipeline: IdempotencyPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
3150
- const requestContext = container.resolve(TOKENS5.NETWORK_CONTEXT_ACCESSOR);
3150
+ const requestContext = container.resolve(TOKENS6.NETWORK_CONTEXT_ACCESSOR);
3151
3151
  const config = opts.idempotency;
3152
3152
  pipelines.push(
3153
3153
  new IdempotencyPipeline2(
@@ -3176,12 +3176,12 @@ var init_pipeline_utils = __esm({
3176
3176
  * @link https://github.com/xeno-js/xeno-js
3177
3177
  */
3178
3178
  async addQuery(container) {
3179
- const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
3179
+ const { TOKENS: TOKENS6 } = await import("@xeno-js/shared");
3180
3180
  const { QueryCachingPipeline: QueryCachingPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
3181
3181
  return new QueryCachingPipeline2(
3182
- container.resolve(TOKENS5.CACHE),
3183
- container.resolve(TOKENS5.CACHE_KEY_BUILDER),
3184
- container.resolve(TOKENS5.LOGGER)
3182
+ container.resolve(TOKENS6.CACHE),
3183
+ container.resolve(TOKENS6.CACHE_KEY_BUILDER),
3184
+ container.resolve(TOKENS6.LOGGER)
3185
3185
  );
3186
3186
  }
3187
3187
  });
@@ -3199,11 +3199,11 @@ var init_cqrs_module = __esm({
3199
3199
  "use strict";
3200
3200
  CqrsModule = class {
3201
3201
  async configure(container, opts) {
3202
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
3203
- const logger = container.resolve(TOKENS5.LOGGER);
3202
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
3203
+ const logger = container.resolve(TOKENS6.LOGGER);
3204
3204
  const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
3205
- container.addSingleton(TOKENS5.MEDIATOR, (c) => {
3206
- const serviceScopeAccessor = c.resolve(TOKENS5.SERVICE_SCOPE_ACCESSOR);
3205
+ container.addSingleton(TOKENS6.MEDIATOR, (c) => {
3206
+ const serviceScopeAccessor = c.resolve(TOKENS6.SERVICE_SCOPE_ACCESSOR);
3207
3207
  return new Mediator2(serviceScopeAccessor);
3208
3208
  });
3209
3209
  const { ExceptionPipeline: ExceptionPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
@@ -3242,10 +3242,10 @@ var init_cqrs_module = __esm({
3242
3242
  queryPipelines.push(newQueryPipelines);
3243
3243
  }
3244
3244
  const { CompositePipeline: CompositePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
3245
- container.addSingleton(TOKENS5.COMMAND_PIPELINES_BEHAVIOR, () => {
3245
+ container.addSingleton(TOKENS6.COMMAND_PIPELINES_BEHAVIOR, () => {
3246
3246
  return new CompositePipeline2(commandPipelines);
3247
3247
  });
3248
- container.addSingleton(TOKENS5.QUERY_PIPELINES_BEHAVIOR, () => {
3248
+ container.addSingleton(TOKENS6.QUERY_PIPELINES_BEHAVIOR, () => {
3249
3249
  return new CompositePipeline2(queryPipelines);
3250
3250
  });
3251
3251
  }
@@ -4091,7 +4091,7 @@ var init_middleware_module = __esm({
4091
4091
  "use strict";
4092
4092
  MiddlewareModule = class {
4093
4093
  async configure(container, opts) {
4094
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
4094
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
4095
4095
  const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
4096
4096
  const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
4097
4097
  const tokenExtractor = await this._getTokenExtractor(
@@ -4100,7 +4100,7 @@ var init_middleware_module = __esm({
4100
4100
  opts.customTokenExtractor
4101
4101
  );
4102
4102
  container.addSingleton(
4103
- TOKENS5.SERVICE_EXTRACTOR,
4103
+ TOKENS6.SERVICE_EXTRACTOR,
4104
4104
  () => new HttpHeaderExtractor2(
4105
4105
  tokenExtractor,
4106
4106
  new HttpCookieExtractor2(),
@@ -4110,18 +4110,18 @@ var init_middleware_module = __esm({
4110
4110
  );
4111
4111
  const { ClientIpResolver: ClientIpResolver2 } = await Promise.resolve().then(() => (init_services(), services_exports));
4112
4112
  const middlewares = [];
4113
- const requestContext = container.resolve(TOKENS5.REQUEST_CONTEXT);
4114
- const logger = container.resolve(TOKENS5.LOGGER);
4113
+ const requestContext = container.resolve(TOKENS6.REQUEST_CONTEXT);
4114
+ const logger = container.resolve(TOKENS6.LOGGER);
4115
4115
  const { RequestContextMiddleware: RequestContextMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
4116
4116
  middlewares.push(
4117
4117
  new RequestContextMiddleware2(
4118
4118
  requestContext,
4119
- container.resolve(TOKENS5.SERVICE_EXTRACTOR),
4119
+ container.resolve(TOKENS6.SERVICE_EXTRACTOR),
4120
4120
  new ClientIpResolver2(opts.trustedProxies),
4121
4121
  logger
4122
4122
  )
4123
4123
  );
4124
- const configuration = container.resolve(TOKENS5.CONFIGURATION_SERVICE);
4124
+ const configuration = container.resolve(TOKENS6.CONFIGURATION_SERVICE);
4125
4125
  const defaultOrigin = configuration.get("APP_URL") ?? `http://localhost:${configuration.getNumber("PORT", 3e3)}`;
4126
4126
  const origins = !Guards51.isNullOrEmpty(opts.allowOrigins) ? opts.allowOrigins : [defaultOrigin];
4127
4127
  if (opts.withCredentials && origins.includes("*"))
@@ -4168,7 +4168,7 @@ var init_middleware_module = __esm({
4168
4168
  new AuthenticationMiddleware2(
4169
4169
  requestContext,
4170
4170
  tokenExtractor,
4171
- new GateKeeper2(container.resolve(TOKENS5.BASE_AUTH_SERVICE), new ClaimsIdentityMapper2()),
4171
+ new GateKeeper2(container.resolve(TOKENS6.BASE_AUTH_SERVICE), new ClaimsIdentityMapper2()),
4172
4172
  logger
4173
4173
  )
4174
4174
  );
@@ -4185,7 +4185,7 @@ var init_middleware_module = __esm({
4185
4185
  middlewares.push(
4186
4186
  new RateLimitMiddleware2(
4187
4187
  requestContext,
4188
- container.resolve(TOKENS5.CACHE),
4188
+ container.resolve(TOKENS6.CACHE),
4189
4189
  new RateLimitKeyBuilder2(requestContext),
4190
4190
  logger,
4191
4191
  { maxRequests, windowSeconds }
@@ -4212,7 +4212,7 @@ var init_middleware_module = __esm({
4212
4212
  middlewares.push(new CsrfMiddleware2(requestContext, container.resolve("CSRF_TOKEN_SERVICE")));
4213
4213
  }
4214
4214
  const { CompositeMiddleware: CompositeMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
4215
- container.addSingleton(TOKENS5.MIDDLEWARE, () => {
4215
+ container.addSingleton(TOKENS6.MIDDLEWARE, () => {
4216
4216
  return new CompositeMiddleware2(middlewares);
4217
4217
  });
4218
4218
  }
@@ -4398,17 +4398,17 @@ var init_context_module = __esm({
4398
4398
  "use strict";
4399
4399
  ContextModule = class {
4400
4400
  async configure(container) {
4401
- const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
4401
+ const { TOKENS: TOKENS6 } = await import("@xeno-js/shared");
4402
4402
  const { ServiceScopeFactory: ServiceScopeFactory2 } = await Promise.resolve().then(() => (init_service_scope_factory(), service_scope_factory_exports));
4403
4403
  const { NodeRequestContextFactory: NodeRequestContextFactory2 } = await Promise.resolve().then(() => (init_request_context_factory(), request_context_factory_exports));
4404
4404
  const requestContext = new NodeRequestContextFactory2(
4405
4405
  new ServiceScopeFactory2(container)
4406
4406
  ).create();
4407
- container.addSingleton(TOKENS5.REQUEST_CONTEXT, () => requestContext);
4408
- container.addSingleton(TOKENS5.CONTEXT_ACCESSOR, () => requestContext);
4409
- container.addSingleton(TOKENS5.IDENTITY_ACCESSOR, () => requestContext);
4410
- container.addSingleton(TOKENS5.SERVICE_SCOPE_ACCESSOR, () => requestContext);
4411
- container.addSingleton(TOKENS5.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
4407
+ container.addSingleton(TOKENS6.REQUEST_CONTEXT, () => requestContext);
4408
+ container.addSingleton(TOKENS6.CONTEXT_ACCESSOR, () => requestContext);
4409
+ container.addSingleton(TOKENS6.IDENTITY_ACCESSOR, () => requestContext);
4410
+ container.addSingleton(TOKENS6.SERVICE_SCOPE_ACCESSOR, () => requestContext);
4411
+ container.addSingleton(TOKENS6.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
4412
4412
  const { UserContextFactory: UserContextFactory2 } = await Promise.resolve().then(() => (init_user_context_factory(), user_context_factory_exports));
4413
4413
  container.addSingleton("USER_CONTEXT_FACTORY", () => {
4414
4414
  return new UserContextFactory2(requestContext);
@@ -4515,8 +4515,15 @@ var init_unit_of_work = __esm({
4515
4515
  // src/index.ts
4516
4516
  init_application();
4517
4517
 
4518
+ // src/domain/constants/tokens.constants.ts
4519
+ import { TOKENS as tokens } from "@xeno-js/shared";
4520
+ var TOKENS3 = Object.freeze({
4521
+ ...tokens,
4522
+ USER_CONTEXT_FACTORY: "USER_CONTEXT_FACTORY"
4523
+ });
4524
+
4518
4525
  // src/infrastructure/builder/app.builder.ts
4519
- import { Guards as Guards47, LOG_LEVEL as LOG_LEVEL6, TOKENS as TOKENS4 } from "@xeno-js/shared";
4526
+ import { Guards as Guards47, LOG_LEVEL as LOG_LEVEL6, TOKENS as TOKENS5 } from "@xeno-js/shared";
4520
4527
 
4521
4528
  // src/infrastructure/configuration/configuration.ts
4522
4529
  import { Guards as Guards13 } from "@xeno-js/shared";
@@ -4791,11 +4798,11 @@ var isDisposable = Object.freeze({
4791
4798
  var AppBuilder = class {
4792
4799
  _container = new ServiceContainer();
4793
4800
  _configuration;
4794
- _isBuilded = false;
4801
+ _buildPromise = null;
4795
4802
  constructor(container, configurationService) {
4796
4803
  this._container = container ?? new ServiceContainer();
4797
4804
  this._configuration = configurationService ?? new EnvironmentConfigurationService();
4798
- this._container.addSingleton(TOKENS4.CONFIGURATION_SERVICE, () => this._configuration);
4805
+ this._container.addSingleton(TOKENS5.CONFIGURATION_SERVICE, () => this._configuration);
4799
4806
  this.addContext();
4800
4807
  }
4801
4808
  // --- Module Configurations ---
@@ -4899,7 +4906,7 @@ var AppBuilder = class {
4899
4906
  setupAction(this._adapterConfig, this._configuration);
4900
4907
  this._isAdapterModuleQueued = true;
4901
4908
  this._modules.push({
4902
- priority: 50,
4909
+ priority: 3,
4903
4910
  name: "AdapterModule",
4904
4911
  action: async () => {
4905
4912
  const { HttpAdapterModule: HttpAdapterModule2 } = await Promise.resolve().then(() => (init_http_adapter_module(), http_adapter_module_exports));
@@ -5170,8 +5177,27 @@ var AppBuilder = class {
5170
5177
  * @since 2025-09-30
5171
5178
  * @link https://github.com/xeno-js/xeno-js
5172
5179
  */
5173
- async build() {
5174
- if (this._isBuilded) return this._container;
5180
+ build() {
5181
+ if (Guards47.isDefined(this._buildPromise)) {
5182
+ return this._buildPromise;
5183
+ }
5184
+ const attempt = this._executeBuild();
5185
+ this._buildPromise = attempt;
5186
+ void attempt.then(
5187
+ () => {
5188
+ },
5189
+ () => {
5190
+ if (this._buildPromise === attempt) {
5191
+ this._buildPromise = null;
5192
+ }
5193
+ }
5194
+ );
5195
+ return attempt;
5196
+ }
5197
+ /**
5198
+ * @description Executes the build process by initializing all registered modules in the container.
5199
+ */
5200
+ async _executeBuild() {
5175
5201
  console.info("\u2699\uFE0F Bootstrapping application modules...");
5176
5202
  const sortedModules = this._modules.sort((a, b) => a.priority - b.priority);
5177
5203
  for (const queued of sortedModules) {
@@ -5192,7 +5218,6 @@ var AppBuilder = class {
5192
5218
  }
5193
5219
  }
5194
5220
  console.info("\u2705 Application modules bootstrapped successfully.");
5195
- this._isBuilded = true;
5196
5221
  return this._container;
5197
5222
  }
5198
5223
  // ─────────────────────────────────────────────────────────────────────────────
@@ -5242,6 +5267,10 @@ var AppBuilder = class {
5242
5267
  action: async () => {
5243
5268
  const { MiddlewareModule: MiddlewareModule2 } = await Promise.resolve().then(() => (init_middleware_module(), middleware_module_exports));
5244
5269
  const middlewareModule = new MiddlewareModule2();
5270
+ if (!this._isAdapterModuleQueued) {
5271
+ const { HttpAdapterModule: HttpAdapterModule2 } = await Promise.resolve().then(() => (init_http_adapter_module(), http_adapter_module_exports));
5272
+ await new HttpAdapterModule2().configure(this._container, this._adapterConfig);
5273
+ }
5245
5274
  await middlewareModule.configure(this._container, {
5246
5275
  ...this._middlewareConfig,
5247
5276
  isAuth: this._isAuthModuleQueued,
@@ -5280,18 +5309,18 @@ init_base_http_adapter();
5280
5309
  // src/infrastructure/modules/db.module.ts
5281
5310
  var DbModule = class {
5282
5311
  async configure(container, opts) {
5283
- const { Guards: Guards51, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
5312
+ const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
5284
5313
  const db = opts.client;
5285
5314
  const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
5286
5315
  container.addScoped("TRANSACTION_STATE", () => {
5287
5316
  return new TransactionState2();
5288
5317
  });
5289
5318
  const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
5290
- container.addScoped(TOKENS5.UNIT_OF_WORK, (c) => {
5319
+ container.addScoped(TOKENS6.UNIT_OF_WORK, (c) => {
5291
5320
  const ttx = c.resolve("TRANSACTION_STATE");
5292
5321
  return new UnitOfWork2(db, ttx);
5293
5322
  });
5294
- container.addScoped(TOKENS5.DB_CONTEXT, (c) => {
5323
+ container.addScoped(TOKENS6.DB_CONTEXT, (c) => {
5295
5324
  const ttx = c.resolve("TRANSACTION_STATE");
5296
5325
  return new Proxy(db, {
5297
5326
  get(_target, prop, receiver) {
@@ -5414,7 +5443,8 @@ export {
5414
5443
  Query,
5415
5444
  ReadDao,
5416
5445
  Repository,
5417
- Specification
5446
+ Specification,
5447
+ TOKENS3 as TOKENS
5418
5448
  };
5419
5449
  /**
5420
5450
  * @description The CsrfCookieMiddleware class implements the IMiddleware interface, providing a concrete implementation for handling CSRF token validation and cookie management. It checks the incoming request for a valid CSRF token and sets a CSRF cookie if necessary.