@xeno-js/core 1.2.13 → 2.0.0

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 CHANGED
@@ -2062,527 +2062,18 @@ var init_services = __esm({
2062
2062
  }
2063
2063
  });
2064
2064
 
2065
- // src/infrastructure/factories/allow-method.factory.ts
2066
- var AllowMethodFactory;
2067
- var init_allow_method_factory = __esm({
2068
- "src/infrastructure/factories/allow-method.factory.ts"() {
2069
- "use strict";
2070
- init_services();
2071
- AllowMethodFactory = class {
2072
- create(opts) {
2073
- const allowMethodService = new AllowMethodRegistry();
2074
- for (const [intentKey, schema] of Object.entries(opts)) {
2075
- allowMethodService.add(intentKey, schema);
2076
- }
2077
- return allowMethodService;
2078
- }
2079
- };
2080
- }
2081
- });
2082
-
2083
- // src/infrastructure/factories/axios.factory.ts
2084
- var import_node_http, import_node_https, import_shared47, import_axios, NodeAxiosFactory;
2085
- var init_axios_factory = __esm({
2086
- "src/infrastructure/factories/axios.factory.ts"() {
2087
- "use strict";
2088
- import_node_http = __toESM(require("http"), 1);
2089
- import_node_https = __toESM(require("https"), 1);
2090
- import_shared47 = require("@xeno-js/shared");
2091
- import_axios = __toESM(require("axios"), 1);
2092
- NodeAxiosFactory = class {
2093
- create(config) {
2094
- const isKeepAlive = config.keepAlive ?? true;
2095
- const maxSockets = config.maxSockets ?? 100;
2096
- const httpAgent = new import_node_http.default.Agent({
2097
- keepAlive: isKeepAlive,
2098
- maxSockets,
2099
- scheduling: "lifo"
2100
- });
2101
- const httpsAgent = new import_node_https.default.Agent({
2102
- keepAlive: isKeepAlive,
2103
- maxSockets,
2104
- scheduling: "lifo"
2105
- });
2106
- const axiosInstance = import_axios.default.create({
2107
- baseURL: config.baseURL,
2108
- headers: config.defaultHeaders,
2109
- timeout: config.timeoutMs,
2110
- httpAgent,
2111
- httpsAgent,
2112
- maxRedirects: config.maxRedirects ?? 5,
2113
- decompress: config.decompress ?? true,
2114
- proxy: config.proxy,
2115
- withCredentials: config.withCredentials
2116
- });
2117
- return new import_shared47.AxiosHttpClient(axiosInstance);
2118
- }
2119
- };
2120
- }
2121
- });
2122
-
2123
- // src/infrastructure/factories/cockatiel-resilience.factory.ts
2124
- var import_shared48, import_cockatiel, CockatielResilienceFactory;
2125
- var init_cockatiel_resilience_factory = __esm({
2126
- "src/infrastructure/factories/cockatiel-resilience.factory.ts"() {
2127
- "use strict";
2128
- import_shared48 = require("@xeno-js/shared");
2129
- import_cockatiel = require("cockatiel");
2130
- init_resilience_service();
2131
- CockatielResilienceFactory = class {
2132
- create(config) {
2133
- const message = "The resilience configuration provided is invalid. Please ensure that all values are non-negative numbers.";
2134
- const normalizedConfig = {
2135
- retry: {
2136
- attempts: this.checkConfigValue(
2137
- config.retry.attempts,
2138
- import_shared48.RESILIENCE_DEFAULTS.RETRY.ATTEMPTS,
2139
- message
2140
- ),
2141
- baseDelayMs: this.checkConfigValue(
2142
- config.retry.baseDelayMs,
2143
- import_shared48.RESILIENCE_DEFAULTS.RETRY.BASE_DELAY_MS,
2144
- message
2145
- ),
2146
- maxDelayMs: this.checkConfigValue(
2147
- config.retry.maxDelayMs,
2148
- import_shared48.RESILIENCE_DEFAULTS.RETRY.MAX_DELAY_MS,
2149
- message
2150
- )
2151
- },
2152
- circuitBreaker: {
2153
- consecutiveFailures: this.checkConfigValue(
2154
- config.circuitBreaker.consecutiveFailures,
2155
- import_shared48.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.CONSECUTIVE_FAILURES,
2156
- message
2157
- ),
2158
- halfOpenTimeoutMs: this.checkConfigValue(
2159
- config.circuitBreaker.halfOpenTimeoutMs,
2160
- import_shared48.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.HALF_OPEN_TIMEOUT_MS,
2161
- message
2162
- )
2163
- },
2164
- bulkhead: {
2165
- maxConcurrent: this.checkConfigValue(
2166
- config.bulkhead.maxConcurrent,
2167
- import_shared48.RESILIENCE_DEFAULTS.BULKHEAD.MAX_CONCURRENT,
2168
- message
2169
- )
2170
- }
2171
- };
2172
- const retryPolicy = (0, import_cockatiel.retry)(
2173
- (0, import_cockatiel.handleWhen)((error) => this.isTransientAndIdempotent(error)),
2174
- {
2175
- maxAttempts: normalizedConfig.retry.attempts,
2176
- backoff: new import_cockatiel.ExponentialBackoff({
2177
- initialDelay: normalizedConfig.retry.baseDelayMs,
2178
- maxDelay: normalizedConfig.retry.maxDelayMs
2179
- })
2180
- }
2181
- );
2182
- const circuitBreakerPolicy = (0, import_cockatiel.circuitBreaker)(
2183
- (0, import_cockatiel.handleWhen)((error) => this.isTransientError(error)),
2184
- {
2185
- breaker: new import_cockatiel.ConsecutiveBreaker(normalizedConfig.circuitBreaker.consecutiveFailures),
2186
- halfOpenAfter: normalizedConfig.circuitBreaker.halfOpenTimeoutMs
2187
- }
2188
- );
2189
- const bulkheadPolicy = (0, import_cockatiel.bulkhead)(normalizedConfig.bulkhead.maxConcurrent);
2190
- return new ServiceResilience((0, import_cockatiel.wrap)(bulkheadPolicy, circuitBreakerPolicy, retryPolicy));
2191
- }
2192
- isTransientError(error) {
2193
- if (!import_shared48.Guards.isDefined(error) || !import_shared48.Guards.isObject(error)) return false;
2194
- let status;
2195
- let isNetworkError = false;
2196
- if (error instanceof import_shared48.AppError) {
2197
- status = error.status;
2198
- const cause = error.cause;
2199
- if (import_shared48.Guards.isDefined(cause) && import_shared48.Guards.isString(cause.code)) {
2200
- isNetworkError = [
2201
- "ECONNABORTED",
2202
- "ECONNRESET",
2203
- "ETIMEDOUT",
2204
- "ENOTFOUND",
2205
- "ECONNREFUSED"
2206
- ].includes(cause.code.toUpperCase());
2207
- }
2208
- } else {
2209
- const err = error;
2210
- status = err.status;
2211
- if (import_shared48.Guards.isString(err.code)) {
2212
- isNetworkError = [
2213
- "ECONNABORTED",
2214
- "ECONNRESET",
2215
- "ETIMEDOUT",
2216
- "ENOTFOUND",
2217
- "ECONNREFUSED"
2218
- ].includes(err.code.toUpperCase());
2219
- }
2220
- }
2221
- if (isNetworkError) return true;
2222
- if (import_shared48.Guards.isDefined(status)) return status === 408 || status >= 500 && status < 600;
2223
- return false;
2224
- }
2225
- isTransientAndIdempotent(error) {
2226
- if (!this.isTransientError(error)) return false;
2227
- let method;
2228
- if (error instanceof import_shared48.AppError) {
2229
- const cause = error.cause;
2230
- if (import_shared48.Guards.isDefined(cause) && import_shared48.Guards.isDefined(cause.config) && import_shared48.Guards.isString(cause.config.method)) {
2231
- method = cause.config.method.toUpperCase();
2232
- }
2233
- } else {
2234
- const err = error;
2235
- if (import_shared48.Guards.isDefined(err.config) && import_shared48.Guards.isString(err.config.method)) {
2236
- method = err.config.method.toUpperCase();
2237
- }
2238
- }
2239
- if (import_shared48.Guards.isNullOrEmpty(method)) return false;
2240
- const idempotentMethods = ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"];
2241
- return idempotentMethods.includes(method);
2242
- }
2243
- checkConfigValue(value, defaultValue, message) {
2244
- if (import_shared48.Guards.isDefined(value)) {
2245
- import_shared48.Guards.throwIfNegative(value, message);
2246
- return value;
2247
- }
2248
- return defaultValue;
2249
- }
2250
- };
2251
- }
2252
- });
2253
-
2254
- // src/infrastructure/factories/db-client.factory.ts
2255
- var db_client_factory_exports = {};
2256
- __export(db_client_factory_exports, {
2257
- DbClientFactory: () => DbClientFactory
2258
- });
2259
- var import_node_postgres, import_pg, DbClientFactory;
2260
- var init_db_client_factory = __esm({
2261
- "src/infrastructure/factories/db-client.factory.ts"() {
2262
- "use strict";
2263
- import_node_postgres = require("drizzle-orm/node-postgres");
2264
- import_pg = require("pg");
2265
- DbClientFactory = class {
2266
- create(opts) {
2267
- const pool = new import_pg.Pool({
2268
- connectionString: opts.connectionString
2269
- });
2270
- return (0, import_node_postgres.drizzle)({ client: pool });
2271
- }
2272
- };
2273
- }
2274
- });
2275
-
2276
- // src/infrastructure/loggers/pino.logger.ts
2277
- var import_shared49, PinoLogger;
2278
- var init_pino_logger = __esm({
2279
- "src/infrastructure/loggers/pino.logger.ts"() {
2280
- "use strict";
2281
- import_shared49 = require("@xeno-js/shared");
2282
- PinoLogger = class {
2283
- /**
2284
- * Constructs a new instance of the PinoTransport class, which takes an optional minimum log level and an optional instance of the Pino logger. If no logger instance is provided, it initializes a new Pino logger with default settings. The minimum log level determines the threshold for logging messages, where messages with a log level below the specified minimum will be ignored.
2285
- * @param _logger The Pino logger instance used for logging messages.
2286
- * @param _minLevel The minimum log level for logging messages. Messages with a log level below this threshold will not be logged. Default is LOG_LEVEL.DEBUG.
2287
-
2288
- *
2289
- * @author Xeno
2290
- * @version 1.0.0
2291
- * @since 2025-09-30
2292
- * @link https://github.com/xeno-js/xeno-js
2293
- */
2294
- constructor(_logger, _minLevel = import_shared49.LOG_LEVEL.DEBUG) {
2295
- this._logger = _logger;
2296
- this._minLevel = _minLevel;
2297
- }
2298
- _logger;
2299
- _minLevel;
2300
- track(level, message, context, error = void 0) {
2301
- if (level < this._minLevel) return;
2302
- const payload = import_shared49.Guards.isDefined(error) ? { ...context, error } : context;
2303
- switch (level) {
2304
- case import_shared49.LOG_LEVEL.ERROR:
2305
- this._logger.error(payload ?? {}, message);
2306
- break;
2307
- case import_shared49.LOG_LEVEL.WARN:
2308
- this._logger.warn(payload ?? {}, message);
2309
- break;
2310
- case import_shared49.LOG_LEVEL.DEBUG:
2311
- this._logger.debug(payload ?? {}, message);
2312
- break;
2313
- default:
2314
- this._logger.info(payload ?? {}, message);
2315
- break;
2316
- }
2317
- }
2318
- };
2319
- }
2320
- });
2321
-
2322
- // src/infrastructure/factories/pino-logger.factory.ts
2323
- var pino_logger_factory_exports = {};
2324
- __export(pino_logger_factory_exports, {
2325
- PinoLoggerFactory: () => PinoLoggerFactory
2326
- });
2327
- var import_shared50, import_pino, PinoLoggerFactory;
2328
- var init_pino_logger_factory = __esm({
2329
- "src/infrastructure/factories/pino-logger.factory.ts"() {
2330
- "use strict";
2331
- import_shared50 = require("@xeno-js/shared");
2332
- import_pino = __toESM(require("pino"), 1);
2333
- init_pino_logger();
2334
- PinoLoggerFactory = class {
2335
- create(config) {
2336
- const level = config.level ?? import_shared50.LOG_LEVEL.DEBUG;
2337
- const env = config.pino.config?.env ?? process.env.NODE_ENV ?? "development";
2338
- const destinationType = config.pino.config?.destination ?? "stdout";
2339
- const filePath = config.pino.config?.filePath ?? "logs/app.log";
2340
- const prettyPrint = config.pino.config?.prettyPrint ?? env === "development";
2341
- const options = {
2342
- level: "trace",
2343
- serializers: {
2344
- err: import_pino.default.stdSerializers.err
2345
- },
2346
- timestamp: import_pino.default.stdTimeFunctions.isoTime,
2347
- redact: {
2348
- paths: ["password", "token", "secret", "authorization", "headers.authorization"],
2349
- censor: "***"
2350
- }
2351
- };
2352
- if (prettyPrint) {
2353
- return new PinoLogger(
2354
- (0, import_pino.default)({
2355
- ...options,
2356
- transport: {
2357
- target: "pino-pretty",
2358
- options: {
2359
- colorize: true,
2360
- ignore: "pid,hostname",
2361
- translateTime: "SYS:standard"
2362
- }
2363
- }
2364
- }),
2365
- level
2366
- );
2367
- }
2368
- if (destinationType === "file") {
2369
- const destination = import_pino.default.destination({ dest: filePath, sync: false });
2370
- return new PinoLogger((0, import_pino.default)(options, destination), level);
2371
- } else {
2372
- const stream = import_pino.default.destination({ dest: 1, sync: false });
2373
- return new PinoLogger((0, import_pino.default)(options, stream), level);
2374
- }
2375
- }
2376
- };
2377
- }
2378
- });
2379
-
2380
- // src/infrastructure/cache/redis.cache.ts
2381
- var import_shared51, RedisCache;
2382
- var init_redis_cache = __esm({
2383
- "src/infrastructure/cache/redis.cache.ts"() {
2384
- "use strict";
2385
- import_shared51 = require("@xeno-js/shared");
2386
- RedisCache = class {
2387
- /**
2388
- * @description Constructs a new instance of the RedisCache class, which takes an instance of the Redis client as a parameter. This client is used to perform caching operations such as setting, getting, and removing values from the Redis database. The constructor initializes the RedisCache with the provided Redis client, allowing it to interact with the Redis server for all caching operations defined in the ICache interface.
2389
- * @param _redisClient An instance of the Redis client from the ioredis library, used to perform caching operations in the Redis database.
2390
-
2391
- *
2392
- * @author Xeno
2393
- * @version 1.0.0
2394
- * @since 2025-09-30
2395
- * @link https://github.com/xeno-js/xeno-js
2396
- */
2397
- constructor(_redisClient) {
2398
- this._redisClient = _redisClient;
2399
- }
2400
- _redisClient;
2401
- async increment(key, ttlSeconds) {
2402
- const multi = this._redisClient.multi();
2403
- multi.incr(key);
2404
- multi.expire(key, ttlSeconds ?? 60);
2405
- const results = await multi.exec();
2406
- return results?.[0]?.[1] ?? 1;
2407
- }
2408
- async get(key) {
2409
- const value = await this._redisClient.get(key);
2410
- if (!import_shared51.Guards.isDefined(value)) {
2411
- return void 0;
2412
- }
2413
- return JSON.parse(value);
2414
- }
2415
- async set(key, value, ttl) {
2416
- const stringValue = import_shared51.StringHelper.safeStringify(value);
2417
- const ttlOption = import_shared51.Guards.isDefined(ttl) ? ttl : 86400;
2418
- await this._redisClient.set(key, stringValue, "EX", ttlOption);
2419
- }
2420
- async setIfAbsent(key, value, ttl) {
2421
- const stringValue = import_shared51.StringHelper.safeStringify(value);
2422
- const ttlOption = import_shared51.Guards.isDefined(ttl) ? ttl : 300;
2423
- const result = await this._redisClient.set(key, stringValue, "EX", ttlOption, "NX");
2424
- return result === "OK";
2425
- }
2426
- async remove(key) {
2427
- await this._redisClient.del(key);
2428
- }
2429
- async has(key) {
2430
- const exists = await this._redisClient.exists(key);
2431
- return exists === 1;
2432
- }
2433
- async clear() {
2434
- await this._redisClient.flushdb();
2435
- }
2436
- };
2437
- }
2438
- });
2439
-
2440
- // src/infrastructure/factories/redis-cache.factory.ts
2441
- var redis_cache_factory_exports = {};
2442
- __export(redis_cache_factory_exports, {
2443
- RedisCacheFactory: () => RedisCacheFactory
2444
- });
2445
- var import_shared52, import_ioredis, RedisCacheFactory;
2446
- var init_redis_cache_factory = __esm({
2447
- "src/infrastructure/factories/redis-cache.factory.ts"() {
2448
- "use strict";
2449
- import_shared52 = require("@xeno-js/shared");
2450
- import_ioredis = require("ioredis");
2451
- init_redis_cache();
2452
- RedisCacheFactory = class {
2453
- create(config) {
2454
- const host = config?.host ?? "localhost";
2455
- const port = config?.port ?? 6379;
2456
- const password = config?.password;
2457
- const username = config?.username;
2458
- const useTls = config?.tls ?? false;
2459
- const maxRetries = config?.maxRetriesPerRequest ?? 3;
2460
- const redisOptions = {
2461
- host,
2462
- port,
2463
- maxRetriesPerRequest: maxRetries,
2464
- // Strategia di riconnessione esponenziale per garantire resilienza
2465
- retryStrategy(times) {
2466
- const delay = Math.min(times * 50, 2e3);
2467
- return delay;
2468
- }
2469
- };
2470
- if (import_shared52.Guards.isDefined(password)) {
2471
- redisOptions.password = password;
2472
- }
2473
- if (import_shared52.Guards.isDefined(username)) {
2474
- redisOptions.username = username;
2475
- }
2476
- if (useTls) {
2477
- redisOptions.tls = {};
2478
- }
2479
- const nativeRedisInstance = new import_ioredis.Redis(redisOptions);
2480
- nativeRedisInstance.on("error", (err) => {
2481
- console.error("\u274C [Redis Error]:", err.message);
2482
- });
2483
- return new RedisCache(nativeRedisInstance);
2484
- }
2485
- };
2486
- }
2487
- });
2488
-
2489
- // src/infrastructure/loggers/sentry.logger.ts
2490
- var import_shared53, SentryLogger;
2491
- var init_sentry_logger = __esm({
2492
- "src/infrastructure/loggers/sentry.logger.ts"() {
2493
- "use strict";
2494
- import_shared53 = require("@xeno-js/shared");
2495
- SentryLogger = class {
2496
- constructor(_client, _minLevel) {
2497
- this._client = _client;
2498
- this._minLevel = _minLevel;
2499
- }
2500
- _client;
2501
- _minLevel;
2502
- track(level, message, context = void 0, error = void 0) {
2503
- if (level < this._minLevel) return;
2504
- if (level === import_shared53.LOG_LEVEL.ERROR || level === import_shared53.LOG_LEVEL.WARN) {
2505
- this._client.withScope((scope) => {
2506
- if (import_shared53.Guards.isDefined(context)) scope.setExtras(context);
2507
- if (import_shared53.Guards.isDefined(error)) {
2508
- this._client.captureException(error);
2509
- } else {
2510
- this._client.captureMessage(message, "warning");
2511
- }
2512
- });
2513
- }
2514
- }
2515
- };
2516
- }
2517
- });
2518
-
2519
- // src/infrastructure/factories/sentry-logger.factory.ts
2520
- var sentry_logger_factory_exports = {};
2521
- __export(sentry_logger_factory_exports, {
2522
- SentryLoggerFactory: () => SentryLoggerFactory
2523
- });
2524
- var Sentry, import_shared54, SentryLoggerFactory;
2525
- var init_sentry_logger_factory = __esm({
2526
- "src/infrastructure/factories/sentry-logger.factory.ts"() {
2527
- "use strict";
2528
- Sentry = __toESM(require("@sentry/node"), 1);
2529
- import_shared54 = require("@xeno-js/shared");
2530
- init_sentry_logger();
2531
- SentryLoggerFactory = class {
2532
- create(config) {
2533
- const level = config.level ?? import_shared54.LOG_LEVEL.WARN;
2534
- const sentryConfig = config.sentry?.config;
2535
- const env = sentryConfig?.environment ?? process.env.NODE_ENV ?? "development";
2536
- if (!import_shared54.Guards.isDefined(sentryConfig))
2537
- throw new Error("Sentry configuration is required when Sentry logging is enabled.");
2538
- if (!import_shared54.Guards.isDefined(sentryConfig.dsn))
2539
- throw new Error("Sentry DSN is required when Sentry logging is enabled.");
2540
- Sentry.init({
2541
- dsn: sentryConfig.dsn,
2542
- environment: env,
2543
- tracesSampleRate: env === "production" ? 0.1 : 1,
2544
- integrations: [Sentry.httpIntegration()],
2545
- beforeSend(event, hint) {
2546
- const error = hint.originalException;
2547
- if (error instanceof Error && error.name === "ZodError") {
2548
- return null;
2549
- }
2550
- return event;
2551
- }
2552
- });
2553
- return new SentryLogger(Sentry, level);
2554
- }
2555
- };
2556
- }
2557
- });
2558
-
2559
- // src/infrastructure/factories/sql-light-db-client.factory.ts
2560
- var sql_light_db_client_factory_exports = {};
2561
- __export(sql_light_db_client_factory_exports, {
2562
- DbSqlLiteClientFactory: () => DbSqlLiteClientFactory
2563
- });
2564
- var import_client, import_libsql, DbSqlLiteClientFactory;
2565
- var init_sql_light_db_client_factory = __esm({
2566
- "src/infrastructure/factories/sql-light-db-client.factory.ts"() {
2567
- "use strict";
2568
- import_client = require("@libsql/client");
2569
- import_libsql = require("drizzle-orm/libsql");
2570
- DbSqlLiteClientFactory = class {
2571
- create(opts) {
2572
- const client = (0, import_client.createClient)({ url: opts.connectionString });
2573
- return (0, import_libsql.drizzle)({ client });
2574
- }
2575
- };
2576
- }
2577
- });
2578
-
2579
2065
  // src/infrastructure/factories/supabase.factory.ts
