@xeno-js/core 0.1.8 → 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 +263 -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 +243 -442
- package/dist/index.js.map +1 -1
- package/package.json +166 -160
package/dist/index.cjs
CHANGED
|
@@ -1509,47 +1509,31 @@ var init_logger_utils = __esm({
|
|
|
1509
1509
|
*/
|
|
1510
1510
|
async addLogger(container, opts) {
|
|
1511
1511
|
const loggerDependencies = [];
|
|
1512
|
-
const { Guards:
|
|
1513
|
-
if (!
|
|
1512
|
+
const { Guards: Guards46, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
1513
|
+
if (!Guards46.isDefined(opts) || opts.console) {
|
|
1514
1514
|
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
1515
|
-
|
|
1516
|
-
loggerDependencies.push(TOKENS4.CONSOLE_LOGGER);
|
|
1515
|
+
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
1517
1516
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
if (Guards47.isDefined(opts.sentry.config)) {
|
|
1517
|
+
if (Guards46.isDefined(opts)) {
|
|
1518
|
+
if (Guards46.isDefined(opts.sentry.config)) {
|
|
1521
1519
|
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
1522
|
-
|
|
1523
|
-
const factory = new SentryLoggerFactory2();
|
|
1524
|
-
return factory.create(opts);
|
|
1525
|
-
});
|
|
1526
|
-
loggerDependencies.push(TOKENS4.SENTRY_LOGGER);
|
|
1520
|
+
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
1527
1521
|
}
|
|
1528
|
-
if (
|
|
1522
|
+
if (Guards46.isDefined(opts.pino.config)) {
|
|
1529
1523
|
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
1530
|
-
|
|
1531
|
-
const factory = new PinoLoggerFactory2();
|
|
1532
|
-
return factory.create(opts);
|
|
1533
|
-
});
|
|
1534
|
-
loggerDependencies.push(TOKENS4.PINO_LOGGER);
|
|
1524
|
+
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
1535
1525
|
}
|
|
1536
|
-
if (!
|
|
1526
|
+
if (!Guards46.isNullOrEmpty(opts.customLoggers)) {
|
|
1537
1527
|
const customLoggers = opts.customLoggers;
|
|
1538
|
-
customLoggers.forEach((
|
|
1539
|
-
if (
|
|
1540
|
-
customLoggerFactories.push(f);
|
|
1541
|
-
}
|
|
1528
|
+
customLoggers.forEach((fn) => {
|
|
1529
|
+
if (Guards46.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
1542
1530
|
});
|
|
1543
1531
|
}
|
|
1544
1532
|
}
|
|
1545
1533
|
const { BaseLogger } = await import("@xeno-js/shared");
|
|
1546
1534
|
container.addSingleton(TOKENS4.LOGGER, (c) => {
|
|
1547
1535
|
const context = c.resolve(TOKENS4.CONTEXT_ACCESSOR);
|
|
1548
|
-
|
|
1549
|
-
...loggerDependencies.map((token) => c.resolve(token)),
|
|
1550
|
-
...customLoggerFactories.map((factory) => factory(c))
|
|
1551
|
-
];
|
|
1552
|
-
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, resolvedDependencies);
|
|
1536
|
+
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, loggerDependencies);
|
|
1553
1537
|
});
|
|
1554
1538
|
}
|
|
1555
1539
|
});
|
|
@@ -1709,8 +1693,8 @@ var init_cache_utils = __esm({
|
|
|
1709
1693
|
* @link https://github.com/xeno-js/xeno-js
|
|
1710
1694
|
*/
|
|
1711
1695
|
async addCache(container, opts) {
|
|
1712
|
-
const { Guards:
|
|
1713
|
-
if (!opts.inMemory && !
|
|
1696
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
1697
|
+
if (!opts.inMemory && !Guards46.isDefined(opts.redis)) {
|
|
1714
1698
|
throw new Error(
|
|
1715
1699
|
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
1716
1700
|
);
|
|
@@ -1720,12 +1704,12 @@ var init_cache_utils = __esm({
|
|
|
1720
1704
|
TOKENS4.CACHE_KEY_BUILDER,
|
|
1721
1705
|
(c) => new CacheKeyBuilder(c.resolve(TOKENS4.IDENTITY_ACCESSOR))
|
|
1722
1706
|
);
|
|
1723
|
-
if (opts.inMemory || !
|
|
1707
|
+
if (opts.inMemory || !Guards46.isDefined(opts.redis)) {
|
|
1724
1708
|
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
1725
1709
|
container.addSingleton(TOKENS4.CACHE, () => new InMemoryCacheExtended2());
|
|
1726
1710
|
return;
|
|
1727
1711
|
}
|
|
1728
|
-
if (
|
|
1712
|
+
if (Guards46.isDefined(opts.redis)) {
|
|
1729
1713
|
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
1730
1714
|
container.addSingleton(TOKENS4.CACHE, () => {
|
|
1731
1715
|
const config = opts.redis;
|
|
@@ -2634,7 +2618,9 @@ var init_supabase_factory = __esm({
|
|
|
2634
2618
|
container
|
|
2635
2619
|
}) {
|
|
2636
2620
|
if (!import_shared55.Guards.isDefined(config.ssrOpts)) {
|
|
2637
|
-
throw new Error(
|
|
2621
|
+
throw new Error(
|
|
2622
|
+
"ISsrCookieHandler is required for @supabase/ssr initialization., Please provide it in the config object."
|
|
2623
|
+
);
|
|
2638
2624
|
}
|
|
2639
2625
|
const cookieService = config.ssrOpts(container);
|
|
2640
2626
|
const client = (0, import_ssr.createServerClient)(config.url, config.key, {
|
|
@@ -2697,10 +2683,6 @@ var init_user_context_factory = __esm({
|
|
|
2697
2683
|
});
|
|
2698
2684
|
|
|
2699
2685
|
// src/infrastructure/factories/zod-validator.factory.ts
|
|
2700
|
-
var zod_validator_factory_exports = {};
|
|
2701
|
-
__export(zod_validator_factory_exports, {
|
|
2702
|
-
ZodValidatorFactory: () => ZodValidatorFactory
|
|
2703
|
-
});
|
|
2704
2686
|
var import_shared57, ZodValidatorFactory;
|
|
2705
2687
|
var init_zod_validator_factory = __esm({
|
|
2706
2688
|
"src/infrastructure/factories/zod-validator.factory.ts"() {
|
|
@@ -2777,97 +2759,57 @@ var init_auth_utils = __esm({
|
|
|
2777
2759
|
*/
|
|
2778
2760
|
async addAuthZ(container, opts) {
|
|
2779
2761
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2780
|
-
const pipelines = [];
|
|
2781
2762
|
const strategies = [];
|
|
2782
|
-
const { Guards:
|
|
2783
|
-
if (
|
|
2763
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
2764
|
+
if (Guards46.isDefined(opts.policies)) {
|
|
2784
2765
|
const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2785
|
-
container.addSingleton(TOKENS4.POLICY_REGISTRY, () => new PolicyRegistry2());
|
|
2786
2766
|
const policyRegistry = opts.policies;
|
|
2787
|
-
const registryInstance =
|
|
2767
|
+
const registryInstance = new PolicyRegistry2();
|
|
2768
|
+
const ctxAccessor = container.resolve(TOKENS4.CONTEXT_ACCESSOR);
|
|
2788
2769
|
const Policies = /* @__PURE__ */ new Set();
|
|
2789
2770
|
for (const [intent, policy] of Object.entries(policyRegistry)) {
|
|
2790
2771
|
const intentLower = intent.toLowerCase();
|
|
2791
2772
|
registryInstance.addPolicy(intentLower, policy);
|
|
2792
|
-
if (!
|
|
2773
|
+
if (!Guards46.isNullOrEmpty(policy.roles)) {
|
|
2793
2774
|
Policies.add("roles");
|
|
2794
2775
|
}
|
|
2795
|
-
if (!
|
|
2776
|
+
if (!Guards46.isNullOrEmpty(policy.permissions)) {
|
|
2796
2777
|
Policies.add("permissions");
|
|
2797
2778
|
}
|
|
2798
|
-
if (!
|
|
2779
|
+
if (!Guards46.isNullOrEmpty(policy.userId)) {
|
|
2799
2780
|
Policies.add("userId");
|
|
2800
2781
|
}
|
|
2801
|
-
if (!
|
|
2782
|
+
if (!Guards46.isNullOrEmpty(policy.tenantId)) {
|
|
2802
2783
|
Policies.add("tenantId");
|
|
2803
2784
|
}
|
|
2804
2785
|
}
|
|
2805
2786
|
if (Policies.has("roles")) {
|
|
2806
2787
|
const { RoleAuthorizationStrategy: RoleAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2807
|
-
|
|
2808
|
-
TOKENS4.ROLE_AUTHORIZATION_PIPELINE,
|
|
2809
|
-
(c) => new RoleAuthorizationStrategy2(
|
|
2810
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2811
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2812
|
-
)
|
|
2813
|
-
);
|
|
2814
|
-
strategies.push(TOKENS4.ROLE_AUTHORIZATION_PIPELINE);
|
|
2788
|
+
strategies.push(new RoleAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2815
2789
|
}
|
|
2816
2790
|
if (Policies.has("permissions")) {
|
|
2817
2791
|
const { PermissionAuthorizationStrategy: PermissionAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2818
|
-
|
|
2819
|
-
TOKENS4.PERMISSION_AUTHORIZATION_PIPELINE,
|
|
2820
|
-
(c) => new PermissionAuthorizationStrategy2(
|
|
2821
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2822
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2823
|
-
)
|
|
2824
|
-
);
|
|
2825
|
-
strategies.push(TOKENS4.PERMISSION_AUTHORIZATION_PIPELINE);
|
|
2792
|
+
strategies.push(new PermissionAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2826
2793
|
}
|
|
2827
2794
|
if (Policies.has("userId")) {
|
|
2828
2795
|
const { UserAuthorizationStrategy: UserAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2829
|
-
|
|
2830
|
-
TOKENS4.USER_AUTHORIZATION_PIPELINE,
|
|
2831
|
-
(c) => new UserAuthorizationStrategy2(
|
|
2832
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2833
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2834
|
-
)
|
|
2835
|
-
);
|
|
2836
|
-
strategies.push(TOKENS4.USER_AUTHORIZATION_PIPELINE);
|
|
2796
|
+
strategies.push(new UserAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2837
2797
|
}
|
|
2838
2798
|
if (Policies.has("tenantId")) {
|
|
2839
2799
|
const { TenantAuthorizationStrategy: TenantAuthorizationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2840
|
-
|
|
2841
|
-
TOKENS4.TENANT_AUTHORIZATION_PIPELINE,
|
|
2842
|
-
(c) => new TenantAuthorizationStrategy2(
|
|
2843
|
-
c.resolve(TOKENS4.POLICY_REGISTRY),
|
|
2844
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR)
|
|
2845
|
-
)
|
|
2846
|
-
);
|
|
2847
|
-
strategies.push(TOKENS4.TENANT_AUTHORIZATION_PIPELINE);
|
|
2800
|
+
strategies.push(new TenantAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2848
2801
|
}
|
|
2849
2802
|
}
|
|
2850
|
-
if (!
|
|
2803
|
+
if (!Guards46.isNullOrEmpty(opts.customAuthorizationStrategy)) {
|
|
2851
2804
|
const customStrategies = opts.customAuthorizationStrategy;
|
|
2852
|
-
customStrategies.forEach((strategyToken
|
|
2853
|
-
if (
|
|
2854
|
-
|
|
2855
|
-
container.addSingleton(token, (c) => {
|
|
2856
|
-
return strategyToken(c);
|
|
2857
|
-
});
|
|
2858
|
-
strategies.push(token);
|
|
2805
|
+
customStrategies.forEach((strategyToken) => {
|
|
2806
|
+
if (Guards46.isDefined(strategyToken)) {
|
|
2807
|
+
strategies.push(strategyToken(container));
|
|
2859
2808
|
}
|
|
2860
2809
|
});
|
|
2861
2810
|
}
|
|
2862
2811
|
const { AuthorizationPipeline: AuthorizationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2863
|
-
|
|
2864
|
-
const resolvedStrategies = strategies.map(
|
|
2865
|
-
(strategy) => c.resolve(strategy)
|
|
2866
|
-
);
|
|
2867
|
-
return new AuthorizationPipeline2(resolvedStrategies);
|
|
2868
|
-
});
|
|
2869
|
-
pipelines.push(TOKENS4.AUTHORIZATION_PIPELINE);
|
|
2870
|
-
return pipelines;
|
|
2812
|
+
return new AuthorizationPipeline2(strategies);
|
|
2871
2813
|
},
|
|
2872
2814
|
/**
|
|
2873
2815
|
* @description Configures the authentication service and gatekeeper in the service container.
|
|
@@ -2884,22 +2826,13 @@ var init_auth_utils = __esm({
|
|
|
2884
2826
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
2885
2827
|
const _t = opts;
|
|
2886
2828
|
const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2829
|
+
const factory = new SupabaseServerAuthFactory2();
|
|
2830
|
+
const supabase = factory.create({ config: opts, container });
|
|
2887
2831
|
container.addScoped(TOKENS4.AUTH_SERVICE, () => {
|
|
2888
|
-
|
|
2889
|
-
return factory.create({ config: opts, container });
|
|
2832
|
+
return supabase;
|
|
2890
2833
|
});
|
|
2891
2834
|
container.addSingleton(TOKENS4.BASE_AUTH_SERVICE, () => {
|
|
2892
|
-
|
|
2893
|
-
return factory.create({ config: opts, container });
|
|
2894
|
-
});
|
|
2895
|
-
const { ClaimsIdentityMapper: ClaimsIdentityMapper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2896
|
-
container.addSingleton(TOKENS4.CLAIMS_IDENTITY_MAPPER, () => new ClaimsIdentityMapper2());
|
|
2897
|
-
const { GateKeeper: GateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2898
|
-
container.addSingleton(TOKENS4.GATE_KEEPER, (c) => {
|
|
2899
|
-
return new GateKeeper2(
|
|
2900
|
-
c.resolve(TOKENS4.BASE_AUTH_SERVICE),
|
|
2901
|
-
c.resolve(TOKENS4.CLAIMS_IDENTITY_MAPPER)
|
|
2902
|
-
);
|
|
2835
|
+
return supabase;
|
|
2903
2836
|
});
|
|
2904
2837
|
}
|
|
2905
2838
|
});
|
|
@@ -3053,24 +2986,20 @@ var init_db_module = __esm({
|
|
|
3053
2986
|
"use strict";
|
|
3054
2987
|
DbModule = class {
|
|
3055
2988
|
async configure(container, opts) {
|
|
3056
|
-
const { Guards:
|
|
2989
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3057
2990
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3058
2991
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3059
2992
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
3060
|
-
|
|
3061
|
-
return new TransactionState2();
|
|
3062
|
-
});
|
|
2993
|
+
const ttx = new TransactionState2();
|
|
3063
2994
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3064
|
-
container.addScoped(TOKENS4.UNIT_OF_WORK, (
|
|
3065
|
-
const ttx = c.resolve(TOKENS4.TRANSACTION_STATE);
|
|
2995
|
+
container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
|
|
3066
2996
|
return new UnitOfWork2(db, ttx);
|
|
3067
2997
|
});
|
|
3068
|
-
container.addScoped(TOKENS4.DB_CONTEXT, (
|
|
3069
|
-
const ttx = c.resolve(TOKENS4.TRANSACTION_STATE);
|
|
2998
|
+
container.addScoped(TOKENS4.DB_CONTEXT, () => {
|
|
3070
2999
|
return new Proxy(db, {
|
|
3071
3000
|
get(_target, prop, receiver) {
|
|
3072
3001
|
const activeState = ttx.state;
|
|
3073
|
-
if (
|
|
3002
|
+
if (Guards46.isDefined(activeState)) {
|
|
3074
3003
|
if (prop === "transaction") {
|
|
3075
3004
|
return activeState.transaction.bind(activeState);
|
|
3076
3005
|
}
|
|
@@ -3107,14 +3036,14 @@ var init_http_utils = __esm({
|
|
|
3107
3036
|
*/
|
|
3108
3037
|
async addAxios(container, opts) {
|
|
3109
3038
|
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3110
|
-
const { Guards:
|
|
3111
|
-
if (!
|
|
3039
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3040
|
+
if (!Guards46.isDefined(opts.token)) {
|
|
3112
3041
|
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3113
3042
|
}
|
|
3114
3043
|
container.addSingleton(opts.token, () => {
|
|
3115
3044
|
const factory = new NodeAxiosFactory2();
|
|
3116
3045
|
const instance = factory.create(opts.client);
|
|
3117
|
-
if (!
|
|
3046
|
+
if (!Guards46.hasMethod(instance, "get") || !Guards46.hasMethod(instance, "post") || !Guards46.hasMethod(instance, "put") || !Guards46.hasMethod(instance, "patch") || !Guards46.hasMethod(instance, "delete")) {
|
|
3118
3047
|
throw new Error(
|
|
3119
3048
|
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3120
3049
|
);
|
|
@@ -3139,17 +3068,6 @@ var init_http_utils = __esm({
|
|
|
3139
3068
|
const factory = new CockatielResilienceFactory2();
|
|
3140
3069
|
return factory.create(opts);
|
|
3141
3070
|
});
|
|
3142
|
-
},
|
|
3143
|
-
async addAllowOrigin(container, opts) {
|
|
3144
|
-
const { Guards: Guards47 } = await import("@xeno-js/shared");
|
|
3145
|
-
if (Guards47.isNullOrEmpty(opts)) throw new Error("At least an allow origin must be passed");
|
|
3146
|
-
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3147
|
-
const { AllowOrigin: AllowOrigin2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
3148
|
-
const allowOrigin = [];
|
|
3149
|
-
opts.forEach((x) => {
|
|
3150
|
-
allowOrigin.push(x.trim().toLowerCase());
|
|
3151
|
-
});
|
|
3152
|
-
container.addSingleton(TOKENS4.ALLOW_ORIGIN, () => new AllowOrigin2(allowOrigin));
|
|
3153
3071
|
}
|
|
3154
3072
|
});
|
|
3155
3073
|
}
|
|
@@ -3158,10 +3076,9 @@ var init_http_utils = __esm({
|
|
|
3158
3076
|
// src/infrastructure/modules/http-core.module.ts
|
|
3159
3077
|
var http_core_module_exports = {};
|
|
3160
3078
|
__export(http_core_module_exports, {
|
|
3161
|
-
HttpCoreModule: () => HttpCoreModule
|
|
3162
|
-
HttpOriginModule: () => HttpOriginModule
|
|
3079
|
+
HttpCoreModule: () => HttpCoreModule
|
|
3163
3080
|
});
|
|
3164
|
-
var HttpCoreModule
|
|
3081
|
+
var HttpCoreModule;
|
|
3165
3082
|
var init_http_core_module = __esm({
|
|
3166
3083
|
"src/infrastructure/modules/http-core.module.ts"() {
|
|
3167
3084
|
"use strict";
|
|
@@ -3172,12 +3089,6 @@ var init_http_core_module = __esm({
|
|
|
3172
3089
|
await HttpUtils2.addResilience(container, opts.resilience);
|
|
3173
3090
|
}
|
|
3174
3091
|
};
|
|
3175
|
-
HttpOriginModule = class {
|
|
3176
|
-
async configure(container, opts) {
|
|
3177
|
-
const { HttpUtils: HttpUtils2 } = await Promise.resolve().then(() => (init_http_utils(), http_utils_exports));
|
|
3178
|
-
await HttpUtils2.addAllowOrigin(container, opts);
|
|
3179
|
-
}
|
|
3180
|
-
};
|
|
3181
3092
|
}
|
|
3182
3093
|
});
|
|
3183
3094
|
|
|
@@ -3202,53 +3113,32 @@ var init_validation_utils = __esm({
|
|
|
3202
3113
|
* @link https://github.com/xeno-js/xeno-js
|
|
3203
3114
|
*/
|
|
3204
3115
|
async addValidation(container, opts, logger) {
|
|
3205
|
-
const { Guards:
|
|
3206
|
-
if (!
|
|
3207
|
-
return
|
|
3116
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3117
|
+
if (!Guards46.isDefined(opts.zod) && Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3118
|
+
return;
|
|
3208
3119
|
}
|
|
3209
|
-
const pipelines = [];
|
|
3210
3120
|
const validationStrategies = [];
|
|
3211
|
-
if (
|
|
3121
|
+
if (Guards46.isDefined(opts.zod)) {
|
|
3212
3122
|
const config = opts.zod;
|
|
3213
|
-
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (
|
|
3214
|
-
container.addSingleton(TOKENS4.ZOD_VALIDATOR, () => {
|
|
3215
|
-
return new ZodValidatorFactory2().create({ ...config, logger });
|
|
3216
|
-
});
|
|
3123
|
+
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3217
3124
|
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
);
|
|
3222
|
-
validationStrategies.push(TOKENS4.SCHEMA_VALIDATION_STRATEGY);
|
|
3125
|
+
const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
|
|
3126
|
+
container.addSingleton(TOKENS4.VALIDATOR_SERVICE, () => validatorService);
|
|
3127
|
+
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
3223
3128
|
}
|
|
3224
|
-
|
|
3225
|
-
if (!Guards47.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3129
|
+
if (!Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3226
3130
|
for (const strategyToken of opts.customValidationStrategy) {
|
|
3227
|
-
if (
|
|
3228
|
-
customValidationFactory.push(strategyToken);
|
|
3229
|
-
}
|
|
3131
|
+
if (Guards46.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
3230
3132
|
}
|
|
3231
3133
|
}
|
|
3232
3134
|
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3233
|
-
|
|
3234
|
-
const resolvedStrategies = [
|
|
3235
|
-
...validationStrategies.map((token) => c.resolve(token)),
|
|
3236
|
-
...customValidationFactory.map((factory) => factory(c))
|
|
3237
|
-
];
|
|
3238
|
-
return new ValidationPipeline2(resolvedStrategies);
|
|
3239
|
-
});
|
|
3240
|
-
pipelines.push(TOKENS4.VALIDATION_PIPELINE);
|
|
3241
|
-
return pipelines;
|
|
3135
|
+
return new ValidationPipeline2(validationStrategies);
|
|
3242
3136
|
}
|
|
3243
3137
|
});
|
|
3244
3138
|
}
|
|
3245
3139
|
});
|
|
3246
3140
|
|
|
3247
3141
|
// src/infrastructure/idempotency/idempotency-store.ts
|
|
3248
|
-
var idempotency_store_exports = {};
|
|
3249
|
-
__export(idempotency_store_exports, {
|
|
3250
|
-
IdempotencyStore: () => IdempotencyStore
|
|
3251
|
-
});
|
|
3252
3142
|
var import_shared60, IdempotencyStore;
|
|
3253
3143
|
var init_idempotency_store = __esm({
|
|
3254
3144
|
"src/infrastructure/idempotency/idempotency-store.ts"() {
|
|
@@ -3305,6 +3195,18 @@ var init_idempotency_store = __esm({
|
|
|
3305
3195
|
}
|
|
3306
3196
|
});
|
|
3307
3197
|
|
|
3198
|
+
// src/infrastructure/idempotency/index.ts
|
|
3199
|
+
var idempotency_exports = {};
|
|
3200
|
+
__export(idempotency_exports, {
|
|
3201
|
+
IdempotencyStore: () => IdempotencyStore
|
|
3202
|
+
});
|
|
3203
|
+
var init_idempotency = __esm({
|
|
3204
|
+
"src/infrastructure/idempotency/index.ts"() {
|
|
3205
|
+
"use strict";
|
|
3206
|
+
init_idempotency_store();
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
|
|
3308
3210
|
// src/infrastructure/modules/utils/pipeline.utils.ts
|
|
3309
3211
|
var pipeline_utils_exports = {};
|
|
3310
3212
|
__export(pipeline_utils_exports, {
|
|
@@ -3326,35 +3228,30 @@ var init_pipeline_utils = __esm({
|
|
|
3326
3228
|
* @link https://github.com/xeno-js/xeno-js
|
|
3327
3229
|
*/
|
|
3328
3230
|
async addCommand(container, opts) {
|
|
3231
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3329
3232
|
const pipelines = [];
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
TOKENS4.
|
|
3335
|
-
(c) => new IdempotencyStore2(c.resolve(TOKENS4.CACHE), c.resolve(TOKENS4.CACHE_KEY_BUILDER))
|
|
3233
|
+
if (Guards46.isDefined(opts.idempotency)) {
|
|
3234
|
+
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
3235
|
+
const imdStore = new IdempotencyStore2(
|
|
3236
|
+
container.resolve(TOKENS4.CACHE),
|
|
3237
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER)
|
|
3336
3238
|
);
|
|
3337
3239
|
const { IdempotencyPipeline: IdempotencyPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3338
|
-
container.
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
return new IdempotencyPipeline2(
|
|
3240
|
+
const requestContext = container.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR);
|
|
3241
|
+
const config = opts.idempotency;
|
|
3242
|
+
pipelines.push(
|
|
3243
|
+
new IdempotencyPipeline2(
|
|
3343
3244
|
requestContext,
|
|
3344
|
-
|
|
3245
|
+
imdStore,
|
|
3345
3246
|
config?.lockTtlSeconds,
|
|
3346
3247
|
config?.processedTtlSeconds
|
|
3347
|
-
)
|
|
3348
|
-
|
|
3349
|
-
pipelines.push(TOKENS4.IDEMPOTENCY_PIPELINE);
|
|
3248
|
+
)
|
|
3249
|
+
);
|
|
3350
3250
|
}
|
|
3351
|
-
if (
|
|
3251
|
+
if (Guards46.isDefined(opts.concurrency)) {
|
|
3352
3252
|
const { ConcurrencyRetryPipeline: ConcurrencyRetryPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
return new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig);
|
|
3356
|
-
});
|
|
3357
|
-
pipelines.push(TOKENS4.CONCURRENCY_RETRY_PIPELINE);
|
|
3253
|
+
const config = opts.concurrency;
|
|
3254
|
+
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
3358
3255
|
}
|
|
3359
3256
|
return pipelines;
|
|
3360
3257
|
},
|
|
@@ -3368,24 +3265,14 @@ var init_pipeline_utils = __esm({
|
|
|
3368
3265
|
* @since 2025-09-30
|
|
3369
3266
|
* @link https://github.com/xeno-js/xeno-js
|
|
3370
3267
|
*/
|
|
3371
|
-
async addQuery(container
|
|
3268
|
+
async addQuery(container) {
|
|
3372
3269
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3373
|
-
const pipelines = [];
|
|
3374
|
-
if (!opts.isCache) {
|
|
3375
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
3376
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
3377
|
-
}
|
|
3378
3270
|
const { QueryCachingPipeline: QueryCachingPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3379
|
-
|
|
3380
|
-
TOKENS4.
|
|
3381
|
-
(
|
|
3382
|
-
|
|
3383
|
-
c.resolve(TOKENS4.CACHE_KEY_BUILDER),
|
|
3384
|
-
c.resolve(TOKENS4.LOGGER)
|
|
3385
|
-
)
|
|
3271
|
+
return new QueryCachingPipeline2(
|
|
3272
|
+
container.resolve(TOKENS4.CACHE),
|
|
3273
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER),
|
|
3274
|
+
container.resolve(TOKENS4.LOGGER)
|
|
3386
3275
|
);
|
|
3387
|
-
pipelines.push(TOKENS4.QUERY_CACHING_PIPELINE);
|
|
3388
|
-
return pipelines;
|
|
3389
3276
|
}
|
|
3390
3277
|
});
|
|
3391
3278
|
}
|
|
@@ -3403,79 +3290,54 @@ var init_cqrs_module = __esm({
|
|
|
3403
3290
|
CqrsModule = class {
|
|
3404
3291
|
async configure(container, opts) {
|
|
3405
3292
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3406
|
-
|
|
3293
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3407
3294
|
const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3408
3295
|
container.addSingleton(TOKENS4.MEDIATOR, (c) => {
|
|
3409
3296
|
const serviceScopeAccessor = c.resolve(TOKENS4.SERVICE_SCOPE_ACCESSOR);
|
|
3410
3297
|
return new Mediator2(serviceScopeAccessor);
|
|
3411
3298
|
});
|
|
3412
3299
|
const { ExceptionPipeline: ExceptionPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3413
|
-
container.addSingleton(TOKENS4.EXCEPTION_PIPELINE, () => new ExceptionPipeline2());
|
|
3414
|
-
if (!opts.isLogger) {
|
|
3415
|
-
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
3416
|
-
await LoggerUtils2.addLogger(container, void 0);
|
|
3417
|
-
}
|
|
3418
3300
|
const { LoggingPipeline: LoggingPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3419
|
-
container.addSingleton(
|
|
3420
|
-
TOKENS4.LOGGING_PIPELINE,
|
|
3421
|
-
(c) => new LoggingPipeline2(c.resolve(TOKENS4.LOGGER))
|
|
3422
|
-
);
|
|
3423
|
-
const pipelines = [TOKENS4.EXCEPTION_PIPELINE, TOKENS4.LOGGING_PIPELINE];
|
|
3424
3301
|
const { PerformancePipeline: PerformancePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
const { Guards:
|
|
3432
|
-
if (
|
|
3302
|
+
const thresholdMs = opts.performance?.thresholdMs;
|
|
3303
|
+
const pipelines = [
|
|
3304
|
+
new ExceptionPipeline2(),
|
|
3305
|
+
new LoggingPipeline2(logger),
|
|
3306
|
+
new PerformancePipeline2(logger, thresholdMs)
|
|
3307
|
+
];
|
|
3308
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3309
|
+
if (Guards46.isDefined(opts.authorization.policies) || Guards46.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3433
3310
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3434
3311
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3435
|
-
pipelines.push(
|
|
3312
|
+
pipelines.push(authPipelines);
|
|
3436
3313
|
}
|
|
3437
|
-
if (
|
|
3314
|
+
if (Guards46.isDefined(opts.validation.zod) || Guards46.isDefined(opts.validation.customValidationStrategy)) {
|
|
3438
3315
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3439
|
-
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3440
3316
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3441
3317
|
container,
|
|
3442
3318
|
opts.validation,
|
|
3443
3319
|
logger
|
|
3444
3320
|
);
|
|
3445
|
-
pipelines.push(
|
|
3321
|
+
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3446
3322
|
}
|
|
3447
3323
|
const commandPipelines = pipelines;
|
|
3448
3324
|
const queryPipelines = pipelines;
|
|
3449
|
-
if (
|
|
3450
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
3451
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
3452
|
-
}
|
|
3453
|
-
if (Guards47.isDefined(opts.commandBus.idempotency) || Guards47.isDefined(opts.commandBus.concurrency)) {
|
|
3325
|
+
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3454
3326
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3455
|
-
const newCommandPipelines = await PipelineUtils2.addCommand(container,
|
|
3456
|
-
...opts.commandBus,
|
|
3457
|
-
isCache
|
|
3458
|
-
});
|
|
3459
|
-
isCache = true;
|
|
3327
|
+
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3460
3328
|
commandPipelines.push(...newCommandPipelines);
|
|
3461
3329
|
}
|
|
3462
3330
|
if (opts.queryBus.isEnabled) {
|
|
3463
3331
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3464
|
-
const newQueryPipelines = await PipelineUtils2.addQuery(container
|
|
3465
|
-
queryPipelines.push(
|
|
3332
|
+
const newQueryPipelines = await PipelineUtils2.addQuery(container);
|
|
3333
|
+
queryPipelines.push(newQueryPipelines);
|
|
3466
3334
|
}
|
|
3467
3335
|
const { CompositePipeline: CompositePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3468
|
-
container.addSingleton(TOKENS4.COMMAND_PIPELINES_BEHAVIOR, (
|
|
3469
|
-
|
|
3470
|
-
return c.resolve(token);
|
|
3471
|
-
});
|
|
3472
|
-
return new CompositePipeline2(resolvedCommandPipelines);
|
|
3336
|
+
container.addSingleton(TOKENS4.COMMAND_PIPELINES_BEHAVIOR, () => {
|
|
3337
|
+
return new CompositePipeline2(commandPipelines);
|
|
3473
3338
|
});
|
|
3474
|
-
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, (
|
|
3475
|
-
|
|
3476
|
-
(token) => c.resolve(token)
|
|
3477
|
-
);
|
|
3478
|
-
return new CompositePipeline2(resolvedQueryPipelines);
|
|
3339
|
+
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, () => {
|
|
3340
|
+
return new CompositePipeline2(queryPipelines);
|
|
3479
3341
|
});
|
|
3480
3342
|
}
|
|
3481
3343
|
};
|
|
@@ -4259,181 +4121,149 @@ var middleware_module_exports = {};
|
|
|
4259
4121
|
__export(middleware_module_exports, {
|
|
4260
4122
|
MiddlewareModule: () => MiddlewareModule
|
|
4261
4123
|
});
|
|
4262
|
-
var
|
|
4124
|
+
var MiddlewareModule;
|
|
4263
4125
|
var init_middleware_module = __esm({
|
|
4264
4126
|
"src/infrastructure/modules/middleware.module.ts"() {
|
|
4265
4127
|
"use strict";
|
|
4266
|
-
import_shared73 = require("@xeno-js/shared");
|
|
4267
4128
|
MiddlewareModule = class {
|
|
4268
4129
|
async configure(container, opts) {
|
|
4269
|
-
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4270
|
-
if (!opts.isAuth) {
|
|
4271
|
-
const { NoAuthGateKeeper: NoAuthGateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4272
|
-
container.addSingleton(TOKENS4.GATE_KEEPER, () => new NoAuthGateKeeper2());
|
|
4273
|
-
}
|
|
4274
|
-
if (opts.isSSR) {
|
|
4275
|
-
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4276
|
-
container.addSingleton(TOKENS4.BEARER_TOKEN_EXTRACTOR, () => new SupabaseSsrTokenExtractor2());
|
|
4277
|
-
} else {
|
|
4278
|
-
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4279
|
-
container.addSingleton(TOKENS4.BEARER_TOKEN_EXTRACTOR, () => new BearerTokenExtractor2());
|
|
4280
|
-
}
|
|
4130
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4281
4131
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4282
|
-
container.addSingleton("COOKIE_EXTRACTOR", () => new HttpCookieExtractor2());
|
|
4283
4132
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4133
|
+
const tokenExtractor = await this._getTokenExtractor(opts.isSSR);
|
|
4284
4134
|
container.addSingleton(
|
|
4285
4135
|
TOKENS4.SERVICE_EXTRACTOR,
|
|
4286
|
-
(
|
|
4287
|
-
|
|
4288
|
-
|
|
4136
|
+
() => new HttpHeaderExtractor2(
|
|
4137
|
+
tokenExtractor,
|
|
4138
|
+
new HttpCookieExtractor2(),
|
|
4289
4139
|
opts.trustedIpHeader,
|
|
4290
4140
|
opts.csrf?.cookieName ?? "__Host-xeno-csrf"
|
|
4291
4141
|
)
|
|
4292
4142
|
);
|
|
4293
|
-
if (!opts.isLogger) {
|
|
4294
|
-
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
4295
|
-
await LoggerUtils2.addLogger(container, void 0);
|
|
4296
|
-
}
|
|
4297
4143
|
const { ClientIpResolver: ClientIpResolver2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4298
|
-
|
|
4299
|
-
const
|
|
4144
|
+
const middlewares = [];
|
|
4145
|
+
const requestContext = container.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4146
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
4300
4147
|
const { RequestContextMiddleware: RequestContextMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
c.resolve(TOKENS4.LOGGER)
|
|
4148
|
+
middlewares.push(
|
|
4149
|
+
new RequestContextMiddleware2(
|
|
4150
|
+
requestContext,
|
|
4151
|
+
container.resolve(TOKENS4.SERVICE_EXTRACTOR),
|
|
4152
|
+
new ClientIpResolver2(opts.trustedProxies),
|
|
4153
|
+
logger
|
|
4308
4154
|
)
|
|
4309
4155
|
);
|
|
4310
|
-
if (!
|
|
4156
|
+
if (!Guards46.isNullOrEmpty(opts.allowOrigins)) {
|
|
4311
4157
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4312
4158
|
throw new Error(
|
|
4313
4159
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
4314
4160
|
);
|
|
4315
4161
|
const { AllowOrigin: AllowOrigin2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4316
|
-
container.addSingleton("ALLOW_ORIGIN", () => {
|
|
4317
|
-
return new AllowOrigin2(opts.allowOrigins);
|
|
4318
|
-
});
|
|
4319
4162
|
const { AllowOriginMiddleware: AllowOriginMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
c.resolve(TOKENS4.CONTEXT_ACCESSOR),
|
|
4324
|
-
c.resolve(TOKENS4.LOGGER)
|
|
4325
|
-
);
|
|
4326
|
-
});
|
|
4327
|
-
middlewares.push(TOKENS4.ALLOW_ORIGIN_MIDDLEWARE);
|
|
4163
|
+
middlewares.push(
|
|
4164
|
+
new AllowOriginMiddleware2(new AllowOrigin2(opts.allowOrigins), requestContext, logger)
|
|
4165
|
+
);
|
|
4328
4166
|
}
|
|
4329
4167
|
const withCredentials = opts.withCredentials ? "true" : "false";
|
|
4168
|
+
const allowMethod = await this._getAllowMethod(
|
|
4169
|
+
opts.optionsMiddleware || opts.cors,
|
|
4170
|
+
opts.routeRegistry
|
|
4171
|
+
);
|
|
4330
4172
|
if (opts.optionsMiddleware) {
|
|
4331
4173
|
const { OptionsMiddleware: OptionsMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
(c) => new OptionsMiddleware2(
|
|
4335
|
-
c.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR),
|
|
4336
|
-
c.resolve(TOKENS4.ALLOW_METHOD),
|
|
4337
|
-
opts.allowHeaders,
|
|
4338
|
-
withCredentials
|
|
4339
|
-
)
|
|
4174
|
+
middlewares.push(
|
|
4175
|
+
new OptionsMiddleware2(requestContext, allowMethod, opts.allowHeaders, withCredentials)
|
|
4340
4176
|
);
|
|
4341
|
-
middlewares.push(TOKENS4.OPTIONS_MIDDLEWARE);
|
|
4342
4177
|
}
|
|
4343
4178
|
if (opts.cors) {
|
|
4344
4179
|
const { CORSMiddleware: CORSMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4345
|
-
|
|
4346
|
-
return new CORSMiddleware2(c.resolve(TOKENS4.CONTEXT_ACCESSOR), withCredentials);
|
|
4347
|
-
});
|
|
4348
|
-
middlewares.push(TOKENS4.CORS_MIDDLEWARE);
|
|
4180
|
+
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4349
4181
|
}
|
|
4350
|
-
if (
|
|
4351
|
-
const registry = opts.routeRegistry;
|
|
4352
|
-
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4353
|
-
container.addSingleton(TOKENS4.ALLOW_METHOD, () => new AllowMethodFactory2().create(registry));
|
|
4182
|
+
if (Guards46.isDefined(opts.routeRegistry)) {
|
|
4354
4183
|
const { MethodCheckMiddleware: MethodCheckMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4355
|
-
|
|
4356
|
-
TOKENS4.METHOD_CHECK_MIDDLEWARE,
|
|
4357
|
-
(c) => new MethodCheckMiddleware2(
|
|
4358
|
-
c.resolve(TOKENS4.REQUEST_CONTEXT),
|
|
4359
|
-
c.resolve(TOKENS4.ALLOW_METHOD)
|
|
4360
|
-
)
|
|
4361
|
-
);
|
|
4362
|
-
middlewares.push(TOKENS4.METHOD_CHECK_MIDDLEWARE);
|
|
4184
|
+
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4363
4185
|
}
|
|
4364
4186
|
const { AuthenticationMiddleware: AuthenticationMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4187
|
+
if (!opts.isAuth) {
|
|
4188
|
+
const { NoAuthGateKeeper: NoAuthGateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4189
|
+
middlewares.push(
|
|
4190
|
+
new AuthenticationMiddleware2(
|
|
4191
|
+
requestContext,
|
|
4192
|
+
tokenExtractor,
|
|
4193
|
+
new NoAuthGateKeeper2(),
|
|
4194
|
+
logger
|
|
4195
|
+
)
|
|
4371
4196
|
);
|
|
4372
|
-
}
|
|
4373
|
-
|
|
4374
|
-
|
|
4197
|
+
} else {
|
|
4198
|
+
const { ClaimsIdentityMapper: ClaimsIdentityMapper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4199
|
+
const { GateKeeper: GateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4200
|
+
middlewares.push(
|
|
4201
|
+
new AuthenticationMiddleware2(
|
|
4202
|
+
requestContext,
|
|
4203
|
+
tokenExtractor,
|
|
4204
|
+
new GateKeeper2(container.resolve(TOKENS4.BASE_AUTH_SERVICE), new ClaimsIdentityMapper2()),
|
|
4205
|
+
logger
|
|
4206
|
+
)
|
|
4207
|
+
);
|
|
4208
|
+
}
|
|
4209
|
+
if (Guards46.isDefined(opts.rateLimite.maxRequests) || Guards46.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4375
4210
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4376
|
-
|
|
4377
|
-
|
|
4211
|
+
Guards46.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4212
|
+
Guards46.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4378
4213
|
const windowSeconds = opts.rateLimite.windowSeconds ?? 30;
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
if (!opts.isCache) {
|
|
4382
|
-
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
4383
|
-
await CacheUtils2.addCache(container, { inMemory: true, redis: void 0 });
|
|
4384
|
-
}
|
|
4214
|
+
Guards46.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4215
|
+
Guards46.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4385
4216
|
const { RateLimitKeyBuilder: RateLimitKeyBuilder2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
4386
|
-
container.addSingleton(
|
|
4387
|
-
"RATE_LIMIT_KEY_BUILDER",
|
|
4388
|
-
(c) => new RateLimitKeyBuilder2(c.resolve(TOKENS4.REQUEST_CONTEXT))
|
|
4389
|
-
);
|
|
4390
4217
|
const { RateLimitMiddleware: RateLimitMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
{
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
}
|
|
4401
|
-
);
|
|
4402
|
-
});
|
|
4403
|
-
middlewares.push(TOKENS4.RATE_LIMITER_MIDDLEWARE);
|
|
4218
|
+
middlewares.push(
|
|
4219
|
+
new RateLimitMiddleware2(
|
|
4220
|
+
requestContext,
|
|
4221
|
+
container.resolve(TOKENS4.CACHE),
|
|
4222
|
+
new RateLimitKeyBuilder2(requestContext),
|
|
4223
|
+
logger,
|
|
4224
|
+
{ maxRequests, windowSeconds }
|
|
4225
|
+
)
|
|
4226
|
+
);
|
|
4404
4227
|
}
|
|
4405
|
-
if (
|
|
4228
|
+
if (Guards46.isDefined(opts.csrf)) {
|
|
4406
4229
|
const csrf = opts.csrf;
|
|
4230
|
+
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4231
|
+
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
4407
4232
|
const { CsrfTokenService: CsrfTokenService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4408
4233
|
container.addSingleton("CSRF_TOKEN_SERVICE", (c) => {
|
|
4409
4234
|
return new CsrfTokenService2(csrf.secret, c.resolve("CRYPTO_SERVICE"));
|
|
4410
4235
|
});
|
|
4411
4236
|
const { CsrfCookieMiddleware: CsrfCookieMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
csrf
|
|
4417
|
-
)
|
|
4418
|
-
|
|
4419
|
-
middlewares.push("CSRF_COOKIE_MIDDLEWARE");
|
|
4237
|
+
middlewares.push(
|
|
4238
|
+
new CsrfCookieMiddleware2(
|
|
4239
|
+
requestContext,
|
|
4240
|
+
container.resolve("CSRF_TOKEN_SERVICE"),
|
|
4241
|
+
opts.csrf
|
|
4242
|
+
)
|
|
4243
|
+
);
|
|
4420
4244
|
const { CsrfMiddleware: CsrfMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4421
|
-
|
|
4422
|
-
return new CsrfMiddleware2(
|
|
4423
|
-
c.resolve(TOKENS4.REQUEST_CONTEXT),
|
|
4424
|
-
c.resolve("CSRF_TOKEN_SERVICE")
|
|
4425
|
-
);
|
|
4426
|
-
});
|
|
4427
|
-
middlewares.push(TOKENS4.CSRF_MIDDLEWARE);
|
|
4245
|
+
middlewares.push(new CsrfMiddleware2(requestContext, container.resolve("CSRF_TOKEN_SERVICE")));
|
|
4428
4246
|
}
|
|
4429
4247
|
const { CompositeMiddleware: CompositeMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4430
|
-
container.addSingleton(TOKENS4.MIDDLEWARE, (
|
|
4431
|
-
|
|
4432
|
-
(token) => c.resolve(token)
|
|
4433
|
-
);
|
|
4434
|
-
return new CompositeMiddleware2(resolvedMiddleware);
|
|
4248
|
+
container.addSingleton(TOKENS4.MIDDLEWARE, () => {
|
|
4249
|
+
return new CompositeMiddleware2(middlewares);
|
|
4435
4250
|
});
|
|
4436
4251
|
}
|
|
4252
|
+
async _getTokenExtractor(isSSR) {
|
|
4253
|
+
if (isSSR) {
|
|
4254
|
+
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4255
|
+
return new SupabaseSsrTokenExtractor2();
|
|
4256
|
+
} else {
|
|
4257
|
+
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4258
|
+
return new BearerTokenExtractor2();
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
async _getAllowMethod(configure, opts) {
|
|
4262
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
4263
|
+
if (!configure || !Guards46.isDefined(opts)) return void 0;
|
|
4264
|
+
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4265
|
+
return new AllowMethodFactory2().create(opts);
|
|
4266
|
+
}
|
|
4437
4267
|
};
|
|
4438
4268
|
}
|
|
4439
4269
|
});
|
|
@@ -4451,26 +4281,17 @@ var init_context_module = __esm({
|
|
|
4451
4281
|
async configure(container) {
|
|
4452
4282
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4453
4283
|
const { ServiceScopeFactory: ServiceScopeFactory2 } = await Promise.resolve().then(() => (init_service_scope_factory(), service_scope_factory_exports));
|
|
4454
|
-
container.addSingleton(TOKENS4.SERVICE_SCOPE_FACTORY, () => {
|
|
4455
|
-
const factory = new ServiceScopeFactory2(container);
|
|
4456
|
-
return factory;
|
|
4457
|
-
});
|
|
4458
4284
|
const { NodeRequestContextFactory: NodeRequestContextFactory2 } = await Promise.resolve().then(() => (init_request_context_factory(), request_context_factory_exports));
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
container.addSingleton(TOKENS4.
|
|
4465
|
-
container.addSingleton(TOKENS4.
|
|
4466
|
-
container.addSingleton(TOKENS4.
|
|
4467
|
-
container.addSingleton(
|
|
4468
|
-
TOKENS4.NETWORK_CONTEXT_ACCESSOR,
|
|
4469
|
-
(c) => c.resolve(TOKENS4.REQUEST_CONTEXT)
|
|
4470
|
-
);
|
|
4285
|
+
const requestContext = new NodeRequestContextFactory2(
|
|
4286
|
+
new ServiceScopeFactory2(container)
|
|
4287
|
+
).create();
|
|
4288
|
+
container.addSingleton(TOKENS4.REQUEST_CONTEXT, () => requestContext);
|
|
4289
|
+
container.addSingleton(TOKENS4.CONTEXT_ACCESSOR, () => requestContext);
|
|
4290
|
+
container.addSingleton(TOKENS4.IDENTITY_ACCESSOR, () => requestContext);
|
|
4291
|
+
container.addSingleton(TOKENS4.SERVICE_SCOPE_ACCESSOR, () => requestContext);
|
|
4292
|
+
container.addSingleton(TOKENS4.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
|
|
4471
4293
|
const { UserContextFactory: UserContextFactory2 } = await Promise.resolve().then(() => (init_user_context_factory(), user_context_factory_exports));
|
|
4472
|
-
container.addSingleton(
|
|
4473
|
-
const requestContext = c.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4294
|
+
container.addSingleton("USER_CONTEXT_FACTORY", () => {
|
|
4474
4295
|
return new UserContextFactory2(requestContext);
|
|
4475
4296
|
});
|
|
4476
4297
|
}
|
|
@@ -4486,7 +4307,7 @@ __export(index_exports, {
|
|
|
4486
4307
|
BaseController: () => BaseController,
|
|
4487
4308
|
BaseHandler: () => BaseHandler,
|
|
4488
4309
|
BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
|
|
4489
|
-
BaseQuery: () =>
|
|
4310
|
+
BaseQuery: () => import_shared79.Query,
|
|
4490
4311
|
BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
|
|
4491
4312
|
ContainerUtils: () => ContainerUtils,
|
|
4492
4313
|
ReadDao: () => ReadDao,
|
|
@@ -4498,7 +4319,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
4498
4319
|
init_application();
|
|
4499
4320
|
|
|
4500
4321
|
// src/infrastructure/builder/app.builder.ts
|
|
4501
|
-
var
|
|
4322
|
+
var import_shared73 = require("@xeno-js/shared");
|
|
4502
4323
|
|
|
4503
4324
|
// src/infrastructure/configuration/configuration.ts
|
|
4504
4325
|
var import_shared32 = require("@xeno-js/shared");
|
|
@@ -4770,10 +4591,10 @@ var AppBuilder = class {
|
|
|
4770
4591
|
constructor(container) {
|
|
4771
4592
|
this._container = container ?? new ServiceContainer();
|
|
4772
4593
|
this._container.addSingleton(
|
|
4773
|
-
|
|
4594
|
+
import_shared73.TOKENS.CONFIGURATION_SERVICE,
|
|
4774
4595
|
() => new EnvironmentConfigurationService()
|
|
4775
4596
|
);
|
|
4776
|
-
this._configuration = this._container.resolve(
|
|
4597
|
+
this._configuration = this._container.resolve(import_shared73.TOKENS.CONFIGURATION_SERVICE);
|
|
4777
4598
|
this._middlewareConfig.allowOrigins?.push(
|
|
4778
4599
|
this._configuration.get("APP_URL") ?? `http://localhost:${this._configuration.getNumber("PORT", 3e3)}`
|
|
4779
4600
|
);
|
|
@@ -4832,6 +4653,13 @@ var AppBuilder = class {
|
|
|
4832
4653
|
},
|
|
4833
4654
|
resilience: { retry: {}, circuitBreaker: {}, bulkhead: {} }
|
|
4834
4655
|
};
|
|
4656
|
+
_loggerConfig = {
|
|
4657
|
+
level: import_shared73.LOG_LEVEL.DEBUG,
|
|
4658
|
+
console: true,
|
|
4659
|
+
sentry: { config: void 0 },
|
|
4660
|
+
pino: { config: void 0 },
|
|
4661
|
+
customLoggers: void 0
|
|
4662
|
+
};
|
|
4835
4663
|
// --- Module Queuing Flags ---
|
|
4836
4664
|
_isContextModuleQueued = false;
|
|
4837
4665
|
_isMiddlewareModuleQueued = false;
|
|
@@ -4877,31 +4705,22 @@ var AppBuilder = class {
|
|
|
4877
4705
|
* @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.
|
|
4878
4706
|
* @param setupAction A callback function that receives a LoggerConfig object to configure the logger settings.
|
|
4879
4707
|
* @returns The current instance of AppBuilder for method chaining.
|
|
4880
|
-
|
|
4881
|
-
*
|
|
4708
|
+
*
|
|
4882
4709
|
* @author Xeno
|
|
4883
4710
|
* @version 1.0.0
|
|
4884
4711
|
* @since 2025-09-30
|
|
4885
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
4712
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4886
4713
|
*/
|
|
4887
4714
|
addLogger(setupAction) {
|
|
4715
|
+
if (import_shared73.Guards.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
4888
4716
|
if (this._isLoggerModuleQueued) return this;
|
|
4889
4717
|
this._isLoggerModuleQueued = true;
|
|
4890
|
-
const config = {
|
|
4891
|
-
level: import_shared74.LOG_LEVEL.DEBUG,
|
|
4892
|
-
console: true,
|
|
4893
|
-
sentry: { config: void 0 },
|
|
4894
|
-
pino: { config: void 0 },
|
|
4895
|
-
customLoggers: void 0
|
|
4896
|
-
};
|
|
4897
|
-
if (import_shared74.Guards.isDefined(setupAction) && import_shared74.Guards.isDefined(config))
|
|
4898
|
-
setupAction(config, this._configuration);
|
|
4899
4718
|
this._modules.push({
|
|
4900
|
-
priority:
|
|
4719
|
+
priority: 1,
|
|
4901
4720
|
name: "LoggerModule",
|
|
4902
4721
|
action: async () => {
|
|
4903
4722
|
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
4904
|
-
await LoggerUtils2.addLogger(this._container,
|
|
4723
|
+
await LoggerUtils2.addLogger(this._container, this._loggerConfig);
|
|
4905
4724
|
}
|
|
4906
4725
|
});
|
|
4907
4726
|
return this;
|
|
@@ -4918,11 +4737,11 @@ var AppBuilder = class {
|
|
|
4918
4737
|
* @link https://github.com/xeno-js/xeno-js
|
|
4919
4738
|
*/
|
|
4920
4739
|
addCache(setupAction) {
|
|
4740
|
+
if (import_shared73.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4921
4741
|
if (this._isCacheModuleQueued) return this;
|
|
4922
4742
|
this._isCacheModuleQueued = true;
|
|
4923
|
-
if (import_shared74.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4924
4743
|
this._modules.push({
|
|
4925
|
-
priority:
|
|
4744
|
+
priority: 2,
|
|
4926
4745
|
name: "CacheModule",
|
|
4927
4746
|
action: async () => {
|
|
4928
4747
|
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
@@ -4955,7 +4774,7 @@ var AppBuilder = class {
|
|
|
4955
4774
|
};
|
|
4956
4775
|
setupAction(config, this._configuration);
|
|
4957
4776
|
this._modules.push({
|
|
4958
|
-
priority:
|
|
4777
|
+
priority: 3,
|
|
4959
4778
|
name: "AuthModule",
|
|
4960
4779
|
action: async () => {
|
|
4961
4780
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
@@ -5029,7 +4848,7 @@ var AppBuilder = class {
|
|
|
5029
4848
|
* @link https://github.com/xeno-js/xeno-js
|
|
5030
4849
|
*/
|
|
5031
4850
|
addPipeline(setupAction) {
|
|
5032
|
-
if (
|
|
4851
|
+
if (import_shared73.Guards.isDefined(setupAction)) {
|
|
5033
4852
|
setupAction(this._pipelineConfig, this._configuration);
|
|
5034
4853
|
}
|
|
5035
4854
|
this._queuePipelineModule();
|
|
@@ -5062,20 +4881,6 @@ var AppBuilder = class {
|
|
|
5062
4881
|
});
|
|
5063
4882
|
return this;
|
|
5064
4883
|
}
|
|
5065
|
-
addAllowOrigin(setupAction) {
|
|
5066
|
-
const config = [];
|
|
5067
|
-
setupAction(config, this._configuration);
|
|
5068
|
-
this._modules.push({
|
|
5069
|
-
priority: 30,
|
|
5070
|
-
name: "HttpCoreModule",
|
|
5071
|
-
action: async () => {
|
|
5072
|
-
const { HttpOriginModule: HttpOriginModule2 } = await Promise.resolve().then(() => (init_http_core_module(), http_core_module_exports));
|
|
5073
|
-
const httpOriginModule = new HttpOriginModule2();
|
|
5074
|
-
await httpOriginModule.configure(this._container, config);
|
|
5075
|
-
}
|
|
5076
|
-
});
|
|
5077
|
-
return this;
|
|
5078
|
-
}
|
|
5079
4884
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5080
4885
|
// Dependency Injection Pass-through Methods
|
|
5081
4886
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -5163,7 +4968,7 @@ var AppBuilder = class {
|
|
|
5163
4968
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5164
4969
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5165
4970
|
`);
|
|
5166
|
-
if (error instanceof Error &&
|
|
4971
|
+
if (error instanceof Error && import_shared73.Guards.isDefined(error.stack)) {
|
|
5167
4972
|
console.error(error.stack);
|
|
5168
4973
|
}
|
|
5169
4974
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5188,17 +4993,15 @@ var AppBuilder = class {
|
|
|
5188
4993
|
if (this._isPipelineModuleQueued) return;
|
|
5189
4994
|
this._isPipelineModuleQueued = true;
|
|
5190
4995
|
this._queueContextModule();
|
|
4996
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
4997
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5191
4998
|
this._modules.push({
|
|
5192
4999
|
priority: 5,
|
|
5193
5000
|
name: "CqrsModule",
|
|
5194
5001
|
action: async () => {
|
|
5195
5002
|
const { CqrsModule: CqrsModule2 } = await Promise.resolve().then(() => (init_cqrs_module(), cqrs_module_exports));
|
|
5196
5003
|
const pipelineModule = new CqrsModule2();
|
|
5197
|
-
await pipelineModule.configure(this._container,
|
|
5198
|
-
...this._pipelineConfig,
|
|
5199
|
-
isLogger: this._isLoggerModuleQueued || this._isMiddlewareModuleQueued,
|
|
5200
|
-
isCache: !this._isCacheModuleQueued
|
|
5201
|
-
});
|
|
5004
|
+
await pipelineModule.configure(this._container, this._pipelineConfig);
|
|
5202
5005
|
}
|
|
5203
5006
|
});
|
|
5204
5007
|
}
|
|
@@ -5215,17 +5018,17 @@ var AppBuilder = class {
|
|
|
5215
5018
|
if (this._isMiddlewareModuleQueued) return;
|
|
5216
5019
|
this._isMiddlewareModuleQueued = true;
|
|
5217
5020
|
this._queueContextModule();
|
|
5021
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
5022
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5218
5023
|
this._modules.push({
|
|
5219
|
-
priority:
|
|
5024
|
+
priority: 4,
|
|
5220
5025
|
name: "MiddlewareModule",
|
|
5221
5026
|
action: async () => {
|
|
5222
5027
|
const { MiddlewareModule: MiddlewareModule2 } = await Promise.resolve().then(() => (init_middleware_module(), middleware_module_exports));
|
|
5223
5028
|
const middlewareModule = new MiddlewareModule2();
|
|
5224
5029
|
await middlewareModule.configure(this._container, {
|
|
5225
5030
|
...this._middlewareConfig,
|
|
5226
|
-
isAuth: this._isAuthModuleQueued
|
|
5227
|
-
isLogger: this._isLoggerModuleQueued,
|
|
5228
|
-
isCache: this._isCacheModuleQueued || this._isPipelineModuleQueued
|
|
5031
|
+
isAuth: this._isAuthModuleQueued
|
|
5229
5032
|
});
|
|
5230
5033
|
}
|
|
5231
5034
|
});
|
|
@@ -5291,13 +5094,11 @@ var BaseSqliteSqlDataSource = class {
|
|
|
5291
5094
|
};
|
|
5292
5095
|
|
|
5293
5096
|
// src/infrastructure/datasources/remote.datasource.ts
|
|
5294
|
-
var
|
|
5097
|
+
var import_shared74 = require("@xeno-js/shared");
|
|
5295
5098
|
|
|
5296
5099
|
// src/infrastructure/index.ts
|
|
5297
5100
|
init_factories();
|
|
5298
|
-
|
|
5299
|
-
// src/infrastructure/idempotency/index.ts
|
|
5300
|
-
init_idempotency_store();
|
|
5101
|
+
init_idempotency();
|
|
5301
5102
|
|
|
5302
5103
|
// src/infrastructure/loggers/index.ts
|
|
5303
5104
|
init_console_logger();
|
|
@@ -5321,8 +5122,8 @@ init_pipeline_utils();
|
|
|
5321
5122
|
init_validation_utils();
|
|
5322
5123
|
|
|
5323
5124
|
// src/infrastructure/repositories/read-dao.ts
|
|
5125
|
+
var import_shared75 = require("@xeno-js/shared");
|
|
5324
5126
|
var import_shared76 = require("@xeno-js/shared");
|
|
5325
|
-
var import_shared77 = require("@xeno-js/shared");
|
|
5326
5127
|
var ReadDao = class {
|
|
5327
5128
|
/**
|
|
5328
5129
|
* Constructs a new ReadDao instance.
|
|
@@ -5342,23 +5143,23 @@ var ReadDao = class {
|
|
|
5342
5143
|
_dataSource;
|
|
5343
5144
|
_mapper;
|
|
5344
5145
|
async findById(id, ctx, signal) {
|
|
5345
|
-
|
|
5146
|
+
import_shared75.AppError.throwIfAborted(signal, "ReadDao.findById");
|
|
5346
5147
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5347
|
-
if (
|
|
5148
|
+
if (import_shared76.Guards.isNullOrEmpty(result)) return import_shared75.Result.ok();
|
|
5348
5149
|
const entity = this._mapper.toEntity(result);
|
|
5349
|
-
return
|
|
5150
|
+
return import_shared75.Result.ok(entity);
|
|
5350
5151
|
}
|
|
5351
5152
|
async findAll(ctx, signal) {
|
|
5352
|
-
|
|
5153
|
+
import_shared75.AppError.throwIfAborted(signal, "ReadDao.findAll");
|
|
5353
5154
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5354
5155
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5355
|
-
return
|
|
5156
|
+
return import_shared75.Result.ok(entities);
|
|
5356
5157
|
}
|
|
5357
5158
|
};
|
|
5358
5159
|
|
|
5359
5160
|
// src/infrastructure/repositories/repository.ts
|
|
5161
|
+
var import_shared77 = require("@xeno-js/shared");
|
|
5360
5162
|
var import_shared78 = require("@xeno-js/shared");
|
|
5361
|
-
var import_shared79 = require("@xeno-js/shared");
|
|
5362
5163
|
var Repository = class {
|
|
5363
5164
|
/**
|
|
5364
5165
|
* Constructs a new Repository instance.
|
|
@@ -5378,35 +5179,35 @@ var Repository = class {
|
|
|
5378
5179
|
_dataSource;
|
|
5379
5180
|
_mapper;
|
|
5380
5181
|
async findById(id, ctx, signal) {
|
|
5381
|
-
|
|
5182
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.findById");
|
|
5382
5183
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5383
|
-
if (
|
|
5184
|
+
if (import_shared78.Guards.isNullOrEmpty(result)) return import_shared77.Result.ok();
|
|
5384
5185
|
const entity = this._mapper.toEntity(result);
|
|
5385
|
-
return
|
|
5186
|
+
return import_shared77.Result.ok(entity);
|
|
5386
5187
|
}
|
|
5387
5188
|
async findAll(ctx, signal) {
|
|
5388
|
-
|
|
5189
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.findAll");
|
|
5389
5190
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5390
5191
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5391
|
-
return
|
|
5192
|
+
return import_shared77.Result.ok(entities);
|
|
5392
5193
|
}
|
|
5393
5194
|
async save(entity, signal) {
|
|
5394
5195
|
const dto = this._mapper.toDto(entity);
|
|
5395
|
-
|
|
5196
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.save");
|
|
5396
5197
|
await this._dataSource.insert(dto, signal);
|
|
5397
|
-
return
|
|
5198
|
+
return import_shared77.Result.ok();
|
|
5398
5199
|
}
|
|
5399
5200
|
async delete(entity, ctx, signal) {
|
|
5400
5201
|
const dto = this._mapper.toDto(entity);
|
|
5401
|
-
|
|
5202
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.delete");
|
|
5402
5203
|
await this._dataSource.delete(dto, ctx, signal);
|
|
5403
|
-
return
|
|
5204
|
+
return import_shared77.Result.ok();
|
|
5404
5205
|
}
|
|
5405
5206
|
async update(id, entity, ctx, signal) {
|
|
5406
5207
|
const dto = this._mapper.toPartialDto(entity);
|
|
5407
|
-
|
|
5208
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.update");
|
|
5408
5209
|
await this._dataSource.update(id, dto, ctx, signal);
|
|
5409
|
-
return
|
|
5210
|
+
return import_shared77.Result.ok();
|
|
5410
5211
|
}
|
|
5411
5212
|
};
|
|
5412
5213
|
|
|
@@ -5424,7 +5225,7 @@ __reExport(drizzle_types_exports, require("drizzle-orm"));
|
|
|
5424
5225
|
__reExport(index_exports, drizzle_types_exports, module.exports);
|
|
5425
5226
|
init_presentation();
|
|
5426
5227
|
__reExport(index_exports, require("@xeno-js/shared"), module.exports);
|
|
5427
|
-
var
|
|
5228
|
+
var import_shared79 = require("@xeno-js/shared");
|
|
5428
5229
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5429
5230
|
0 && (module.exports = {
|
|
5430
5231
|
AppBuilder,
|