@xeno-js/core 3.0.2 → 3.0.3
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/README.md +589 -445
- package/dist/index.cjs +391 -372
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +79 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
|
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:
|
|
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(
|
|
1752
|
-
const context = c.resolve(
|
|
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:
|
|
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
|
-
|
|
1922
|
-
(c) => new CacheKeyBuilder(c.resolve(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
2597
|
-
container.resolve(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
2696
|
+
container.addScoped(TOKENS6.AUTH_SERVICE, () => {
|
|
2697
2697
|
return authService;
|
|
2698
2698
|
});
|
|
2699
|
-
container.addSingleton(
|
|
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(
|
|
2706
|
+
container.addScoped(TOKENS6.AUTH_SERVICE, () => {
|
|
2707
2707
|
return supabase;
|
|
2708
2708
|
});
|
|
2709
|
-
container.addSingleton(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
3147
|
-
container.resolve(
|
|
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(
|
|
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:
|
|
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(
|
|
3183
|
-
container.resolve(
|
|
3184
|
-
container.resolve(
|
|
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:
|
|
3203
|
-
const logger = container.resolve(
|
|
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(
|
|
3206
|
-
const serviceScopeAccessor = c.resolve(
|
|
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(
|
|
3245
|
+
container.addSingleton(TOKENS6.COMMAND_PIPELINES_BEHAVIOR, () => {
|
|
3246
3246
|
return new CompositePipeline2(commandPipelines);
|
|
3247
3247
|
});
|
|
3248
|
-
container.addSingleton(
|
|
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:
|
|
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
|
-
|
|
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(
|
|
4114
|
-
const logger = container.resolve(
|
|
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(
|
|
4119
|
+
container.resolve(TOKENS6.SERVICE_EXTRACTOR),
|
|
4120
4120
|
new ClientIpResolver2(opts.trustedProxies),
|
|
4121
4121
|
logger
|
|
4122
4122
|
)
|
|
4123
4123
|
);
|
|
4124
|
-
const configuration = container.resolve(
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
|
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(
|
|
4408
|
-
container.addSingleton(
|
|
4409
|
-
container.addSingleton(
|
|
4410
|
-
container.addSingleton(
|
|
4411
|
-
container.addSingleton(
|
|
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
|
|
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
|
-
|
|
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(
|
|
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:
|
|
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));
|
|
@@ -5171,7 +5178,14 @@ var AppBuilder = class {
|
|
|
5171
5178
|
* @link https://github.com/xeno-js/xeno-js
|
|
5172
5179
|
*/
|
|
5173
5180
|
async build() {
|
|
5174
|
-
if (this.
|
|
5181
|
+
if (Guards47.isDefined(this._buildPromise)) return this._buildPromise;
|
|
5182
|
+
this._buildPromise = this._executeBuild();
|
|
5183
|
+
return this._buildPromise;
|
|
5184
|
+
}
|
|
5185
|
+
/**
|
|
5186
|
+
* @description Executes the build process by initializing all registered modules in the container.
|
|
5187
|
+
*/
|
|
5188
|
+
async _executeBuild() {
|
|
5175
5189
|
console.info("\u2699\uFE0F Bootstrapping application modules...");
|
|
5176
5190
|
const sortedModules = this._modules.sort((a, b) => a.priority - b.priority);
|
|
5177
5191
|
for (const queued of sortedModules) {
|
|
@@ -5192,7 +5206,6 @@ var AppBuilder = class {
|
|
|
5192
5206
|
}
|
|
5193
5207
|
}
|
|
5194
5208
|
console.info("\u2705 Application modules bootstrapped successfully.");
|
|
5195
|
-
this._isBuilded = true;
|
|
5196
5209
|
return this._container;
|
|
5197
5210
|
}
|
|
5198
5211
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -5242,6 +5255,10 @@ var AppBuilder = class {
|
|
|
5242
5255
|
action: async () => {
|
|
5243
5256
|
const { MiddlewareModule: MiddlewareModule2 } = await Promise.resolve().then(() => (init_middleware_module(), middleware_module_exports));
|
|
5244
5257
|
const middlewareModule = new MiddlewareModule2();
|
|
5258
|
+
if (!this._isAdapterModuleQueued) {
|
|
5259
|
+
const { HttpAdapterModule: HttpAdapterModule2 } = await Promise.resolve().then(() => (init_http_adapter_module(), http_adapter_module_exports));
|
|
5260
|
+
await new HttpAdapterModule2().configure(this._container, this._adapterConfig);
|
|
5261
|
+
}
|
|
5245
5262
|
await middlewareModule.configure(this._container, {
|
|
5246
5263
|
...this._middlewareConfig,
|
|
5247
5264
|
isAuth: this._isAuthModuleQueued,
|
|
@@ -5280,18 +5297,18 @@ init_base_http_adapter();
|
|
|
5280
5297
|
// src/infrastructure/modules/db.module.ts
|
|
5281
5298
|
var DbModule = class {
|
|
5282
5299
|
async configure(container, opts) {
|
|
5283
|
-
const { Guards: Guards51, TOKENS:
|
|
5300
|
+
const { Guards: Guards51, TOKENS: TOKENS6 } = await import("@xeno-js/shared");
|
|
5284
5301
|
const db = opts.client;
|
|
5285
5302
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
5286
5303
|
container.addScoped("TRANSACTION_STATE", () => {
|
|
5287
5304
|
return new TransactionState2();
|
|
5288
5305
|
});
|
|
5289
5306
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
5290
|
-
container.addScoped(
|
|
5307
|
+
container.addScoped(TOKENS6.UNIT_OF_WORK, (c) => {
|
|
5291
5308
|
const ttx = c.resolve("TRANSACTION_STATE");
|
|
5292
5309
|
return new UnitOfWork2(db, ttx);
|
|
5293
5310
|
});
|
|
5294
|
-
container.addScoped(
|
|
5311
|
+
container.addScoped(TOKENS6.DB_CONTEXT, (c) => {
|
|
5295
5312
|
const ttx = c.resolve("TRANSACTION_STATE");
|
|
5296
5313
|
return new Proxy(db, {
|
|
5297
5314
|
get(_target, prop, receiver) {
|
|
@@ -5414,7 +5431,8 @@ export {
|
|
|
5414
5431
|
Query,
|
|
5415
5432
|
ReadDao,
|
|
5416
5433
|
Repository,
|
|
5417
|
-
Specification
|
|
5434
|
+
Specification,
|
|
5435
|
+
TOKENS3 as TOKENS
|
|
5418
5436
|
};
|
|
5419
5437
|
/**
|
|
5420
5438
|
* @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.
|