2580
- var import_ssr, import_shared55, SupabaseServerAuthFactory;
2066
+ var supabase_factory_exports = {};
2067
+ __export(supabase_factory_exports, {
2068
+ SupabaseServerAuthFactory: () => SupabaseServerAuthFactory
2069
+ });
2070
+ var import_ssr, import_shared47, import_supabase, SupabaseServerAuthFactory;
2581
2071
  var init_supabase_factory = __esm({
2582
2072
  "src/infrastructure/factories/supabase.factory.ts"() {
2583
2073
  "use strict";
2584
2074
  import_ssr = require("@supabase/ssr");
2585
- import_shared55 = require("@xeno-js/shared");
2075
+ import_shared47 = require("@xeno-js/shared");
2076
+ import_supabase = require("@xeno-js/shared/supabase");
2586
2077
  init_services();
2587
2078
  SupabaseServerAuthFactory = class {
2588
2079
  create({
@@ -2601,17 +2092,17 @@ var init_supabase_factory = __esm({
2601
2092
  }
2602
2093
  }
2603
2094
  });
2604
- const mapper = new import_shared55.SupabaseClaimsMapper();
2605
- const sessionMapper = new import_shared55.SupabaseSessionMapper(mapper);
2606
- return new import_shared55.SupabaseAuthService(client, mapper, sessionMapper, config);
2095
+ const mapper = new import_supabase.SupabaseClaimsMapper();
2096
+ const sessionMapper = new import_supabase.SupabaseSessionMapper(mapper);
2097
+ return new import_supabase.SupabaseAuthService(client, mapper, sessionMapper, config);
2607
2098
  }
2608
2099
  _getCookieSsr(ssrOpts, container, config) {
2609
- if (import_shared55.Guards.isDefined(ssrOpts)) {
2100
+ if (import_shared47.Guards.isDefined(ssrOpts)) {
2610
2101
  return ssrOpts(container);
2611
2102
  } else {
2612
2103
  return new CookieHandler(
2613
- container.resolve(import_shared55.TOKENS.NETWORK_CONTEXT_ACCESSOR),
2614
- container.resolve(import_shared55.TOKENS.CONFIGURATION_SERVICE),
2104
+ container.resolve(import_shared47.TOKENS.NETWORK_CONTEXT_ACCESSOR),
2105
+ container.resolve(import_shared47.TOKENS.CONFIGURATION_SERVICE),
2615
2106
  config
2616
2107
  );
2617
2108
  }
@@ -2620,60 +2111,6 @@ var init_supabase_factory = __esm({
2620
2111
  }
2621
2112
  });
2622
2113
 
2623
- // src/infrastructure/factories/zod-validator.factory.ts
2624
- var import_shared56, ZodValidatorFactory;
2625
- var init_zod_validator_factory = __esm({
2626
- "src/infrastructure/factories/zod-validator.factory.ts"() {
2627
- "use strict";
2628
- import_shared56 = require("@xeno-js/shared");
2629
- ZodValidatorFactory = class {
2630
- create(opts) {
2631
- const validatorService = new import_shared56.ZodValidatorService(/* @__PURE__ */ new Map(), opts.logger);
2632
- for (const [intentKey, schema] of Object.entries(opts.schemas)) {
2633
- validatorService.addSchema(intentKey, schema);
2634
- }
2635
- return validatorService;
2636
- }
2637
- };
2638
- }
2639
- });
2640
-
2641
- // src/infrastructure/factories/index.ts
2642
- var factories_exports = {};
2643
- __export(factories_exports, {
2644
- AllowMethodFactory: () => AllowMethodFactory,
2645
- CockatielResilienceFactory: () => CockatielResilienceFactory,
2646
- DbClientFactory: () => DbClientFactory,
2647
- DbSqlLiteClientFactory: () => DbSqlLiteClientFactory,
2648
- NodeAxiosFactory: () => NodeAxiosFactory,
2649
- NodeRequestContextFactory: () => NodeRequestContextFactory,
2650
- PinoLoggerFactory: () => PinoLoggerFactory,
2651
- RedisCacheFactory: () => RedisCacheFactory,
2652
- SentryLoggerFactory: () => SentryLoggerFactory,
2653
- ServiceScopeFactory: () => ServiceScopeFactory,
2654
- SupabaseServerAuthFactory: () => SupabaseServerAuthFactory,
2655
- UserContextFactory: () => UserContextFactory,
2656
- ZodValidatorFactory: () => ZodValidatorFactory
2657
- });
2658
- var init_factories = __esm({
2659
- "src/infrastructure/factories/index.ts"() {
2660
- "use strict";
2661
- init_allow_method_factory();
2662
- init_axios_factory();
2663
- init_cockatiel_resilience_factory();
2664
- init_db_client_factory();
2665
- init_pino_logger_factory();
2666
- init_redis_cache_factory();
2667
- init_request_context_factory();
2668
- init_sentry_logger_factory();
2669
- init_service_scope_factory();
2670
- init_sql_light_db_client_factory();
2671
- init_supabase_factory();
2672
- init_user_context_factory();
2673
- init_zod_validator_factory();
2674
- }
2675
- });
2676
-
2677
2114
  // src/infrastructure/modules/utils/auth.utils.ts
2678
2115
  var auth_utils_exports = {};
2679
2116
  __export(auth_utils_exports, {
@@ -2771,7 +2208,7 @@ var init_auth_utils = __esm({
2771
2208
  return authService;
2772
2209
  });
2773
2210
  } else {
2774
- const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
2211
+ const { SupabaseServerAuthFactory: SupabaseServerAuthFactory2 } = await Promise.resolve().then(() => (init_supabase_factory(), supabase_factory_exports));
2775
2212
  const factory = new SupabaseServerAuthFactory2();
2776
2213
  const supabase = factory.create({ config: opts, container });
2777
2214
  container.addScoped(TOKENS5.AUTH_SERVICE, () => {
@@ -2786,6 +2223,28 @@ var init_auth_utils = __esm({
2786
2223
  }
2787
2224
  });
2788
2225
 
2226
+ // src/infrastructure/factories/zod-validator.factory.ts
2227
+ var zod_validator_factory_exports = {};
2228
+ __export(zod_validator_factory_exports, {
2229
+ ZodValidatorFactory: () => ZodValidatorFactory
2230
+ });
2231
+ var import_zod, ZodValidatorFactory;
2232
+ var init_zod_validator_factory = __esm({
2233
+ "src/infrastructure/factories/zod-validator.factory.ts"() {
2234
+ "use strict";
2235
+ import_zod = require("@xeno-js/shared/zod");
2236
+ ZodValidatorFactory = class {
2237
+ create(opts) {
2238
+ const validatorService = new import_zod.ZodValidatorService(/* @__PURE__ */ new Map(), opts.logger);
2239
+ for (const [intentKey, schema] of Object.entries(opts.schemas)) {
2240
+ validatorService.addSchema(intentKey, schema);
2241
+ }
2242
+ return validatorService;
2243
+ }
2244
+ };
2245
+ }
2246
+ });
2247
+
2789
2248
  // src/infrastructure/modules/utils/validation.utils.ts
2790
2249
  var validation_utils_exports = {};
2791
2250
  __export(validation_utils_exports, {
@@ -2814,7 +2273,7 @@ var init_validation_utils = __esm({
2814
2273
  const validationStrategies = [];
2815
2274
  if (Guards51.isDefined(opts.zod)) {
2816
2275
  const config = opts.zod;
2817
- const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
2276
+ const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_zod_validator_factory(), zod_validator_factory_exports));
2818
2277
  const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
2819
2278
  const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
2820
2279
  container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
@@ -2833,11 +2292,11 @@ var init_validation_utils = __esm({
2833
2292
  });
2834
2293
 
2835
2294
  // src/infrastructure/idempotency/idempotency-store.ts
2836
- var import_shared57, IdempotencyStore;
2295
+ var import_shared48, IdempotencyStore;
2837
2296
  var init_idempotency_store = __esm({
2838
2297
  "src/infrastructure/idempotency/idempotency-store.ts"() {
2839
2298
  "use strict";
2840
- import_shared57 = require("@xeno-js/shared");
2299
+ import_shared48 = require("@xeno-js/shared");
2841
2300
  IdempotencyStore = class {
2842
2301
  /**
2843
2302
  * @description Constructs a new instance of IdempotencyStore, accepting an instance of ICache for accessing the caching system and an instance of IIdentityAccessor for obtaining the user's identity context. The IdempotencyStore uses the caching system to manage locks and results of idempotent commands, ensuring that commands with the same ID are processed only once. The identity context is used to build contextual keys, allowing for more granular management of idempotent commands in multi-tenant scenarios.
@@ -2859,31 +2318,31 @@ var init_idempotency_store = __esm({
2859
2318
  async acquireLock(requestId, ttlSeconds) {
2860
2319
  const key = this._cacheKeyBuilder.buildContextualKey(`command:${requestId}`);
2861
2320
  return await this._cache.setIfAbsent(
2862
- `${import_shared57.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`,
2863
- import_shared57.IDEMPOTENCY_CONSTANTS.LOCKED_VALUE,
2321
+ `${import_shared48.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`,
2322
+ import_shared48.IDEMPOTENCY_CONSTANTS.LOCKED_VALUE,
2864
2323
  ttlSeconds
2865
2324
  );
2866
2325
  }
2867
2326
  async hasBeenProcessed(commandId) {
2868
2327
  const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
2869
- return await this._cache.has(`${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
2328
+ return await this._cache.has(`${import_shared48.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
2870
2329
  }
2871
2330
  async markAsProcessed(commandId, payload, ttlSeconds) {
2872
2331
  const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
2873
2332
  await this._cache.set(
2874
- `${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`,
2333
+ `${import_shared48.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`,
2875
2334
  payload,
2876
2335
  ttlSeconds
2877
2336
  );
2878
2337
  }
2879
2338
  async getPayload(commandId) {
2880
2339
  const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
2881
- const payload = await this._cache.get(`${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
2340
+ const payload = await this._cache.get(`${import_shared48.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
2882
2341
  return payload;
2883
2342
  }
2884
2343
  async releaseLock(commandId) {
2885
2344
  const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
2886
- await this._cache.remove(`${import_shared57.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`);
2345
+ await this._cache.remove(`${import_shared48.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`);
2887
2346
  }
2888
2347
  };
2889
2348
  }
@@ -3037,6 +2496,48 @@ var init_cqrs_module = __esm({
3037
2496
  }
3038
2497
  });
3039
2498
 
2499
+ // src/infrastructure/factories/sql-light-db-client.factory.ts
2500
+ var sql_light_db_client_factory_exports = {};
2501
+ __export(sql_light_db_client_factory_exports, {
2502
+ DbSqlLiteClientFactory: () => DbSqlLiteClientFactory
2503
+ });
2504
+ var import_client, import_libsql, DbSqlLiteClientFactory;
2505
+ var init_sql_light_db_client_factory = __esm({
2506
+ "src/infrastructure/factories/sql-light-db-client.factory.ts"() {
2507
+ "use strict";
2508
+ import_client = require("@libsql/client");
2509
+ import_libsql = require("drizzle-orm/libsql");
2510
+ DbSqlLiteClientFactory = class {
2511
+ create(opts) {
2512
+ const client = (0, import_client.createClient)({ url: opts.connectionString });
2513
+ return (0, import_libsql.drizzle)({ client });
2514
+ }
2515
+ };
2516
+ }
2517
+ });
2518
+
2519
+ // src/infrastructure/factories/db-client.factory.ts
2520
+ var db_client_factory_exports = {};
2521
+ __export(db_client_factory_exports, {
2522
+ DbClientFactory: () => DbClientFactory
2523
+ });
2524
+ var import_node_postgres, import_pg, DbClientFactory;
2525
+ var init_db_client_factory = __esm({
2526
+ "src/infrastructure/factories/db-client.factory.ts"() {
2527
+ "use strict";
2528
+ import_node_postgres = require("drizzle-orm/node-postgres");
2529
+ import_pg = require("pg");
2530
+ DbClientFactory = class {
2531
+ create(opts) {
2532
+ const pool = new import_pg.Pool({
2533
+ connectionString: opts.connectionString
2534
+ });
2535
+ return (0, import_node_postgres.drizzle)({ client: pool });
2536
+ }
2537
+ };
2538
+ }
2539
+ });
2540
+
3040
2541
  // src/infrastructure/modules/utils/db.utils.ts
3041
2542
  var db_utils_exports = {};
3042
2543
  __export(db_utils_exports, {
@@ -3123,12 +2624,12 @@ var unit_of_work_exports = {};
3123
2624
  __export(unit_of_work_exports, {
3124
2625
  UnitOfWork: () => UnitOfWork
3125
2626
  });
3126
- var import_shared58, import_shared59, UnitOfWork;
2627
+ var import_shared49, import_shared50, UnitOfWork;
3127
2628
  var init_unit_of_work = __esm({
3128
2629
  "src/infrastructure/transaction/unit-of-work.ts"() {
3129
2630
  "use strict";
3130
- import_shared58 = require("@xeno-js/shared");
3131
- import_shared59 = require("@xeno-js/shared");
2631
+ import_shared49 = require("@xeno-js/shared");
2632
+ import_shared50 = require("@xeno-js/shared");
3132
2633
  UnitOfWork = class {
3133
2634
  /**
3134
2635
  * Creates an instance of UnitOfWork.
@@ -3147,7 +2648,7 @@ var init_unit_of_work = __esm({
3147
2648
  _dbContext;
3148
2649
  _ttx;
3149
2650
  async runInTransaction(callback, signal) {
3150
- import_shared58.AppError.throwIfAborted(signal, "UnitOfWork.runInTransaction");
2651
+ import_shared49.AppError.throwIfAborted(signal, "UnitOfWork.runInTransaction");
3151
2652
  return this._dbContext.transaction(async (tx) => {
3152
2653
  this._ttx.state = tx;
3153
2654
  try {
@@ -3159,9 +2660,9 @@ var init_unit_of_work = __esm({
3159
2660
  });
3160
2661
  }
3161
2662
  async dispose() {
3162
- if (import_shared59.Guards.isDefined(this._ttx.state)) {
2663
+ if (import_shared50.Guards.isDefined(this._ttx.state)) {
3163
2664
  try {
3164
- if (import_shared59.Guards.hasMethod(this._ttx.state, "rollback")) {
2665
+ if (import_shared50.Guards.hasMethod(this._ttx.state, "rollback")) {
3165
2666
  await this._ttx.state.rollback();
3166
2667
  }
3167
2668
  } finally {
@@ -3217,11 +2718,11 @@ var init_db_module = __esm({
3217
2718
  });
3218
2719
 
3219
2720
  // src/infrastructure/http/base.http-adapter.ts
3220
- var import_shared60, BaseHttpAdapter;
2721
+ var import_shared51, BaseHttpAdapter;
3221
2722
  var init_base_http_adapter = __esm({
3222
2723
  "src/infrastructure/http/base.http-adapter.ts"() {
3223
2724
  "use strict";
3224
- import_shared60 = require("@xeno-js/shared");
2725
+ import_shared51 = require("@xeno-js/shared");
3225
2726
  BaseHttpAdapter = class {
3226
2727
  /**
3227
2728
  * @description Parse the URL from the request.
@@ -3231,15 +2732,15 @@ var init_base_http_adapter = __esm({
3231
2732
  * @returns The parsed URL.
3232
2733
  */
3233
2734
  parseUrl(rawUrl = "/", headers, queryParams) {
3234
- const protocol = import_shared60.StringHelper.getSingleValue(headers["x-forwarded-proto"]) ?? "https";
3235
- const host = import_shared60.StringHelper.safeStringify(headers["host"]) ?? "localhost";
2735
+ const protocol = import_shared51.StringHelper.getSingleValue(headers["x-forwarded-proto"]) ?? "https";
2736
+ const host = import_shared51.StringHelper.safeStringify(headers["host"]) ?? "localhost";
3236
2737
  const cleanHost = host.replace(/['"]/g, "");
3237
2738
  const url = new URL(rawUrl, `${protocol}://${cleanHost}`);
3238
- if (!import_shared60.Guards.isNullOrEmpty(queryParams)) {
2739
+ if (!import_shared51.Guards.isNullOrEmpty(queryParams)) {
3239
2740
  for (const [key, value] of Object.entries(queryParams)) {
3240
- if (import_shared60.Guards.isArray(value)) {
2741
+ if (import_shared51.Guards.isArray(value)) {
3241
2742
  value.forEach((v) => url.searchParams.append(key, String(v)));
3242
- } else if (import_shared60.Guards.isDefined(value)) {
2743
+ } else if (import_shared51.Guards.isDefined(value)) {
3243
2744
  url.searchParams.set(key, String(value));
3244
2745
  }
3245
2746
  }
@@ -3254,8 +2755,8 @@ var init_base_http_adapter = __esm({
3254
2755
  parseHeaders(rawHeaders) {
3255
2756
  const headers = new Headers();
3256
2757
  for (const [key, value] of Object.entries(rawHeaders)) {
3257
- if (import_shared60.Guards.isDefined(value)) {
3258
- if (import_shared60.Guards.isArray(value)) {
2758
+ if (import_shared51.Guards.isDefined(value)) {
2759
+ if (import_shared51.Guards.isArray(value)) {
3259
2760
  value.forEach((v) => headers.append(key, String(v)));
3260
2761
  } else {
3261
2762
  headers.set(key, String(value));
@@ -3271,10 +2772,10 @@ var init_base_http_adapter = __esm({
3271
2772
  * @returns The parsed body.
3272
2773
  */
3273
2774
  parseBody(method, rawBody) {
3274
- if (!import_shared60.Guards.isDefined(method) || !["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase()) || !import_shared60.Guards.isDefined(rawBody))
2775
+ if (!import_shared51.Guards.isDefined(method) || !["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase()) || !import_shared51.Guards.isDefined(rawBody))
3275
2776
  return void 0;
3276
- if (import_shared60.Guards.isObject(rawBody)) return JSON.stringify(rawBody);
3277
- if (import_shared60.Guards.isString(rawBody) || rawBody instanceof Blob || rawBody instanceof ArrayBuffer || ArrayBuffer.isView(rawBody) || rawBody instanceof URLSearchParams || rawBody instanceof FormData)
2777
+ if (import_shared51.Guards.isObject(rawBody)) return JSON.stringify(rawBody);
2778
+ if (import_shared51.Guards.isString(rawBody) || rawBody instanceof Blob || rawBody instanceof ArrayBuffer || ArrayBuffer.isView(rawBody) || rawBody instanceof URLSearchParams || rawBody instanceof FormData)
3278
2779
  return rawBody;
3279
2780
  return String(rawBody);
3280
2781
  }
@@ -3292,14 +2793,14 @@ var init_base_http_adapter = __esm({
3292
2793
  headers
3293
2794
  };
3294
2795
  const parsedBody = this.parseBody(method, body);
3295
- if (import_shared60.Guards.isDefined(parsedBody)) {
2796
+ if (import_shared51.Guards.isDefined(parsedBody)) {
3296
2797
  init2.body = parsedBody;
3297
2798
  init2.duplex = "half";
3298
2799
  }
3299
2800
  const extendedRequest = new Request(url, init2);
3300
2801
  extendedRequest.path = url.pathname;
3301
2802
  const webResponse = new Response();
3302
- if (import_shared60.Guards.isDefined(res)) {
2803
+ if (import_shared51.Guards.isDefined(res)) {
3303
2804
  const originalAppend = webResponse.headers.append.bind(webResponse.headers);
3304
2805
  const originalSet = webResponse.headers.set.bind(webResponse.headers);
3305
2806
  const originalDelete = webResponse.headers.delete.bind(webResponse.headers);
@@ -3325,19 +2826,22 @@ var init_base_http_adapter = __esm({
3325
2826
  }
3326
2827
  });
3327
2828
 
3328
- // src/infrastructure/http/fastify.http-adapter.ts
3329
- var import_shared61, FastifyHttpAdapter;
3330
- var init_fastify_http_adapter = __esm({
3331
- "src/infrastructure/http/fastify.http-adapter.ts"() {
2829
+ // src/infrastructure/http/vercel.http-adapter.ts
2830
+ var vercel_http_adapter_exports = {};
2831
+ __export(vercel_http_adapter_exports, {
2832
+ VercelHttpAdapter: () => VercelHttpAdapter
2833
+ });
2834
+ var import_shared52, VercelHttpAdapter;
2835
+ var init_vercel_http_adapter = __esm({
2836
+ "src/infrastructure/http/vercel.http-adapter.ts"() {
3332
2837
  "use strict";
3333
- import_shared61 = require("@xeno-js/shared");
2838
+ import_shared52 = require("@xeno-js/shared");
3334
2839
  init_base_http_adapter();
3335
- FastifyHttpAdapter = class extends BaseHttpAdapter {
2840
+ VercelHttpAdapter = class extends BaseHttpAdapter {
3336
2841
  adapt(req, res) {
3337
2842
  const headers = this.parseHeaders(req.headers);
3338
2843
  const url = this.parseUrl(req.url, req.headers, req.query);
3339
- const body = req.body;
3340
- return this.createXenoWebTransport(url, req.method, headers, body, res);
2844
+ return this.createXenoWebTransport(url, req.method, headers, req.body, res);
3341
2845
  }
3342
2846
  handleHeaderChange(res, name, value, action) {
3343
2847
  if (action === "delete") {
@@ -3345,11 +2849,11 @@ var init_fastify_http_adapter = __esm({
3345
2849
  return;
3346
2850
  }
3347
2851
  if (name.toLowerCase() === "set-cookie") {
3348
- const existing = res.getHeader("set-cookie");
2852
+ const existing = res.getHeader("Set-Cookie");
3349
2853
  let cookies = [];
3350
- if (import_shared61.Guards.isArray(existing)) {
2854
+ if (import_shared52.Guards.isArray(existing)) {
3351
2855
  cookies = existing;
3352
- } else if (import_shared61.Guards.isString(existing)) {
2856
+ } else if (import_shared52.Guards.isString(existing)) {
3353
2857
  cookies = [existing];
3354
2858
  }
3355
2859
  if (action === "append") {
@@ -3357,49 +2861,32 @@ var init_fastify_http_adapter = __esm({
3357
2861
  } else {
3358
2862
  cookies = [value];
3359
2863
  }
3360
- res.header("set-cookie", cookies);
2864
+ res.setHeader("Set-Cookie", cookies);
3361
2865
  } else {
3362
- res.header(name, value);
2866
+ res.setHeader(name, value);
3363
2867
  }
3364
2868
  }
3365
2869
  };
3366
2870
  }
3367
2871
  });
3368
2872
 
3369
- // src/infrastructure/http/native.http-adapter.ts
3370
- var NativeHttpAdapter;
3371
- var init_native_http_adapter = __esm({
3372
- "src/infrastructure/http/native.http-adapter.ts"() {
3373
- "use strict";
3374
- init_base_http_adapter();
3375
- NativeHttpAdapter = class extends BaseHttpAdapter {
3376
- adapt(req, res) {
3377
- const extendedRequest = req;
3378
- extendedRequest.path = new URL(req.url).pathname;
3379
- return {
3380
- request: extendedRequest,
3381
- response: res
3382
- };
3383
- }
3384
- handleHeaderChange(_res, _name, _value, _action) {
3385
- return;
3386
- }
3387
- };
3388
- }
2873
+ // src/infrastructure/http/fastify.http-adapter.ts
2874
+ var fastify_http_adapter_exports = {};
2875
+ __export(fastify_http_adapter_exports, {
2876
+ FastifyHttpAdapter: () => FastifyHttpAdapter
3389
2877
  });
3390
-
3391
- // src/infrastructure/http/vercel.http-adapter.ts
3392
- var import_shared62, VercelHttpAdapter;
3393
- var init_vercel_http_adapter = __esm({
3394
- "src/infrastructure/http/vercel.http-adapter.ts"() {
2878
+ var import_shared53, FastifyHttpAdapter;
2879
+ var init_fastify_http_adapter = __esm({
2880
+ "src/infrastructure/http/fastify.http-adapter.ts"() {
3395
2881
  "use strict";
3396
- import_shared62 = require("@xeno-js/shared");
2882
+ import_shared53 = require("@xeno-js/shared");
3397
2883
  init_base_http_adapter();
3398
- VercelHttpAdapter = class extends BaseHttpAdapter {
2884
+ FastifyHttpAdapter = class extends BaseHttpAdapter {
3399
2885
  adapt(req, res) {
3400
2886
  const headers = this.parseHeaders(req.headers);
3401
2887
  const url = this.parseUrl(req.url, req.headers, req.query);
3402
- return this.createXenoWebTransport(url, req.method, headers, req.body, res);
2888
+ const body = req.body;
2889
+ return this.createXenoWebTransport(url, req.method, headers, body, res);
3403
2890
  }
3404
2891
  handleHeaderChange(res, name, value, action) {
3405
2892
  if (action === "delete") {
@@ -3407,11 +2894,11 @@ var init_vercel_http_adapter = __esm({
3407
2894
  return;
3408
2895
  }
3409
2896
  if (name.toLowerCase() === "set-cookie") {
3410
- const existing = res.getHeader("Set-Cookie");
2897
+ const existing = res.getHeader("set-cookie");
3411
2898
  let cookies = [];
3412
- if (import_shared62.Guards.isArray(existing)) {
2899
+ if (import_shared53.Guards.isArray(existing)) {
3413
2900
  cookies = existing;
3414
- } else if (import_shared62.Guards.isString(existing)) {
2901
+ } else if (import_shared53.Guards.isString(existing)) {
3415
2902
  cookies = [existing];
3416
2903
  }
3417
2904
  if (action === "append") {
@@ -3419,39 +2906,47 @@ var init_vercel_http_adapter = __esm({
3419
2906
  } else {
3420
2907
  cookies = [value];
3421
2908
  }
3422
- res.setHeader("Set-Cookie", cookies);
2909
+ res.header("set-cookie", cookies);
3423
2910
  } else {
3424
- res.setHeader(name, value);
2911
+ res.header(name, value);
3425
2912
  }
3426
2913
  }
3427
2914
  };
3428
2915
  }
3429
2916
  });
3430
2917
 
3431
- // src/infrastructure/http/index.ts
3432
- var http_exports = {};
3433
- __export(http_exports, {
3434
- BaseHttpAdapter: () => BaseHttpAdapter,
3435
- FastifyHttpAdapter: () => FastifyHttpAdapter,
3436
- NativeHttpAdapter: () => NativeHttpAdapter,
3437
- VercelHttpAdapter: () => VercelHttpAdapter
2918
+ // src/infrastructure/http/native.http-adapter.ts
2919
+ var native_http_adapter_exports = {};
2920
+ __export(native_http_adapter_exports, {
2921
+ NativeHttpAdapter: () => NativeHttpAdapter
3438
2922
  });
3439
- var init_http = __esm({
3440
- "src/infrastructure/http/index.ts"() {
2923
+ var NativeHttpAdapter;
2924
+ var init_native_http_adapter = __esm({
2925
+ "src/infrastructure/http/native.http-adapter.ts"() {
3441
2926
  "use strict";
3442
2927
  init_base_http_adapter();
3443
- init_fastify_http_adapter();
3444
- init_native_http_adapter();
3445
- init_vercel_http_adapter();
2928
+ NativeHttpAdapter = class extends BaseHttpAdapter {
2929
+ adapt(req, res) {
2930
+ const extendedRequest = req;
2931
+ extendedRequest.path = new URL(req.url).pathname;
2932
+ return {
2933
+ request: extendedRequest,
2934
+ response: res
2935
+ };
2936
+ }
2937
+ handleHeaderChange(_res, _name, _value, _action) {
2938
+ return;
2939
+ }
2940
+ };
3446
2941
  }
3447
2942
  });
3448
2943
 
3449
2944
  // src/infrastructure/modules/http-adapter.module.ts
3450
- var import_shared63, HttpAdapterModule;
2945
+ var import_shared54, HttpAdapterModule;
3451
2946
  var init_http_adapter_module = __esm({
3452
2947
  "src/infrastructure/modules/http-adapter.module.ts"() {
3453
2948
  "use strict";
3454
- import_shared63 = require("@xeno-js/shared");
2949
+ import_shared54 = require("@xeno-js/shared");
3455
2950
  HttpAdapterModule = class {
3456
2951
  async configure(container, opts) {
3457
2952
  const adapter = await this._getAdapter(opts);
@@ -3459,15 +2954,15 @@ var init_http_adapter_module = __esm({
3459
2954
  }
3460
2955
  async _getAdapter(opts) {
3461
2956
  if (opts.vercel) {
3462
- const { VercelHttpAdapter: VercelHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
2957
+ const { VercelHttpAdapter: VercelHttpAdapter2 } = await Promise.resolve().then(() => (init_vercel_http_adapter(), vercel_http_adapter_exports));
3463
2958
  return new VercelHttpAdapter2();
3464
2959
  } else if (opts.fastify) {
3465
- const { FastifyHttpAdapter: FastifyHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
2960
+ const { FastifyHttpAdapter: FastifyHttpAdapter2 } = await Promise.resolve().then(() => (init_fastify_http_adapter(), fastify_http_adapter_exports));
3466
2961
  return new FastifyHttpAdapter2();
3467
- } else if (import_shared63.Guards.isDefined(opts.custom)) {
2962
+ } else if (import_shared54.Guards.isDefined(opts.custom)) {
3468
2963
  return opts.custom();
3469
2964
  } else {
3470
- const { NativeHttpAdapter: NativeHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
2965
+ const { NativeHttpAdapter: NativeHttpAdapter2 } = await Promise.resolve().then(() => (init_native_http_adapter(), native_http_adapter_exports));
3471
2966
  return new NativeHttpAdapter2();
3472
2967
  }
3473
2968
  }
@@ -3475,6 +2970,185 @@ var init_http_adapter_module = __esm({
3475
2970
  }
3476
2971
  });
3477
2972
 
2973
+ // src/infrastructure/factories/axios.factory.ts
2974
+ var axios_factory_exports = {};
2975
+ __export(axios_factory_exports, {
2976
+ NodeAxiosFactory: () => NodeAxiosFactory
2977
+ });
2978
+ var import_node_http, import_node_https, import_axios, import_axios2, NodeAxiosFactory;
2979
+ var init_axios_factory = __esm({
2980
+ "src/infrastructure/factories/axios.factory.ts"() {
2981
+ "use strict";
2982
+ import_node_http = __toESM(require("http"), 1);
2983
+ import_node_https = __toESM(require("https"), 1);
2984
+ import_axios = require("@xeno-js/shared/axios");
2985
+ import_axios2 = __toESM(require("axios"), 1);
2986
+ NodeAxiosFactory = class {
2987
+ create(config) {
2988
+ const isKeepAlive = config.keepAlive ?? true;
2989
+ const maxSockets = config.maxSockets ?? 100;
2990
+ const httpAgent = new import_node_http.default.Agent({
2991
+ keepAlive: isKeepAlive,
2992
+ maxSockets,
2993
+ scheduling: "lifo"
2994
+ });
2995
+ const httpsAgent = new import_node_https.default.Agent({
2996
+ keepAlive: isKeepAlive,
2997
+ maxSockets,
2998
+ scheduling: "lifo"
2999
+ });
3000
+ const axiosInstance = import_axios2.default.create({
3001
+ baseURL: config.baseURL,
3002
+ headers: config.defaultHeaders,
3003
+ timeout: config.timeoutMs,
3004
+ httpAgent,
3005
+ httpsAgent,
3006
+ maxRedirects: config.maxRedirects ?? 5,
3007
+ decompress: config.decompress ?? true,
3008
+ proxy: config.proxy,
3009
+ withCredentials: config.withCredentials
3010
+ });
3011
+ return new import_axios.AxiosHttpClient(axiosInstance);
3012
+ }
3013
+ };
3014
+ }
3015
+ });
3016
+
3017
+ // src/infrastructure/factories/cockatiel-resilience.factory.ts
3018
+ var cockatiel_resilience_factory_exports = {};
3019
+ __export(cockatiel_resilience_factory_exports, {
3020
+ CockatielResilienceFactory: () => CockatielResilienceFactory
3021
+ });
3022
+ var import_shared55, import_cockatiel, CockatielResilienceFactory;
3023
+ var init_cockatiel_resilience_factory = __esm({
3024
+ "src/infrastructure/factories/cockatiel-resilience.factory.ts"() {
3025
+ "use strict";
3026
+ import_shared55 = require("@xeno-js/shared");
3027
+ import_cockatiel = require("cockatiel");
3028
+ init_resilience_service();
3029
+ CockatielResilienceFactory = class {
3030
+ create(config) {
3031
+ const message = "The resilience configuration provided is invalid. Please ensure that all values are non-negative numbers.";
3032
+ const normalizedConfig = {
3033
+ retry: {
3034
+ attempts: this.checkConfigValue(
3035
+ config.retry.attempts,
3036
+ import_shared55.RESILIENCE_DEFAULTS.RETRY.ATTEMPTS,
3037
+ message
3038
+ ),
3039
+ baseDelayMs: this.checkConfigValue(
3040
+ config.retry.baseDelayMs,
3041
+ import_shared55.RESILIENCE_DEFAULTS.RETRY.BASE_DELAY_MS,
3042
+ message
3043
+ ),
3044
+ maxDelayMs: this.checkConfigValue(
3045
+ config.retry.maxDelayMs,
3046
+ import_shared55.RESILIENCE_DEFAULTS.RETRY.MAX_DELAY_MS,
3047
+ message
3048
+ )
3049
+ },
3050
+ circuitBreaker: {
3051
+ consecutiveFailures: this.checkConfigValue(
3052
+ config.circuitBreaker.consecutiveFailures,
3053
+ import_shared55.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.CONSECUTIVE_FAILURES,
3054
+ message
3055
+ ),
3056
+ halfOpenTimeoutMs: this.checkConfigValue(
3057
+ config.circuitBreaker.halfOpenTimeoutMs,
3058
+ import_shared55.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.HALF_OPEN_TIMEOUT_MS,
3059
+ message
3060
+ )
3061
+ },
3062
+ bulkhead: {
3063
+ maxConcurrent: this.checkConfigValue(
3064
+ config.bulkhead.maxConcurrent,
3065
+ import_shared55.RESILIENCE_DEFAULTS.BULKHEAD.MAX_CONCURRENT,
3066
+ message
3067
+ )
3068
+ }
3069
+ };
3070
+ const retryPolicy = (0, import_cockatiel.retry)(
3071
+ (0, import_cockatiel.handleWhen)((error) => this.isTransientAndIdempotent(error)),
3072
+ {
3073
+ maxAttempts: normalizedConfig.retry.attempts,
3074
+ backoff: new import_cockatiel.ExponentialBackoff({
3075
+ initialDelay: normalizedConfig.retry.baseDelayMs,
3076
+ maxDelay: normalizedConfig.retry.maxDelayMs
3077
+ })
3078
+ }
3079
+ );
3080
+ const circuitBreakerPolicy = (0, import_cockatiel.circuitBreaker)(
3081
+ (0, import_cockatiel.handleWhen)((error) => this.isTransientError(error)),
3082
+ {
3083
+ breaker: new import_cockatiel.ConsecutiveBreaker(normalizedConfig.circuitBreaker.consecutiveFailures),
3084
+ halfOpenAfter: normalizedConfig.circuitBreaker.halfOpenTimeoutMs
3085
+ }
3086
+ );
3087
+ const bulkheadPolicy = (0, import_cockatiel.bulkhead)(normalizedConfig.bulkhead.maxConcurrent);
3088
+ return new ServiceResilience((0, import_cockatiel.wrap)(bulkheadPolicy, circuitBreakerPolicy, retryPolicy));
3089
+ }
3090
+ isTransientError(error) {
3091
+ if (!import_shared55.Guards.isDefined(error) || !import_shared55.Guards.isObject(error)) return false;
3092
+ let status;
3093
+ let isNetworkError = false;
3094
+ if (error instanceof import_shared55.AppError) {
3095
+ status = error.status;
3096
+ const cause = error.cause;
3097
+ if (import_shared55.Guards.isDefined(cause) && import_shared55.Guards.isString(cause.code)) {
3098
+ isNetworkError = [
3099
+ "ECONNABORTED",
3100
+ "ECONNRESET",
3101
+ "ETIMEDOUT",
3102
+ "ENOTFOUND",
3103
+ "ECONNREFUSED"
3104
+ ].includes(cause.code.toUpperCase());
3105
+ }
3106
+ } else {
3107
+ const err = error;
3108
+ status = err.status;
3109
+ if (import_shared55.Guards.isString(err.code)) {
3110
+ isNetworkError = [
3111
+ "ECONNABORTED",
3112
+ "ECONNRESET",
3113
+ "ETIMEDOUT",
3114
+ "ENOTFOUND",
3115
+ "ECONNREFUSED"
3116
+ ].includes(err.code.toUpperCase());
3117
+ }
3118
+ }
3119
+ if (isNetworkError) return true;
3120
+ if (import_shared55.Guards.isDefined(status)) return status === 408 || status >= 500 && status < 600;
3121
+ return false;
3122
+ }
3123
+ isTransientAndIdempotent(error) {
3124
+ if (!this.isTransientError(error)) return false;
3125
+ let method;
3126
+ if (error instanceof import_shared55.AppError) {
3127
+ const cause = error.cause;
3128
+ if (import_shared55.Guards.isDefined(cause) && import_shared55.Guards.isDefined(cause.config) && import_shared55.Guards.isString(cause.config.method)) {
3129
+ method = cause.config.method.toUpperCase();
3130
+ }
3131
+ } else {
3132
+ const err = error;
3133
+ if (import_shared55.Guards.isDefined(err.config) && import_shared55.Guards.isString(err.config.method)) {
3134
+ method = err.config.method.toUpperCase();
3135
+ }
3136
+ }
3137
+ if (import_shared55.Guards.isNullOrEmpty(method)) return false;
3138
+ const idempotentMethods = ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"];
3139
+ return idempotentMethods.includes(method);
3140
+ }
3141
+ checkConfigValue(value, defaultValue, message) {
3142
+ if (import_shared55.Guards.isDefined(value)) {
3143
+ import_shared55.Guards.throwIfNegative(value, message);
3144
+ return value;
3145
+ }
3146
+ return defaultValue;
3147
+ }
3148
+ };
3149
+ }
3150
+ });
3151
+
3478
3152
  // src/infrastructure/modules/utils/http.utils.ts
3479
3153
  var http_utils_exports = {};
3480
3154
  __export(http_utils_exports, {
@@ -3496,7 +3170,7 @@ var init_http_utils = __esm({
3496
3170
  * @link https://github.com/xeno-js/xeno-js
3497
3171
  */
3498
3172
  async addAxios(container, opts) {
3499
- const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
3173
+ const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_axios_factory(), axios_factory_exports));
3500
3174
  const { Guards: Guards51 } = await import("@xeno-js/shared");
3501
3175
  if (!Guards51.isDefined(opts.token)) {
3502
3176
  throw new Error("HttpConfig.token is required and must be defined.");
@@ -3524,7 +3198,7 @@ var init_http_utils = __esm({
3524
3198
  */
3525
3199
  async addResilience(container, opts) {
3526
3200
  const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
3527
- const { CockatielResilienceFactory: CockatielResilienceFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
3201
+ const { CockatielResilienceFactory: CockatielResilienceFactory2 } = await Promise.resolve().then(() => (init_cockatiel_resilience_factory(), cockatiel_resilience_factory_exports));
3528
3202
  container.addSingleton(TOKENS5.RESILIENCE_CLIENT, () => {
3529
3203
  const factory = new CockatielResilienceFactory2();
3530
3204
  return factory.create(opts);
@@ -3554,11 +3228,11 @@ var init_http_core_module = __esm({
3554
3228
  });
3555
3229
 
3556
3230
  // src/presentation/controllers/base.controller.ts
3557
- var import_shared64, BaseController;
3231
+ var import_shared56, BaseController;
3558
3232
  var init_base_controller = __esm({
3559
3233
  "src/presentation/controllers/base.controller.ts"() {
3560
3234
  "use strict";
3561
- import_shared64 = require("@xeno-js/shared");
3235
+ import_shared56 = require("@xeno-js/shared");
3562
3236
  BaseController = class {
3563
3237
  /**
3564
3238
  * Constructs a new instance of the BaseController class.
@@ -3590,7 +3264,7 @@ var init_base_controller = __esm({
3590
3264
  * @link https://github.com/xeno-js/xeno-js
3591
3265
  */
3592
3266
  ok(data, status = 200, meta = {}, headers = {}) {
3593
- return import_shared64.HttpHelper.success(data, status, meta, headers);
3267
+ return import_shared56.HttpHelper.success(data, status, meta, headers);
3594
3268
  }
3595
3269
  /**
3596
3270
  * Helper to automatically map a failed Result (from the CQRS pipeline)
@@ -3608,7 +3282,7 @@ var init_base_controller = __esm({
3608
3282
  fail(error, details = void 0, headers = {}) {
3609
3283
  const context = this._requestContext.getContext();
3610
3284
  const customHeaders = error["header"];
3611
- return import_shared64.HttpHelper.error(
3285
+ return import_shared56.HttpHelper.error(
3612
3286
  {
3613
3287
  success: false,
3614
3288
  error: {
@@ -3617,9 +3291,9 @@ var init_base_controller = __esm({
3617
3291
  path: context?.network.path,
3618
3292
  details: details ?? error.message
3619
3293
  },
3620
- correlationId: context?.tracing.correlationId ?? import_shared64.GuidHelper.generate(),
3621
- requestId: context?.network.requestId ?? import_shared64.GuidHelper.generate(),
3622
- spanId: context?.tracing.spanId ?? import_shared64.GuidHelper.generate(),
3294
+ correlationId: context?.tracing.correlationId ?? import_shared56.GuidHelper.generate(),
3295
+ requestId: context?.network.requestId ?? import_shared56.GuidHelper.generate(),
3296
+ spanId: context?.tracing.spanId ?? import_shared56.GuidHelper.generate(),
3623
3297
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3624
3298
  },
3625
3299
  error.status,
@@ -3674,11 +3348,11 @@ var init_controllers = __esm({
3674
3348
  });
3675
3349
 
3676
3350
  // src/presentation/middlewares/allow-method.middleware.ts
3677
- var import_shared65, MethodCheckMiddleware;
3351
+ var import_shared57, MethodCheckMiddleware;
3678
3352
  var init_allow_method_middleware = __esm({
3679
3353
  "src/presentation/middlewares/allow-method.middleware.ts"() {
3680
3354
  "use strict";
3681
- import_shared65 = require("@xeno-js/shared");
3355
+ import_shared57 = require("@xeno-js/shared");
3682
3356
  MethodCheckMiddleware = class {
3683
3357
  constructor(_requestContext, _allowMethod) {
3684
3358
  this._requestContext = _requestContext;
@@ -3690,21 +3364,21 @@ var init_allow_method_middleware = __esm({
3690
3364
  const isAllowed = this._allowMethod.check(req.path, req.method);
3691
3365
  if (!isAllowed) {
3692
3366
  const { network, tracing } = this._requestContext.getContext() ?? {};
3693
- return import_shared65.HttpHelper.error(
3367
+ return import_shared57.HttpHelper.error(
3694
3368
  {
3695
3369
  success: false,
3696
3370
  error: {
3697
- code: import_shared65.ERROR_CODES.NOT_ALLOWED,
3698
- message: import_shared65.ERROR_CODE_MESSAGES[import_shared65.ERROR_CODES.NOT_ALLOWED],
3371
+ code: import_shared57.ERROR_CODES.NOT_ALLOWED,
3372
+ message: import_shared57.ERROR_CODE_MESSAGES[import_shared57.ERROR_CODES.NOT_ALLOWED],
3699
3373
  details: `Operation blocked by allow method middleware`,
3700
3374
  path: req.path
3701
3375
  },
3702
- correlationId: tracing?.correlationId ?? import_shared65.GuidHelper.generate(),
3703
- requestId: network?.requestId ?? import_shared65.GuidHelper.generate(),
3704
- spanId: tracing?.spanId ?? import_shared65.GuidHelper.generate(),
3376
+ correlationId: tracing?.correlationId ?? import_shared57.GuidHelper.generate(),
3377
+ requestId: network?.requestId ?? import_shared57.GuidHelper.generate(),
3378
+ spanId: tracing?.spanId ?? import_shared57.GuidHelper.generate(),
3705
3379
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3706
3380
  },
3707
- import_shared65.STATUS_CODES.NOT_ALLOWED,
3381
+ import_shared57.STATUS_CODES.NOT_ALLOWED,
3708
3382
  {
3709
3383
  Allow: this._allowMethod.getMethods(req.path)
3710
3384
  }
@@ -3717,11 +3391,11 @@ var init_allow_method_middleware = __esm({
3717
3391
  });
3718
3392
 
3719
3393
  // src/presentation/middlewares/allow-origin.middleware.ts
3720
- var import_shared66, AllowOriginMiddleware;
3394
+ var import_shared58, AllowOriginMiddleware;
3721
3395
  var init_allow_origin_middleware = __esm({
3722
3396
  "src/presentation/middlewares/allow-origin.middleware.ts"() {
3723
3397
  "use strict";
3724
- import_shared66 = require("@xeno-js/shared");
3398
+ import_shared58 = require("@xeno-js/shared");
3725
3399
  AllowOriginMiddleware = class {
3726
3400
  constructor(_allowOrigin, _requestContext, _logger) {
3727
3401
  this._allowOrigin = _allowOrigin;
@@ -3736,21 +3410,21 @@ var init_allow_origin_middleware = __esm({
3736
3410
  const origin = network?.origin;
3737
3411
  if (!this._allowOrigin.isAllowed(origin)) {
3738
3412
  this._logger.warn(`Access denied by AllowOrigin policy for origin: ${origin ?? "unknown"}`);
3739
- return import_shared66.HttpHelper.error(
3413
+ return import_shared58.HttpHelper.error(
3740
3414
  {
3741
3415
  success: false,
3742
3416
  error: {
3743
- code: import_shared66.ERROR_CODES.FORBIDDEN,
3744
- message: import_shared66.ERROR_CODE_MESSAGES[import_shared66.ERROR_CODES.FORBIDDEN],
3417
+ code: import_shared58.ERROR_CODES.FORBIDDEN,
3418
+ message: import_shared58.ERROR_CODE_MESSAGES[import_shared58.ERROR_CODES.FORBIDDEN],
3745
3419
  details: `The origin '${origin ?? "unknown"}' is not allowed to access this resource.`,
3746
3420
  path: req.path
3747
3421
  },
3748
- correlationId: tracing?.correlationId ?? import_shared66.GuidHelper.generate(),
3749
- requestId: network?.requestId ?? import_shared66.GuidHelper.generate(),
3750
- spanId: tracing?.spanId ?? import_shared66.GuidHelper.generate(),
3422
+ correlationId: tracing?.correlationId ?? import_shared58.GuidHelper.generate(),
3423
+ requestId: network?.requestId ?? import_shared58.GuidHelper.generate(),
3424
+ spanId: tracing?.spanId ?? import_shared58.GuidHelper.generate(),
3751
3425
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3752
3426
  },
3753
- import_shared66.STATUS_CODES.FORBIDDEN
3427
+ import_shared58.STATUS_CODES.FORBIDDEN
3754
3428
  );
3755
3429
  }
3756
3430
  return next();
@@ -3760,11 +3434,11 @@ var init_allow_origin_middleware = __esm({
3760
3434
  });
3761
3435
 
3762
3436
  // src/presentation/middlewares/auth.middleware.ts
3763
- var import_shared67, AuthenticationMiddleware;
3437
+ var import_shared59, AuthenticationMiddleware;
3764
3438
  var init_auth_middleware = __esm({
3765
3439
  "src/presentation/middlewares/auth.middleware.ts"() {
3766
3440
  "use strict";
3767
- import_shared67 = require("@xeno-js/shared");
3441
+ import_shared59 = require("@xeno-js/shared");
3768
3442
  AuthenticationMiddleware = class {
3769
3443
  constructor(_requestContext, _tokenExtractor, _gateKeeper, _logger) {
3770
3444
  this._requestContext = _requestContext;
@@ -3785,7 +3459,7 @@ var init_auth_middleware = __esm({
3785
3459
  `Authentication failed for request on path: ${req.path}. Code: ${error.code}. Error: ${error}`
3786
3460
  );
3787
3461
  const { network, tracing } = this._requestContext.getContext() ?? {};
3788
- return import_shared67.HttpHelper.error(
3462
+ return import_shared59.HttpHelper.error(
3789
3463
  {
3790
3464
  success: false,
3791
3465
  error: {
@@ -3794,12 +3468,12 @@ var init_auth_middleware = __esm({
3794
3468
  details: `[Authentication Error] Failed to authenticate request on path: ${req.path}`,
3795
3469
  path: req.path
3796
3470
  },
3797
- correlationId: tracing?.correlationId ?? import_shared67.GuidHelper.generate(),
3798
- requestId: network?.requestId ?? import_shared67.GuidHelper.generate(),
3799
- spanId: tracing?.spanId ?? import_shared67.GuidHelper.generate(),
3471
+ correlationId: tracing?.correlationId ?? import_shared59.GuidHelper.generate(),
3472
+ requestId: network?.requestId ?? import_shared59.GuidHelper.generate(),
3473
+ spanId: tracing?.spanId ?? import_shared59.GuidHelper.generate(),
3800
3474
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3801
3475
  },
3802
- error.status ?? import_shared67.STATUS_CODES.UNAUTHORIZED,
3476
+ error.status ?? import_shared59.STATUS_CODES.UNAUTHORIZED,
3803
3477
  { "Content-Type": [network?.formatIndicator ?? "application/json"] }
3804
3478
  );
3805
3479
  }
@@ -3834,11 +3508,11 @@ var init_composite_middleware = __esm({
3834
3508
  });
3835
3509
 
3836
3510
  // src/presentation/middlewares/cors.middleware.ts
3837
- var import_shared68, CORSMiddleware;
3511
+ var import_shared60, CORSMiddleware;
3838
3512
  var init_cors_middleware = __esm({
3839
3513
  "src/presentation/middlewares/cors.middleware.ts"() {
3840
3514
  "use strict";
3841
- import_shared68 = require("@xeno-js/shared");
3515
+ import_shared60 = require("@xeno-js/shared");
3842
3516
  CORSMiddleware = class {
3843
3517
  constructor(_requestContext, _withCredentials = "false") {
3844
3518
  this._requestContext = _requestContext;
@@ -3850,7 +3524,7 @@ var init_cors_middleware = __esm({
3850
3524
  const { network } = this._requestContext.getContext() ?? {};
3851
3525
  const origin = network?.origin;
3852
3526
  const response = await next();
3853
- if (import_shared68.Guards.isDefined(origin))
3527
+ if (import_shared60.Guards.isDefined(origin))
3854
3528
  response.headers = {
3855
3529
  ...response.headers ?? {},
3856
3530
  "Access-Control-Allow-Origin": origin,
@@ -3864,11 +3538,11 @@ var init_cors_middleware = __esm({
3864
3538
  });
3865
3539
 
3866
3540
  // src/presentation/middlewares/csrf.middleware.ts
3867
- var import_shared69, CsrfMiddleware;
3541
+ var import_shared61, CsrfMiddleware;
3868
3542
  var init_csrf_middleware = __esm({
3869
3543
  "src/presentation/middlewares/csrf.middleware.ts"() {
3870
3544
  "use strict";
3871
- import_shared69 = require("@xeno-js/shared");
3545
+ import_shared61 = require("@xeno-js/shared");
3872
3546
  CsrfMiddleware = class {
3873
3547
  constructor(_requestContext, _csrfTokenService) {
3874
3548
  this._requestContext = _requestContext;
@@ -3883,64 +3557,64 @@ var init_csrf_middleware = __esm({
3883
3557
  const { network, tracing, identity } = this._requestContext.getContext() ?? {};
3884
3558
  const headerToken = network?.csrf;
3885
3559
  const cookieToken = network?.csrfCookie;
3886
- if (!import_shared69.Guards.isDefined(headerToken) || !import_shared69.Guards.isDefined(cookieToken)) {
3887
- return import_shared69.HttpHelper.error(
3560
+ if (!import_shared61.Guards.isDefined(headerToken) || !import_shared61.Guards.isDefined(cookieToken)) {
3561
+ return import_shared61.HttpHelper.error(
3888
3562
  {
3889
3563
  success: false,
3890
3564
  error: {
3891
- code: import_shared69.ERROR_CODES.FORBIDDEN,
3892
- message: import_shared69.ERROR_CODE_MESSAGES[import_shared69.ERROR_CODES.FORBIDDEN],
3565
+ code: import_shared61.ERROR_CODES.FORBIDDEN,
3566
+ message: import_shared61.ERROR_CODE_MESSAGES[import_shared61.ERROR_CODES.FORBIDDEN],
3893
3567
  details: "CSRF token missing",
3894
3568
  path: req.path
3895
3569
  },
3896
- correlationId: tracing?.correlationId ?? import_shared69.GuidHelper.generate(),
3897
- requestId: network?.requestId ?? import_shared69.GuidHelper.generate(),
3898
- spanId: tracing?.spanId ?? import_shared69.GuidHelper.generate(),
3570
+ correlationId: tracing?.correlationId ?? import_shared61.GuidHelper.generate(),
3571
+ requestId: network?.requestId ?? import_shared61.GuidHelper.generate(),
3572
+ spanId: tracing?.spanId ?? import_shared61.GuidHelper.generate(),
3899
3573
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3900
3574
  },
3901
- import_shared69.STATUS_CODES.FORBIDDEN,
3575
+ import_shared61.STATUS_CODES.FORBIDDEN,
3902
3576
  {
3903
3577
  "Content-Type": [network?.formatIndicator ?? "application/json"]
3904
3578
  }
3905
3579
  );
3906
3580
  }
3907
3581
  if (headerToken !== cookieToken) {
3908
- return import_shared69.HttpHelper.error(
3582
+ return import_shared61.HttpHelper.error(
3909
3583
  {
3910
3584
  success: false,
3911
3585
  error: {
3912
- code: import_shared69.ERROR_CODES.FORBIDDEN,
3913
- message: import_shared69.ERROR_CODE_MESSAGES[import_shared69.ERROR_CODES.FORBIDDEN],
3586
+ code: import_shared61.ERROR_CODES.FORBIDDEN,
3587
+ message: import_shared61.ERROR_CODE_MESSAGES[import_shared61.ERROR_CODES.FORBIDDEN],
3914
3588
  details: "CSRF token mismatch",
3915
3589
  path: req.path
3916
3590
  },
3917
- correlationId: tracing?.correlationId ?? import_shared69.GuidHelper.generate(),
3918
- requestId: network?.requestId ?? import_shared69.GuidHelper.generate(),
3919
- spanId: tracing?.spanId ?? import_shared69.GuidHelper.generate(),
3591
+ correlationId: tracing?.correlationId ?? import_shared61.GuidHelper.generate(),
3592
+ requestId: network?.requestId ?? import_shared61.GuidHelper.generate(),
3593
+ spanId: tracing?.spanId ?? import_shared61.GuidHelper.generate(),
3920
3594
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3921
3595
  },
3922
- import_shared69.STATUS_CODES.FORBIDDEN,
3596
+ import_shared61.STATUS_CODES.FORBIDDEN,
3923
3597
  {
3924
3598
  "Content-Type": [network?.formatIndicator ?? "application/json"]
3925
3599
  }
3926
3600
  );
3927
3601
  }
3928
- if (!import_shared69.Guards.isDefined(identity?.userId) || !await this._csrfTokenService.validate(headerToken, identity?.userId)) {
3929
- return import_shared69.HttpHelper.error(
3602
+ if (!import_shared61.Guards.isDefined(identity?.userId) || !await this._csrfTokenService.validate(headerToken, identity?.userId)) {
3603
+ return import_shared61.HttpHelper.error(
3930
3604
  {
3931
3605
  success: false,
3932
3606
  error: {
3933
- code: import_shared69.ERROR_CODES.FORBIDDEN,
3934
- message: import_shared69.ERROR_CODE_MESSAGES[import_shared69.ERROR_CODES.FORBIDDEN],
3607
+ code: import_shared61.ERROR_CODES.FORBIDDEN,
3608
+ message: import_shared61.ERROR_CODE_MESSAGES[import_shared61.ERROR_CODES.FORBIDDEN],
3935
3609
  details: "CSRF token invalid",
3936
3610
  path: req.path
3937
3611
  },
3938
- correlationId: tracing?.correlationId ?? import_shared69.GuidHelper.generate(),
3939
- requestId: network?.requestId ?? import_shared69.GuidHelper.generate(),
3940
- spanId: tracing?.spanId ?? import_shared69.GuidHelper.generate(),
3612
+ correlationId: tracing?.correlationId ?? import_shared61.GuidHelper.generate(),
3613
+ requestId: network?.requestId ?? import_shared61.GuidHelper.generate(),
3614
+ spanId: tracing?.spanId ?? import_shared61.GuidHelper.generate(),
3941
3615
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3942
3616
  },
3943
- import_shared69.STATUS_CODES.FORBIDDEN,
3617
+ import_shared61.STATUS_CODES.FORBIDDEN,
3944
3618
  {
3945
3619
  "Content-Type": [network?.formatIndicator ?? "application/json"]
3946
3620
  }
@@ -3954,11 +3628,11 @@ var init_csrf_middleware = __esm({
3954
3628
  });
3955
3629
 
3956
3630
  // src/presentation/middlewares/csrf-cookie.middleware.ts
3957
- var import_shared70, CsrfCookieMiddleware;
3631
+ var import_shared62, CsrfCookieMiddleware;
3958
3632
  var init_csrf_cookie_middleware = __esm({
3959
3633
  "src/presentation/middlewares/csrf-cookie.middleware.ts"() {
3960
3634
  "use strict";
3961
- import_shared70 = require("@xeno-js/shared");
3635
+ import_shared62 = require("@xeno-js/shared");
3962
3636
  CsrfCookieMiddleware = class {
3963
3637
  constructor(_requestContext, _csrfTokenService, _csrf) {
3964
3638
  this._requestContext = _requestContext;
@@ -3973,8 +3647,8 @@ var init_csrf_cookie_middleware = __esm({
3973
3647
  const context = this._requestContext.getContext();
3974
3648
  const identity = context?.identity;
3975
3649
  const network = context?.network;
3976
- if (!import_shared70.Guards.isDefined(identity?.userId)) return response;
3977
- if (import_shared70.Guards.isDefined(network?.csrfCookie)) return response;
3650
+ if (!import_shared62.Guards.isDefined(identity?.userId)) return response;
3651
+ if (import_shared62.Guards.isDefined(network?.csrfCookie)) return response;
3978
3652
  const token = await this._csrfTokenService.generate(identity.userId);
3979
3653
  const cookieName = this._csrf.cookieName ?? "__Host-xeno-csrf";
3980
3654
  const maxAge = this._csrf.cookieMaxAgeSeconds ?? 3600;
@@ -3992,11 +3666,11 @@ var init_csrf_cookie_middleware = __esm({
3992
3666
  });
3993
3667
 
3994
3668
  // src/presentation/middlewares/options.middleware.ts
3995
- var import_shared71, OptionsMiddleware;
3669
+ var import_shared63, OptionsMiddleware;
3996
3670
  var init_options_middleware = __esm({
3997
3671
  "src/presentation/middlewares/options.middleware.ts"() {
3998
3672
  "use strict";
3999
- import_shared71 = require("@xeno-js/shared");
3673
+ import_shared63 = require("@xeno-js/shared");
4000
3674
  OptionsMiddleware = class {
4001
3675
  constructor(_requestContext, _alloewMethod, _allowHeaders = [], _withCredentials = "false") {
4002
3676
  this._requestContext = _requestContext;
@@ -4013,14 +3687,14 @@ var init_options_middleware = __esm({
4013
3687
  const network = this._requestContext.getNetworkContext();
4014
3688
  const origin = network?.origin;
4015
3689
  const headers = {};
4016
- if (import_shared71.Guards.isDefined(origin)) {
3690
+ if (import_shared63.Guards.isDefined(origin)) {
4017
3691
  headers["Access-Control-Allow-Origin"] = origin;
4018
3692
  headers["Access-Control-Allow-Credentials"] = this._withCredentials;
4019
3693
  headers["Vary"] = "Origin";
4020
3694
  }
4021
3695
  headers["Access-Control-Allow-Methods"] = this._alloewMethod.getMethods(req.path);
4022
3696
  headers["Access-Control-Allow-Headers"] = this._allowHeaders.join(", ");
4023
- return import_shared71.HttpHelper.success(null, import_shared71.STATUS_CODES.NO_CONTENT, {}, headers);
3697
+ return import_shared63.HttpHelper.success(null, import_shared63.STATUS_CODES.NO_CONTENT, {}, headers);
4024
3698
  }
4025
3699
  return await next();
4026
3700
  }
@@ -4029,11 +3703,11 @@ var init_options_middleware = __esm({
4029
3703
  });
4030
3704
 
4031
3705
  // src/presentation/middlewares/rate-limiter.middleware.ts
4032
- var import_shared72, RateLimitMiddleware;
3706
+ var import_shared64, RateLimitMiddleware;
4033
3707
  var init_rate_limiter_middleware = __esm({
4034
3708
  "src/presentation/middlewares/rate-limiter.middleware.ts"() {
4035
3709
  "use strict";
4036
- import_shared72 = require("@xeno-js/shared");
3710
+ import_shared64 = require("@xeno-js/shared");
4037
3711
  RateLimitMiddleware = class {
4038
3712
  constructor(_ctxAccessor, _cache, _keyBuilder, _logger, _opts) {
4039
3713
  this._ctxAccessor = _ctxAccessor;
@@ -4050,22 +3724,22 @@ var init_rate_limiter_middleware = __esm({
4050
3724
  async execute(req, _res, next) {
4051
3725
  const cacheKey = this._keyBuilder.buildRateLimitKey(req.path);
4052
3726
  const { network, tracing } = this._ctxAccessor.getContext() ?? {};
4053
- if (!import_shared72.Guards.isDefined(cacheKey))
4054
- return import_shared72.HttpHelper.error(
3727
+ if (!import_shared64.Guards.isDefined(cacheKey))
3728
+ return import_shared64.HttpHelper.error(
4055
3729
  {
4056
3730
  success: false,
4057
3731
  error: {
4058
- code: import_shared72.ERROR_CODES.SYSTEM_ERROR,
4059
- message: import_shared72.ERROR_CODE_MESSAGES[import_shared72.ERROR_CODES.SYSTEM_ERROR],
3732
+ code: import_shared64.ERROR_CODES.SYSTEM_ERROR,
3733
+ message: import_shared64.ERROR_CODE_MESSAGES[import_shared64.ERROR_CODES.SYSTEM_ERROR],
4060
3734
  details: `Bad Request: Unable to identify client context for rate limiting.`,
4061
3735
  path: req.path
4062
3736
  },
4063
- correlationId: tracing?.correlationId ?? import_shared72.GuidHelper.generate(),
4064
- requestId: network?.requestId ?? import_shared72.GuidHelper.generate(),
4065
- spanId: tracing?.spanId ?? import_shared72.GuidHelper.generate(),
3737
+ correlationId: tracing?.correlationId ?? import_shared64.GuidHelper.generate(),
3738
+ requestId: network?.requestId ?? import_shared64.GuidHelper.generate(),
3739
+ spanId: tracing?.spanId ?? import_shared64.GuidHelper.generate(),
4066
3740
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4067
3741
  },
4068
- import_shared72.STATUS_CODES.SERVICE_UNAVAILABLE,
3742
+ import_shared64.STATUS_CODES.SERVICE_UNAVAILABLE,
4069
3743
  {
4070
3744
  "Content-Type": [network?.formatIndicator ?? "application/json"],
4071
3745
  "Retry-After": [String(this._opts.windowSeconds)]
@@ -4074,21 +3748,21 @@ var init_rate_limiter_middleware = __esm({
4074
3748
  const currentHits = await this._cache.increment(cacheKey, this._opts.windowSeconds);
4075
3749
  if (currentHits > this._opts.maxRequests) {
4076
3750
  this._logger.warn(`[RateLimit] key ${cacheKey} has been blocked on ${req.path}`);
4077
- return import_shared72.HttpHelper.error(
3751
+ return import_shared64.HttpHelper.error(
4078
3752
  {
4079
3753
  success: false,
4080
3754
  error: {
4081
- code: import_shared72.ERROR_CODES.TOO_MANY_REQUESTS,
4082
- message: import_shared72.ERROR_CODE_MESSAGES[import_shared72.ERROR_CODES.TOO_MANY_REQUESTS],
3755
+ code: import_shared64.ERROR_CODES.TOO_MANY_REQUESTS,
3756
+ message: import_shared64.ERROR_CODE_MESSAGES[import_shared64.ERROR_CODES.TOO_MANY_REQUESTS],
4083
3757
  details: `Rate limit exceeded.`,
4084
3758
  path: req.path
4085
3759
  },
4086
- correlationId: tracing?.correlationId ?? import_shared72.GuidHelper.generate(),
4087
- requestId: network?.requestId ?? import_shared72.GuidHelper.generate(),
4088
- spanId: tracing?.spanId ?? import_shared72.GuidHelper.generate(),
3760
+ correlationId: tracing?.correlationId ?? import_shared64.GuidHelper.generate(),
3761
+ requestId: network?.requestId ?? import_shared64.GuidHelper.generate(),
3762
+ spanId: tracing?.spanId ?? import_shared64.GuidHelper.generate(),
4089
3763
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4090
3764
  },
4091
- import_shared72.STATUS_CODES.TOO_MANY_REQUESTS,
3765
+ import_shared64.STATUS_CODES.TOO_MANY_REQUESTS,
4092
3766
  {
4093
3767
  "Content-Type": [network?.formatIndicator ?? "application/json"],
4094
3768
  "Retry-After": [String(this._opts.windowSeconds)]
@@ -4103,8 +3777,8 @@ var init_rate_limiter_middleware = __esm({
4103
3777
 
4104
3778
  // src/presentation/mappers/context.mapper.ts
4105
3779
  function _buildMessagingContext(meta) {
4106
- const hasSequenceData = import_shared73.Guards.isDefined(meta.sequence?.sequenceId) || import_shared73.Guards.isDefined(meta.sequence?.position) || import_shared73.Guards.isDefined(meta.sequence?.size);
4107
- const hasMessagingData = hasSequenceData || import_shared73.Guards.isDefined(meta.expiration) || import_shared73.Guards.isDefined(meta.returnAddress);
3780
+ const hasSequenceData = import_shared65.Guards.isDefined(meta.sequence?.sequenceId) || import_shared65.Guards.isDefined(meta.sequence?.position) || import_shared65.Guards.isDefined(meta.sequence?.size);
3781
+ const hasMessagingData = hasSequenceData || import_shared65.Guards.isDefined(meta.expiration) || import_shared65.Guards.isDefined(meta.returnAddress);
4108
3782
  const messaging = hasMessagingData ? {
4109
3783
  returnAddress: meta.returnAddress,
4110
3784
  expiration: meta.expiration,
@@ -4112,11 +3786,11 @@ function _buildMessagingContext(meta) {
4112
3786
  } : void 0;
4113
3787
  return messaging;
4114
3788
  }
4115
- var import_shared73, ContextMapper;
3789
+ var import_shared65, ContextMapper;
4116
3790
  var init_context_mapper = __esm({
4117
3791
  "src/presentation/mappers/context.mapper.ts"() {
4118
3792
  "use strict";
4119
- import_shared73 = require("@xeno-js/shared");
3793
+ import_shared65 = require("@xeno-js/shared");
4120
3794
  ContextMapper = Object.freeze({
4121
3795
  /**
4122
3796
  * @description Maps to RequestContext. It extracts relevant information from the object, such as correlation ID, request ID, authentication token, client IP, user agent, format indicator, and messaging context (if available). The method constructs a RequestContext object that encapsulates all this information, providing a structured representation of the request context for further processing in the application.
@@ -4160,11 +3834,11 @@ var init_context_mapper = __esm({
4160
3834
  });
4161
3835
 
4162
3836
  // src/presentation/middlewares/request.middleware.ts
4163
- var import_shared74, RequestContextMiddleware;
3837
+ var import_shared66, RequestContextMiddleware;
4164
3838
  var init_request_middleware = __esm({
4165
3839
  "src/presentation/middlewares/request.middleware.ts"() {
4166
3840
  "use strict";
4167
- import_shared74 = require("@xeno-js/shared");
3841
+ import_shared66 = require("@xeno-js/shared");
4168
3842
  init_context_mapper();
4169
3843
  RequestContextMiddleware = class {
4170
3844
  /**
@@ -4189,8 +3863,8 @@ var init_request_middleware = __esm({
4189
3863
  _resolver;
4190
3864
  _logger;
4191
3865
  async execute(req, res, next) {
4192
- const correlationId = import_shared74.GuidHelper.generate();
4193
- const requestId = import_shared74.GuidHelper.generate();
3866
+ const correlationId = import_shared66.GuidHelper.generate();
3867
+ const requestId = import_shared66.GuidHelper.generate();
4194
3868
  const spanId = correlationId;
4195
3869
  const formatIndicator = "application/json";
4196
3870
  try {
@@ -4206,7 +3880,7 @@ var init_request_middleware = __esm({
4206
3880
  };
4207
3881
  const tmpContext = ContextMapper.map({
4208
3882
  metadata,
4209
- identity: import_shared74.GUEST,
3883
+ identity: import_shared66.GUEST,
4210
3884
  path: req.path,
4211
3885
  transport: { req, res }
4212
3886
  });
@@ -4218,12 +3892,12 @@ var init_request_middleware = __esm({
4218
3892
  return result;
4219
3893
  } catch (error) {
4220
3894
  this._logger.error("RequestContextMiddleware encountered an error", error);
4221
- return import_shared74.HttpHelper.error(
3895
+ return import_shared66.HttpHelper.error(
4222
3896
  {
4223
3897
  success: false,
4224
3898
  error: {
4225
- code: import_shared74.ERROR_CODES.SYSTEM_ERROR,
4226
- message: import_shared74.ERROR_CODE_MESSAGES[import_shared74.ERROR_CODES.SYSTEM_ERROR],
3899
+ code: import_shared66.ERROR_CODES.SYSTEM_ERROR,
3900
+ message: import_shared66.ERROR_CODE_MESSAGES[import_shared66.ERROR_CODES.SYSTEM_ERROR],
4227
3901
  details: `[Fatal System Error] Exception caught during request handling on path: ${req.path}`,
4228
3902
  path: req.path
4229
3903
  },
@@ -4232,7 +3906,7 @@ var init_request_middleware = __esm({
4232
3906
  spanId,
4233
3907
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4234
3908
  },
4235
- import_shared74.STATUS_CODES.INTERNAL_SERVER_ERROR,
3909
+ import_shared66.STATUS_CODES.INTERNAL_SERVER_ERROR,
4236
3910
  { "Content-Type": [formatIndicator] }
4237
3911
  );
4238
3912
  }
@@ -4286,16 +3960,16 @@ var inmemory_cache_exports = {};
4286
3960
  __export(inmemory_cache_exports, {
4287
3961
  InMemoryCacheExtended: () => InMemoryCacheExtended
4288
3962
  });
4289
- var import_shared75, InMemoryCacheExtended;
3963
+ var import_shared67, InMemoryCacheExtended;
4290
3964
  var init_inmemory_cache = __esm({
4291
3965
  "src/infrastructure/cache/inmemory.cache.ts"() {
4292
3966
  "use strict";
4293
- import_shared75 = require("@xeno-js/shared");
4294
- InMemoryCacheExtended = class extends import_shared75.InMemoryCache {
3967
+ import_shared67 = require("@xeno-js/shared");
3968
+ InMemoryCacheExtended = class extends import_shared67.InMemoryCache {
4295
3969
  async increment(key, ttlSeconds) {
4296
3970
  const current = await this.get(key) ?? 0;
4297
3971
  const next = Number(current) + 1;
4298
- const ttl = import_shared75.Guards.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
3972
+ const ttl = import_shared67.Guards.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
4299
3973
  await this.set(key, next, ttl);
4300
3974
  return next;
4301
3975
  }
@@ -4304,11 +3978,11 @@ var init_inmemory_cache = __esm({
4304
3978
  });
4305
3979
 
4306
3980
  // src/infrastructure/cache/rate-limit-key-builder.cache.ts
4307
- var import_shared76, RateLimitKeyBuilder;
3981
+ var import_shared68, RateLimitKeyBuilder;
4308
3982
  var init_rate_limit_key_builder_cache = __esm({
4309
3983
  "src/infrastructure/cache/rate-limit-key-builder.cache.ts"() {
4310
3984
  "use strict";
4311
- import_shared76 = require("@xeno-js/shared");
3985
+ import_shared68 = require("@xeno-js/shared");
4312
3986
  RateLimitKeyBuilder = class {
4313
3987
  constructor(_contextAccessor) {
4314
3988
  this._contextAccessor = _contextAccessor;
@@ -4319,18 +3993,78 @@ var init_rate_limit_key_builder_cache = __esm({
4319
3993
  const tenantId = ctx?.identity?.tenantId;
4320
3994
  const userId = ctx?.identity?.userId;
4321
3995
  const clientIp = ctx?.network?.clientIp;
4322
- if (!import_shared76.Guards.isNullOrEmpty(tenantId) && !import_shared76.Guards.isNullOrEmpty(userId))
3996
+ if (!import_shared68.Guards.isNullOrEmpty(tenantId) && !import_shared68.Guards.isNullOrEmpty(userId))
4323
3997
  return `ratelimit:tenant:${tenantId}:user:${userId}:${resource}`;
4324
- if (!import_shared76.Guards.isNullOrEmpty(tenantId) && !import_shared76.Guards.isNullOrEmpty(clientIp))
3998
+ if (!import_shared68.Guards.isNullOrEmpty(tenantId) && !import_shared68.Guards.isNullOrEmpty(clientIp))
4325
3999
  return `ratelimit:tenant:${tenantId}:ip:${clientIp}:${resource}`;
4326
- if (!import_shared76.Guards.isNullOrEmpty(userId)) return `ratelimit:user:${userId}:${resource}`;
4327
- if (!import_shared76.Guards.isNullOrEmpty(clientIp)) return `ratelimit:ip:${clientIp}:${resource}`;
4000
+ if (!import_shared68.Guards.isNullOrEmpty(userId)) return `ratelimit:user:${userId}:${resource}`;
4001
+ if (!import_shared68.Guards.isNullOrEmpty(clientIp)) return `ratelimit:ip:${clientIp}:${resource}`;
4328
4002
  return void 0;
4329
4003
  }
4330
4004
  };
4331
4005
  }
4332
4006
  });
4333
4007
 
4008
+ // src/infrastructure/cache/redis.cache.ts
4009
+ var import_shared69, RedisCache;
4010
+ var init_redis_cache = __esm({
4011
+ "src/infrastructure/cache/redis.cache.ts"() {
4012
+ "use strict";
4013
+ import_shared69 = require("@xeno-js/shared");
4014
+ RedisCache = class {
4015
+ /**
4016
+ * @description Constructs a new instance of the RedisCache class, which takes an instance of the Redis client as a parameter. This client is used to perform caching operations such as setting, getting, and removing values from the Redis database. The constructor initializes the RedisCache with the provided Redis client, allowing it to interact with the Redis server for all caching operations defined in the ICache interface.
4017
+ * @param _redisClient An instance of the Redis client from the ioredis library, used to perform caching operations in the Redis database.
4018
+
4019
+ *
4020
+ * @author Xeno
4021
+ * @version 1.0.0
4022
+ * @since 2025-09-30
4023
+ * @link https://github.com/xeno-js/xeno-js
4024
+ */
4025
+ constructor(_redisClient) {
4026
+ this._redisClient = _redisClient;
4027
+ }
4028
+ _redisClient;
4029
+ async increment(key, ttlSeconds) {
4030
+ const multi = this._redisClient.multi();
4031
+ multi.incr(key);
4032
+ multi.expire(key, ttlSeconds ?? 60);
4033
+ const results = await multi.exec();
4034
+ return results?.[0]?.[1] ?? 1;
4035
+ }
4036
+ async get(key) {
4037
+ const value = await this._redisClient.get(key);
4038
+ if (!import_shared69.Guards.isDefined(value)) {
4039
+ return void 0;
4040
+ }
4041
+ return JSON.parse(value);
4042
+ }
4043
+ async set(key, value, ttl) {
4044
+ const stringValue = import_shared69.StringHelper.safeStringify(value);
4045
+ const ttlOption = import_shared69.Guards.isDefined(ttl) ? ttl : 86400;
4046
+ await this._redisClient.set(key, stringValue, "EX", ttlOption);
4047
+ }
4048
+ async setIfAbsent(key, value, ttl) {
4049
+ const stringValue = import_shared69.StringHelper.safeStringify(value);
4050
+ const ttlOption = import_shared69.Guards.isDefined(ttl) ? ttl : 300;
4051
+ const result = await this._redisClient.set(key, stringValue, "EX", ttlOption, "NX");
4052
+ return result === "OK";
4053
+ }
4054
+ async remove(key) {
4055
+ await this._redisClient.del(key);
4056
+ }
4057
+ async has(key) {
4058
+ const exists = await this._redisClient.exists(key);
4059
+ return exists === 1;
4060
+ }
4061
+ async clear() {
4062
+ await this._redisClient.flushdb();
4063
+ }
4064
+ };
4065
+ }
4066
+ });
4067
+
4334
4068
  // src/infrastructure/cache/index.ts
4335
4069
  var cache_exports = {};
4336
4070
  __export(cache_exports, {
@@ -4347,6 +4081,28 @@ var init_cache = __esm({
4347
4081
  }
4348
4082
  });
4349
4083
 
4084
+ // src/infrastructure/factories/allow-method.factory.ts
4085
+ var allow_method_factory_exports = {};
4086
+ __export(allow_method_factory_exports, {
4087
+ AllowMethodFactory: () => AllowMethodFactory
4088
+ });
4089
+ var AllowMethodFactory;
4090
+ var init_allow_method_factory = __esm({
4091
+ "src/infrastructure/factories/allow-method.factory.ts"() {
4092
+ "use strict";
4093
+ init_services();
4094
+ AllowMethodFactory = class {
4095
+ create(opts) {
4096
+ const allowMethodService = new AllowMethodRegistry();
4097
+ for (const [intentKey, schema] of Object.entries(opts)) {
4098
+ allowMethodService.add(intentKey, schema);
4099
+ }
4100
+ return allowMethodService;
4101
+ }
4102
+ };
4103
+ }
4104
+ });
4105
+
4350
4106
  // src/infrastructure/modules/middleware.module.ts
4351
4107
  var middleware_module_exports = {};
4352
4108
  __export(middleware_module_exports, {
@@ -4497,13 +4253,62 @@ var init_middleware_module = __esm({
4497
4253
  async _getAllowMethod(configure, opts) {
4498
4254
  const { Guards: Guards51 } = await import("@xeno-js/shared");
4499
4255
  if (!configure || !Guards51.isDefined(opts)) return void 0;
4500
- const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
4256
+ const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_allow_method_factory(), allow_method_factory_exports));
4501
4257
  return new AllowMethodFactory2().create(opts);
4502
4258
  }
4503
4259
  };
4504
4260
  }
4505
4261
  });
4506
4262
 
4263
+ // src/infrastructure/factories/redis-cache.factory.ts
4264
+ var redis_cache_factory_exports = {};
4265
+ __export(redis_cache_factory_exports, {
4266
+ RedisCacheFactory: () => RedisCacheFactory
4267
+ });
4268
+ var import_shared70, import_ioredis, RedisCacheFactory;
4269
+ var init_redis_cache_factory = __esm({
4270
+ "src/infrastructure/factories/redis-cache.factory.ts"() {
4271
+ "use strict";
4272
+ import_shared70 = require("@xeno-js/shared");
4273
+ import_ioredis = require("ioredis");
4274
+ init_redis_cache();
4275
+ RedisCacheFactory = class {
4276
+ create(config) {
4277
+ const host = config?.host ?? "localhost";
4278
+ const port = config?.port ?? 6379;
4279
+ const password = config?.password;
4280
+ const username = config?.username;
4281
+ const useTls = config?.tls ?? false;
4282
+ const maxRetries = config?.maxRetriesPerRequest ?? 3;
4283
+ const redisOptions = {
4284
+ host,
4285
+ port,
4286
+ maxRetriesPerRequest: maxRetries,
4287
+ // Strategia di riconnessione esponenziale per garantire resilienza
4288
+ retryStrategy(times) {
4289
+ const delay = Math.min(times * 50, 2e3);
4290
+ return delay;
4291
+ }
4292
+ };
4293
+ if (import_shared70.Guards.isDefined(password)) {
4294
+ redisOptions.password = password;
4295
+ }
4296
+ if (import_shared70.Guards.isDefined(username)) {
4297
+ redisOptions.username = username;
4298
+ }
4299
+ if (useTls) {
4300
+ redisOptions.tls = {};
4301
+ }
4302
+ const nativeRedisInstance = new import_ioredis.Redis(redisOptions);
4303
+ nativeRedisInstance.on("error", (err) => {
4304
+ console.error("\u274C [Redis Error]:", err.message);
4305
+ });
4306
+ return new RedisCache(nativeRedisInstance);
4307
+ }
4308
+ };
4309
+ }
4310
+ });
4311
+
4507
4312
  // src/infrastructure/modules/utils/cache.utils.ts
4508
4313
  var cache_utils_exports = {};
4509
4314
  __export(cache_utils_exports, {
@@ -4559,11 +4364,11 @@ var console_logger_exports = {};
4559
4364
  __export(console_logger_exports, {
4560
4365
  ConsoleLogger: () => ConsoleLogger
4561
4366
  });
4562
- var import_shared77, ConsoleLogger;
4367
+ var import_shared71, ConsoleLogger;
4563
4368
  var init_console_logger = __esm({
4564
4369
  "src/infrastructure/loggers/console.logger.ts"() {
4565
4370
  "use strict";
4566
- import_shared77 = require("@xeno-js/shared");
4371
+ import_shared71 = require("@xeno-js/shared");
4567
4372
  ConsoleLogger = class {
4568
4373
  /**
4569
4374
  * Constructs a new instance of the ConsoleLogger class, which takes an optional minimum log level. The minimum log level determines the threshold for logging messages, where messages with a log level below the specified minimum will be ignored.
@@ -4575,22 +4380,22 @@ var init_console_logger = __esm({
4575
4380
  * @since 2025-09-30
4576
4381
  * @link https://github.com/xeno-js/xeno-js
4577
4382
  */
4578
- constructor(_minLevel = import_shared77.LOG_LEVEL.DEBUG) {
4383
+ constructor(_minLevel = import_shared71.LOG_LEVEL.DEBUG) {
4579
4384
  this._minLevel = _minLevel;
4580
4385
  }
4581
4386
  _minLevel;
4582
4387
  track(level, message, context, error = void 0) {
4583
4388
  if (level < this._minLevel) return;
4584
4389
  const logMessage = `[${level}] ${message}`;
4585
- const payload = import_shared77.Guards.isDefined(error) ? { ...context, error } : context;
4390
+ const payload = import_shared71.Guards.isDefined(error) ? { ...context, error } : context;
4586
4391
  switch (level) {
4587
- case import_shared77.LOG_LEVEL.ERROR:
4392
+ case import_shared71.LOG_LEVEL.ERROR:
4588
4393
  console.error(logMessage, payload ?? {});
4589
4394
  break;
4590
- case import_shared77.LOG_LEVEL.WARN:
4395
+ case import_shared71.LOG_LEVEL.WARN:
4591
4396
  console.warn(logMessage, payload ?? {});
4592
4397
  break;
4593
- case import_shared77.LOG_LEVEL.DEBUG:
4398
+ case import_shared71.LOG_LEVEL.DEBUG:
4594
4399
  console.debug(logMessage, payload ?? {});
4595
4400
  break;
4596
4401
  default:
@@ -4602,6 +4407,180 @@ var init_console_logger = __esm({
4602
4407
  }
4603
4408
  });
4604
4409
 
4410
+ // src/infrastructure/loggers/sentry.logger.ts
4411
+ var import_shared72, SentryLogger;
4412
+ var init_sentry_logger = __esm({
4413
+ "src/infrastructure/loggers/sentry.logger.ts"() {
4414
+ "use strict";
4415
+ import_shared72 = require("@xeno-js/shared");
4416
+ SentryLogger = class {
4417
+ constructor(_client, _minLevel) {
4418
+ this._client = _client;
4419
+ this._minLevel = _minLevel;
4420
+ }
4421
+ _client;
4422
+ _minLevel;
4423
+ track(level, message, context = void 0, error = void 0) {
4424
+ if (level < this._minLevel) return;
4425
+ if (level === import_shared72.LOG_LEVEL.ERROR || level === import_shared72.LOG_LEVEL.WARN) {
4426
+ this._client.withScope((scope) => {
4427
+ if (import_shared72.Guards.isDefined(context)) scope.setExtras(context);
4428
+ if (import_shared72.Guards.isDefined(error)) {
4429
+ this._client.captureException(error);
4430
+ } else {
4431
+ this._client.captureMessage(message, "warning");
4432
+ }
4433
+ });
4434
+ }
4435
+ }
4436
+ };
4437
+ }
4438
+ });
4439
+
4440
+ // src/infrastructure/factories/sentry-logger.factory.ts
4441
+ var sentry_logger_factory_exports = {};
4442
+ __export(sentry_logger_factory_exports, {
4443
+ SentryLoggerFactory: () => SentryLoggerFactory
4444
+ });
4445
+ var Sentry, import_shared73, SentryLoggerFactory;
4446
+ var init_sentry_logger_factory = __esm({
4447
+ "src/infrastructure/factories/sentry-logger.factory.ts"() {
4448
+ "use strict";
4449
+ Sentry = __toESM(require("@sentry/node"), 1);
4450
+ import_shared73 = require("@xeno-js/shared");
4451
+ init_sentry_logger();
4452
+ SentryLoggerFactory = class {
4453
+ create(config) {
4454
+ const level = config.level ?? import_shared73.LOG_LEVEL.WARN;
4455
+ const sentryConfig = config.sentry?.config;
4456
+ const env = sentryConfig?.environment ?? process.env.NODE_ENV ?? "development";
4457
+ if (!import_shared73.Guards.isDefined(sentryConfig))
4458
+ throw new Error("Sentry configuration is required when Sentry logging is enabled.");
4459
+ if (!import_shared73.Guards.isDefined(sentryConfig.dsn))
4460
+ throw new Error("Sentry DSN is required when Sentry logging is enabled.");
4461
+ Sentry.init({
4462
+ dsn: sentryConfig.dsn,
4463
+ environment: env,
4464
+ tracesSampleRate: env === "production" ? 0.1 : 1,
4465
+ integrations: [Sentry.httpIntegration()],
4466
+ beforeSend(event, hint) {
4467
+ const error = hint.originalException;
4468
+ if (error instanceof Error && error.name === "ZodError") {
4469
+ return null;
4470
+ }
4471
+ return event;
4472
+ }
4473
+ });
4474
+ return new SentryLogger(Sentry, level);
4475
+ }
4476
+ };
4477
+ }
4478
+ });
4479
+
4480
+ // src/infrastructure/loggers/pino.logger.ts
4481
+ var import_shared74, PinoLogger;
4482
+ var init_pino_logger = __esm({
4483
+ "src/infrastructure/loggers/pino.logger.ts"() {
4484
+ "use strict";
4485
+ import_shared74 = require("@xeno-js/shared");
4486
+ PinoLogger = class {
4487
+ /**
4488
+ * Constructs a new instance of the PinoTransport class, which takes an optional minimum log level and an optional instance of the Pino logger. If no logger instance is provided, it initializes a new Pino logger with default settings. The minimum log level determines the threshold for logging messages, where messages with a log level below the specified minimum will be ignored.
4489
+ * @param _logger The Pino logger instance used for logging messages.
4490
+ * @param _minLevel The minimum log level for logging messages. Messages with a log level below this threshold will not be logged. Default is LOG_LEVEL.DEBUG.
4491
+
4492
+ *
4493
+ * @author Xeno
4494
+ * @version 1.0.0
4495
+ * @since 2025-09-30
4496
+ * @link https://github.com/xeno-js/xeno-js
4497
+ */
4498
+ constructor(_logger, _minLevel = import_shared74.LOG_LEVEL.DEBUG) {
4499
+ this._logger = _logger;
4500
+ this._minLevel = _minLevel;
4501
+ }
4502
+ _logger;
4503
+ _minLevel;
4504
+ track(level, message, context, error = void 0) {
4505
+ if (level < this._minLevel) return;
4506
+ const payload = import_shared74.Guards.isDefined(error) ? { ...context, error } : context;
4507
+ switch (level) {
4508
+ case import_shared74.LOG_LEVEL.ERROR:
4509
+ this._logger.error(payload ?? {}, message);
4510
+ break;
4511
+ case import_shared74.LOG_LEVEL.WARN:
4512
+ this._logger.warn(payload ?? {}, message);
4513
+ break;
4514
+ case import_shared74.LOG_LEVEL.DEBUG:
4515
+ this._logger.debug(payload ?? {}, message);
4516
+ break;
4517
+ default:
4518
+ this._logger.info(payload ?? {}, message);
4519
+ break;
4520
+ }
4521
+ }
4522
+ };
4523
+ }
4524
+ });
4525
+
4526
+ // src/infrastructure/factories/pino-logger.factory.ts
4527
+ var pino_logger_factory_exports = {};
4528
+ __export(pino_logger_factory_exports, {
4529
+ PinoLoggerFactory: () => PinoLoggerFactory
4530
+ });
4531
+ var import_shared75, import_pino, PinoLoggerFactory;
4532
+ var init_pino_logger_factory = __esm({
4533
+ "src/infrastructure/factories/pino-logger.factory.ts"() {
4534
+ "use strict";
4535
+ import_shared75 = require("@xeno-js/shared");
4536
+ import_pino = __toESM(require("pino"), 1);
4537
+ init_pino_logger();
4538
+ PinoLoggerFactory = class {
4539
+ create(config) {
4540
+ const level = config.level ?? import_shared75.LOG_LEVEL.DEBUG;
4541
+ const env = config.pino.config?.env ?? process.env.NODE_ENV ?? "development";
4542
+ const destinationType = config.pino.config?.destination ?? "stdout";
4543
+ const filePath = config.pino.config?.filePath ?? "logs/app.log";
4544
+ const prettyPrint = config.pino.config?.prettyPrint ?? env === "development";
4545
+ const options = {
4546
+ level: "trace",
4547
+ serializers: {
4548
+ err: import_pino.default.stdSerializers.err
4549
+ },
4550
+ timestamp: import_pino.default.stdTimeFunctions.isoTime,
4551
+ redact: {
4552
+ paths: ["password", "token", "secret", "authorization", "headers.authorization"],
4553
+ censor: "***"
4554
+ }
4555
+ };
4556
+ if (prettyPrint) {
4557
+ return new PinoLogger(
4558
+ (0, import_pino.default)({
4559
+ ...options,
4560
+ transport: {
4561
+ target: "pino-pretty",
4562
+ options: {
4563
+ colorize: true,
4564
+ ignore: "pid,hostname",
4565
+ translateTime: "SYS:standard"
4566
+ }
4567
+ }
4568
+ }),
4569
+ level
4570
+ );
4571
+ }
4572
+ if (destinationType === "file") {
4573
+ const destination = import_pino.default.destination({ dest: filePath, sync: false });
4574
+ return new PinoLogger((0, import_pino.default)(options, destination), level);
4575
+ } else {
4576
+ const stream = import_pino.default.destination({ dest: 1, sync: false });
4577
+ return new PinoLogger((0, import_pino.default)(options, stream), level);
4578
+ }
4579
+ }
4580
+ };
4581
+ }
4582
+ });
4583
+
4605
4584
  // src/infrastructure/modules/utils/logger.utils.ts
4606
4585
  var logger_utils_exports = {};
4607
4586
  __export(logger_utils_exports, {
@@ -4709,20 +4688,17 @@ __export(index_exports, {
4709
4688
  BaseController: () => BaseController,
4710
4689
  BaseHandler: () => BaseHandler,
4711
4690
  BaseHttpAdapter: () => BaseHttpAdapter,
4712
- BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
4713
- BaseQuery: () => import_shared84.Query,
4714
- BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
4715
4691
  ContainerUtils: () => ContainerUtils,
4692
+ Query: () => import_shared81.Query,
4716
4693
  ReadDao: () => ReadDao,
4717
4694
  Repository: () => Repository,
4718
- Specification: () => Specification,
4719
- SupabaseServerAuthFactory: () => SupabaseServerAuthFactory
4695
+ Specification: () => Specification
4720
4696
  });
4721
4697
  module.exports = __toCommonJS(index_exports);
4722
4698
  init_application();
4723
4699
 
4724
4700
  // src/infrastructure/builder/app.builder.ts
4725
- var import_shared78 = require("@xeno-js/shared");
4701
+ var import_shared76 = require("@xeno-js/shared");
4726
4702
 
4727
4703
  // src/infrastructure/configuration/configuration.ts
4728
4704
  var import_shared32 = require("@xeno-js/shared");
@@ -5001,7 +4977,7 @@ var AppBuilder = class {
5001
4977
  constructor(container, configurationService) {
5002
4978
  this._container = container ?? new ServiceContainer();
5003
4979
  this._configuration = configurationService ?? new EnvironmentConfigurationService();
5004
- this._container.addSingleton(import_shared78.TOKENS.CONFIGURATION_SERVICE, () => this._configuration);
4980
+ this._container.addSingleton(import_shared76.TOKENS.CONFIGURATION_SERVICE, () => this._configuration);
5005
4981
  this.addContext();
5006
4982
  }
5007
4983
  // --- Module Configurations ---
@@ -5081,7 +5057,7 @@ var AppBuilder = class {
5081
5057
  resilience: { retry: {}, circuitBreaker: {}, bulkhead: {} }
5082
5058
  };
5083
5059
  _loggerConfig = {
5084
- level: import_shared78.LOG_LEVEL.DEBUG,
5060
+ level: import_shared76.LOG_LEVEL.DEBUG,
5085
5061
  console: true,
5086
5062
  sentry: { config: void 0 },
5087
5063
  pino: { config: void 0 },
@@ -5154,7 +5130,7 @@ var AppBuilder = class {
5154
5130
  * @link https://github.com/xeno-js/xeno-js
5155
5131
  */
5156
5132
  addLogger(setupAction) {
5157
- if (import_shared78.Guards.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
5133
+ if (import_shared76.Guards.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
5158
5134
  if (this._isLoggerModuleQueued) return this;
5159
5135
  this._isLoggerModuleQueued = true;
5160
5136
  this._modules.push({
@@ -5179,7 +5155,7 @@ var AppBuilder = class {
5179
5155
  * @link https://github.com/xeno-js/xeno-js
5180
5156
  */
5181
5157
  addCache(setupAction) {
5182
- if (import_shared78.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
5158
+ if (import_shared76.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
5183
5159
  if (this._isCacheModuleQueued) return this;
5184
5160
  this._isCacheModuleQueued = true;
5185
5161
  this._modules.push({
@@ -5282,7 +5258,7 @@ var AppBuilder = class {
5282
5258
  * @link https://github.com/xeno-js/xeno-js
5283
5259
  */
5284
5260
  addPipeline(setupAction) {
5285
- if (import_shared78.Guards.isDefined(setupAction)) {
5261
+ if (import_shared76.Guards.isDefined(setupAction)) {
5286
5262
  setupAction(this._pipelineConfig, this._configuration);
5287
5263
  }
5288
5264
  this._queuePipelineModule();
@@ -5401,7 +5377,7 @@ var AppBuilder = class {
5401
5377
  console.error(`\u{1F449} Module: **${queued.name}**`);
5402
5378
  console.error(`\u{1F4DD} Reason: ${errorMessage}
5403
5379
  `);
5404
- if (error instanceof Error && import_shared78.Guards.isDefined(error.stack)) {
5380
+ if (error instanceof Error && import_shared76.Guards.isDefined(error.stack)) {
5405
5381
  console.error(error.stack);
5406
5382
  }
5407
5383
  throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
@@ -5490,61 +5466,12 @@ var AppBuilder = class {
5490
5466
  }
5491
5467
  };
5492
5468
 
5493
- // src/infrastructure/index.ts
5494
- init_cache();
5495
-
5496
- // src/infrastructure/context/index.ts
5497
- init_request_context();
5498
-
5499
- // src/infrastructure/datasources/base-postgressql.datasource.ts
5500
- var BasePostgresSqlDataSource = class {
5501
- constructor(_db) {
5502
- this._db = _db;
5503
- }
5504
- _db;
5505
- /**
5506
- * @description Returns the database connection.
5507
- * @returns {NodePgDatabase<TSchema>} The database connection.
5508
- */
5509
- get db() {
5510
- return this._db;
5511
- }
5512
- };
5513
-
5514
- // src/infrastructure/datasources/base-sqllite.datasource.ts
5515
- var BaseSqliteSqlDataSource = class {
5516
- constructor(_db) {
5517
- this._db = _db;
5518
- }
5519
- _db;
5520
- /**
5521
- * @description Returns the SQLite database connection.
5522
- * @returns {LibSQLDatabase<TSchema>} The database connection.
5523
- */
5524
- get db() {
5525
- return this._db;
5526
- }
5527
- };
5528
-
5529
- // src/infrastructure/datasources/remote.datasource.ts
5530
- var import_shared79 = require("@xeno-js/shared");
5531
-
5532
- // src/infrastructure/index.ts
5533
- init_factories();
5534
- init_http();
5535
- init_idempotency();
5536
-
5537
- // src/infrastructure/loggers/index.ts
5538
- init_console_logger();
5539
- init_pino_logger();
5540
- init_sentry_logger();
5541
-
5542
- // src/infrastructure/index.ts
5543
- init_modules();
5469
+ // src/infrastructure/http/index.ts
5470
+ init_base_http_adapter();
5544
5471
 
5545
5472
  // src/infrastructure/repositories/read-dao.ts
5546
- var import_shared80 = require("@xeno-js/shared");
5547
- var import_shared81 = require("@xeno-js/shared");
5473
+ var import_shared77 = require("@xeno-js/shared");
5474
+ var import_shared78 = require("@xeno-js/shared");
5548
5475
  var ReadDao = class {
5549
5476
  /**
5550
5477
  * Constructs a new ReadDao instance.
@@ -5564,23 +5491,23 @@ var ReadDao = class {
5564
5491
  _dataSource;
5565
5492
  _mapper;
5566
5493
  async findById(id, ctx, signal) {
5567
- import_shared80.AppError.throwIfAborted(signal, "ReadDao.findById");
5494
+ import_shared77.AppError.throwIfAborted(signal, "ReadDao.findById");
5568
5495
  const result = await this._dataSource.findById(id, ctx, signal);
5569
- if (import_shared81.Guards.isNullOrEmpty(result)) return import_shared80.Result.ok();
5496
+ if (import_shared78.Guards.isNullOrEmpty(result)) return import_shared77.Result.ok();
5570
5497
  const entity = this._mapper.toEntity(result);
5571
- return import_shared80.Result.ok(entity);
5498
+ return import_shared77.Result.ok(entity);
5572
5499
  }
5573
5500
  async findAll(ctx, signal) {
5574
- import_shared80.AppError.throwIfAborted(signal, "ReadDao.findAll");
5501
+ import_shared77.AppError.throwIfAborted(signal, "ReadDao.findAll");
5575
5502
  const results = await this._dataSource.findAll(ctx, signal);
5576
5503
  const entities = results.map((result) => this._mapper.toEntity(result));
5577
- return import_shared80.Result.ok(entities);
5504
+ return import_shared77.Result.ok(entities);
5578
5505
  }
5579
5506
  };
5580
5507
 
5581
5508
  // src/infrastructure/repositories/repository.ts
5582
- var import_shared82 = require("@xeno-js/shared");
5583
- var import_shared83 = require("@xeno-js/shared");
5509
+ var import_shared79 = require("@xeno-js/shared");
5510
+ var import_shared80 = require("@xeno-js/shared");
5584
5511
  var Repository = class {
5585
5512
  /**
5586
5513
  * Constructs a new Repository instance.
@@ -5600,53 +5527,42 @@ var Repository = class {
5600
5527
  _dataSource;
5601
5528
  _mapper;
5602
5529
  async findById(id, ctx, signal) {
5603
- import_shared82.AppError.throwIfAborted(signal, "Repository.findById");
5530
+ import_shared79.AppError.throwIfAborted(signal, "Repository.findById");
5604
5531
  const result = await this._dataSource.findById(id, ctx, signal);
5605
- if (import_shared83.Guards.isNullOrEmpty(result)) return import_shared82.Result.ok();
5532
+ if (import_shared80.Guards.isNullOrEmpty(result)) return import_shared79.Result.ok();
5606
5533
  const entity = this._mapper.toEntity(result);
5607
- return import_shared82.Result.ok(entity);
5534
+ return import_shared79.Result.ok(entity);
5608
5535
  }
5609
5536
  async findAll(ctx, signal) {
5610
- import_shared82.AppError.throwIfAborted(signal, "Repository.findAll");
5537
+ import_shared79.AppError.throwIfAborted(signal, "Repository.findAll");
5611
5538
  const results = await this._dataSource.findAll(ctx, signal);
5612
5539
  const entities = results.map((result) => this._mapper.toEntity(result));
5613
- return import_shared82.Result.ok(entities);
5540
+ return import_shared79.Result.ok(entities);
5614
5541
  }
5615
5542
  async save(entity, signal) {
5616
5543
  const dto = this._mapper.toDto(entity);
5617
- import_shared82.AppError.throwIfAborted(signal, "Repository.save");
5544
+ import_shared79.AppError.throwIfAborted(signal, "Repository.save");
5618
5545
  await this._dataSource.insert(dto, signal);
5619
- return import_shared82.Result.ok();
5546
+ return import_shared79.Result.ok();
5620
5547
  }
5621
5548
  async delete(entity, ctx, signal) {
5622
5549
  const dto = this._mapper.toDto(entity);
5623
- import_shared82.AppError.throwIfAborted(signal, "Repository.delete");
5550
+ import_shared79.AppError.throwIfAborted(signal, "Repository.delete");
5624
5551
  await this._dataSource.delete(dto, ctx, signal);
5625
- return import_shared82.Result.ok();
5552
+ return import_shared79.Result.ok();
5626
5553
  }
5627
5554
  async update(id, entity, ctx, signal) {
5628
5555
  const dto = this._mapper.toPartialDto(entity);
5629
- import_shared82.AppError.throwIfAborted(signal, "Repository.update");
5556
+ import_shared79.AppError.throwIfAborted(signal, "Repository.update");
5630
5557
  await this._dataSource.update(id, dto, ctx, signal);
5631
- return import_shared82.Result.ok();
5558
+ return import_shared79.Result.ok();
5632
5559
  }
5633
5560
  };
5634
5561
 
5635
- // src/infrastructure/index.ts
5636
- init_services();
5637
-
5638
- // src/infrastructure/transaction/index.ts
5639
- init_unit_of_work();
5640
-
5641
- // src/infrastructure/db/drizzle.types.ts
5642
- var drizzle_types_exports = {};
5643
- __reExport(drizzle_types_exports, require("drizzle-orm"));
5644
-
5645
5562
  // src/index.ts
5646
- __reExport(index_exports, drizzle_types_exports, module.exports);
5647
5563
  init_presentation();
5648
5564
  __reExport(index_exports, require("@xeno-js/shared"), module.exports);
5649
- var import_shared84 = require("@xeno-js/shared");
5565
+ var import_shared81 = require("@xeno-js/shared");
5650
5566
  // Annotate the CommonJS export names for ESM import in node:
5651
5567
  0 && (module.exports = {
5652
5568
  AppBuilder,
@@ -5654,14 +5570,11 @@ var import_shared84 = require("@xeno-js/shared");
5654
5570
  BaseController,
5655
5571
  BaseHandler,
5656
5572
  BaseHttpAdapter,
5657
- BasePostgresSqlDataSource,
5658
- BaseQuery,
5659
- BaseSqliteSqlDataSource,
5660
5573
  ContainerUtils,
5574
+ Query,
5661
5575
  ReadDao,
5662
5576
  Repository,
5663
5577
  Specification,
5664
- SupabaseServerAuthFactory,
5665
5578
  ...require("@xeno-js/shared")
5666
5579
  });
5667
5580
  /**