@xeno-js/core 0.1.9 → 0.1.10
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.cjs +261 -462
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -235
- package/dist/index.d.ts +10 -235
- package/dist/index.js +241 -442
- package/dist/index.js.map +1 -1
- package/package.json +166 -160
package/dist/index.js
CHANGED
|
@@ -1508,47 +1508,31 @@ var init_logger_utils = __esm({
|
|
|
1508
1508
|
*/
|
|
1509
1509
|
async addLogger(container, opts) {
|
|
1510
1510
|
const loggerDependencies = [];
|
|
1511
|
-
const { Guards:
|
|
1512
|
-
if (!
|
|
1511
|
+
const { Guards: Guards46, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
1512
|
+
if (!Guards46.isDefined(opts) || opts.console) {
|
|
1513
1513
|
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
1514
|
-
|
|
1515
|
-
loggerDependencies.push(TOKENS4.CONSOLE_LOGGER);
|
|
1514
|
+
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
1516
1515
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
if (Guards47.isDefined(opts.sentry.config)) {
|
|
1516
|
+
if (Guards46.isDefined(opts)) {
|
|
1517
|
+
if (Guards46.isDefined(opts.sentry.config)) {
|
|
1520
1518
|
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
1521
|
-
|
|
1522
|
-
const factory = new SentryLoggerFactory2();
|
|
1523
|
-
return factory.create(opts);
|
|
1524
|
-
});
|
|
1525
|
-
loggerDependencies.push(TOKENS4.SENTRY_LOGGER);
|
|
1519
|
+
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
1526
1520
|
}
|
|
1527
|
-
if (
|
|
1521
|
+
if (Guards46.isDefined(opts.pino.config)) {
|
|
1528
1522
|
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
1529
|
-
|
|
1530
|
-
const factory = new PinoLoggerFactory2();
|
|
1531
|
-
return factory.create(opts);
|
|
1532
|
-
});
|
|
1533
|
-
loggerDependencies.push(TOKENS4.PINO_LOGGER);
|
|
1523
|
+
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
1534
1524
|
}
|
|
1535
|
-
if (!
|
|
1525
|
+
if (!Guards46.isNullOrEmpty(opts.customLoggers)) {
|
|
1536
1526
|
const customLoggers = opts.customLoggers;
|
|
1537
|
-
customLoggers.forEach((
|
|
1538
|
-
if (
|
|
1539
|
-
customLoggerFactories.push(f);
|
|
1540
|
-
}
|
|
1527
|
+
customLoggers.forEach((fn) => {
|
|
1528
|
+
if (Guards46.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
1541
1529
|
});
|
|
1542
1530
|
}
|
|
1543
1531
|
}
|
|
1544
1532
|
const { BaseLogger } = await import("@xeno-js/shared");
|
|
1545
1533
|
container.addSingleton(TOKENS4.LOGGER, (c) => {
|
|
1546
1534
|
const context = c.resolve(TOKENS4.CONTEXT_ACCESSOR);
|
|
1547
|
-
|
|
1548
|
-
...loggerDependencies.map((token) => c.resolve(token)),
|
|
1549
|
-
...customLoggerFactories.map((factory) => factory(c))
|
|
1550
|
-
];
|
|
1551
|
-
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, resolvedDependencies);
|
|
1535
|
+
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, loggerDependencies);
|
|
1552
1536
|
});
|
|
1553
1537
|
}
|
|
1554
1538
|
});
|
|
@@ -1708,8 +1692,8 @@ var init_cache_utils = __esm({
|
|
|
1708
1692
|
* @link https://github.com/xeno-js/xeno-js
|
|
1709
1693
|
*/
|
|
1710
1694
|
async addCache(container, opts) {
|
|
1711
|
-
const { Guards:
|
|
1712
|
-
if (!opts.inMemory && !
|
|
1695
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
1696
|
+
if (!opts.inMemory && !Guards46.isDefined(opts.redis)) {
|
|
1713
1697
|
throw new Error(
|
|
1714
1698
|
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
1715
1699
|
);
|
|
@@ -1719,12 +1703,12 @@ var init_cache_utils = __esm({
|
|
|
1719
1703
|
TOKENS4.CACHE_KEY_BUILDER,
|
|
1720
1704
|
(c) => new CacheKeyBuilder(c.resolve(TOKENS4.IDENTITY_ACCESSOR))
|
|
1721
1705
|
);
|
|
1722
|
-
if (opts.inMemory || !
|
|
1706
|
+
if (opts.inMemory || !Guards46.isDefined(opts.redis)) {
|
|
1723
1707
|
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
1724
1708
|
container.addSingleton(TOKENS4.CACHE, () => new InMemoryCacheExtended2());
|
|
1725
1709
|
return;
|
|
1726
1710
|
}
|
|
1727
|
-
if (
|
|
1711
|
+
if (Guards46.isDefined(opts.redis)) {
|
|
1728
1712
|
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
1729
1713
|
container.addSingleton(TOKENS4.CACHE, () => {
|
|
1730
1714
|
const config = opts.redis;
|
|
@@ -2655,7 +2639,9 @@ var init_supabase_factory = __esm({
|
|
|
2655
2639
|
container
|
|
2656
2640
|
}) {
|
|
2657
2641
|
if (!Guards33.isDefined(config.ssrOpts)) {
|
|
2658
|
-
throw new Error(
|
|
2642
|
+
throw new Error(
|
|
2643
|
+
"ISsrCookieHandler is required for @supabase/ssr initialization., Please provide it in the config object."
|
|
2644
|
+
);
|
|
2659
2645
|
}
|
|
2660
2646
|
const cookieService = config.ssrOpts(container);
|
|
2661
2647
|
const client = createServerClient(config.url, config.key, {
|
|
@@ -2718,10 +2704,6 @@ var init_user_context_factory = __esm({
|
|
|
2718
2704
|
});
|
|
2719
2705
|
|
|
2720
2706
|
// src/infrastructure/factories/zod-validator.factory.ts
|
|
2721
|
-
var zod_validator_factory_exports = {};
|
|
2722
|
-
__export(zod_validator_factory_exports, {
|
|
2723
|
-
ZodValidatorFactory: () => ZodValidatorFactory
|
|
2724
|
-
});
|
|
2725
2707
|
import { ZodValidatorService } from "@xeno-js/shared";
|
|
2726
2708
|
var ZodValidatorFactory;
|
|
2727
2709
|
var init_zod_validator_factory = __esm({
|
|
@@ -2798,97 +2780,57 @@ var init_auth_utils = __esm({
|
|
|
2798
2780
|
*/
|
|
2799
2781
|
async addAuthZ(container, opts) {
|
|
2800
2782
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2801
|
-
const pipelines = [];
|
|
2802
2783
|
const strategies = [];
|
|
2803
|
-
const { Guards:
|
|
2804
|
-
if (
|
|
2784
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
2785
|
+
if (Guards46.isDefined(opts.policies)) {
|
|
2805
2786
|
const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2806
|
-
container.addSingleton(TOKENS4.POLICY_REGISTRY, () => new PolicyRegistry2());
|
|
2807
2787
|
const policyRegistry = opts.policies;
|
|
2808
|
-
const registryInstance =
|
|
2788
|
+
const registryInstance = new PolicyRegistry2();
|
|
2789
|
+
const ctxAccessor = container.resolve(TOKENS4.CONTEXT_ACCESSOR);
|
|
2809
2790
|
const Policies = /* @__PURE__ */ new Set();
|
|
2810
2791
|
for (const [intent, policy] of Object.entries(policyRegistry)) {
|
|
2811
2792
|
const intentLower = intent.toLowerCase();
|
|
2812
2793
|
registryInstance.addPolicy(intentLower, policy);
|
|
2813
|
-
if (!
|
|
2794
|
+
if (!Guards46.isNullOrEmpty(policy.roles)) {
|
|
2814
2795
|
Policies.add("roles");
|
|
2815
2796
|
}
|
|
2816
|
-
if (!
|
|
2797
|
+
if (!Guards46.isNullOrEmpty(policy.permissions)) {
|
|
2817
2798
|
Policies.add("permissions");
|
|
2818
2799
|
}
|
|
2819
|
-
if (!
|
|
2800
|
+
if (!Guards46.isNullOrEmpty(policy.userId)) {
|
|
2820
2801
|
Policies.add("userId");
|
|
2821
2802
|
}
|
|
2822
|
-
if (!
|
|
2803
|
+
if (!Guards46.isNullOrEmpty(policy.tenantId)) {
|
|
2823
2804
|
Policies.add("tenantId");
|
|
2824
2805
|
}
|
|
2825
2806
|
}
|
|
2826
2807
|
if (Policies.has("roles")) {
|
|
2827
2808
|
const { RoleAuthorizationStrategy: RoleAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2828
|
-
|
|
2829
|
-
TOKENS4.ROLE_AUTHORIZATION_PIPELINE,
|
|
2830
|
-
(c) => new RoleAuthorizationStrategy2(
|
|
2831
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2832
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2833
|
-
)
|
|
2834
|
-
);
|
|
2835
|
-
strategies.push(TOKENS4.ROLE_AUTHORIZATION_PIPELINE);
|
|
2809
|
+
strategies.push(new RoleAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2836
2810
|
}
|
|
2837
2811
|
if (Policies.has("permissions")) {
|
|
2838
2812
|
const { PermissionAuthorizationStrategy: PermissionAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2839
|
-
|
|
2840
|
-
TOKENS4.PERMISSION_AUTHORIZATION_PIPELINE,
|
|
2841
|
-
(c) => new PermissionAuthorizationStrategy2(
|
|
2842
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2843
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2844
|
-
)
|
|
2845
|
-
);
|
|
2846
|
-
strategies.push(TOKENS4.PERMISSION_AUTHORIZATION_PIPELINE);
|
|
2813
|
+
strategies.push(new PermissionAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2847
2814
|
}
|
|
2848
2815
|
if (Policies.has("userId")) {
|
|
2849
2816
|
const { UserAuthorizationStrategy: UserAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2850
|
-
|
|
2851
|
-
TOKENS4.USER_AUTHORIZATION_PIPELINE,
|
|
2852
|
-
(c) => new UserAuthorizationStrategy2(
|
|
2853
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2854
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2855
|
-
)
|
|
2856
|
-
);
|
|
2857
|
-
strategies.push(TOKENS4.USER_AUTHORIZATION_PIPELINE);
|
|
2817
|
+
strategies.push(new UserAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2858
2818
|
}
|
|
2859
2819
|
if (Policies.has("tenantId")) {
|
|
2860
2820
|
const { TenantAuthorizationStrategy: TenantAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2861
|
-
|
|
2862
|
-
TOKENS4.TENANT_AUTHORIZATION_PIPELINE,
|
|
2863
|
-
(c) => new TenantAuthorizationStrategy2(
|
|
2864
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2865
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2866
|
-
)
|
|
2867
|
-
);
|
|
2868
|
-
strategies.push(TOKENS4.TENANT_AUTHORIZATION_PIPELINE);
|
|
2821
|
+
strategies.push(new TenantAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2869
2822
|
}
|
|
2870
2823
|
}
|
|
2871
|
-
if (!
|
|
2824
|
+
if (!Guards46.isNullOrEmpty(opts.customAuthorizationStrategy)) {
|
|
2872
2825
|
const customStrategies = opts.customAuthorizationStrategy;
|
|
2873
|
-
customStrategies.forEach((strategyToken
|
|
2874
|
-
if (
|
|
2875
|
-
|
|
2876
|
-
container.addSingleton(token, (c) => {
|
|
2877
|
-
return strategyToken(c);
|
|
2878
|
-
});
|
|
2879
|
-
strategies.push(token);
|
|
2826
|
+
customStrategies.forEach((strategyToken) => {
|
|
2827
|
+
if (Guards46.isDefined(strategyToken)) {
|
|
2828
|
+
strategies.push(strategyToken(container));
|
|
2880
2829
|
}
|
|
2881
2830
|
});
|
|
2882
2831
|
}
|
|
2883
2832
|
const { AuthorizationPipeline: AuthorizationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2884
|
-
|
|
2885
|
-
const resolvedStrategies = strategies.map(
|
|
2886
|
-
(strategy) => c.resolve(strategy)
|
|
2887
|
-
);
|
|
2888
|
-
return new AuthorizationPipeline2(resolvedStrategies);
|
|
2889
|
-
});
|
|
2890
|
-
pipelines.push(TOKENS4.AUTHORIZATION_PIPELINE);
|
|
2891
|
-
return pipelines;
|
|
2833
|
+
return new AuthorizationPipeline2(strategies);
|
|
2892
2834
|
},
|
|
2893
2835
|
/**
|
|
2894
2836
|
* @description Configures the authentication service and gatekeeper in the service container.
|
|
@@ -2905,22 +2847,13 @@ var init_auth_utils = __esm({
|
|
|
2905
2847
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2906
2848
|
const _t = opts;
|
|
2907
2849
|
const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2850
|
+
const factory = new SupabaseServerAuthFactory2();
|
|
2851
|
+
const supabase = factory.create({ config: opts, container });
|
|
2908
2852
|
container.addScoped(TOKENS4.AUTH_SERVICE, () => {
|
|
2909
|
-
|
|
2910
|
-
return factory.create({ config: opts, container });
|
|
2853
|
+
return supabase;
|
|
2911
2854
|
});
|
|
2912
2855
|
container.addSingleton(TOKENS4.BASE_AUTH_SERVICE, () => {
|
|
2913
|
-
|
|
2914
|
-
return factory.create({ config: opts, container });
|
|
2915
|
-
});
|
|
2916
|
-
const { ClaimsIdentityMapper: ClaimsIdentityMapper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2917
|
-
container.addSingleton(TOKENS4.CLAIMS_IDENTITY_MAPPER, () => new ClaimsIdentityMapper2());
|
|
2918
|
-
const { GateKeeper: GateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2919
|
-
container.addSingleton(TOKENS4.GATE_KEEPER, (c) => {
|
|
2920
|
-
return new GateKeeper2(
|
|
2921
|
-
c.resolve(TOKENS4.BASE_AUTH_SERVICE),
|
|
2922
|
-
c.resolve(TOKENS4.CLAIMS_IDENTITY_MAPPER)
|
|
2923
|
-
);
|
|
2856
|
+
return supabase;
|
|
2924
2857
|
});
|
|
2925
2858
|
}
|
|
2926
2859
|
});
|
|
@@ -3074,24 +3007,20 @@ var init_db_module = __esm({
|
|
|
3074
3007
|
"use strict";
|
|
3075
3008
|
DbModule = class {
|
|
3076
3009
|
async configure(container, opts) {
|
|
3077
|
-
const { Guards:
|
|
3010
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3078
3011
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3079
3012
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3080
3013
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
3081
|
-
|
|
3082
|
-
return new TransactionState2();
|
|
3083
|
-
});
|
|
3014
|
+
const ttx = new TransactionState2();
|
|
3084
3015
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3085
|
-
container.addScoped(TOKENS4.UNIT_OF_WORK, (
|
|
3086
|
-
const ttx = c.resolve(TOKENS4.TRANSACTION_STATE);
|
|
3016
|
+
container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
|
|
3087
3017
|
return new UnitOfWork2(db, ttx);
|
|
3088
3018
|
});
|
|
3089
|
-
container.addScoped(TOKENS4.DB_CONTEXT, (
|
|
3090
|
-
const ttx = c.resolve(TOKENS4.TRANSACTION_STATE);
|
|
3019
|
+
container.addScoped(TOKENS4.DB_CONTEXT, () => {
|
|
3091
3020
|
return new Proxy(db, {
|
|
3092
3021
|
get(_target, prop, receiver) {
|
|
3093
3022
|
const activeState = ttx.state;
|
|
3094
|
-
if (
|
|
3023
|
+
if (Guards46.isDefined(activeState)) {
|
|
3095
3024
|
if (prop === "transaction") {
|
|
3096
3025
|
return activeState.transaction.bind(activeState);
|
|
3097
3026
|
}
|
|
@@ -3128,14 +3057,14 @@ var init_http_utils = __esm({
|
|
|
3128
3057
|
*/
|
|
3129
3058
|
async addAxios(container, opts) {
|
|
3130
3059
|
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3131
|
-
const { Guards:
|
|
3132
|
-
if (!
|
|
3060
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3061
|
+
if (!Guards46.isDefined(opts.token)) {
|
|
3133
3062
|
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3134
3063
|
}
|
|
3135
3064
|
container.addSingleton(opts.token, () => {
|
|
3136
3065
|
const factory = new NodeAxiosFactory2();
|
|
3137
3066
|
const instance = factory.create(opts.client);
|
|
3138
|
-
if (!
|
|
3067
|
+
if (!Guards46.hasMethod(instance, "get") || !Guards46.hasMethod(instance, "post") || !Guards46.hasMethod(instance, "put") || !Guards46.hasMethod(instance, "patch") || !Guards46.hasMethod(instance, "delete")) {
|
|
3139
3068
|
throw new Error(
|
|
3140
3069
|
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3141
3070
|
);
|
|
@@ -3160,17 +3089,6 @@ var init_http_utils = __esm({
|
|
|
3160
3089
|
const factory = new CockatielResilienceFactory2();
|
|
3161
3090
|
return factory.create(opts);
|
|
3162
3091
|
});
|
|
3163
|
-
},
|
|
3164
|
-
async addAllowOrigin(container, opts) {
|
|
3165
|
-
const { Guards: Guards47 } = await import("@xeno-js/shared");
|
|
3166
|
-
if (Guards47.isNullOrEmpty(opts)) throw new Error("At least an allow origin must be passed");
|
|
3167
|
-
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3168
|
-
const { AllowOrigin: AllowOrigin2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
3169
|
-
const allowOrigin = [];
|
|
3170
|
-
opts.forEach((x) => {
|
|
3171
|
-
allowOrigin.push(x.trim().toLowerCase());
|
|
3172
|
-
});
|
|
3173
|
-
container.addSingleton(TOKENS4.ALLOW_ORIGIN, () => new AllowOrigin2(allowOrigin));
|
|
3174
3092
|
}
|
|
3175
3093
|
});
|
|
3176
3094
|
}
|
|
@@ -3179,10 +3097,9 @@ var init_http_utils = __esm({
|
|
|
3179
3097
|
// src/infrastructure/modules/http-core.module.ts
|
|
3180
3098
|
var http_core_module_exports = {};
|
|
3181
3099
|
__export(http_core_module_exports, {
|
|
3182
|
-
HttpCoreModule: () => HttpCoreModule
|
|
3183
|
-
HttpOriginModule: () => HttpOriginModule
|
|
3100
|
+
HttpCoreModule: () => HttpCoreModule
|
|
3184
3101
|
});
|
|
3185
|
-
var HttpCoreModule
|
|
3102
|
+
var HttpCoreModule;
|
|
3186
3103
|
var init_http_core_module = __esm({
|
|
3187
3104
|
"src/infrastructure/modules/http-core.module.ts"() {
|
|
3188
3105
|
"use strict";
|
|
@@ -3193,12 +3110,6 @@ var init_http_core_module = __esm({
|
|
|
3193
3110
|
await HttpUtils2.addResilience(container, opts.resilience);
|
|
3194
3111
|
}
|
|
3195
3112
|
};
|
|
3196
|
-
HttpOriginModule = class {
|
|
3197
|
-
async configure(container, opts) {
|
|
3198
|
-
const { HttpUtils: HttpUtils2 } = await Promise.resolve().then(() => (init_http_utils(), http_utils_exports));
|
|
3199
|
-
await HttpUtils2.addAllowOrigin(container, opts);
|
|
3200
|
-
}
|
|
3201
|
-
};
|
|
3202
3113
|
}
|
|
3203
3114
|
});
|
|
3204
3115
|
|
|
@@ -3223,53 +3134,32 @@ var init_validation_utils = __esm({
|
|
|
3223
3134
|
* @link https://github.com/xeno-js/xeno-js
|
|
3224
3135
|
*/
|
|
3225
3136
|
async addValidation(container, opts, logger) {
|
|
3226
|
-
const { Guards:
|
|
3227
|
-
if (!
|
|
3228
|
-
return
|
|
3137
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3138
|
+
if (!Guards46.isDefined(opts.zod) && Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3139
|
+
return;
|
|
3229
3140
|
}
|
|
3230
|
-
const pipelines = [];
|
|
3231
3141
|
const validationStrategies = [];
|
|
3232
|
-
if (
|
|
3142
|
+
if (Guards46.isDefined(opts.zod)) {
|
|
3233
3143
|
const config = opts.zod;
|
|
3234
|
-
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (
|
|
3235
|
-
container.addSingleton(TOKENS4.ZOD_VALIDATOR, () => {
|
|
3236
|
-
return new ZodValidatorFactory2().create({ ...config, logger });
|
|
3237
|
-
});
|
|
3144
|
+
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3238
3145
|
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
);
|
|
3243
|
-
validationStrategies.push(TOKENS4.SCHEMA_VALIDATION_STRATEGY);
|
|
3146
|
+
const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
|
|
3147
|
+
container.addSingleton(TOKENS4.VALIDATOR_SERVICE, () => validatorService);
|
|
3148
|
+
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
3244
3149
|
}
|
|
3245
|
-
|
|
3246
|
-
if (!Guards47.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3150
|
+
if (!Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3247
3151
|
for (const strategyToken of opts.customValidationStrategy) {
|
|
3248
|
-
if (
|
|
3249
|
-
customValidationFactory.push(strategyToken);
|
|
3250
|
-
}
|
|
3152
|
+
if (Guards46.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
3251
3153
|
}
|
|
3252
3154
|
}
|
|
3253
3155
|
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3254
|
-
|
|
3255
|
-
const resolvedStrategies = [
|
|
3256
|
-
...validationStrategies.map((token) => c.resolve(token)),
|
|
3257
|
-
...customValidationFactory.map((factory) => factory(c))
|
|
3258
|
-
];
|
|
3259
|
-
return new ValidationPipeline2(resolvedStrategies);
|
|
3260
|
-
});
|
|
3261
|
-
pipelines.push(TOKENS4.VALIDATION_PIPELINE);
|
|
3262
|
-
return pipelines;
|
|
3156
|
+
return new ValidationPipeline2(validationStrategies);
|
|
3263
3157
|
}
|
|
3264
3158
|
});
|
|
3265
3159
|
}
|
|
3266
3160
|
});
|
|
3267
3161
|
|
|
3268
3162
|
// src/infrastructure/idempotency/idempotency-store.ts
|
|
3269
|
-
var idempotency_store_exports = {};
|
|
3270
|
-
__export(idempotency_store_exports, {
|
|
3271
|
-
IdempotencyStore: () => IdempotencyStore
|
|
3272
|
-
});
|
|
3273
3163
|
import { IDEMPOTENCY_CONSTANTS as IDEMPOTENCY_CONSTANTS2 } from "@xeno-js/shared";
|
|
3274
3164
|
var IdempotencyStore;
|
|
3275
3165
|
var init_idempotency_store = __esm({
|
|
@@ -3326,6 +3216,18 @@ var init_idempotency_store = __esm({
|
|
|
3326
3216
|
}
|
|
3327
3217
|
});
|
|
3328
3218
|
|
|
3219
|
+
// src/infrastructure/idempotency/index.ts
|
|
3220
|
+
var idempotency_exports = {};
|
|
3221
|
+
__export(idempotency_exports, {
|
|
3222
|
+
IdempotencyStore: () => IdempotencyStore
|
|
3223
|
+
});
|
|
3224
|
+
var init_idempotency = __esm({
|
|
3225
|
+
"src/infrastructure/idempotency/index.ts"() {
|
|
3226
|
+
"use strict";
|
|
3227
|
+
init_idempotency_store();
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
|
|
3329
3231
|
// src/infrastructure/modules/utils/pipeline.utils.ts
|
|
3330
3232
|
var pipeline_utils_exports = {};
|
|
3331
3233
|
__export(pipeline_utils_exports, {
|
|
@@ -3347,35 +3249,30 @@ var init_pipeline_utils = __esm({
|
|
|
3347
3249
|
* @link https://github.com/xeno-js/xeno-js
|
|
3348
3250
|
*/
|
|
3349
3251
|
async addCommand(container, opts) {
|
|
3252
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3350
3253
|
const pipelines = [];
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3355
|
-
TOKENS4.
|
|
3356
|
-
(c) => new IdempotencyStore2(c.resolve(TOKENS4.CACHE), c.resolve(TOKENS4.CACHE_KEY_BUILDER))
|
|
3254
|
+
if (Guards46.isDefined(opts.idempotency)) {
|
|
3255
|
+
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
3256
|
+
const imdStore = new IdempotencyStore2(
|
|
3257
|
+
container.resolve(TOKENS4.CACHE),
|
|
3258
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER)
|
|
3357
3259
|
);
|
|
3358
3260
|
const { IdempotencyPipeline: IdempotencyPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3359
|
-
container.
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
return new IdempotencyPipeline2(
|
|
3261
|
+
const requestContext = container.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR);
|
|
3262
|
+
const config = opts.idempotency;
|
|
3263
|
+
pipelines.push(
|
|
3264
|
+
new IdempotencyPipeline2(
|
|
3364
3265
|
requestContext,
|
|
3365
|
-
|
|
3266
|
+
imdStore,
|
|
3366
3267
|
config?.lockTtlSeconds,
|
|
3367
3268
|
config?.processedTtlSeconds
|
|
3368
|
-
)
|
|
3369
|
-
|
|
3370
|
-
pipelines.push(TOKENS4.IDEMPOTENCY_PIPELINE);
|
|
3269
|
+
)
|
|
3270
|
+
);
|
|
3371
3271
|
}
|
|
3372
|
-
if (
|
|
3272
|
+
if (Guards46.isDefined(opts.concurrency)) {
|
|
3373
3273
|
const { ConcurrencyRetryPipeline: ConcurrencyRetryPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
return new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig);
|
|
3377
|
-
});
|
|
3378
|
-
pipelines.push(TOKENS4.CONCURRENCY_RETRY_PIPELINE);
|
|
3274
|
+
const config = opts.concurrency;
|
|
3275
|
+
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
3379
3276
|
}
|
|
3380
3277
|
return pipelines;
|
|
3381
3278
|
},
|
|
@@ -3389,24 +3286,14 @@ var init_pipeline_utils = __esm({
|
|
|
3389
3286
|
* @since 2025-09-30
|
|
3390
3287
|
* @link https://github.com/xeno-js/xeno-js
|
|
3391
3288
|
*/
|
|
3392
|
-
async addQuery(container
|
|
3289
|
+
async addQuery(container) {
|
|
3393
3290
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3394
|
-
const pipelines = [];
|
|
3395
|
-
if (!opts.isCache) {
|
|
3396
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
3397
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
3398
|
-
}
|
|
3399
3291
|
const { QueryCachingPipeline: QueryCachingPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3400
|
-
|
|
3401
|
-
TOKENS4.
|
|
3402
|
-
(
|
|
3403
|
-
|
|
3404
|
-
c.resolve(TOKENS4.CACHE_KEY_BUILDER),
|
|
3405
|
-
c.resolve(TOKENS4.LOGGER)
|
|
3406
|
-
)
|
|
3292
|
+
return new QueryCachingPipeline2(
|
|
3293
|
+
container.resolve(TOKENS4.CACHE),
|
|
3294
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER),
|
|
3295
|
+
container.resolve(TOKENS4.LOGGER)
|
|
3407
3296
|
);
|
|
3408
|
-
pipelines.push(TOKENS4.QUERY_CACHING_PIPELINE);
|
|
3409
|
-
return pipelines;
|
|
3410
3297
|
}
|
|
3411
3298
|
});
|
|
3412
3299
|
}
|
|
@@ -3424,79 +3311,54 @@ var init_cqrs_module = __esm({
|
|
|
3424
3311
|
CqrsModule = class {
|
|
3425
3312
|
async configure(container, opts) {
|
|
3426
3313
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3427
|
-
|
|
3314
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3428
3315
|
const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3429
3316
|
container.addSingleton(TOKENS4.MEDIATOR, (c) => {
|
|
3430
3317
|
const serviceScopeAccessor = c.resolve(TOKENS4.SERVICE_SCOPE_ACCESSOR);
|
|
3431
3318
|
return new Mediator2(serviceScopeAccessor);
|
|
3432
3319
|
});
|
|
3433
3320
|
const { ExceptionPipeline: ExceptionPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3434
|
-
container.addSingleton(TOKENS4.EXCEPTION_PIPELINE, () => new ExceptionPipeline2());
|
|
3435
|
-
if (!opts.isLogger) {
|
|
3436
|
-
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
3437
|
-
await LoggerUtils2.addLogger(container, void 0);
|
|
3438
|
-
}
|
|
3439
3321
|
const { LoggingPipeline: LoggingPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3440
|
-
container.addSingleton(
|
|
3441
|
-
TOKENS4.LOGGING_PIPELINE,
|
|
3442
|
-
(c) => new LoggingPipeline2(c.resolve(TOKENS4.LOGGER))
|
|
3443
|
-
);
|
|
3444
|
-
const pipelines = [TOKENS4.EXCEPTION_PIPELINE, TOKENS4.LOGGING_PIPELINE];
|
|
3445
3322
|
const { PerformancePipeline: PerformancePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
const { Guards:
|
|
3453
|
-
if (
|
|
3323
|
+
const thresholdMs = opts.performance?.thresholdMs;
|
|
3324
|
+
const pipelines = [
|
|
3325
|
+
new ExceptionPipeline2(),
|
|
3326
|
+
new LoggingPipeline2(logger),
|
|
3327
|
+
new PerformancePipeline2(logger, thresholdMs)
|
|
3328
|
+
];
|
|
3329
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3330
|
+
if (Guards46.isDefined(opts.authorization.policies) || Guards46.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3454
3331
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3455
3332
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3456
|
-
pipelines.push(
|
|
3333
|
+
pipelines.push(authPipelines);
|
|
3457
3334
|
}
|
|
3458
|
-
if (
|
|
3335
|
+
if (Guards46.isDefined(opts.validation.zod) || Guards46.isDefined(opts.validation.customValidationStrategy)) {
|
|
3459
3336
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3460
|
-
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3461
3337
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3462
3338
|
container,
|
|
3463
3339
|
opts.validation,
|
|
3464
3340
|
logger
|
|
3465
3341
|
);
|
|
3466
|
-
pipelines.push(
|
|
3342
|
+
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3467
3343
|
}
|
|
3468
3344
|
const commandPipelines = pipelines;
|
|
3469
3345
|
const queryPipelines = pipelines;
|
|
3470
|
-
if (
|
|
3471
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
3472
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
3473
|
-
}
|
|
3474
|
-
if (Guards47.isDefined(opts.commandBus.idempotency) || Guards47.isDefined(opts.commandBus.concurrency)) {
|
|
3346
|
+
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3475
3347
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3476
|
-
const newCommandPipelines = await PipelineUtils2.addCommand(container,
|
|
3477
|
-
...opts.commandBus,
|
|
3478
|
-
isCache
|
|
3479
|
-
});
|
|
3480
|
-
isCache = true;
|
|
3348
|
+
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3481
3349
|
commandPipelines.push(...newCommandPipelines);
|
|
3482
3350
|
}
|
|
3483
3351
|
if (opts.queryBus.isEnabled) {
|
|
3484
3352
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3485
|
-
const newQueryPipelines = await PipelineUtils2.addQuery(container
|
|
3486
|
-
queryPipelines.push(
|
|
3353
|
+
const newQueryPipelines = await PipelineUtils2.addQuery(container);
|
|
3354
|
+
queryPipelines.push(newQueryPipelines);
|
|
3487
3355
|
}
|
|
3488
3356
|
const { CompositePipeline: CompositePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3489
|
-
container.addSingleton(TOKENS4.COMMAND_PIPELINES_BEHAVIOR, (
|
|
3490
|
-
|
|
3491
|
-
return c.resolve(token);
|
|
3492
|
-
});
|
|
3493
|
-
return new CompositePipeline2(resolvedCommandPipelines);
|
|
3357
|
+
container.addSingleton(TOKENS4.COMMAND_PIPELINES_BEHAVIOR, () => {
|
|
3358
|
+
return new CompositePipeline2(commandPipelines);
|
|
3494
3359
|
});
|
|
3495
|
-
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, (
|
|
3496
|
-
|
|
3497
|
-
(token) => c.resolve(token)
|
|
3498
|
-
);
|
|
3499
|
-
return new CompositePipeline2(resolvedQueryPipelines);
|
|
3360
|
+
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, () => {
|
|
3361
|
+
return new CompositePipeline2(queryPipelines);
|
|
3500
3362
|
});
|
|
3501
3363
|
}
|
|
3502
3364
|
};
|
|
@@ -4313,150 +4175,111 @@ var middleware_module_exports = {};
|
|
|
4313
4175
|
__export(middleware_module_exports, {
|
|
4314
4176
|
MiddlewareModule: () => MiddlewareModule
|
|
4315
4177
|
});
|
|
4316
|
-
import { Guards as Guards43 } from "@xeno-js/shared";
|
|
4317
4178
|
var MiddlewareModule;
|
|
4318
4179
|
var init_middleware_module = __esm({
|
|
4319
4180
|
"src/infrastructure/modules/middleware.module.ts"() {
|
|
4320
4181
|
"use strict";
|
|
4321
4182
|
MiddlewareModule = class {
|
|
4322
4183
|
async configure(container, opts) {
|
|
4323
|
-
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4324
|
-
if (!opts.isAuth) {
|
|
4325
|
-
const { NoAuthGateKeeper: NoAuthGateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4326
|
-
container.addSingleton(TOKENS4.GATE_KEEPER, () => new NoAuthGateKeeper2());
|
|
4327
|
-
}
|
|
4328
|
-
if (opts.isSSR) {
|
|
4329
|
-
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4330
|
-
container.addSingleton(TOKENS4.BEARER_TOKEN_EXTRACTOR, () => new SupabaseSsrTokenExtractor2());
|
|
4331
|
-
} else {
|
|
4332
|
-
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4333
|
-
container.addSingleton(TOKENS4.BEARER_TOKEN_EXTRACTOR, () => new BearerTokenExtractor2());
|
|
4334
|
-
}
|
|
4184
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4335
4185
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4336
|
-
container.addSingleton("COOKIE_EXTRACTOR", () => new HttpCookieExtractor2());
|
|
4337
4186
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4187
|
+
const tokenExtractor = await this._getTokenExtractor(opts.isSSR);
|
|
4338
4188
|
container.addSingleton(
|
|
4339
4189
|
TOKENS4.SERVICE_EXTRACTOR,
|
|
4340
|
-
(
|
|
4341
|
-
|
|
4342
|
-
|
|
4190
|
+
() => new HttpHeaderExtractor2(
|
|
4191
|
+
tokenExtractor,
|
|
4192
|
+
new HttpCookieExtractor2(),
|
|
4343
4193
|
opts.trustedIpHeader,
|
|
4344
4194
|
opts.csrf?.cookieName ?? "__Host-xeno-csrf"
|
|
4345
4195
|
)
|
|
4346
4196
|
);
|
|
4347
|
-
if (!opts.isLogger) {
|
|
4348
|
-
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
4349
|
-
await LoggerUtils2.addLogger(container, void 0);
|
|
4350
|
-
}
|
|
4351
4197
|
const { ClientIpResolver: ClientIpResolver2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4352
|
-
|
|
4353
|
-
const
|
|
4198
|
+
const middlewares = [];
|
|
4199
|
+
const requestContext = container.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4200
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
4354
4201
|
const { RequestContextMiddleware: RequestContextMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
c.resolve(TOKENS4.LOGGER)
|
|
4202
|
+
middlewares.push(
|
|
4203
|
+
new RequestContextMiddleware2(
|
|
4204
|
+
requestContext,
|
|
4205
|
+
container.resolve(TOKENS4.SERVICE_EXTRACTOR),
|
|
4206
|
+
new ClientIpResolver2(opts.trustedProxies),
|
|
4207
|
+
logger
|
|
4362
4208
|
)
|
|
4363
4209
|
);
|
|
4364
|
-
if (!
|
|
4210
|
+
if (!Guards46.isNullOrEmpty(opts.allowOrigins)) {
|
|
4365
4211
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4366
4212
|
throw new Error(
|
|
4367
4213
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
4368
4214
|
);
|
|
4369
4215
|
const { AllowOrigin: AllowOrigin2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4370
|
-
container.addSingleton("ALLOW_ORIGIN", () => {
|
|
4371
|
-
return new AllowOrigin2(opts.allowOrigins);
|
|
4372
|
-
});
|
|
4373
4216
|
const { AllowOriginMiddleware: AllowOriginMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR),
|
|
4378
|
-
c.resolve(TOKENS4.LOGGER)
|
|
4379
|
-
);
|
|
4380
|
-
});
|
|
4381
|
-
middlewares.push(TOKENS4.ALLOW_ORIGIN_MIDDLEWARE);
|
|
4217
|
+
middlewares.push(
|
|
4218
|
+
new AllowOriginMiddleware2(new AllowOrigin2(opts.allowOrigins), requestContext, logger)
|
|
4219
|
+
);
|
|
4382
4220
|
}
|
|
4383
4221
|
const withCredentials = opts.withCredentials ? "true" : "false";
|
|
4222
|
+
const allowMethod = await this._getAllowMethod(
|
|
4223
|
+
opts.optionsMiddleware || opts.cors,
|
|
4224
|
+
opts.routeRegistry
|
|
4225
|
+
);
|
|
4384
4226
|
if (opts.optionsMiddleware) {
|
|
4385
4227
|
const { OptionsMiddleware: OptionsMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
(c) => new OptionsMiddleware2(
|
|
4389
|
-
c.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR),
|
|
4390
|
-
c.resolve(TOKENS4.ALLOW_METHOD),
|
|
4391
|
-
opts.allowHeaders,
|
|
4392
|
-
withCredentials
|
|
4393
|
-
)
|
|
4228
|
+
middlewares.push(
|
|
4229
|
+
new OptionsMiddleware2(requestContext, allowMethod, opts.allowHeaders, withCredentials)
|
|
4394
4230
|
);
|
|
4395
|
-
middlewares.push(TOKENS4.OPTIONS_MIDDLEWARE);
|
|
4396
4231
|
}
|
|
4397
4232
|
if (opts.cors) {
|
|
4398
4233
|
const { CORSMiddleware: CORSMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4399
|
-
|
|
4400
|
-
return new CORSMiddleware2(c.resolve(TOKENS4.CONTEXT_ACCESSOR), withCredentials);
|
|
4401
|
-
});
|
|
4402
|
-
middlewares.push(TOKENS4.CORS_MIDDLEWARE);
|
|
4234
|
+
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4403
4235
|
}
|
|
4404
|
-
if (
|
|
4405
|
-
const registry = opts.routeRegistry;
|
|
4406
|
-
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4407
|
-
container.addSingleton(TOKENS4.ALLOW_METHOD, () => new AllowMethodFactory2().create(registry));
|
|
4236
|
+
if (Guards46.isDefined(opts.routeRegistry)) {
|
|
4408
4237
|
const { MethodCheckMiddleware: MethodCheckMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4409
|
-
|
|
4410
|
-
TOKENS4.METHOD_CHECK_MIDDLEWARE,
|
|
4411
|
-
(c) => new MethodCheckMiddleware2(
|
|
4412
|
-
c.resolve(TOKENS4.REQUEST_CONTEXT),
|
|
4413
|
-
c.resolve(TOKENS4.ALLOW_METHOD)
|
|
4414
|
-
)
|
|
4415
|
-
);
|
|
4416
|
-
middlewares.push(TOKENS4.METHOD_CHECK_MIDDLEWARE);
|
|
4238
|
+
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4417
4239
|
}
|
|
4418
4240
|
const { AuthenticationMiddleware: AuthenticationMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4241
|
+
if (!opts.isAuth) {
|
|
4242
|
+
const { NoAuthGateKeeper: NoAuthGateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4243
|
+
middlewares.push(
|
|
4244
|
+
new AuthenticationMiddleware2(
|
|
4245
|
+
requestContext,
|
|
4246
|
+
tokenExtractor,
|
|
4247
|
+
new NoAuthGateKeeper2(),
|
|
4248
|
+
logger
|
|
4249
|
+
)
|
|
4425
4250
|
);
|
|
4426
|
-
}
|
|
4427
|
-
|
|
4428
|
-
|
|
4251
|
+
} else {
|
|
4252
|
+
const { ClaimsIdentityMapper: ClaimsIdentityMapper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4253
|
+
const { GateKeeper: GateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4254
|
+
middlewares.push(
|
|
4255
|
+
new AuthenticationMiddleware2(
|
|
4256
|
+
requestContext,
|
|
4257
|
+
tokenExtractor,
|
|
4258
|
+
new GateKeeper2(container.resolve(TOKENS4.BASE_AUTH_SERVICE), new ClaimsIdentityMapper2()),
|
|
4259
|
+
logger
|
|
4260
|
+
)
|
|
4261
|
+
);
|
|
4262
|
+
}
|
|
4263
|
+
if (Guards46.isDefined(opts.rateLimite.maxRequests) || Guards46.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4429
4264
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4430
|
-
|
|
4431
|
-
|
|
4265
|
+
Guards46.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4266
|
+
Guards46.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4432
4267
|
const windowSeconds = opts.rateLimite.windowSeconds ?? 30;
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
if (!opts.isCache) {
|
|
4436
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
4437
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
4438
|
-
}
|
|
4268
|
+
Guards46.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4269
|
+
Guards46.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4439
4270
|
const { RateLimitKeyBuilder: RateLimitKeyBuilder2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
4440
|
-
container.addSingleton(
|
|
4441
|
-
"RATE_LIMIT_KEY_BUILDER",
|
|
4442
|
-
(c) => new RateLimitKeyBuilder2(c.resolve(TOKENS4.REQUEST_CONTEXT))
|
|
4443
|
-
);
|
|
4444
4271
|
const { RateLimitMiddleware: RateLimitMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
{
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
}
|
|
4455
|
-
);
|
|
4456
|
-
});
|
|
4457
|
-
middlewares.push(TOKENS4.RATE_LIMITER_MIDDLEWARE);
|
|
4272
|
+
middlewares.push(
|
|
4273
|
+
new RateLimitMiddleware2(
|
|
4274
|
+
requestContext,
|
|
4275
|
+
container.resolve(TOKENS4.CACHE),
|
|
4276
|
+
new RateLimitKeyBuilder2(requestContext),
|
|
4277
|
+
logger,
|
|
4278
|
+
{ maxRequests, windowSeconds }
|
|
4279
|
+
)
|
|
4280
|
+
);
|
|
4458
4281
|
}
|
|
4459
|
-
if (
|
|
4282
|
+
if (Guards46.isDefined(opts.csrf)) {
|
|
4460
4283
|
const csrf = opts.csrf;
|
|
4461
4284
|
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4462
4285
|
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
@@ -4465,31 +4288,36 @@ var init_middleware_module = __esm({
|
|
|
4465
4288
|
return new CsrfTokenService2(csrf.secret, c.resolve("CRYPTO_SERVICE"));
|
|
4466
4289
|
});
|
|
4467
4290
|
const { CsrfCookieMiddleware: CsrfCookieMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
csrf
|
|
4473
|
-
)
|
|
4474
|
-
|
|
4475
|
-
middlewares.push("CSRF_COOKIE_MIDDLEWARE");
|
|
4291
|
+
middlewares.push(
|
|
4292
|
+
new CsrfCookieMiddleware2(
|
|
4293
|
+
requestContext,
|
|
4294
|
+
container.resolve("CSRF_TOKEN_SERVICE"),
|
|
4295
|
+
opts.csrf
|
|
4296
|
+
)
|
|
4297
|
+
);
|
|
4476
4298
|
const { CsrfMiddleware: CsrfMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4477
|
-
|
|
4478
|
-
return new CsrfMiddleware2(
|
|
4479
|
-
c.resolve(TOKENS4.REQUEST_CONTEXT),
|
|
4480
|
-
c.resolve("CSRF_TOKEN_SERVICE")
|
|
4481
|
-
);
|
|
4482
|
-
});
|
|
4483
|
-
middlewares.push(TOKENS4.CSRF_MIDDLEWARE);
|
|
4299
|
+
middlewares.push(new CsrfMiddleware2(requestContext, container.resolve("CSRF_TOKEN_SERVICE")));
|
|
4484
4300
|
}
|
|
4485
4301
|
const { CompositeMiddleware: CompositeMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4486
|
-
container.addSingleton(TOKENS4.MIDDLEWARE, (
|
|
4487
|
-
|
|
4488
|
-
(token) => c.resolve(token)
|
|
4489
|
-
);
|
|
4490
|
-
return new CompositeMiddleware2(resolvedMiddleware);
|
|
4302
|
+
container.addSingleton(TOKENS4.MIDDLEWARE, () => {
|
|
4303
|
+
return new CompositeMiddleware2(middlewares);
|
|
4491
4304
|
});
|
|
4492
4305
|
}
|
|
4306
|
+
async _getTokenExtractor(isSSR) {
|
|
4307
|
+
if (isSSR) {
|
|
4308
|
+
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4309
|
+
return new SupabaseSsrTokenExtractor2();
|
|
4310
|
+
} else {
|
|
4311
|
+
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4312
|
+
return new BearerTokenExtractor2();
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
async _getAllowMethod(configure, opts) {
|
|
4316
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
4317
|
+
if (!configure || !Guards46.isDefined(opts)) return void 0;
|
|
4318
|
+
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4319
|
+
return new AllowMethodFactory2().create(opts);
|
|
4320
|
+
}
|
|
4493
4321
|
};
|
|
4494
4322
|
}
|
|
4495
4323
|
});
|
|
@@ -4507,26 +4335,17 @@ var init_context_module = __esm({
|
|
|
4507
4335
|
async configure(container) {
|
|
4508
4336
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4509
4337
|
const { ServiceScopeFactory: ServiceScopeFactory2 } = await Promise.resolve().then(() => (init_service_scope_factory(), service_scope_factory_exports));
|
|
4510
|
-
container.addSingleton(TOKENS4.SERVICE_SCOPE_FACTORY, () => {
|
|
4511
|
-
const factory = new ServiceScopeFactory2(container);
|
|
4512
|
-
return factory;
|
|
4513
|
-
});
|
|
4514
4338
|
const { NodeRequestContextFactory: NodeRequestContextFactory2 } = await Promise.resolve().then(() => (init_request_context_factory(), request_context_factory_exports));
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
container.addSingleton(TOKENS4.
|
|
4521
|
-
container.addSingleton(TOKENS4.
|
|
4522
|
-
container.addSingleton(TOKENS4.
|
|
4523
|
-
container.addSingleton(
|
|
4524
|
-
TOKENS4.NETWORK_CONTEXT_ACCESSOR,
|
|
4525
|
-
(c) => c.resolve(TOKENS4.REQUEST_CONTEXT)
|
|
4526
|
-
);
|
|
4339
|
+
const requestContext = new NodeRequestContextFactory2(
|
|
4340
|
+
new ServiceScopeFactory2(container)
|
|
4341
|
+
).create();
|
|
4342
|
+
container.addSingleton(TOKENS4.REQUEST_CONTEXT, () => requestContext);
|
|
4343
|
+
container.addSingleton(TOKENS4.CONTEXT_ACCESSOR, () => requestContext);
|
|
4344
|
+
container.addSingleton(TOKENS4.IDENTITY_ACCESSOR, () => requestContext);
|
|
4345
|
+
container.addSingleton(TOKENS4.SERVICE_SCOPE_ACCESSOR, () => requestContext);
|
|
4346
|
+
container.addSingleton(TOKENS4.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
|
|
4527
4347
|
const { UserContextFactory: UserContextFactory2 } = await Promise.resolve().then(() => (init_user_context_factory(), user_context_factory_exports));
|
|
4528
|
-
container.addSingleton(
|
|
4529
|
-
const requestContext = c.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4348
|
+
container.addSingleton("USER_CONTEXT_FACTORY", () => {
|
|
4530
4349
|
return new UserContextFactory2(requestContext);
|
|
4531
4350
|
});
|
|
4532
4351
|
}
|
|
@@ -4553,7 +4372,7 @@ __export(index_exports, {
|
|
|
4553
4372
|
init_application();
|
|
4554
4373
|
|
|
4555
4374
|
// src/infrastructure/builder/app.builder.ts
|
|
4556
|
-
import { Guards as
|
|
4375
|
+
import { Guards as Guards43, LOG_LEVEL as LOG_LEVEL6, TOKENS as TOKENS3 } from "@xeno-js/shared";
|
|
4557
4376
|
|
|
4558
4377
|
// src/infrastructure/configuration/configuration.ts
|
|
4559
4378
|
import { Guards as Guards13 } from "@xeno-js/shared";
|
|
@@ -4887,6 +4706,13 @@ var AppBuilder = class {
|
|
|
4887
4706
|
},
|
|
4888
4707
|
resilience: { retry: {}, circuitBreaker: {}, bulkhead: {} }
|
|
4889
4708
|
};
|
|
4709
|
+
_loggerConfig = {
|
|
4710
|
+
level: LOG_LEVEL6.DEBUG,
|
|
4711
|
+
console: true,
|
|
4712
|
+
sentry: { config: void 0 },
|
|
4713
|
+
pino: { config: void 0 },
|
|
4714
|
+
customLoggers: void 0
|
|
4715
|
+
};
|
|
4890
4716
|
// --- Module Queuing Flags ---
|
|
4891
4717
|
_isContextModuleQueued = false;
|
|
4892
4718
|
_isMiddlewareModuleQueued = false;
|
|
@@ -4932,31 +4758,22 @@ var AppBuilder = class {
|
|
|
4932
4758
|
* @description Configures the logger for the application. This method allows you to set up logging options such as log level, console logging, and integration with external logging services like Sentry or Pino.
|
|
4933
4759
|
* @param setupAction A callback function that receives a LoggerConfig object to configure the logger settings.
|
|
4934
4760
|
* @returns The current instance of AppBuilder for method chaining.
|
|
4935
|
-
|
|
4936
|
-
*
|
|
4761
|
+
*
|
|
4937
4762
|
* @author Xeno
|
|
4938
4763
|
* @version 1.0.0
|
|
4939
4764
|
* @since 2025-09-30
|
|
4940
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
4765
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4941
4766
|
*/
|
|
4942
4767
|
addLogger(setupAction) {
|
|
4768
|
+
if (Guards43.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
4943
4769
|
if (this._isLoggerModuleQueued) return this;
|
|
4944
4770
|
this._isLoggerModuleQueued = true;
|
|
4945
|
-
const config = {
|
|
4946
|
-
level: LOG_LEVEL6.DEBUG,
|
|
4947
|
-
console: true,
|
|
4948
|
-
sentry: { config: void 0 },
|
|
4949
|
-
pino: { config: void 0 },
|
|
4950
|
-
customLoggers: void 0
|
|
4951
|
-
};
|
|
4952
|
-
if (Guards44.isDefined(setupAction) && Guards44.isDefined(config))
|
|
4953
|
-
setupAction(config, this._configuration);
|
|
4954
4771
|
this._modules.push({
|
|
4955
|
-
priority:
|
|
4772
|
+
priority: 1,
|
|
4956
4773
|
name: "LoggerModule",
|
|
4957
4774
|
action: async () => {
|
|
4958
4775
|
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
4959
|
-
await LoggerUtils2.addLogger(this._container,
|
|
4776
|
+
await LoggerUtils2.addLogger(this._container, this._loggerConfig);
|
|
4960
4777
|
}
|
|
4961
4778
|
});
|
|
4962
4779
|
return this;
|
|
@@ -4973,11 +4790,11 @@ var AppBuilder = class {
|
|
|
4973
4790
|
* @link https://github.com/xeno-js/xeno-js
|
|
4974
4791
|
*/
|
|
4975
4792
|
addCache(setupAction) {
|
|
4793
|
+
if (Guards43.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4976
4794
|
if (this._isCacheModuleQueued) return this;
|
|
4977
4795
|
this._isCacheModuleQueued = true;
|
|
4978
|
-
if (Guards44.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4979
4796
|
this._modules.push({
|
|
4980
|
-
priority:
|
|
4797
|
+
priority: 2,
|
|
4981
4798
|
name: "CacheModule",
|
|
4982
4799
|
action: async () => {
|
|
4983
4800
|
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
@@ -5010,7 +4827,7 @@ var AppBuilder = class {
|
|
|
5010
4827
|
};
|
|
5011
4828
|
setupAction(config, this._configuration);
|
|
5012
4829
|
this._modules.push({
|
|
5013
|
-
priority:
|
|
4830
|
+
priority: 3,
|
|
5014
4831
|
name: "AuthModule",
|
|
5015
4832
|
action: async () => {
|
|
5016
4833
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
@@ -5084,7 +4901,7 @@ var AppBuilder = class {
|
|
|
5084
4901
|
* @link https://github.com/xeno-js/xeno-js
|
|
5085
4902
|
*/
|
|
5086
4903
|
addPipeline(setupAction) {
|
|
5087
|
-
if (
|
|
4904
|
+
if (Guards43.isDefined(setupAction)) {
|
|
5088
4905
|
setupAction(this._pipelineConfig, this._configuration);
|
|
5089
4906
|
}
|
|
5090
4907
|
this._queuePipelineModule();
|
|
@@ -5117,20 +4934,6 @@ var AppBuilder = class {
|
|
|
5117
4934
|
});
|
|
5118
4935
|
return this;
|
|
5119
4936
|
}
|
|
5120
|
-
addAllowOrigin(setupAction) {
|
|
5121
|
-
const config = [];
|
|
5122
|
-
setupAction(config, this._configuration);
|
|
5123
|
-
this._modules.push({
|
|
5124
|
-
priority: 30,
|
|
5125
|
-
name: "HttpCoreModule",
|
|
5126
|
-
action: async () => {
|
|
5127
|
-
const { HttpOriginModule: HttpOriginModule2 } = await Promise.resolve().then(() => (init_http_core_module(), http_core_module_exports));
|
|
5128
|
-
const httpOriginModule = new HttpOriginModule2();
|
|
5129
|
-
await httpOriginModule.configure(this._container, config);
|
|
5130
|
-
}
|
|
5131
|
-
});
|
|
5132
|
-
return this;
|
|
5133
|
-
}
|
|
5134
4937
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5135
4938
|
// Dependency Injection Pass-through Methods
|
|
5136
4939
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -5218,7 +5021,7 @@ var AppBuilder = class {
|
|
|
5218
5021
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5219
5022
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5220
5023
|
`);
|
|
5221
|
-
if (error instanceof Error &&
|
|
5024
|
+
if (error instanceof Error && Guards43.isDefined(error.stack)) {
|
|
5222
5025
|
console.error(error.stack);
|
|
5223
5026
|
}
|
|
5224
5027
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5243,17 +5046,15 @@ var AppBuilder = class {
|
|
|
5243
5046
|
if (this._isPipelineModuleQueued) return;
|
|
5244
5047
|
this._isPipelineModuleQueued = true;
|
|
5245
5048
|
this._queueContextModule();
|
|
5049
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
5050
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5246
5051
|
this._modules.push({
|
|
5247
5052
|
priority: 5,
|
|
5248
5053
|
name: "CqrsModule",
|
|
5249
5054
|
action: async () => {
|
|
5250
5055
|
const { CqrsModule: CqrsModule2 } = await Promise.resolve().then(() => (init_cqrs_module(), cqrs_module_exports));
|
|
5251
5056
|
const pipelineModule = new CqrsModule2();
|
|
5252
|
-
await pipelineModule.configure(this._container,
|
|
5253
|
-
...this._pipelineConfig,
|
|
5254
|
-
isLogger: this._isLoggerModuleQueued || this._isMiddlewareModuleQueued,
|
|
5255
|
-
isCache: !this._isCacheModuleQueued
|
|
5256
|
-
});
|
|
5057
|
+
await pipelineModule.configure(this._container, this._pipelineConfig);
|
|
5257
5058
|
}
|
|
5258
5059
|
});
|
|
5259
5060
|
}
|
|
@@ -5270,17 +5071,17 @@ var AppBuilder = class {
|
|
|
5270
5071
|
if (this._isMiddlewareModuleQueued) return;
|
|
5271
5072
|
this._isMiddlewareModuleQueued = true;
|
|
5272
5073
|
this._queueContextModule();
|
|
5074
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
5075
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5273
5076
|
this._modules.push({
|
|
5274
|
-
priority:
|
|
5077
|
+
priority: 4,
|
|
5275
5078
|
name: "MiddlewareModule",
|
|
5276
5079
|
action: async () => {
|
|
5277
5080
|
const { MiddlewareModule: MiddlewareModule2 } = await Promise.resolve().then(() => (init_middleware_module(), middleware_module_exports));
|
|
5278
5081
|
const middlewareModule = new MiddlewareModule2();
|
|
5279
5082
|
await middlewareModule.configure(this._container, {
|
|
5280
5083
|
...this._middlewareConfig,
|
|
5281
|
-
isAuth: this._isAuthModuleQueued
|
|
5282
|
-
isLogger: this._isLoggerModuleQueued,
|
|
5283
|
-
isCache: this._isCacheModuleQueued || this._isPipelineModuleQueued
|
|
5084
|
+
isAuth: this._isAuthModuleQueued
|
|
5284
5085
|
});
|
|
5285
5086
|
}
|
|
5286
5087
|
});
|
|
@@ -5350,9 +5151,7 @@ import { AppError as AppError15, Result as Result16 } from "@xeno-js/shared";
|
|
|
5350
5151
|
|
|
5351
5152
|
// src/infrastructure/index.ts
|
|
5352
5153
|
init_factories();
|
|
5353
|
-
|
|
5354
|
-
// src/infrastructure/idempotency/index.ts
|
|
5355
|
-
init_idempotency_store();
|
|
5154
|
+
init_idempotency();
|
|
5356
5155
|
|
|
5357
5156
|
// src/infrastructure/loggers/index.ts
|
|
5358
5157
|
init_console_logger();
|
|
@@ -5377,7 +5176,7 @@ init_validation_utils();
|
|
|
5377
5176
|
|
|
5378
5177
|
// src/infrastructure/repositories/read-dao.ts
|
|
5379
5178
|
import { AppError as AppError16, Result as Result17 } from "@xeno-js/shared";
|
|
5380
|
-
import { Guards as
|
|
5179
|
+
import { Guards as Guards44 } from "@xeno-js/shared";
|
|
5381
5180
|
var ReadDao = class {
|
|
5382
5181
|
/**
|
|
5383
5182
|
* Constructs a new ReadDao instance.
|
|
@@ -5399,7 +5198,7 @@ var ReadDao = class {
|
|
|
5399
5198
|
async findById(id, ctx, signal) {
|
|
5400
5199
|
AppError16.throwIfAborted(signal, "ReadDao.findById");
|
|
5401
5200
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5402
|
-
if (
|
|
5201
|
+
if (Guards44.isNullOrEmpty(result)) return Result17.ok();
|
|
5403
5202
|
const entity = this._mapper.toEntity(result);
|
|
5404
5203
|
return Result17.ok(entity);
|
|
5405
5204
|
}
|
|
@@ -5413,7 +5212,7 @@ var ReadDao = class {
|
|
|
5413
5212
|
|
|
5414
5213
|
// src/infrastructure/repositories/repository.ts
|
|
5415
5214
|
import { AppError as AppError17, Result as Result18 } from "@xeno-js/shared";
|
|
5416
|
-
import { Guards as
|
|
5215
|
+
import { Guards as Guards45 } from "@xeno-js/shared";
|
|
5417
5216
|
var Repository = class {
|
|
5418
5217
|
/**
|
|
5419
5218
|
* Constructs a new Repository instance.
|
|
@@ -5435,7 +5234,7 @@ var Repository = class {
|
|
|
5435
5234
|
async findById(id, ctx, signal) {
|
|
5436
5235
|
AppError17.throwIfAborted(signal, "Repository.findById");
|
|
5437
5236
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5438
|
-
if (
|
|
5237
|
+
if (Guards45.isNullOrEmpty(result)) return Result18.ok();
|
|
5439
5238
|
const entity = this._mapper.toEntity(result);
|
|
5440
5239
|
return Result18.ok(entity);
|
|
5441
5240
|
}
|