@xeno-js/core 0.1.9 → 0.1.11
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/LICENSE +18 -12
- package/README.md +341 -321
- package/dist/index.cjs +267 -458
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -234
- package/dist/index.d.ts +17 -234
- package/dist/index.js +247 -438
- package/dist/index.js.map +1 -1
- package/package.json +171 -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,24 @@ 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
|
-
container.addScoped(
|
|
2993
|
+
container.addScoped("TRANSACTION_STATE", () => {
|
|
3061
2994
|
return new TransactionState2();
|
|
3062
2995
|
});
|
|
3063
2996
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3064
2997
|
container.addScoped(TOKENS4.UNIT_OF_WORK, (c) => {
|
|
3065
|
-
const ttx = c.resolve(
|
|
2998
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3066
2999
|
return new UnitOfWork2(db, ttx);
|
|
3067
3000
|
});
|
|
3068
3001
|
container.addScoped(TOKENS4.DB_CONTEXT, (c) => {
|
|
3069
|
-
const ttx = c.resolve(
|
|
3002
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3070
3003
|
return new Proxy(db, {
|
|
3071
3004
|
get(_target, prop, receiver) {
|
|
3072
3005
|
const activeState = ttx.state;
|
|
3073
|
-
if (
|
|
3006
|
+
if (Guards46.isDefined(activeState)) {
|
|
3074
3007
|
if (prop === "transaction") {
|
|
3075
3008
|
return activeState.transaction.bind(activeState);
|
|
3076
3009
|
}
|
|
@@ -3107,14 +3040,14 @@ var init_http_utils = __esm({
|
|
|
3107
3040
|
*/
|
|
3108
3041
|
async addAxios(container, opts) {
|
|
3109
3042
|
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3110
|
-
const { Guards:
|
|
3111
|
-
if (!
|
|
3043
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3044
|
+
if (!Guards46.isDefined(opts.token)) {
|
|
3112
3045
|
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3113
3046
|
}
|
|
3114
3047
|
container.addSingleton(opts.token, () => {
|
|
3115
3048
|
const factory = new NodeAxiosFactory2();
|
|
3116
3049
|
const instance = factory.create(opts.client);
|
|
3117
|
-
if (!
|
|
3050
|
+
if (!Guards46.hasMethod(instance, "get") || !Guards46.hasMethod(instance, "post") || !Guards46.hasMethod(instance, "put") || !Guards46.hasMethod(instance, "patch") || !Guards46.hasMethod(instance, "delete")) {
|
|
3118
3051
|
throw new Error(
|
|
3119
3052
|
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3120
3053
|
);
|
|
@@ -3139,17 +3072,6 @@ var init_http_utils = __esm({
|
|
|
3139
3072
|
const factory = new CockatielResilienceFactory2();
|
|
3140
3073
|
return factory.create(opts);
|
|
3141
3074
|
});
|
|
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
3075
|
}
|
|
3154
3076
|
});
|
|
3155
3077
|
}
|
|
@@ -3158,10 +3080,9 @@ var init_http_utils = __esm({
|
|
|
3158
3080
|
// src/infrastructure/modules/http-core.module.ts
|
|
3159
3081
|
var http_core_module_exports = {};
|
|
3160
3082
|
__export(http_core_module_exports, {
|
|
3161
|
-
HttpCoreModule: () => HttpCoreModule
|
|
3162
|
-
HttpOriginModule: () => HttpOriginModule
|
|
3083
|
+
HttpCoreModule: () => HttpCoreModule
|
|
3163
3084
|
});
|
|
3164
|
-
var HttpCoreModule
|
|
3085
|
+
var HttpCoreModule;
|
|
3165
3086
|
var init_http_core_module = __esm({
|
|
3166
3087
|
"src/infrastructure/modules/http-core.module.ts"() {
|
|
3167
3088
|
"use strict";
|
|
@@ -3172,12 +3093,6 @@ var init_http_core_module = __esm({
|
|
|
3172
3093
|
await HttpUtils2.addResilience(container, opts.resilience);
|
|
3173
3094
|
}
|
|
3174
3095
|
};
|
|
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
3096
|
}
|
|
3182
3097
|
});
|
|
3183
3098
|
|
|
@@ -3202,53 +3117,32 @@ var init_validation_utils = __esm({
|
|
|
3202
3117
|
* @link https://github.com/xeno-js/xeno-js
|
|
3203
3118
|
*/
|
|
3204
3119
|
async addValidation(container, opts, logger) {
|
|
3205
|
-
const { Guards:
|
|
3206
|
-
if (!
|
|
3207
|
-
return
|
|
3120
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3121
|
+
if (!Guards46.isDefined(opts.zod) && Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3122
|
+
return;
|
|
3208
3123
|
}
|
|
3209
|
-
const pipelines = [];
|
|
3210
3124
|
const validationStrategies = [];
|
|
3211
|
-
if (
|
|
3125
|
+
if (Guards46.isDefined(opts.zod)) {
|
|
3212
3126
|
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
|
-
});
|
|
3127
|
+
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3217
3128
|
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
);
|
|
3222
|
-
validationStrategies.push(TOKENS4.SCHEMA_VALIDATION_STRATEGY);
|
|
3129
|
+
const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
|
|
3130
|
+
container.addSingleton(TOKENS4.VALIDATOR_SERVICE, () => validatorService);
|
|
3131
|
+
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
3223
3132
|
}
|
|
3224
|
-
|
|
3225
|
-
if (!Guards47.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3133
|
+
if (!Guards46.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3226
3134
|
for (const strategyToken of opts.customValidationStrategy) {
|
|
3227
|
-
if (
|
|
3228
|
-
customValidationFactory.push(strategyToken);
|
|
3229
|
-
}
|
|
3135
|
+
if (Guards46.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
3230
3136
|
}
|
|
3231
3137
|
}
|
|
3232
3138
|
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;
|
|
3139
|
+
return new ValidationPipeline2(validationStrategies);
|
|
3242
3140
|
}
|
|
3243
3141
|
});
|
|
3244
3142
|
}
|
|
3245
3143
|
});
|
|
3246
3144
|
|
|
3247
3145
|
// src/infrastructure/idempotency/idempotency-store.ts
|
|
3248
|
-
var idempotency_store_exports = {};
|
|
3249
|
-
__export(idempotency_store_exports, {
|
|
3250
|
-
IdempotencyStore: () => IdempotencyStore
|
|
3251
|
-
});
|
|
3252
3146
|
var import_shared60, IdempotencyStore;
|
|
3253
3147
|
var init_idempotency_store = __esm({
|
|
3254
3148
|
"src/infrastructure/idempotency/idempotency-store.ts"() {
|
|
@@ -3305,6 +3199,18 @@ var init_idempotency_store = __esm({
|
|
|
3305
3199
|
}
|
|
3306
3200
|
});
|
|
3307
3201
|
|
|
3202
|
+
// src/infrastructure/idempotency/index.ts
|
|
3203
|
+
var idempotency_exports = {};
|
|
3204
|
+
__export(idempotency_exports, {
|
|
3205
|
+
IdempotencyStore: () => IdempotencyStore
|
|
3206
|
+
});
|
|
3207
|
+
var init_idempotency = __esm({
|
|
3208
|
+
"src/infrastructure/idempotency/index.ts"() {
|
|
3209
|
+
"use strict";
|
|
3210
|
+
init_idempotency_store();
|
|
3211
|
+
}
|
|
3212
|
+
});
|
|
3213
|
+
|
|
3308
3214
|
// src/infrastructure/modules/utils/pipeline.utils.ts
|
|
3309
3215
|
var pipeline_utils_exports = {};
|
|
3310
3216
|
__export(pipeline_utils_exports, {
|
|
@@ -3326,35 +3232,30 @@ var init_pipeline_utils = __esm({
|
|
|
3326
3232
|
* @link https://github.com/xeno-js/xeno-js
|
|
3327
3233
|
*/
|
|
3328
3234
|
async addCommand(container, opts) {
|
|
3235
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3329
3236
|
const pipelines = [];
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
TOKENS4.
|
|
3335
|
-
(c) => new IdempotencyStore2(c.resolve(TOKENS4.CACHE), c.resolve(TOKENS4.CACHE_KEY_BUILDER))
|
|
3237
|
+
if (Guards46.isDefined(opts.idempotency)) {
|
|
3238
|
+
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
3239
|
+
const imdStore = new IdempotencyStore2(
|
|
3240
|
+
container.resolve(TOKENS4.CACHE),
|
|
3241
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER)
|
|
3336
3242
|
);
|
|
3337
3243
|
const { IdempotencyPipeline: IdempotencyPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3338
|
-
container.
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
return new IdempotencyPipeline2(
|
|
3244
|
+
const requestContext = container.resolve(TOKENS4.NETWORK_CONTEXT_ACCESSOR);
|
|
3245
|
+
const config = opts.idempotency;
|
|
3246
|
+
pipelines.push(
|
|
3247
|
+
new IdempotencyPipeline2(
|
|
3343
3248
|
requestContext,
|
|
3344
|
-
|
|
3249
|
+
imdStore,
|
|
3345
3250
|
config?.lockTtlSeconds,
|
|
3346
3251
|
config?.processedTtlSeconds
|
|
3347
|
-
)
|
|
3348
|
-
|
|
3349
|
-
pipelines.push(TOKENS4.IDEMPOTENCY_PIPELINE);
|
|
3252
|
+
)
|
|
3253
|
+
);
|
|
3350
3254
|
}
|
|
3351
|
-
if (
|
|
3255
|
+
if (Guards46.isDefined(opts.concurrency)) {
|
|
3352
3256
|
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);
|
|
3257
|
+
const config = opts.concurrency;
|
|
3258
|
+
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
3358
3259
|
}
|
|
3359
3260
|
return pipelines;
|
|
3360
3261
|
},
|
|
@@ -3368,24 +3269,14 @@ var init_pipeline_utils = __esm({
|
|
|
3368
3269
|
* @since 2025-09-30
|
|
3369
3270
|
* @link https://github.com/xeno-js/xeno-js
|
|
3370
3271
|
*/
|
|
3371
|
-
async addQuery(container
|
|
3272
|
+
async addQuery(container) {
|
|
3372
3273
|
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
3274
|
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
|
-
)
|
|
3275
|
+
return new QueryCachingPipeline2(
|
|
3276
|
+
container.resolve(TOKENS4.CACHE),
|
|
3277
|
+
container.resolve(TOKENS4.CACHE_KEY_BUILDER),
|
|
3278
|
+
container.resolve(TOKENS4.LOGGER)
|
|
3386
3279
|
);
|
|
3387
|
-
pipelines.push(TOKENS4.QUERY_CACHING_PIPELINE);
|
|
3388
|
-
return pipelines;
|
|
3389
3280
|
}
|
|
3390
3281
|
});
|
|
3391
3282
|
}
|
|
@@ -3403,79 +3294,54 @@ var init_cqrs_module = __esm({
|
|
|
3403
3294
|
CqrsModule = class {
|
|
3404
3295
|
async configure(container, opts) {
|
|
3405
3296
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
3406
|
-
|
|
3297
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3407
3298
|
const { Mediator: Mediator2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3408
3299
|
container.addSingleton(TOKENS4.MEDIATOR, (c) => {
|
|
3409
3300
|
const serviceScopeAccessor = c.resolve(TOKENS4.SERVICE_SCOPE_ACCESSOR);
|
|
3410
3301
|
return new Mediator2(serviceScopeAccessor);
|
|
3411
3302
|
});
|
|
3412
3303
|
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
3304
|
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
3305
|
const { PerformancePipeline: PerformancePipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
const { Guards:
|
|
3432
|
-
if (
|
|
3306
|
+
const thresholdMs = opts.performance?.thresholdMs;
|
|
3307
|
+
const pipelines = [
|
|
3308
|
+
new ExceptionPipeline2(),
|
|
3309
|
+
new LoggingPipeline2(logger),
|
|
3310
|
+
new PerformancePipeline2(logger, thresholdMs)
|
|
3311
|
+
];
|
|
3312
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
3313
|
+
if (Guards46.isDefined(opts.authorization.policies) || Guards46.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3433
3314
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3434
3315
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3435
|
-
pipelines.push(
|
|
3316
|
+
pipelines.push(authPipelines);
|
|
3436
3317
|
}
|
|
3437
|
-
if (
|
|
3318
|
+
if (Guards46.isDefined(opts.validation.zod) || Guards46.isDefined(opts.validation.customValidationStrategy)) {
|
|
3438
3319
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3439
|
-
const logger = container.resolve(TOKENS4.LOGGER);
|
|
3440
3320
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3441
3321
|
container,
|
|
3442
3322
|
opts.validation,
|
|
3443
3323
|
logger
|
|
3444
3324
|
);
|
|
3445
|
-
pipelines.push(
|
|
3325
|
+
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3446
3326
|
}
|
|
3447
3327
|
const commandPipelines = pipelines;
|
|
3448
3328
|
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)) {
|
|
3329
|
+
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3454
3330
|
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;
|
|
3331
|
+
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3460
3332
|
commandPipelines.push(...newCommandPipelines);
|
|
3461
3333
|
}
|
|
3462
3334
|
if (opts.queryBus.isEnabled) {
|
|
3463
3335
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3464
|
-
const newQueryPipelines = await PipelineUtils2.addQuery(container
|
|
3465
|
-
queryPipelines.push(
|
|
3336
|
+
const newQueryPipelines = await PipelineUtils2.addQuery(container);
|
|
3337
|
+
queryPipelines.push(newQueryPipelines);
|
|
3466
3338
|
}
|
|
3467
3339
|
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);
|
|
3340
|
+
container.addSingleton(TOKENS4.COMMAND_PIPELINES_BEHAVIOR, () => {
|
|
3341
|
+
return new CompositePipeline2(commandPipelines);
|
|
3473
3342
|
});
|
|
3474
|
-
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, (
|
|
3475
|
-
|
|
3476
|
-
(token) => c.resolve(token)
|
|
3477
|
-
);
|
|
3478
|
-
return new CompositePipeline2(resolvedQueryPipelines);
|
|
3343
|
+
container.addSingleton(TOKENS4.QUERY_PIPELINES_BEHAVIOR, () => {
|
|
3344
|
+
return new CompositePipeline2(queryPipelines);
|
|
3479
3345
|
});
|
|
3480
3346
|
}
|
|
3481
3347
|
};
|
|
@@ -4259,150 +4125,111 @@ var middleware_module_exports = {};
|
|
|
4259
4125
|
__export(middleware_module_exports, {
|
|
4260
4126
|
MiddlewareModule: () => MiddlewareModule
|
|
4261
4127
|
});
|
|
4262
|
-
var
|
|
4128
|
+
var MiddlewareModule;
|
|
4263
4129
|
var init_middleware_module = __esm({
|
|
4264
4130
|
"src/infrastructure/modules/middleware.module.ts"() {
|
|
4265
4131
|
"use strict";
|
|
4266
|
-
import_shared73 = require("@xeno-js/shared");
|
|
4267
4132
|
MiddlewareModule = class {
|
|
4268
4133
|
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
|
-
}
|
|
4134
|
+
const { Guards: Guards46, TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4281
4135
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4282
|
-
container.addSingleton("COOKIE_EXTRACTOR", () => new HttpCookieExtractor2());
|
|
4283
4136
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4137
|
+
const tokenExtractor = await this._getTokenExtractor(opts.isSSR);
|
|
4284
4138
|
container.addSingleton(
|
|
4285
4139
|
TOKENS4.SERVICE_EXTRACTOR,
|
|
4286
|
-
(
|
|
4287
|
-
|
|
4288
|
-
|
|
4140
|
+
() => new HttpHeaderExtractor2(
|
|
4141
|
+
tokenExtractor,
|
|
4142
|
+
new HttpCookieExtractor2(),
|
|
4289
4143
|
opts.trustedIpHeader,
|
|
4290
4144
|
opts.csrf?.cookieName ?? "__Host-xeno-csrf"
|
|
4291
4145
|
)
|
|
4292
4146
|
);
|
|
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
4147
|
const { ClientIpResolver: ClientIpResolver2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4298
|
-
|
|
4299
|
-
const
|
|
4148
|
+
const middlewares = [];
|
|
4149
|
+
const requestContext = container.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4150
|
+
const logger = container.resolve(TOKENS4.LOGGER);
|
|
4300
4151
|
const { RequestContextMiddleware: RequestContextMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
c.resolve(TOKENS4.LOGGER)
|
|
4152
|
+
middlewares.push(
|
|
4153
|
+
new RequestContextMiddleware2(
|
|
4154
|
+
requestContext,
|
|
4155
|
+
container.resolve(TOKENS4.SERVICE_EXTRACTOR),
|
|
4156
|
+
new ClientIpResolver2(opts.trustedProxies),
|
|
4157
|
+
logger
|
|
4308
4158
|
)
|
|
4309
4159
|
);
|
|
4310
|
-
if (!
|
|
4160
|
+
if (!Guards46.isNullOrEmpty(opts.allowOrigins)) {
|
|
4311
4161
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4312
4162
|
throw new Error(
|
|
4313
4163
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
4314
4164
|
);
|
|
4315
4165
|
const { AllowOrigin: AllowOrigin2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4316
|
-
container.addSingleton("ALLOW_ORIGIN", () => {
|
|
4317
|
-
return new AllowOrigin2(opts.allowOrigins);
|
|
4318
|
-
});
|
|
4319
4166
|
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);
|
|
4167
|
+
middlewares.push(
|
|
4168
|
+
new AllowOriginMiddleware2(new AllowOrigin2(opts.allowOrigins), requestContext, logger)
|
|
4169
|
+
);
|
|
4328
4170
|
}
|
|
4329
4171
|
const withCredentials = opts.withCredentials ? "true" : "false";
|
|
4172
|
+
const allowMethod = await this._getAllowMethod(
|
|
4173
|
+
opts.optionsMiddleware || opts.cors,
|
|
4174
|
+
opts.routeRegistry
|
|
4175
|
+
);
|
|
4330
4176
|
if (opts.optionsMiddleware) {
|
|
4331
4177
|
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
|
-
)
|
|
4178
|
+
middlewares.push(
|
|
4179
|
+
new OptionsMiddleware2(requestContext, allowMethod, opts.allowHeaders, withCredentials)
|
|
4340
4180
|
);
|
|
4341
|
-
middlewares.push(TOKENS4.OPTIONS_MIDDLEWARE);
|
|
4342
4181
|
}
|
|
4343
4182
|
if (opts.cors) {
|
|
4344
4183
|
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);
|
|
4184
|
+
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4349
4185
|
}
|
|
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));
|
|
4186
|
+
if (Guards46.isDefined(opts.routeRegistry)) {
|
|
4354
4187
|
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);
|
|
4188
|
+
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4363
4189
|
}
|
|
4364
4190
|
const { AuthenticationMiddleware: AuthenticationMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4191
|
+
if (!opts.isAuth) {
|
|
4192
|
+
const { NoAuthGateKeeper: NoAuthGateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4193
|
+
middlewares.push(
|
|
4194
|
+
new AuthenticationMiddleware2(
|
|
4195
|
+
requestContext,
|
|
4196
|
+
tokenExtractor,
|
|
4197
|
+
new NoAuthGateKeeper2(),
|
|
4198
|
+
logger
|
|
4199
|
+
)
|
|
4371
4200
|
);
|
|
4372
|
-
}
|
|
4373
|
-
|
|
4374
|
-
|
|
4201
|
+
} else {
|
|
4202
|
+
const { ClaimsIdentityMapper: ClaimsIdentityMapper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4203
|
+
const { GateKeeper: GateKeeper2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
4204
|
+
middlewares.push(
|
|
4205
|
+
new AuthenticationMiddleware2(
|
|
4206
|
+
requestContext,
|
|
4207
|
+
tokenExtractor,
|
|
4208
|
+
new GateKeeper2(container.resolve(TOKENS4.BASE_AUTH_SERVICE), new ClaimsIdentityMapper2()),
|
|
4209
|
+
logger
|
|
4210
|
+
)
|
|
4211
|
+
);
|
|
4212
|
+
}
|
|
4213
|
+
if (Guards46.isDefined(opts.rateLimite.maxRequests) || Guards46.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4375
4214
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4376
|
-
|
|
4377
|
-
|
|
4215
|
+
Guards46.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4216
|
+
Guards46.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4378
4217
|
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
|
-
}
|
|
4218
|
+
Guards46.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4219
|
+
Guards46.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4385
4220
|
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
4221
|
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);
|
|
4222
|
+
middlewares.push(
|
|
4223
|
+
new RateLimitMiddleware2(
|
|
4224
|
+
requestContext,
|
|
4225
|
+
container.resolve(TOKENS4.CACHE),
|
|
4226
|
+
new RateLimitKeyBuilder2(requestContext),
|
|
4227
|
+
logger,
|
|
4228
|
+
{ maxRequests, windowSeconds }
|
|
4229
|
+
)
|
|
4230
|
+
);
|
|
4404
4231
|
}
|
|
4405
|
-
if (
|
|
4232
|
+
if (Guards46.isDefined(opts.csrf)) {
|
|
4406
4233
|
const csrf = opts.csrf;
|
|
4407
4234
|
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4408
4235
|
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
@@ -4411,31 +4238,36 @@ var init_middleware_module = __esm({
|
|
|
4411
4238
|
return new CsrfTokenService2(csrf.secret, c.resolve("CRYPTO_SERVICE"));
|
|
4412
4239
|
});
|
|
4413
4240
|
const { CsrfCookieMiddleware: CsrfCookieMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
csrf
|
|
4419
|
-
)
|
|
4420
|
-
|
|
4421
|
-
middlewares.push("CSRF_COOKIE_MIDDLEWARE");
|
|
4241
|
+
middlewares.push(
|
|
4242
|
+
new CsrfCookieMiddleware2(
|
|
4243
|
+
requestContext,
|
|
4244
|
+
container.resolve("CSRF_TOKEN_SERVICE"),
|
|
4245
|
+
opts.csrf
|
|
4246
|
+
)
|
|
4247
|
+
);
|
|
4422
4248
|
const { CsrfMiddleware: CsrfMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4423
|
-
|
|
4424
|
-
return new CsrfMiddleware2(
|
|
4425
|
-
c.resolve(TOKENS4.REQUEST_CONTEXT),
|
|
4426
|
-
c.resolve("CSRF_TOKEN_SERVICE")
|
|
4427
|
-
);
|
|
4428
|
-
});
|
|
4429
|
-
middlewares.push(TOKENS4.CSRF_MIDDLEWARE);
|
|
4249
|
+
middlewares.push(new CsrfMiddleware2(requestContext, container.resolve("CSRF_TOKEN_SERVICE")));
|
|
4430
4250
|
}
|
|
4431
4251
|
const { CompositeMiddleware: CompositeMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4432
|
-
container.addSingleton(TOKENS4.MIDDLEWARE, (
|
|
4433
|
-
|
|
4434
|
-
(token) => c.resolve(token)
|
|
4435
|
-
);
|
|
4436
|
-
return new CompositeMiddleware2(resolvedMiddleware);
|
|
4252
|
+
container.addSingleton(TOKENS4.MIDDLEWARE, () => {
|
|
4253
|
+
return new CompositeMiddleware2(middlewares);
|
|
4437
4254
|
});
|
|
4438
4255
|
}
|
|
4256
|
+
async _getTokenExtractor(isSSR) {
|
|
4257
|
+
if (isSSR) {
|
|
4258
|
+
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4259
|
+
return new SupabaseSsrTokenExtractor2();
|
|
4260
|
+
} else {
|
|
4261
|
+
const { BearerTokenExtractor: BearerTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4262
|
+
return new BearerTokenExtractor2();
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
async _getAllowMethod(configure, opts) {
|
|
4266
|
+
const { Guards: Guards46 } = await import("@xeno-js/shared");
|
|
4267
|
+
if (!configure || !Guards46.isDefined(opts)) return void 0;
|
|
4268
|
+
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4269
|
+
return new AllowMethodFactory2().create(opts);
|
|
4270
|
+
}
|
|
4439
4271
|
};
|
|
4440
4272
|
}
|
|
4441
4273
|
});
|
|
@@ -4453,26 +4285,17 @@ var init_context_module = __esm({
|
|
|
4453
4285
|
async configure(container) {
|
|
4454
4286
|
const { TOKENS: TOKENS4 } = await import("@xeno-js/shared");
|
|
4455
4287
|
const { ServiceScopeFactory: ServiceScopeFactory2 } = await Promise.resolve().then(() => (init_service_scope_factory(), service_scope_factory_exports));
|
|
4456
|
-
container.addSingleton(TOKENS4.SERVICE_SCOPE_FACTORY, () => {
|
|
4457
|
-
const factory = new ServiceScopeFactory2(container);
|
|
4458
|
-
return factory;
|
|
4459
|
-
});
|
|
4460
4288
|
const { NodeRequestContextFactory: NodeRequestContextFactory2 } = await Promise.resolve().then(() => (init_request_context_factory(), request_context_factory_exports));
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
container.addSingleton(TOKENS4.
|
|
4467
|
-
container.addSingleton(TOKENS4.
|
|
4468
|
-
container.addSingleton(TOKENS4.
|
|
4469
|
-
container.addSingleton(
|
|
4470
|
-
TOKENS4.NETWORK_CONTEXT_ACCESSOR,
|
|
4471
|
-
(c) => c.resolve(TOKENS4.REQUEST_CONTEXT)
|
|
4472
|
-
);
|
|
4289
|
+
const requestContext = new NodeRequestContextFactory2(
|
|
4290
|
+
new ServiceScopeFactory2(container)
|
|
4291
|
+
).create();
|
|
4292
|
+
container.addSingleton(TOKENS4.REQUEST_CONTEXT, () => requestContext);
|
|
4293
|
+
container.addSingleton(TOKENS4.CONTEXT_ACCESSOR, () => requestContext);
|
|
4294
|
+
container.addSingleton(TOKENS4.IDENTITY_ACCESSOR, () => requestContext);
|
|
4295
|
+
container.addSingleton(TOKENS4.SERVICE_SCOPE_ACCESSOR, () => requestContext);
|
|
4296
|
+
container.addSingleton(TOKENS4.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
|
|
4473
4297
|
const { UserContextFactory: UserContextFactory2 } = await Promise.resolve().then(() => (init_user_context_factory(), user_context_factory_exports));
|
|
4474
|
-
container.addSingleton(
|
|
4475
|
-
const requestContext = c.resolve(TOKENS4.REQUEST_CONTEXT);
|
|
4298
|
+
container.addSingleton("USER_CONTEXT_FACTORY", () => {
|
|
4476
4299
|
return new UserContextFactory2(requestContext);
|
|
4477
4300
|
});
|
|
4478
4301
|
}
|
|
@@ -4488,7 +4311,7 @@ __export(index_exports, {
|
|
|
4488
4311
|
BaseController: () => BaseController,
|
|
4489
4312
|
BaseHandler: () => BaseHandler,
|
|
4490
4313
|
BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
|
|
4491
|
-
BaseQuery: () =>
|
|
4314
|
+
BaseQuery: () => import_shared79.Query,
|
|
4492
4315
|
BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
|
|
4493
4316
|
ContainerUtils: () => ContainerUtils,
|
|
4494
4317
|
ReadDao: () => ReadDao,
|
|
@@ -4500,7 +4323,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
4500
4323
|
init_application();
|
|
4501
4324
|
|
|
4502
4325
|
// src/infrastructure/builder/app.builder.ts
|
|
4503
|
-
var
|
|
4326
|
+
var import_shared73 = require("@xeno-js/shared");
|
|
4504
4327
|
|
|
4505
4328
|
// src/infrastructure/configuration/configuration.ts
|
|
4506
4329
|
var import_shared32 = require("@xeno-js/shared");
|
|
@@ -4650,6 +4473,12 @@ var ServiceContainer = class {
|
|
|
4650
4473
|
this.registrations.set(token, { token, lifetime, factory });
|
|
4651
4474
|
}
|
|
4652
4475
|
resolve(token) {
|
|
4476
|
+
const registration = this.registrations.get(token);
|
|
4477
|
+
if (registration?.lifetime === "scoped") {
|
|
4478
|
+
throw new Error(
|
|
4479
|
+
`[DI Container Error]: Scoped service '${String(token)}' requires an active scope.`
|
|
4480
|
+
);
|
|
4481
|
+
}
|
|
4653
4482
|
return this.internalExecuteInContext(() => this.rootScope.resolve(token));
|
|
4654
4483
|
}
|
|
4655
4484
|
createScope() {
|
|
@@ -4772,10 +4601,10 @@ var AppBuilder = class {
|
|
|
4772
4601
|
constructor(container) {
|
|
4773
4602
|
this._container = container ?? new ServiceContainer();
|
|
4774
4603
|
this._container.addSingleton(
|
|
4775
|
-
|
|
4604
|
+
import_shared73.TOKENS.CONFIGURATION_SERVICE,
|
|
4776
4605
|
() => new EnvironmentConfigurationService()
|
|
4777
4606
|
);
|
|
4778
|
-
this._configuration = this._container.resolve(
|
|
4607
|
+
this._configuration = this._container.resolve(import_shared73.TOKENS.CONFIGURATION_SERVICE);
|
|
4779
4608
|
this._middlewareConfig.allowOrigins?.push(
|
|
4780
4609
|
this._configuration.get("APP_URL") ?? `http://localhost:${this._configuration.getNumber("PORT", 3e3)}`
|
|
4781
4610
|
);
|
|
@@ -4834,6 +4663,13 @@ var AppBuilder = class {
|
|
|
4834
4663
|
},
|
|
4835
4664
|
resilience: { retry: {}, circuitBreaker: {}, bulkhead: {} }
|
|
4836
4665
|
};
|
|
4666
|
+
_loggerConfig = {
|
|
4667
|
+
level: import_shared73.LOG_LEVEL.DEBUG,
|
|
4668
|
+
console: true,
|
|
4669
|
+
sentry: { config: void 0 },
|
|
4670
|
+
pino: { config: void 0 },
|
|
4671
|
+
customLoggers: void 0
|
|
4672
|
+
};
|
|
4837
4673
|
// --- Module Queuing Flags ---
|
|
4838
4674
|
_isContextModuleQueued = false;
|
|
4839
4675
|
_isMiddlewareModuleQueued = false;
|
|
@@ -4879,31 +4715,22 @@ var AppBuilder = class {
|
|
|
4879
4715
|
* @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.
|
|
4880
4716
|
* @param setupAction A callback function that receives a LoggerConfig object to configure the logger settings.
|
|
4881
4717
|
* @returns The current instance of AppBuilder for method chaining.
|
|
4882
|
-
|
|
4883
|
-
*
|
|
4718
|
+
*
|
|
4884
4719
|
* @author Xeno
|
|
4885
4720
|
* @version 1.0.0
|
|
4886
4721
|
* @since 2025-09-30
|
|
4887
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
4722
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4888
4723
|
*/
|
|
4889
4724
|
addLogger(setupAction) {
|
|
4725
|
+
if (import_shared73.Guards.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
4890
4726
|
if (this._isLoggerModuleQueued) return this;
|
|
4891
4727
|
this._isLoggerModuleQueued = true;
|
|
4892
|
-
const config = {
|
|
4893
|
-
level: import_shared74.LOG_LEVEL.DEBUG,
|
|
4894
|
-
console: true,
|
|
4895
|
-
sentry: { config: void 0 },
|
|
4896
|
-
pino: { config: void 0 },
|
|
4897
|
-
customLoggers: void 0
|
|
4898
|
-
};
|
|
4899
|
-
if (import_shared74.Guards.isDefined(setupAction) && import_shared74.Guards.isDefined(config))
|
|
4900
|
-
setupAction(config, this._configuration);
|
|
4901
4728
|
this._modules.push({
|
|
4902
|
-
priority:
|
|
4729
|
+
priority: 1,
|
|
4903
4730
|
name: "LoggerModule",
|
|
4904
4731
|
action: async () => {
|
|
4905
4732
|
const { LoggerUtils: LoggerUtils2 } = await Promise.resolve().then(() => (init_logger_utils(), logger_utils_exports));
|
|
4906
|
-
await LoggerUtils2.addLogger(this._container,
|
|
4733
|
+
await LoggerUtils2.addLogger(this._container, this._loggerConfig);
|
|
4907
4734
|
}
|
|
4908
4735
|
});
|
|
4909
4736
|
return this;
|
|
@@ -4920,11 +4747,11 @@ var AppBuilder = class {
|
|
|
4920
4747
|
* @link https://github.com/xeno-js/xeno-js
|
|
4921
4748
|
*/
|
|
4922
4749
|
addCache(setupAction) {
|
|
4750
|
+
if (import_shared73.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4923
4751
|
if (this._isCacheModuleQueued) return this;
|
|
4924
4752
|
this._isCacheModuleQueued = true;
|
|
4925
|
-
if (import_shared74.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4926
4753
|
this._modules.push({
|
|
4927
|
-
priority:
|
|
4754
|
+
priority: 2,
|
|
4928
4755
|
name: "CacheModule",
|
|
4929
4756
|
action: async () => {
|
|
4930
4757
|
const { CacheUtils: CacheUtils2 } = await Promise.resolve().then(() => (init_cache_utils(), cache_utils_exports));
|
|
@@ -4957,7 +4784,7 @@ var AppBuilder = class {
|
|
|
4957
4784
|
};
|
|
4958
4785
|
setupAction(config, this._configuration);
|
|
4959
4786
|
this._modules.push({
|
|
4960
|
-
priority:
|
|
4787
|
+
priority: 3,
|
|
4961
4788
|
name: "AuthModule",
|
|
4962
4789
|
action: async () => {
|
|
4963
4790
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
@@ -5031,7 +4858,7 @@ var AppBuilder = class {
|
|
|
5031
4858
|
* @link https://github.com/xeno-js/xeno-js
|
|
5032
4859
|
*/
|
|
5033
4860
|
addPipeline(setupAction) {
|
|
5034
|
-
if (
|
|
4861
|
+
if (import_shared73.Guards.isDefined(setupAction)) {
|
|
5035
4862
|
setupAction(this._pipelineConfig, this._configuration);
|
|
5036
4863
|
}
|
|
5037
4864
|
this._queuePipelineModule();
|
|
@@ -5064,20 +4891,6 @@ var AppBuilder = class {
|
|
|
5064
4891
|
});
|
|
5065
4892
|
return this;
|
|
5066
4893
|
}
|
|
5067
|
-
addAllowOrigin(setupAction) {
|
|
5068
|
-
const config = [];
|
|
5069
|
-
setupAction(config, this._configuration);
|
|
5070
|
-
this._modules.push({
|
|
5071
|
-
priority: 30,
|
|
5072
|
-
name: "HttpCoreModule",
|
|
5073
|
-
action: async () => {
|
|
5074
|
-
const { HttpOriginModule: HttpOriginModule2 } = await Promise.resolve().then(() => (init_http_core_module(), http_core_module_exports));
|
|
5075
|
-
const httpOriginModule = new HttpOriginModule2();
|
|
5076
|
-
await httpOriginModule.configure(this._container, config);
|
|
5077
|
-
}
|
|
5078
|
-
});
|
|
5079
|
-
return this;
|
|
5080
|
-
}
|
|
5081
4894
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5082
4895
|
// Dependency Injection Pass-through Methods
|
|
5083
4896
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -5165,7 +4978,7 @@ var AppBuilder = class {
|
|
|
5165
4978
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5166
4979
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5167
4980
|
`);
|
|
5168
|
-
if (error instanceof Error &&
|
|
4981
|
+
if (error instanceof Error && import_shared73.Guards.isDefined(error.stack)) {
|
|
5169
4982
|
console.error(error.stack);
|
|
5170
4983
|
}
|
|
5171
4984
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5190,17 +5003,15 @@ var AppBuilder = class {
|
|
|
5190
5003
|
if (this._isPipelineModuleQueued) return;
|
|
5191
5004
|
this._isPipelineModuleQueued = true;
|
|
5192
5005
|
this._queueContextModule();
|
|
5006
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
5007
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5193
5008
|
this._modules.push({
|
|
5194
5009
|
priority: 5,
|
|
5195
5010
|
name: "CqrsModule",
|
|
5196
5011
|
action: async () => {
|
|
5197
5012
|
const { CqrsModule: CqrsModule2 } = await Promise.resolve().then(() => (init_cqrs_module(), cqrs_module_exports));
|
|
5198
5013
|
const pipelineModule = new CqrsModule2();
|
|
5199
|
-
await pipelineModule.configure(this._container,
|
|
5200
|
-
...this._pipelineConfig,
|
|
5201
|
-
isLogger: this._isLoggerModuleQueued || this._isMiddlewareModuleQueued,
|
|
5202
|
-
isCache: !this._isCacheModuleQueued
|
|
5203
|
-
});
|
|
5014
|
+
await pipelineModule.configure(this._container, this._pipelineConfig);
|
|
5204
5015
|
}
|
|
5205
5016
|
});
|
|
5206
5017
|
}
|
|
@@ -5217,17 +5028,17 @@ var AppBuilder = class {
|
|
|
5217
5028
|
if (this._isMiddlewareModuleQueued) return;
|
|
5218
5029
|
this._isMiddlewareModuleQueued = true;
|
|
5219
5030
|
this._queueContextModule();
|
|
5031
|
+
if (!this._isLoggerModuleQueued) this.addLogger();
|
|
5032
|
+
if (!this._isCacheModuleQueued) this.addCache();
|
|
5220
5033
|
this._modules.push({
|
|
5221
|
-
priority:
|
|
5034
|
+
priority: 4,
|
|
5222
5035
|
name: "MiddlewareModule",
|
|
5223
5036
|
action: async () => {
|
|
5224
5037
|
const { MiddlewareModule: MiddlewareModule2 } = await Promise.resolve().then(() => (init_middleware_module(), middleware_module_exports));
|
|
5225
5038
|
const middlewareModule = new MiddlewareModule2();
|
|
5226
5039
|
await middlewareModule.configure(this._container, {
|
|
5227
5040
|
...this._middlewareConfig,
|
|
5228
|
-
isAuth: this._isAuthModuleQueued
|
|
5229
|
-
isLogger: this._isLoggerModuleQueued,
|
|
5230
|
-
isCache: this._isCacheModuleQueued || this._isPipelineModuleQueued
|
|
5041
|
+
isAuth: this._isAuthModuleQueued
|
|
5231
5042
|
});
|
|
5232
5043
|
}
|
|
5233
5044
|
});
|
|
@@ -5293,13 +5104,11 @@ var BaseSqliteSqlDataSource = class {
|
|
|
5293
5104
|
};
|
|
5294
5105
|
|
|
5295
5106
|
// src/infrastructure/datasources/remote.datasource.ts
|
|
5296
|
-
var
|
|
5107
|
+
var import_shared74 = require("@xeno-js/shared");
|
|
5297
5108
|
|
|
5298
5109
|
// src/infrastructure/index.ts
|
|
5299
5110
|
init_factories();
|
|
5300
|
-
|
|
5301
|
-
// src/infrastructure/idempotency/index.ts
|
|
5302
|
-
init_idempotency_store();
|
|
5111
|
+
init_idempotency();
|
|
5303
5112
|
|
|
5304
5113
|
// src/infrastructure/loggers/index.ts
|
|
5305
5114
|
init_console_logger();
|
|
@@ -5323,8 +5132,8 @@ init_pipeline_utils();
|
|
|
5323
5132
|
init_validation_utils();
|
|
5324
5133
|
|
|
5325
5134
|
// src/infrastructure/repositories/read-dao.ts
|
|
5135
|
+
var import_shared75 = require("@xeno-js/shared");
|
|
5326
5136
|
var import_shared76 = require("@xeno-js/shared");
|
|
5327
|
-
var import_shared77 = require("@xeno-js/shared");
|
|
5328
5137
|
var ReadDao = class {
|
|
5329
5138
|
/**
|
|
5330
5139
|
* Constructs a new ReadDao instance.
|
|
@@ -5344,23 +5153,23 @@ var ReadDao = class {
|
|
|
5344
5153
|
_dataSource;
|
|
5345
5154
|
_mapper;
|
|
5346
5155
|
async findById(id, ctx, signal) {
|
|
5347
|
-
|
|
5156
|
+
import_shared75.AppError.throwIfAborted(signal, "ReadDao.findById");
|
|
5348
5157
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5349
|
-
if (
|
|
5158
|
+
if (import_shared76.Guards.isNullOrEmpty(result)) return import_shared75.Result.ok();
|
|
5350
5159
|
const entity = this._mapper.toEntity(result);
|
|
5351
|
-
return
|
|
5160
|
+
return import_shared75.Result.ok(entity);
|
|
5352
5161
|
}
|
|
5353
5162
|
async findAll(ctx, signal) {
|
|
5354
|
-
|
|
5163
|
+
import_shared75.AppError.throwIfAborted(signal, "ReadDao.findAll");
|
|
5355
5164
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5356
5165
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5357
|
-
return
|
|
5166
|
+
return import_shared75.Result.ok(entities);
|
|
5358
5167
|
}
|
|
5359
5168
|
};
|
|
5360
5169
|
|
|
5361
5170
|
// src/infrastructure/repositories/repository.ts
|
|
5171
|
+
var import_shared77 = require("@xeno-js/shared");
|
|
5362
5172
|
var import_shared78 = require("@xeno-js/shared");
|
|
5363
|
-
var import_shared79 = require("@xeno-js/shared");
|
|
5364
5173
|
var Repository = class {
|
|
5365
5174
|
/**
|
|
5366
5175
|
* Constructs a new Repository instance.
|
|
@@ -5380,35 +5189,35 @@ var Repository = class {
|
|
|
5380
5189
|
_dataSource;
|
|
5381
5190
|
_mapper;
|
|
5382
5191
|
async findById(id, ctx, signal) {
|
|
5383
|
-
|
|
5192
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.findById");
|
|
5384
5193
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5385
|
-
if (
|
|
5194
|
+
if (import_shared78.Guards.isNullOrEmpty(result)) return import_shared77.Result.ok();
|
|
5386
5195
|
const entity = this._mapper.toEntity(result);
|
|
5387
|
-
return
|
|
5196
|
+
return import_shared77.Result.ok(entity);
|
|
5388
5197
|
}
|
|
5389
5198
|
async findAll(ctx, signal) {
|
|
5390
|
-
|
|
5199
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.findAll");
|
|
5391
5200
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5392
5201
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5393
|
-
return
|
|
5202
|
+
return import_shared77.Result.ok(entities);
|
|
5394
5203
|
}
|
|
5395
5204
|
async save(entity, signal) {
|
|
5396
5205
|
const dto = this._mapper.toDto(entity);
|
|
5397
|
-
|
|
5206
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.save");
|
|
5398
5207
|
await this._dataSource.insert(dto, signal);
|
|
5399
|
-
return
|
|
5208
|
+
return import_shared77.Result.ok();
|
|
5400
5209
|
}
|
|
5401
5210
|
async delete(entity, ctx, signal) {
|
|
5402
5211
|
const dto = this._mapper.toDto(entity);
|
|
5403
|
-
|
|
5212
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.delete");
|
|
5404
5213
|
await this._dataSource.delete(dto, ctx, signal);
|
|
5405
|
-
return
|
|
5214
|
+
return import_shared77.Result.ok();
|
|
5406
5215
|
}
|
|
5407
5216
|
async update(id, entity, ctx, signal) {
|
|
5408
5217
|
const dto = this._mapper.toPartialDto(entity);
|
|
5409
|
-
|
|
5218
|
+
import_shared77.AppError.throwIfAborted(signal, "Repository.update");
|
|
5410
5219
|
await this._dataSource.update(id, dto, ctx, signal);
|
|
5411
|
-
return
|
|
5220
|
+
return import_shared77.Result.ok();
|
|
5412
5221
|
}
|
|
5413
5222
|
};
|
|
5414
5223
|
|
|
@@ -5426,7 +5235,7 @@ __reExport(drizzle_types_exports, require("drizzle-orm"));
|
|
|
5426
5235
|
__reExport(index_exports, drizzle_types_exports, module.exports);
|
|
5427
5236
|
init_presentation();
|
|
5428
5237
|
__reExport(index_exports, require("@xeno-js/shared"), module.exports);
|
|
5429
|
-
var
|
|
5238
|
+
var import_shared79 = require("@xeno-js/shared");
|
|
5430
5239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5431
5240
|
0 && (module.exports = {
|
|
5432
5241
|
AppBuilder,
|