@xeno-js/core 1.1.1 → 1.2.1
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 +1328 -1082
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -3
- package/dist/index.d.ts +95 -3
- package/dist/index.js +1284 -1038
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
package/dist/index.cjs
CHANGED
|
@@ -69,8 +69,10 @@ var init_container_utils = __esm({
|
|
|
69
69
|
* @throws Error If the service is not a scoped service.
|
|
70
70
|
*/
|
|
71
71
|
async runExecute(res, req, container, action) {
|
|
72
|
+
const adapter = container.resolve("HTTP_ADAPTER");
|
|
73
|
+
const { request, response } = adapter.adapt(req, res);
|
|
72
74
|
const middleware = container.resolve(import_shared.TOKENS.MIDDLEWARE);
|
|
73
|
-
return await middleware.execute(
|
|
75
|
+
return await middleware.execute(request, response, async () => {
|
|
74
76
|
return await action();
|
|
75
77
|
});
|
|
76
78
|
}
|
|
@@ -1258,470 +1260,193 @@ var init_application = __esm({
|
|
|
1258
1260
|
}
|
|
1259
1261
|
});
|
|
1260
1262
|
|
|
1261
|
-
// src/infrastructure/
|
|
1262
|
-
var
|
|
1263
|
-
__export(
|
|
1264
|
-
|
|
1263
|
+
// src/infrastructure/factories/service-scope.factory.ts
|
|
1264
|
+
var service_scope_factory_exports = {};
|
|
1265
|
+
__export(service_scope_factory_exports, {
|
|
1266
|
+
ServiceScopeFactory: () => ServiceScopeFactory
|
|
1265
1267
|
});
|
|
1266
|
-
var
|
|
1267
|
-
var
|
|
1268
|
-
"src/infrastructure/
|
|
1268
|
+
var ServiceScopeFactory;
|
|
1269
|
+
var init_service_scope_factory = __esm({
|
|
1270
|
+
"src/infrastructure/factories/service-scope.factory.ts"() {
|
|
1271
|
+
"use strict";
|
|
1272
|
+
ServiceScopeFactory = class {
|
|
1273
|
+
constructor(_container) {
|
|
1274
|
+
this._container = _container;
|
|
1275
|
+
}
|
|
1276
|
+
_container;
|
|
1277
|
+
create() {
|
|
1278
|
+
return this._container.createScope();
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
// src/infrastructure/context/request-context.ts
|
|
1285
|
+
var import_shared34, NodeRequestContext;
|
|
1286
|
+
var init_request_context = __esm({
|
|
1287
|
+
"src/infrastructure/context/request-context.ts"() {
|
|
1269
1288
|
"use strict";
|
|
1270
1289
|
import_shared34 = require("@xeno-js/shared");
|
|
1271
|
-
|
|
1290
|
+
NodeRequestContext = class {
|
|
1272
1291
|
/**
|
|
1273
|
-
* Constructs a new instance of the
|
|
1274
|
-
* @param
|
|
1275
|
-
|
|
1276
|
-
*
|
|
1292
|
+
* @description Constructs a new instance of the NodeRequestContext class, which requires an instance of AsyncLocalStorage to manage the request context. The AsyncLocalStorage instance is used to create and access the context for each request, allowing for the storage of identity information and other relevant data that needs to be accessible across asynchronous operations. This constructor initializes the NodeRequestContext with the provided AsyncLocalStorage, enabling it to implement the methods defined in the IRequestContext interface for managing request-specific context data.
|
|
1293
|
+
* @param _storage An instance of AsyncLocalStorage that is used to manage the request context, allowing for the storage and retrieval of identity information and other relevant data across asynchronous operations.
|
|
1294
|
+
* @param _factoryScope An instance of IFactory that is used to create a new IServiceScope for managing service dependencies during the execution of the request. This allows for proper scoping and disposal of services after the request is processed, ensuring that resources are managed efficiently and preventing memory leaks.
|
|
1295
|
+
*
|
|
1277
1296
|
* @author Xeno
|
|
1278
1297
|
* @version 1.0.0
|
|
1279
1298
|
* @since 2025-09-30
|
|
1280
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1299
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
1281
1300
|
*/
|
|
1282
|
-
constructor(
|
|
1283
|
-
this.
|
|
1301
|
+
constructor(_storage, _factoryScope) {
|
|
1302
|
+
this._storage = _storage;
|
|
1303
|
+
this._factoryScope = _factoryScope;
|
|
1284
1304
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
break;
|
|
1294
|
-
case import_shared34.LOG_LEVEL.WARN:
|
|
1295
|
-
console.warn(logMessage, payload ?? {});
|
|
1296
|
-
break;
|
|
1297
|
-
case import_shared34.LOG_LEVEL.DEBUG:
|
|
1298
|
-
console.debug(logMessage, payload ?? {});
|
|
1299
|
-
break;
|
|
1300
|
-
default:
|
|
1301
|
-
console.info(logMessage, payload ?? {});
|
|
1302
|
-
break;
|
|
1305
|
+
_storage;
|
|
1306
|
+
_factoryScope;
|
|
1307
|
+
async runAsync(context, fn) {
|
|
1308
|
+
const scope = this._factoryScope.create();
|
|
1309
|
+
try {
|
|
1310
|
+
return await this._storage.run({ context, scope }, fn);
|
|
1311
|
+
} finally {
|
|
1312
|
+
await scope.dispose();
|
|
1303
1313
|
}
|
|
1304
1314
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
var init_sentry_logger = __esm({
|
|
1312
|
-
"src/infrastructure/loggers/sentry.logger.ts"() {
|
|
1313
|
-
"use strict";
|
|
1314
|
-
import_shared35 = require("@xeno-js/shared");
|
|
1315
|
-
SentryLogger = class {
|
|
1316
|
-
constructor(_client, _minLevel) {
|
|
1317
|
-
this._client = _client;
|
|
1318
|
-
this._minLevel = _minLevel;
|
|
1319
|
-
}
|
|
1320
|
-
_client;
|
|
1321
|
-
_minLevel;
|
|
1322
|
-
track(level, message, context = void 0, error = void 0) {
|
|
1323
|
-
if (level < this._minLevel) return;
|
|
1324
|
-
if (level === import_shared35.LOG_LEVEL.ERROR || level === import_shared35.LOG_LEVEL.WARN) {
|
|
1325
|
-
this._client.withScope((scope) => {
|
|
1326
|
-
if (import_shared35.Guards.isDefined(context)) scope.setExtras(context);
|
|
1327
|
-
if (import_shared35.Guards.isDefined(error)) {
|
|
1328
|
-
this._client.captureException(error);
|
|
1329
|
-
} else {
|
|
1330
|
-
this._client.captureMessage(message, "warning");
|
|
1331
|
-
}
|
|
1315
|
+
updateIdentity(identity) {
|
|
1316
|
+
const store = this._storage.getStore();
|
|
1317
|
+
if (import_shared34.Guards.isDefined(store) && import_shared34.Guards.isDefined(store.context)) {
|
|
1318
|
+
store.context = Object.freeze({
|
|
1319
|
+
...store.context,
|
|
1320
|
+
identity: Object.freeze(identity)
|
|
1332
1321
|
});
|
|
1333
1322
|
}
|
|
1334
1323
|
}
|
|
1324
|
+
getContext() {
|
|
1325
|
+
const store = this._storage.getStore();
|
|
1326
|
+
if (!import_shared34.Guards.isDefined(store)) return void 0;
|
|
1327
|
+
const context = store.context;
|
|
1328
|
+
return Object.freeze(context);
|
|
1329
|
+
}
|
|
1330
|
+
getIdentity() {
|
|
1331
|
+
const store = this._storage.getStore();
|
|
1332
|
+
if (!import_shared34.Guards.isDefined(store)) return void 0;
|
|
1333
|
+
return Object.freeze(store.context?.identity);
|
|
1334
|
+
}
|
|
1335
|
+
getScope() {
|
|
1336
|
+
const store = this._storage.getStore();
|
|
1337
|
+
if (!import_shared34.Guards.isDefined(store)) return void 0;
|
|
1338
|
+
return store.scope;
|
|
1339
|
+
}
|
|
1340
|
+
getNetworkContext() {
|
|
1341
|
+
const store = this._storage.getStore();
|
|
1342
|
+
if (!import_shared34.Guards.isDefined(store)) return void 0;
|
|
1343
|
+
return Object.freeze(store.context?.network);
|
|
1344
|
+
}
|
|
1335
1345
|
};
|
|
1336
1346
|
}
|
|
1337
1347
|
});
|
|
1338
1348
|
|
|
1339
|
-
// src/infrastructure/factories/
|
|
1340
|
-
var
|
|
1341
|
-
__export(
|
|
1342
|
-
|
|
1349
|
+
// src/infrastructure/factories/request-context.factory.ts
|
|
1350
|
+
var request_context_factory_exports = {};
|
|
1351
|
+
__export(request_context_factory_exports, {
|
|
1352
|
+
NodeRequestContextFactory: () => NodeRequestContextFactory
|
|
1343
1353
|
});
|
|
1344
|
-
var
|
|
1345
|
-
var
|
|
1346
|
-
"src/infrastructure/factories/
|
|
1354
|
+
var import_node_async_hooks2, NodeRequestContextFactory;
|
|
1355
|
+
var init_request_context_factory = __esm({
|
|
1356
|
+
"src/infrastructure/factories/request-context.factory.ts"() {
|
|
1347
1357
|
"use strict";
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
if (!import_shared36.Guards.isDefined(sentryConfig.dsn))
|
|
1359
|
-
throw new Error("Sentry DSN is required when Sentry logging is enabled.");
|
|
1360
|
-
Sentry.init({
|
|
1361
|
-
dsn: sentryConfig.dsn,
|
|
1362
|
-
environment: env,
|
|
1363
|
-
tracesSampleRate: env === "production" ? 0.1 : 1,
|
|
1364
|
-
integrations: [Sentry.httpIntegration()],
|
|
1365
|
-
beforeSend(event, hint) {
|
|
1366
|
-
const error = hint.originalException;
|
|
1367
|
-
if (error instanceof Error && error.name === "ZodError") {
|
|
1368
|
-
return null;
|
|
1369
|
-
}
|
|
1370
|
-
return event;
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1373
|
-
return new SentryLogger(Sentry, level);
|
|
1358
|
+
import_node_async_hooks2 = require("async_hooks");
|
|
1359
|
+
init_request_context();
|
|
1360
|
+
NodeRequestContextFactory = class {
|
|
1361
|
+
constructor(_factoryScope) {
|
|
1362
|
+
this._factoryScope = _factoryScope;
|
|
1363
|
+
}
|
|
1364
|
+
_factoryScope;
|
|
1365
|
+
_store = new import_node_async_hooks2.AsyncLocalStorage();
|
|
1366
|
+
create() {
|
|
1367
|
+
return new NodeRequestContext(this._store, this._factoryScope);
|
|
1374
1368
|
}
|
|
1375
1369
|
};
|
|
1376
1370
|
}
|
|
1377
1371
|
});
|
|
1378
1372
|
|
|
1379
|
-
// src/infrastructure/
|
|
1380
|
-
var
|
|
1381
|
-
|
|
1382
|
-
|
|
1373
|
+
// src/infrastructure/factories/user-context.factory.ts
|
|
1374
|
+
var user_context_factory_exports = {};
|
|
1375
|
+
__export(user_context_factory_exports, {
|
|
1376
|
+
UserContextFactory: () => UserContextFactory
|
|
1377
|
+
});
|
|
1378
|
+
var import_shared35, UserContextFactory;
|
|
1379
|
+
var init_user_context_factory = __esm({
|
|
1380
|
+
"src/infrastructure/factories/user-context.factory.ts"() {
|
|
1383
1381
|
"use strict";
|
|
1384
|
-
|
|
1385
|
-
|
|
1382
|
+
import_shared35 = require("@xeno-js/shared");
|
|
1383
|
+
UserContextFactory = class {
|
|
1386
1384
|
/**
|
|
1387
|
-
* Constructs
|
|
1388
|
-
* @param
|
|
1389
|
-
*
|
|
1390
|
-
|
|
1391
|
-
*
|
|
1385
|
+
* @description Constructs an instance of UserContextFactory.
|
|
1386
|
+
* @param _identityFactory - An instance of IIdentityAccessor that provides access to the current identity. This factory is used to retrieve the identity details when creating a UserContext instance.
|
|
1387
|
+
*
|
|
1392
1388
|
* @author Xeno
|
|
1393
1389
|
* @version 1.0.0
|
|
1394
1390
|
* @since 2025-09-30
|
|
1395
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1391
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
1396
1392
|
*/
|
|
1397
|
-
constructor(
|
|
1398
|
-
this.
|
|
1399
|
-
this._minLevel = _minLevel;
|
|
1393
|
+
constructor(_identityFactory) {
|
|
1394
|
+
this._identityFactory = _identityFactory;
|
|
1400
1395
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
this._logger.warn(payload ?? {}, message);
|
|
1412
|
-
break;
|
|
1413
|
-
case import_shared37.LOG_LEVEL.DEBUG:
|
|
1414
|
-
this._logger.debug(payload ?? {}, message);
|
|
1415
|
-
break;
|
|
1416
|
-
default:
|
|
1417
|
-
this._logger.info(payload ?? {}, message);
|
|
1418
|
-
break;
|
|
1396
|
+
_identityFactory;
|
|
1397
|
+
create() {
|
|
1398
|
+
const output = {
|
|
1399
|
+
userId: void 0,
|
|
1400
|
+
tenantId: void 0
|
|
1401
|
+
};
|
|
1402
|
+
const identity = this._identityFactory.getIdentity();
|
|
1403
|
+
if (import_shared35.Guards.isDefined(identity)) {
|
|
1404
|
+
output.userId = identity.userId;
|
|
1405
|
+
output.tenantId = identity.tenantId;
|
|
1419
1406
|
}
|
|
1407
|
+
return output;
|
|
1420
1408
|
}
|
|
1421
1409
|
};
|
|
1422
1410
|
}
|
|
1423
1411
|
});
|
|
1424
1412
|
|
|
1425
|
-
// src/infrastructure/
|
|
1426
|
-
var
|
|
1427
|
-
__export(
|
|
1428
|
-
|
|
1413
|
+
// src/infrastructure/modules/context.module.ts
|
|
1414
|
+
var context_module_exports = {};
|
|
1415
|
+
__export(context_module_exports, {
|
|
1416
|
+
ContextModule: () => ContextModule
|
|
1429
1417
|
});
|
|
1430
|
-
var
|
|
1431
|
-
var
|
|
1432
|
-
"src/infrastructure/
|
|
1418
|
+
var ContextModule;
|
|
1419
|
+
var init_context_module = __esm({
|
|
1420
|
+
"src/infrastructure/modules/context.module.ts"() {
|
|
1433
1421
|
"use strict";
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
redact: {
|
|
1451
|
-
paths: ["password", "token", "secret", "authorization", "headers.authorization"],
|
|
1452
|
-
censor: "***"
|
|
1453
|
-
}
|
|
1454
|
-
};
|
|
1455
|
-
if (prettyPrint) {
|
|
1456
|
-
return new PinoLogger(
|
|
1457
|
-
(0, import_pino.default)({
|
|
1458
|
-
...options,
|
|
1459
|
-
transport: {
|
|
1460
|
-
target: "pino-pretty",
|
|
1461
|
-
options: {
|
|
1462
|
-
colorize: true,
|
|
1463
|
-
ignore: "pid,hostname",
|
|
1464
|
-
translateTime: "SYS:standard"
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
}),
|
|
1468
|
-
level
|
|
1469
|
-
);
|
|
1470
|
-
}
|
|
1471
|
-
if (destinationType === "file") {
|
|
1472
|
-
const destination = import_pino.default.destination({ dest: filePath, sync: false });
|
|
1473
|
-
return new PinoLogger((0, import_pino.default)(options, destination), level);
|
|
1474
|
-
} else {
|
|
1475
|
-
const stream = import_pino.default.destination({ dest: 1, sync: false });
|
|
1476
|
-
return new PinoLogger((0, import_pino.default)(options, stream), level);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
// src/infrastructure/modules/utils/logger.utils.ts
|
|
1484
|
-
var logger_utils_exports = {};
|
|
1485
|
-
__export(logger_utils_exports, {
|
|
1486
|
-
LoggerUtils: () => LoggerUtils
|
|
1487
|
-
});
|
|
1488
|
-
var LoggerUtils;
|
|
1489
|
-
var init_logger_utils = __esm({
|
|
1490
|
-
"src/infrastructure/modules/utils/logger.utils.ts"() {
|
|
1491
|
-
"use strict";
|
|
1492
|
-
LoggerUtils = Object.freeze({
|
|
1493
|
-
/**
|
|
1494
|
-
* @description Configures and registers the logging services in the dependency injection container based on the provided LoggerConfig options. It dynamically imports the necessary logger implementations (e.g., ConsoleLogger, SentryLogger, PinoLogger) and registers them with the container, allowing for flexible and modular logging configuration in the application.
|
|
1495
|
-
*
|
|
1496
|
-
* @param container - The service container to register logging services with.
|
|
1497
|
-
* @param opts - The LoggerConfig options to determine which loggers to enable and their configurations.
|
|
1498
|
-
|
|
1499
|
-
*
|
|
1500
|
-
* @author Xeno
|
|
1501
|
-
* @version 1.0.0
|
|
1502
|
-
* @since 2025-09-30
|
|
1503
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1504
|
-
*/
|
|
1505
|
-
async addLogger(container, opts) {
|
|
1506
|
-
const loggerDependencies = [];
|
|
1507
|
-
const { Guards: Guards47, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
1508
|
-
if (!Guards47.isDefined(opts) || opts.console) {
|
|
1509
|
-
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
1510
|
-
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
1511
|
-
}
|
|
1512
|
-
if (Guards47.isDefined(opts)) {
|
|
1513
|
-
if (Guards47.isDefined(opts.sentry.config)) {
|
|
1514
|
-
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
1515
|
-
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
1516
|
-
}
|
|
1517
|
-
if (Guards47.isDefined(opts.pino.config)) {
|
|
1518
|
-
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
1519
|
-
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
1520
|
-
}
|
|
1521
|
-
if (!Guards47.isNullOrEmpty(opts.customLoggers)) {
|
|
1522
|
-
const customLoggers = opts.customLoggers;
|
|
1523
|
-
customLoggers.forEach((fn) => {
|
|
1524
|
-
if (Guards47.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
const { BaseLogger } = await import("@xeno-js/shared");
|
|
1529
|
-
container.addSingleton(TOKENS5.LOGGER, (c) => {
|
|
1530
|
-
const context = c.resolve(TOKENS5.CONTEXT_ACCESSOR);
|
|
1531
|
-
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, loggerDependencies);
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
});
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
|
|
1538
|
-
// src/infrastructure/cache/inmemory.cache.ts
|
|
1539
|
-
var inmemory_cache_exports = {};
|
|
1540
|
-
__export(inmemory_cache_exports, {
|
|
1541
|
-
InMemoryCacheExtended: () => InMemoryCacheExtended
|
|
1542
|
-
});
|
|
1543
|
-
var import_shared39, InMemoryCacheExtended;
|
|
1544
|
-
var init_inmemory_cache = __esm({
|
|
1545
|
-
"src/infrastructure/cache/inmemory.cache.ts"() {
|
|
1546
|
-
"use strict";
|
|
1547
|
-
import_shared39 = require("@xeno-js/shared");
|
|
1548
|
-
InMemoryCacheExtended = class extends import_shared39.InMemoryCache {
|
|
1549
|
-
async increment(key, ttlSeconds) {
|
|
1550
|
-
const current = await this.get(key) ?? 0;
|
|
1551
|
-
const next = Number(current) + 1;
|
|
1552
|
-
const ttl = import_shared39.Guards.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
|
|
1553
|
-
await this.set(key, next, ttl);
|
|
1554
|
-
return next;
|
|
1555
|
-
}
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
});
|
|
1559
|
-
|
|
1560
|
-
// src/infrastructure/cache/redis.cache.ts
|
|
1561
|
-
var import_shared40, RedisCache;
|
|
1562
|
-
var init_redis_cache = __esm({
|
|
1563
|
-
"src/infrastructure/cache/redis.cache.ts"() {
|
|
1564
|
-
"use strict";
|
|
1565
|
-
import_shared40 = require("@xeno-js/shared");
|
|
1566
|
-
RedisCache = class {
|
|
1567
|
-
/**
|
|
1568
|
-
* @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.
|
|
1569
|
-
* @param _redisClient An instance of the Redis client from the ioredis library, used to perform caching operations in the Redis database.
|
|
1570
|
-
|
|
1571
|
-
*
|
|
1572
|
-
* @author Xeno
|
|
1573
|
-
* @version 1.0.0
|
|
1574
|
-
* @since 2025-09-30
|
|
1575
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1576
|
-
*/
|
|
1577
|
-
constructor(_redisClient) {
|
|
1578
|
-
this._redisClient = _redisClient;
|
|
1579
|
-
}
|
|
1580
|
-
_redisClient;
|
|
1581
|
-
async increment(key, ttlSeconds) {
|
|
1582
|
-
const multi = this._redisClient.multi();
|
|
1583
|
-
multi.incr(key);
|
|
1584
|
-
multi.expire(key, ttlSeconds ?? 60);
|
|
1585
|
-
const results = await multi.exec();
|
|
1586
|
-
return results?.[0]?.[1] ?? 1;
|
|
1587
|
-
}
|
|
1588
|
-
async get(key) {
|
|
1589
|
-
const value = await this._redisClient.get(key);
|
|
1590
|
-
if (!import_shared40.Guards.isDefined(value)) {
|
|
1591
|
-
return void 0;
|
|
1592
|
-
}
|
|
1593
|
-
return JSON.parse(value);
|
|
1594
|
-
}
|
|
1595
|
-
async set(key, value, ttl) {
|
|
1596
|
-
const stringValue = import_shared40.StringHelper.safeStringify(value);
|
|
1597
|
-
const ttlOption = import_shared40.Guards.isDefined(ttl) ? ttl : 86400;
|
|
1598
|
-
await this._redisClient.set(key, stringValue, "EX", ttlOption);
|
|
1599
|
-
}
|
|
1600
|
-
async setIfAbsent(key, value, ttl) {
|
|
1601
|
-
const stringValue = import_shared40.StringHelper.safeStringify(value);
|
|
1602
|
-
const ttlOption = import_shared40.Guards.isDefined(ttl) ? ttl : 300;
|
|
1603
|
-
const result = await this._redisClient.set(key, stringValue, "EX", ttlOption, "NX");
|
|
1604
|
-
return result === "OK";
|
|
1605
|
-
}
|
|
1606
|
-
async remove(key) {
|
|
1607
|
-
await this._redisClient.del(key);
|
|
1608
|
-
}
|
|
1609
|
-
async has(key) {
|
|
1610
|
-
const exists = await this._redisClient.exists(key);
|
|
1611
|
-
return exists === 1;
|
|
1612
|
-
}
|
|
1613
|
-
async clear() {
|
|
1614
|
-
await this._redisClient.flushdb();
|
|
1615
|
-
}
|
|
1616
|
-
};
|
|
1617
|
-
}
|
|
1618
|
-
});
|
|
1619
|
-
|
|
1620
|
-
// src/infrastructure/factories/redis-cache.factory.ts
|
|
1621
|
-
var redis_cache_factory_exports = {};
|
|
1622
|
-
__export(redis_cache_factory_exports, {
|
|
1623
|
-
RedisCacheFactory: () => RedisCacheFactory
|
|
1624
|
-
});
|
|
1625
|
-
var import_shared41, import_ioredis, RedisCacheFactory;
|
|
1626
|
-
var init_redis_cache_factory = __esm({
|
|
1627
|
-
"src/infrastructure/factories/redis-cache.factory.ts"() {
|
|
1628
|
-
"use strict";
|
|
1629
|
-
import_shared41 = require("@xeno-js/shared");
|
|
1630
|
-
import_ioredis = require("ioredis");
|
|
1631
|
-
init_redis_cache();
|
|
1632
|
-
RedisCacheFactory = class {
|
|
1633
|
-
create(config) {
|
|
1634
|
-
const host = config?.host ?? "localhost";
|
|
1635
|
-
const port = config?.port ?? 6379;
|
|
1636
|
-
const password = config?.password;
|
|
1637
|
-
const username = config?.username;
|
|
1638
|
-
const useTls = config?.tls ?? false;
|
|
1639
|
-
const maxRetries = config?.maxRetriesPerRequest ?? 3;
|
|
1640
|
-
const redisOptions = {
|
|
1641
|
-
host,
|
|
1642
|
-
port,
|
|
1643
|
-
maxRetriesPerRequest: maxRetries,
|
|
1644
|
-
// Strategia di riconnessione esponenziale per garantire resilienza
|
|
1645
|
-
retryStrategy(times) {
|
|
1646
|
-
const delay = Math.min(times * 50, 2e3);
|
|
1647
|
-
return delay;
|
|
1648
|
-
}
|
|
1649
|
-
};
|
|
1650
|
-
if (import_shared41.Guards.isDefined(password)) {
|
|
1651
|
-
redisOptions.password = password;
|
|
1652
|
-
}
|
|
1653
|
-
if (import_shared41.Guards.isDefined(username)) {
|
|
1654
|
-
redisOptions.username = username;
|
|
1655
|
-
}
|
|
1656
|
-
if (useTls) {
|
|
1657
|
-
redisOptions.tls = {};
|
|
1658
|
-
}
|
|
1659
|
-
const nativeRedisInstance = new import_ioredis.Redis(redisOptions);
|
|
1660
|
-
nativeRedisInstance.on("error", (err) => {
|
|
1661
|
-
console.error("\u274C [Redis Error]:", err.message);
|
|
1422
|
+
ContextModule = class {
|
|
1423
|
+
async configure(container) {
|
|
1424
|
+
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
1425
|
+
const { ServiceScopeFactory: ServiceScopeFactory2 } = await Promise.resolve().then(() => (init_service_scope_factory(), service_scope_factory_exports));
|
|
1426
|
+
const { NodeRequestContextFactory: NodeRequestContextFactory2 } = await Promise.resolve().then(() => (init_request_context_factory(), request_context_factory_exports));
|
|
1427
|
+
const requestContext = new NodeRequestContextFactory2(
|
|
1428
|
+
new ServiceScopeFactory2(container)
|
|
1429
|
+
).create();
|
|
1430
|
+
container.addSingleton(TOKENS5.REQUEST_CONTEXT, () => requestContext);
|
|
1431
|
+
container.addSingleton(TOKENS5.CONTEXT_ACCESSOR, () => requestContext);
|
|
1432
|
+
container.addSingleton(TOKENS5.IDENTITY_ACCESSOR, () => requestContext);
|
|
1433
|
+
container.addSingleton(TOKENS5.SERVICE_SCOPE_ACCESSOR, () => requestContext);
|
|
1434
|
+
container.addSingleton(TOKENS5.NETWORK_CONTEXT_ACCESSOR, () => requestContext);
|
|
1435
|
+
const { UserContextFactory: UserContextFactory2 } = await Promise.resolve().then(() => (init_user_context_factory(), user_context_factory_exports));
|
|
1436
|
+
container.addSingleton("USER_CONTEXT_FACTORY", () => {
|
|
1437
|
+
return new UserContextFactory2(requestContext);
|
|
1662
1438
|
});
|
|
1663
|
-
return new RedisCache(nativeRedisInstance);
|
|
1664
1439
|
}
|
|
1665
1440
|
};
|
|
1666
1441
|
}
|
|
1667
1442
|
});
|
|
1668
1443
|
|
|
1669
|
-
// src/infrastructure/modules/utils/cache.utils.ts
|
|
1670
|
-
var cache_utils_exports = {};
|
|
1671
|
-
__export(cache_utils_exports, {
|
|
1672
|
-
CacheUtils: () => CacheUtils
|
|
1673
|
-
});
|
|
1674
|
-
var CacheUtils;
|
|
1675
|
-
var init_cache_utils = __esm({
|
|
1676
|
-
"src/infrastructure/modules/utils/cache.utils.ts"() {
|
|
1677
|
-
"use strict";
|
|
1678
|
-
CacheUtils = Object.freeze({
|
|
1679
|
-
/**
|
|
1680
|
-
* @description Checks if the provided cache configuration requires any cache strategies.
|
|
1681
|
-
* @param container The service container to which the cache strategies will be added.
|
|
1682
|
-
* @param opts The cache configuration options.
|
|
1683
|
-
* @returns True if any cache strategies are required, false otherwise.
|
|
1684
|
-
*
|
|
1685
|
-
* @author Xeno
|
|
1686
|
-
* @version 1.0.0
|
|
1687
|
-
* @since 2025-09-30
|
|
1688
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
1689
|
-
*/
|
|
1690
|
-
async addCache(container, opts) {
|
|
1691
|
-
const { Guards: Guards47, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
1692
|
-
if (!opts.inMemory && !Guards47.isDefined(opts.redis)) {
|
|
1693
|
-
throw new Error(
|
|
1694
|
-
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
1695
|
-
);
|
|
1696
|
-
}
|
|
1697
|
-
const { CacheKeyBuilder } = await import("@xeno-js/shared");
|
|
1698
|
-
container.addSingleton(
|
|
1699
|
-
TOKENS5.CACHE_KEY_BUILDER,
|
|
1700
|
-
(c) => new CacheKeyBuilder(c.resolve(TOKENS5.IDENTITY_ACCESSOR))
|
|
1701
|
-
);
|
|
1702
|
-
if (opts.inMemory || !Guards47.isDefined(opts.redis)) {
|
|
1703
|
-
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
1704
|
-
container.addSingleton(TOKENS5.CACHE, () => new InMemoryCacheExtended2());
|
|
1705
|
-
return;
|
|
1706
|
-
}
|
|
1707
|
-
if (Guards47.isDefined(opts.redis)) {
|
|
1708
|
-
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
1709
|
-
container.addSingleton(TOKENS5.CACHE, () => {
|
|
1710
|
-
const config = opts.redis;
|
|
1711
|
-
return new RedisCacheFactory2().create(config);
|
|
1712
|
-
});
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
});
|
|
1716
|
-
}
|
|
1717
|
-
});
|
|
1718
|
-
|
|
1719
1444
|
// src/infrastructure/services/allow_methods/allow-method.service.ts
|
|
1720
|
-
var
|
|
1445
|
+
var import_shared36, AllowMethodRegistry;
|
|
1721
1446
|
var init_allow_method_service = __esm({
|
|
1722
1447
|
"src/infrastructure/services/allow_methods/allow-method.service.ts"() {
|
|
1723
1448
|
"use strict";
|
|
1724
|
-
|
|
1449
|
+
import_shared36 = require("@xeno-js/shared");
|
|
1725
1450
|
AllowMethodRegistry = class {
|
|
1726
1451
|
_staticRoutes = /* @__PURE__ */ new Map();
|
|
1727
1452
|
_dynamicRoutes = [];
|
|
@@ -1737,7 +1462,7 @@ var init_allow_method_service = __esm({
|
|
|
1737
1462
|
check(path, method) {
|
|
1738
1463
|
const cleanPath = this.normalizePath(path.split("?")[0].split("#")[0]);
|
|
1739
1464
|
const staticMethods = this._staticRoutes.get(cleanPath);
|
|
1740
|
-
if (
|
|
1465
|
+
if (import_shared36.Guards.isDefined(staticMethods)) return staticMethods.includes(method);
|
|
1741
1466
|
for (const route of this._dynamicRoutes) {
|
|
1742
1467
|
if (route.pattern.test(cleanPath)) return route.methods.includes(method);
|
|
1743
1468
|
}
|
|
@@ -1746,11 +1471,11 @@ var init_allow_method_service = __esm({
|
|
|
1746
1471
|
getMethods(path) {
|
|
1747
1472
|
const cleanPath = this.normalizePath(path.split("?")[0].split("#")[0]);
|
|
1748
1473
|
const methods = this.findMethods(cleanPath);
|
|
1749
|
-
return
|
|
1474
|
+
return import_shared36.Guards.isDefined(methods) ? methods.join(", ").toUpperCase() : "";
|
|
1750
1475
|
}
|
|
1751
1476
|
findMethods(cleanPath) {
|
|
1752
1477
|
const staticMethods = this._staticRoutes.get(cleanPath);
|
|
1753
|
-
if (
|
|
1478
|
+
if (import_shared36.Guards.isDefined(staticMethods)) return staticMethods;
|
|
1754
1479
|
for (const route of this._dynamicRoutes) if (route.pattern.test(cleanPath)) return route.methods;
|
|
1755
1480
|
return void 0;
|
|
1756
1481
|
}
|
|
@@ -1785,18 +1510,18 @@ var init_allow_methods = __esm({
|
|
|
1785
1510
|
});
|
|
1786
1511
|
|
|
1787
1512
|
// src/infrastructure/services/allow_origins/allow-origin.http.ts
|
|
1788
|
-
var
|
|
1513
|
+
var import_shared37, AllowOrigin;
|
|
1789
1514
|
var init_allow_origin_http = __esm({
|
|
1790
1515
|
"src/infrastructure/services/allow_origins/allow-origin.http.ts"() {
|
|
1791
1516
|
"use strict";
|
|
1792
|
-
|
|
1517
|
+
import_shared37 = require("@xeno-js/shared");
|
|
1793
1518
|
AllowOrigin = class {
|
|
1794
1519
|
constructor(_list) {
|
|
1795
1520
|
this._list = _list;
|
|
1796
1521
|
}
|
|
1797
1522
|
_list;
|
|
1798
1523
|
isAllowed(origin) {
|
|
1799
|
-
if (
|
|
1524
|
+
if (import_shared37.Guards.isNullOrEmpty(origin)) return true;
|
|
1800
1525
|
const cleanOrigin = origin.trim().toLowerCase();
|
|
1801
1526
|
for (const pattern of this._list) {
|
|
1802
1527
|
const cleanPattern = pattern.trim().toLowerCase();
|
|
@@ -1806,7 +1531,7 @@ var init_allow_origin_http = __esm({
|
|
|
1806
1531
|
const domainSuffix = cleanPattern.substring(1);
|
|
1807
1532
|
if (cleanOrigin.endsWith(domainSuffix)) {
|
|
1808
1533
|
const prefix = cleanOrigin.slice(0, cleanOrigin.length - domainSuffix.length);
|
|
1809
|
-
if (!
|
|
1534
|
+
if (!import_shared37.Guards.isNullOrEmpty(prefix) && !prefix.includes(".")) return true;
|
|
1810
1535
|
}
|
|
1811
1536
|
}
|
|
1812
1537
|
}
|
|
@@ -1853,11 +1578,11 @@ var init_concurrency = __esm({
|
|
|
1853
1578
|
});
|
|
1854
1579
|
|
|
1855
1580
|
// src/infrastructure/services/cookies/cookies.service.ts
|
|
1856
|
-
var
|
|
1581
|
+
var import_shared38, CookieHandler;
|
|
1857
1582
|
var init_cookies_service = __esm({
|
|
1858
1583
|
"src/infrastructure/services/cookies/cookies.service.ts"() {
|
|
1859
1584
|
"use strict";
|
|
1860
|
-
|
|
1585
|
+
import_shared38 = require("@xeno-js/shared");
|
|
1861
1586
|
CookieHandler = class {
|
|
1862
1587
|
constructor(contextAccessor, _config, _cookieOpts) {
|
|
1863
1588
|
this.contextAccessor = contextAccessor;
|
|
@@ -1870,7 +1595,7 @@ var init_cookies_service = __esm({
|
|
|
1870
1595
|
getAll() {
|
|
1871
1596
|
const network = this.contextAccessor.getNetworkContext();
|
|
1872
1597
|
const req = network?.transport?.req;
|
|
1873
|
-
if (!
|
|
1598
|
+
if (!import_shared38.Guards.isDefined(req) || import_shared38.Guards.isNullOrEmpty(req.headers.get("cookie"))) return [];
|
|
1874
1599
|
return req.headers.get("cookie")?.split(";").map((cookie) => {
|
|
1875
1600
|
const [name, ...rest] = cookie.split("=");
|
|
1876
1601
|
return { name: name.trim(), value: rest.join("=") };
|
|
@@ -1879,7 +1604,7 @@ var init_cookies_service = __esm({
|
|
|
1879
1604
|
setAll(cookies) {
|
|
1880
1605
|
const network = this.contextAccessor.getNetworkContext();
|
|
1881
1606
|
const res = network?.transport?.res;
|
|
1882
|
-
if (!
|
|
1607
|
+
if (!import_shared38.Guards.isDefined(res)) return;
|
|
1883
1608
|
const serializedCookies = cookies.map((c) => this.serialize(c));
|
|
1884
1609
|
const existingSetCookie = res.headers.getSetCookie();
|
|
1885
1610
|
res.headers.delete("Set-Cookie");
|
|
@@ -1900,9 +1625,9 @@ var init_cookies_service = __esm({
|
|
|
1900
1625
|
};
|
|
1901
1626
|
const opts = { ...defaultOptions, ...cookie.options ?? {} };
|
|
1902
1627
|
str += `; Path=${opts.path}`;
|
|
1903
|
-
if (
|
|
1904
|
-
if (
|
|
1905
|
-
if (
|
|
1628
|
+
if (import_shared38.Guards.isDefined(opts.maxAge)) str += `; Max-Age=${opts.maxAge}`;
|
|
1629
|
+
if (import_shared38.Guards.isDefined(opts.domain)) str += `; Domain=${opts.domain}`;
|
|
1630
|
+
if (import_shared38.Guards.isDefined(opts.sameSite)) str += `; SameSite=${opts.sameSite}`;
|
|
1906
1631
|
if (opts.secure) str += `; Secure`;
|
|
1907
1632
|
if (opts.httpOnly) str += `; HttpOnly`;
|
|
1908
1633
|
return str;
|
|
@@ -1967,11 +1692,11 @@ var init_crypto = __esm({
|
|
|
1967
1692
|
});
|
|
1968
1693
|
|
|
1969
1694
|
// src/infrastructure/services/csrf/csrf-token.service.ts
|
|
1970
|
-
var
|
|
1695
|
+
var import_shared39, CsrfTokenService;
|
|
1971
1696
|
var init_csrf_token_service = __esm({
|
|
1972
1697
|
"src/infrastructure/services/csrf/csrf-token.service.ts"() {
|
|
1973
1698
|
"use strict";
|
|
1974
|
-
|
|
1699
|
+
import_shared39 = require("@xeno-js/shared");
|
|
1975
1700
|
CsrfTokenService = class {
|
|
1976
1701
|
constructor(_secret, _cryptoService) {
|
|
1977
1702
|
this._secret = _secret;
|
|
@@ -1990,7 +1715,7 @@ var init_csrf_token_service = __esm({
|
|
|
1990
1715
|
if (separatorIndex <= 0) return false;
|
|
1991
1716
|
const nonce = token.slice(0, separatorIndex);
|
|
1992
1717
|
const signature = token.slice(separatorIndex + 1);
|
|
1993
|
-
if (
|
|
1718
|
+
if (import_shared39.Guards.isNullOrEmpty(nonce) || import_shared39.Guards.isNullOrEmpty(signature)) return false;
|
|
1994
1719
|
const expected = await this._cryptoService.hmacSha256(this._secret, `${subject}.${nonce}`);
|
|
1995
1720
|
const encoder = new TextEncoder();
|
|
1996
1721
|
const actualBuffer = encoder.encode(signature);
|
|
@@ -2011,11 +1736,11 @@ var init_csrf = __esm({
|
|
|
2011
1736
|
});
|
|
2012
1737
|
|
|
2013
1738
|
// src/infrastructure/services/extractors/extract-bearer.extractor.ts
|
|
2014
|
-
var
|
|
1739
|
+
var import_shared40, BearerTokenExtractor;
|
|
2015
1740
|
var init_extract_bearer_extractor = __esm({
|
|
2016
1741
|
"src/infrastructure/services/extractors/extract-bearer.extractor.ts"() {
|
|
2017
1742
|
"use strict";
|
|
2018
|
-
|
|
1743
|
+
import_shared40 = require("@xeno-js/shared");
|
|
2019
1744
|
BearerTokenExtractor = class {
|
|
2020
1745
|
constructor(_cookiePrefix) {
|
|
2021
1746
|
this._cookiePrefix = _cookiePrefix;
|
|
@@ -2023,14 +1748,14 @@ var init_extract_bearer_extractor = __esm({
|
|
|
2023
1748
|
_cookiePrefix;
|
|
2024
1749
|
extract(headers) {
|
|
2025
1750
|
const authHeader = headers.get("Authorization");
|
|
2026
|
-
if (
|
|
1751
|
+
if (import_shared40.Guards.isDefined(authHeader) && authHeader.toLowerCase().startsWith("bearer ")) {
|
|
2027
1752
|
return authHeader.substring(7);
|
|
2028
1753
|
}
|
|
2029
1754
|
const cookieHeader = headers.get("cookie");
|
|
2030
|
-
if (
|
|
1755
|
+
if (import_shared40.Guards.isDefined(cookieHeader)) {
|
|
2031
1756
|
const regex = new RegExp(`${this._cookiePrefix}=([^;]+)`);
|
|
2032
1757
|
const match = regex.exec(cookieHeader);
|
|
2033
|
-
if (!
|
|
1758
|
+
if (!import_shared40.Guards.isNullOrEmpty(match) && import_shared40.Guards.isDefined(match[1])) {
|
|
2034
1759
|
return match[1].trim();
|
|
2035
1760
|
}
|
|
2036
1761
|
}
|
|
@@ -2041,44 +1766,44 @@ var init_extract_bearer_extractor = __esm({
|
|
|
2041
1766
|
});
|
|
2042
1767
|
|
|
2043
1768
|
// src/infrastructure/services/extractors/extract-ssr-bearer.extractor.ts
|
|
2044
|
-
var
|
|
1769
|
+
var import_shared41, SupabaseSsrTokenExtractor;
|
|
2045
1770
|
var init_extract_ssr_bearer_extractor = __esm({
|
|
2046
1771
|
"src/infrastructure/services/extractors/extract-ssr-bearer.extractor.ts"() {
|
|
2047
1772
|
"use strict";
|
|
2048
|
-
|
|
1773
|
+
import_shared41 = require("@xeno-js/shared");
|
|
2049
1774
|
SupabaseSsrTokenExtractor = class {
|
|
2050
1775
|
extract(headers) {
|
|
2051
1776
|
const authHeader = headers.get("authorization");
|
|
2052
|
-
if (
|
|
1777
|
+
if (import_shared41.Guards.isDefined(authHeader) && authHeader.toLowerCase().startsWith("bearer ")) {
|
|
2053
1778
|
return authHeader.substring(7);
|
|
2054
1779
|
}
|
|
2055
1780
|
const cookieHeader = headers.get("cookie");
|
|
2056
|
-
if (
|
|
1781
|
+
if (import_shared41.Guards.isNullOrEmpty(cookieHeader)) return void 0;
|
|
2057
1782
|
const cookies = cookieHeader.split(";").map((c) => c.trim());
|
|
2058
1783
|
const tokenChunks = {};
|
|
2059
1784
|
let unchunkedToken;
|
|
2060
1785
|
for (const cookie of cookies) {
|
|
2061
1786
|
const [name, ...rest] = cookie.split("=");
|
|
2062
|
-
if (!
|
|
1787
|
+
if (!import_shared41.Guards.isDefined(name) || import_shared41.Guards.isNullOrEmpty(rest)) continue;
|
|
2063
1788
|
const value = decodeURIComponent(rest.join("="));
|
|
2064
|
-
if (
|
|
1789
|
+
if (import_shared41.Guards.isDefined(/^sb-[a-z0-9]+-auth-token$/.exec(name))) {
|
|
2065
1790
|
unchunkedToken = value;
|
|
2066
1791
|
} else {
|
|
2067
1792
|
const match = /^sb-[a-z0-9]+-auth-token\.(\d+)$/.exec(name);
|
|
2068
|
-
if (
|
|
1793
|
+
if (import_shared41.Guards.isDefined(match)) tokenChunks[parseInt(match[1], 10)] = value;
|
|
2069
1794
|
}
|
|
2070
1795
|
}
|
|
2071
1796
|
let fullTokenString = unchunkedToken;
|
|
2072
|
-
if (!
|
|
1797
|
+
if (!import_shared41.Guards.isDefined(fullTokenString) && Object.keys(tokenChunks).length > 0) {
|
|
2073
1798
|
const indices = Object.keys(tokenChunks).map(Number).sort((a, b) => a - b);
|
|
2074
1799
|
fullTokenString = indices.map((i) => tokenChunks[i]).join("");
|
|
2075
1800
|
}
|
|
2076
|
-
if (
|
|
1801
|
+
if (import_shared41.Guards.isNullOrEmpty(fullTokenString)) return void 0;
|
|
2077
1802
|
try {
|
|
2078
|
-
const parsed =
|
|
2079
|
-
if (
|
|
1803
|
+
const parsed = import_shared41.StringHelper.safeParse(fullTokenString);
|
|
1804
|
+
if (import_shared41.Guards.isDefined(parsed) && import_shared41.Guards.isObject(parsed) && "access_token" in parsed) {
|
|
2080
1805
|
const accessToken = parsed["access_token"];
|
|
2081
|
-
if (
|
|
1806
|
+
if (import_shared41.Guards.isString(accessToken)) return accessToken;
|
|
2082
1807
|
}
|
|
2083
1808
|
} catch {
|
|
2084
1809
|
return void 0;
|
|
@@ -2089,14 +1814,14 @@ var init_extract_ssr_bearer_extractor = __esm({
|
|
|
2089
1814
|
});
|
|
2090
1815
|
|
|
2091
1816
|
// src/infrastructure/services/extractors/http-cookie.extractor.ts
|
|
2092
|
-
var
|
|
1817
|
+
var import_shared42, HttpCookieExtractor;
|
|
2093
1818
|
var init_http_cookie_extractor = __esm({
|
|
2094
1819
|
"src/infrastructure/services/extractors/http-cookie.extractor.ts"() {
|
|
2095
1820
|
"use strict";
|
|
2096
|
-
|
|
1821
|
+
import_shared42 = require("@xeno-js/shared");
|
|
2097
1822
|
HttpCookieExtractor = class {
|
|
2098
1823
|
extract(cookie) {
|
|
2099
|
-
if (!
|
|
1824
|
+
if (!import_shared42.Guards.isDefined(cookie.header)) return void 0;
|
|
2100
1825
|
for (const rawCookie of cookie.header.split(";")) {
|
|
2101
1826
|
const separatorIndex = rawCookie.indexOf("=");
|
|
2102
1827
|
if (separatorIndex <= 0) continue;
|
|
@@ -2116,11 +1841,11 @@ var init_http_cookie_extractor = __esm({
|
|
|
2116
1841
|
});
|
|
2117
1842
|
|
|
2118
1843
|
// src/infrastructure/services/extractors/http-header.extractor.ts
|
|
2119
|
-
var
|
|
1844
|
+
var import_shared43, HttpHeaderExtractor;
|
|
2120
1845
|
var init_http_header_extractor = __esm({
|
|
2121
1846
|
"src/infrastructure/services/extractors/http-header.extractor.ts"() {
|
|
2122
1847
|
"use strict";
|
|
2123
|
-
|
|
1848
|
+
import_shared43 = require("@xeno-js/shared");
|
|
2124
1849
|
HttpHeaderExtractor = class {
|
|
2125
1850
|
/**
|
|
2126
1851
|
* @description Constructor for HttpHeaderExtractor. It takes an instance of IServiceExtractor for extracting Bearer tokens, allowing for separation of concerns and adherence to the Single Responsibility Principle (SRP). This design enables the HttpHeaderExtractor to focus on general header extraction while delegating the specific logic of Bearer token extraction to a dedicated extractor, promoting code reusability and maintainability.
|
|
@@ -2142,11 +1867,11 @@ var init_http_header_extractor = __esm({
|
|
|
2142
1867
|
_trustedIp;
|
|
2143
1868
|
_cookieName;
|
|
2144
1869
|
extract(headers) {
|
|
2145
|
-
const correlationId =
|
|
2146
|
-
const requestId =
|
|
1870
|
+
const correlationId = import_shared43.GuidHelper.parse(headers.get("x-correlation-id") ?? void 0);
|
|
1871
|
+
const requestId = import_shared43.GuidHelper.parse(headers.get("x-request-id") ?? void 0);
|
|
2147
1872
|
const token = this._bearerExtractor.extract(headers);
|
|
2148
1873
|
const clientIp = headers.get(this._trustedIp?.toLowerCase() ?? "x-forwarded-for") ?? headers.get("x-real-ip") ?? void 0;
|
|
2149
|
-
const spanId =
|
|
1874
|
+
const spanId = import_shared43.GuidHelper.parse(headers.get("x-span-id") ?? void 0);
|
|
2150
1875
|
const parentSpanId = headers.get("x-parent-span-id") ?? void 0;
|
|
2151
1876
|
const acceptHeader = headers.get("accept");
|
|
2152
1877
|
const contentTypeHeader = headers.get("content-type");
|
|
@@ -2163,9 +1888,9 @@ var init_http_header_extractor = __esm({
|
|
|
2163
1888
|
name: this._cookieName
|
|
2164
1889
|
});
|
|
2165
1890
|
const origin = headers.get("origin") ?? void 0;
|
|
2166
|
-
const cleanOrigin =
|
|
1891
|
+
const cleanOrigin = import_shared43.HttpHelper.sanitizeOriginUrl(origin);
|
|
2167
1892
|
const referer = headers.get("referer") ?? void 0;
|
|
2168
|
-
const cleanReferer =
|
|
1893
|
+
const cleanReferer = import_shared43.HttpHelper.sanitizeOriginUrl(referer);
|
|
2169
1894
|
const accept = acceptHeader === "*/*" ? void 0 : acceptHeader;
|
|
2170
1895
|
const formatIndicator = accept ?? contentTypeHeader ?? "application/json";
|
|
2171
1896
|
const metadata = {
|
|
@@ -2184,10 +1909,10 @@ var init_http_header_extractor = __esm({
|
|
|
2184
1909
|
referer: cleanReferer,
|
|
2185
1910
|
sequence: {
|
|
2186
1911
|
sequenceId,
|
|
2187
|
-
position:
|
|
2188
|
-
size:
|
|
1912
|
+
position: import_shared43.Guards.isDefined(position) ? import_shared43.MathHelper.toNumber(position) : void 0,
|
|
1913
|
+
size: import_shared43.Guards.isDefined(size) ? import_shared43.MathHelper.toNumber(size) : void 0
|
|
2189
1914
|
},
|
|
2190
|
-
expiration:
|
|
1915
|
+
expiration: import_shared43.Guards.isDefined(expiration) ? import_shared43.MathHelper.toNumber(expiration) : void 0
|
|
2191
1916
|
};
|
|
2192
1917
|
return metadata;
|
|
2193
1918
|
}
|
|
@@ -2207,18 +1932,18 @@ var init_extractors = __esm({
|
|
|
2207
1932
|
});
|
|
2208
1933
|
|
|
2209
1934
|
// src/infrastructure/services/resiliences/resilience.service.ts
|
|
2210
|
-
var
|
|
1935
|
+
var import_shared44, ServiceResilience;
|
|
2211
1936
|
var init_resilience_service = __esm({
|
|
2212
1937
|
"src/infrastructure/services/resiliences/resilience.service.ts"() {
|
|
2213
1938
|
"use strict";
|
|
2214
|
-
|
|
1939
|
+
import_shared44 = require("@xeno-js/shared");
|
|
2215
1940
|
ServiceResilience = class {
|
|
2216
1941
|
constructor(policy) {
|
|
2217
1942
|
this.policy = policy;
|
|
2218
1943
|
}
|
|
2219
1944
|
policy;
|
|
2220
1945
|
async execute(operation, signal) {
|
|
2221
|
-
|
|
1946
|
+
import_shared44.AppError.throwIfAborted(signal, "ServiceResilience.execute");
|
|
2222
1947
|
return this.policy.execute(() => operation(), signal);
|
|
2223
1948
|
}
|
|
2224
1949
|
};
|
|
@@ -2234,11 +1959,11 @@ var init_resiliences = __esm({
|
|
|
2234
1959
|
});
|
|
2235
1960
|
|
|
2236
1961
|
// src/infrastructure/services/resolver/utils/socket.utils.ts
|
|
2237
|
-
var
|
|
1962
|
+
var import_shared45, SocketIpExtractor;
|
|
2238
1963
|
var init_socket_utils = __esm({
|
|
2239
1964
|
"src/infrastructure/services/resolver/utils/socket.utils.ts"() {
|
|
2240
1965
|
"use strict";
|
|
2241
|
-
|
|
1966
|
+
import_shared45 = require("@xeno-js/shared");
|
|
2242
1967
|
SocketIpExtractor = Object.freeze({
|
|
2243
1968
|
/**
|
|
2244
1969
|
* @description Extracts the IP address of the remote socket from an incoming request.
|
|
@@ -2246,7 +1971,7 @@ var init_socket_utils = __esm({
|
|
|
2246
1971
|
* @returns The IP address of the remote socket, or undefined if not available.
|
|
2247
1972
|
*/
|
|
2248
1973
|
extract(req) {
|
|
2249
|
-
if (
|
|
1974
|
+
if (import_shared45.Guards.isDefined(req) && import_shared45.Guards.isObject(req)) {
|
|
2250
1975
|
const candidate = req;
|
|
2251
1976
|
return candidate.socket?.remoteAddress ?? candidate.connection?.remoteAddress;
|
|
2252
1977
|
}
|
|
@@ -2265,11 +1990,11 @@ var init_utils = __esm({
|
|
|
2265
1990
|
});
|
|
2266
1991
|
|
|
2267
1992
|
// src/infrastructure/services/resolver/client-ip.resolver.ts
|
|
2268
|
-
var
|
|
1993
|
+
var import_shared46, ClientIpResolver;
|
|
2269
1994
|
var init_client_ip_resolver = __esm({
|
|
2270
1995
|
"src/infrastructure/services/resolver/client-ip.resolver.ts"() {
|
|
2271
1996
|
"use strict";
|
|
2272
|
-
|
|
1997
|
+
import_shared46 = require("@xeno-js/shared");
|
|
2273
1998
|
init_utils();
|
|
2274
1999
|
ClientIpResolver = class {
|
|
2275
2000
|
constructor(_trustedProxies = []) {
|
|
@@ -2278,11 +2003,11 @@ var init_client_ip_resolver = __esm({
|
|
|
2278
2003
|
_trustedProxies;
|
|
2279
2004
|
resolve(req, clientIp) {
|
|
2280
2005
|
const socketIp = SocketIpExtractor.extract(req);
|
|
2281
|
-
if (!
|
|
2282
|
-
return !
|
|
2006
|
+
if (!import_shared46.Guards.isDefined(socketIp))
|
|
2007
|
+
return !import_shared46.Guards.isNullOrEmpty(clientIp) ? clientIp.split(",")[0].trim() : void 0;
|
|
2283
2008
|
const isTrustedProxy = this._trustedProxies.includes(socketIp);
|
|
2284
2009
|
if (!isTrustedProxy) return socketIp;
|
|
2285
|
-
if (
|
|
2010
|
+
if (import_shared46.Guards.isDefined(clientIp)) return clientIp.split(",")[0].trim();
|
|
2286
2011
|
return socketIp;
|
|
2287
2012
|
}
|
|
2288
2013
|
};
|
|
@@ -2347,13 +2072,13 @@ var init_allow_method_factory = __esm({
|
|
|
2347
2072
|
});
|
|
2348
2073
|
|
|
2349
2074
|
// src/infrastructure/factories/axios.factory.ts
|
|
2350
|
-
var import_node_http, import_node_https,
|
|
2075
|
+
var import_node_http, import_node_https, import_shared47, import_axios, NodeAxiosFactory;
|
|
2351
2076
|
var init_axios_factory = __esm({
|
|
2352
2077
|
"src/infrastructure/factories/axios.factory.ts"() {
|
|
2353
2078
|
"use strict";
|
|
2354
2079
|
import_node_http = __toESM(require("http"), 1);
|
|
2355
2080
|
import_node_https = __toESM(require("https"), 1);
|
|
2356
|
-
|
|
2081
|
+
import_shared47 = require("@xeno-js/shared");
|
|
2357
2082
|
import_axios = __toESM(require("axios"), 1);
|
|
2358
2083
|
NodeAxiosFactory = class {
|
|
2359
2084
|
create(config) {
|
|
@@ -2380,18 +2105,18 @@ var init_axios_factory = __esm({
|
|
|
2380
2105
|
proxy: config.proxy,
|
|
2381
2106
|
withCredentials: config.withCredentials
|
|
2382
2107
|
});
|
|
2383
|
-
return new
|
|
2108
|
+
return new import_shared47.AxiosHttpClient(axiosInstance);
|
|
2384
2109
|
}
|
|
2385
2110
|
};
|
|
2386
2111
|
}
|
|
2387
2112
|
});
|
|
2388
2113
|
|
|
2389
2114
|
// src/infrastructure/factories/cockatiel-resilience.factory.ts
|
|
2390
|
-
var
|
|
2115
|
+
var import_shared48, import_cockatiel, CockatielResilienceFactory;
|
|
2391
2116
|
var init_cockatiel_resilience_factory = __esm({
|
|
2392
2117
|
"src/infrastructure/factories/cockatiel-resilience.factory.ts"() {
|
|
2393
2118
|
"use strict";
|
|
2394
|
-
|
|
2119
|
+
import_shared48 = require("@xeno-js/shared");
|
|
2395
2120
|
import_cockatiel = require("cockatiel");
|
|
2396
2121
|
init_resilience_service();
|
|
2397
2122
|
CockatielResilienceFactory = class {
|
|
@@ -2401,36 +2126,36 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2401
2126
|
retry: {
|
|
2402
2127
|
attempts: this.checkConfigValue(
|
|
2403
2128
|
config.retry.attempts,
|
|
2404
|
-
|
|
2129
|
+
import_shared48.RESILIENCE_DEFAULTS.RETRY.ATTEMPTS,
|
|
2405
2130
|
message
|
|
2406
2131
|
),
|
|
2407
2132
|
baseDelayMs: this.checkConfigValue(
|
|
2408
2133
|
config.retry.baseDelayMs,
|
|
2409
|
-
|
|
2134
|
+
import_shared48.RESILIENCE_DEFAULTS.RETRY.BASE_DELAY_MS,
|
|
2410
2135
|
message
|
|
2411
2136
|
),
|
|
2412
2137
|
maxDelayMs: this.checkConfigValue(
|
|
2413
2138
|
config.retry.maxDelayMs,
|
|
2414
|
-
|
|
2139
|
+
import_shared48.RESILIENCE_DEFAULTS.RETRY.MAX_DELAY_MS,
|
|
2415
2140
|
message
|
|
2416
2141
|
)
|
|
2417
2142
|
},
|
|
2418
2143
|
circuitBreaker: {
|
|
2419
2144
|
consecutiveFailures: this.checkConfigValue(
|
|
2420
2145
|
config.circuitBreaker.consecutiveFailures,
|
|
2421
|
-
|
|
2146
|
+
import_shared48.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.CONSECUTIVE_FAILURES,
|
|
2422
2147
|
message
|
|
2423
2148
|
),
|
|
2424
2149
|
halfOpenTimeoutMs: this.checkConfigValue(
|
|
2425
2150
|
config.circuitBreaker.halfOpenTimeoutMs,
|
|
2426
|
-
|
|
2151
|
+
import_shared48.RESILIENCE_DEFAULTS.CIRCUIT_BREAKER.HALF_OPEN_TIMEOUT_MS,
|
|
2427
2152
|
message
|
|
2428
2153
|
)
|
|
2429
2154
|
},
|
|
2430
2155
|
bulkhead: {
|
|
2431
2156
|
maxConcurrent: this.checkConfigValue(
|
|
2432
2157
|
config.bulkhead.maxConcurrent,
|
|
2433
|
-
|
|
2158
|
+
import_shared48.RESILIENCE_DEFAULTS.BULKHEAD.MAX_CONCURRENT,
|
|
2434
2159
|
message
|
|
2435
2160
|
)
|
|
2436
2161
|
}
|
|
@@ -2456,13 +2181,13 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2456
2181
|
return new ServiceResilience((0, import_cockatiel.wrap)(bulkheadPolicy, circuitBreakerPolicy, retryPolicy));
|
|
2457
2182
|
}
|
|
2458
2183
|
isTransientError(error) {
|
|
2459
|
-
if (!
|
|
2184
|
+
if (!import_shared48.Guards.isDefined(error) || !import_shared48.Guards.isObject(error)) return false;
|
|
2460
2185
|
let status;
|
|
2461
2186
|
let isNetworkError = false;
|
|
2462
|
-
if (error instanceof
|
|
2187
|
+
if (error instanceof import_shared48.AppError) {
|
|
2463
2188
|
status = error.status;
|
|
2464
2189
|
const cause = error.cause;
|
|
2465
|
-
if (
|
|
2190
|
+
if (import_shared48.Guards.isDefined(cause) && import_shared48.Guards.isString(cause.code)) {
|
|
2466
2191
|
isNetworkError = [
|
|
2467
2192
|
"ECONNABORTED",
|
|
2468
2193
|
"ECONNRESET",
|
|
@@ -2474,7 +2199,7 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2474
2199
|
} else {
|
|
2475
2200
|
const err = error;
|
|
2476
2201
|
status = err.status;
|
|
2477
|
-
if (
|
|
2202
|
+
if (import_shared48.Guards.isString(err.code)) {
|
|
2478
2203
|
isNetworkError = [
|
|
2479
2204
|
"ECONNABORTED",
|
|
2480
2205
|
"ECONNRESET",
|
|
@@ -2485,30 +2210,30 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2485
2210
|
}
|
|
2486
2211
|
}
|
|
2487
2212
|
if (isNetworkError) return true;
|
|
2488
|
-
if (
|
|
2213
|
+
if (import_shared48.Guards.isDefined(status)) return status === 408 || status >= 500 && status < 600;
|
|
2489
2214
|
return false;
|
|
2490
2215
|
}
|
|
2491
2216
|
isTransientAndIdempotent(error) {
|
|
2492
2217
|
if (!this.isTransientError(error)) return false;
|
|
2493
2218
|
let method;
|
|
2494
|
-
if (error instanceof
|
|
2219
|
+
if (error instanceof import_shared48.AppError) {
|
|
2495
2220
|
const cause = error.cause;
|
|
2496
|
-
if (
|
|
2221
|
+
if (import_shared48.Guards.isDefined(cause) && import_shared48.Guards.isDefined(cause.config) && import_shared48.Guards.isString(cause.config.method)) {
|
|
2497
2222
|
method = cause.config.method.toUpperCase();
|
|
2498
2223
|
}
|
|
2499
2224
|
} else {
|
|
2500
2225
|
const err = error;
|
|
2501
|
-
if (
|
|
2226
|
+
if (import_shared48.Guards.isDefined(err.config) && import_shared48.Guards.isString(err.config.method)) {
|
|
2502
2227
|
method = err.config.method.toUpperCase();
|
|
2503
2228
|
}
|
|
2504
2229
|
}
|
|
2505
|
-
if (
|
|
2230
|
+
if (import_shared48.Guards.isNullOrEmpty(method)) return false;
|
|
2506
2231
|
const idempotentMethods = ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"];
|
|
2507
2232
|
return idempotentMethods.includes(method);
|
|
2508
2233
|
}
|
|
2509
2234
|
checkConfigValue(value, defaultValue, message) {
|
|
2510
|
-
if (
|
|
2511
|
-
|
|
2235
|
+
if (import_shared48.Guards.isDefined(value)) {
|
|
2236
|
+
import_shared48.Guards.throwIfNegative(value, message);
|
|
2512
2237
|
return value;
|
|
2513
2238
|
}
|
|
2514
2239
|
return defaultValue;
|
|
@@ -2539,222 +2264,355 @@ var init_db_client_factory = __esm({
|
|
|
2539
2264
|
}
|
|
2540
2265
|
});
|
|
2541
2266
|
|
|
2542
|
-
// src/infrastructure/
|
|
2543
|
-
var
|
|
2544
|
-
var
|
|
2545
|
-
"src/infrastructure/
|
|
2267
|
+
// src/infrastructure/loggers/pino.logger.ts
|
|
2268
|
+
var import_shared49, PinoLogger;
|
|
2269
|
+
var init_pino_logger = __esm({
|
|
2270
|
+
"src/infrastructure/loggers/pino.logger.ts"() {
|
|
2546
2271
|
"use strict";
|
|
2547
|
-
|
|
2548
|
-
|
|
2272
|
+
import_shared49 = require("@xeno-js/shared");
|
|
2273
|
+
PinoLogger = class {
|
|
2549
2274
|
/**
|
|
2550
|
-
*
|
|
2551
|
-
* @param
|
|
2552
|
-
* @param
|
|
2553
|
-
|
|
2275
|
+
* 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.
|
|
2276
|
+
* @param _logger The Pino logger instance used for logging messages.
|
|
2277
|
+
* @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.
|
|
2278
|
+
|
|
2279
|
+
*
|
|
2554
2280
|
* @author Xeno
|
|
2555
2281
|
* @version 1.0.0
|
|
2556
2282
|
* @since 2025-09-30
|
|
2557
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
2283
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
2558
2284
|
*/
|
|
2559
|
-
constructor(
|
|
2560
|
-
this.
|
|
2561
|
-
this.
|
|
2562
|
-
}
|
|
2563
|
-
_storage;
|
|
2564
|
-
_factoryScope;
|
|
2565
|
-
async runAsync(context, fn) {
|
|
2566
|
-
const scope = this._factoryScope.create();
|
|
2567
|
-
try {
|
|
2568
|
-
return await this._storage.run({ context, scope }, fn);
|
|
2569
|
-
} finally {
|
|
2570
|
-
await scope.dispose();
|
|
2571
|
-
}
|
|
2285
|
+
constructor(_logger, _minLevel = import_shared49.LOG_LEVEL.DEBUG) {
|
|
2286
|
+
this._logger = _logger;
|
|
2287
|
+
this._minLevel = _minLevel;
|
|
2572
2288
|
}
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2289
|
+
_logger;
|
|
2290
|
+
_minLevel;
|
|
2291
|
+
track(level, message, context, error = void 0) {
|
|
2292
|
+
if (level < this._minLevel) return;
|
|
2293
|
+
const payload = import_shared49.Guards.isDefined(error) ? { ...context, error } : context;
|
|
2294
|
+
switch (level) {
|
|
2295
|
+
case import_shared49.LOG_LEVEL.ERROR:
|
|
2296
|
+
this._logger.error(payload ?? {}, message);
|
|
2297
|
+
break;
|
|
2298
|
+
case import_shared49.LOG_LEVEL.WARN:
|
|
2299
|
+
this._logger.warn(payload ?? {}, message);
|
|
2300
|
+
break;
|
|
2301
|
+
case import_shared49.LOG_LEVEL.DEBUG:
|
|
2302
|
+
this._logger.debug(payload ?? {}, message);
|
|
2303
|
+
break;
|
|
2304
|
+
default:
|
|
2305
|
+
this._logger.info(payload ?? {}, message);
|
|
2306
|
+
break;
|
|
2580
2307
|
}
|
|
2581
2308
|
}
|
|
2582
|
-
getContext() {
|
|
2583
|
-
const store = this._storage.getStore();
|
|
2584
|
-
if (!import_shared55.Guards.isDefined(store)) return void 0;
|
|
2585
|
-
const context = store.context;
|
|
2586
|
-
return Object.freeze(context);
|
|
2587
|
-
}
|
|
2588
|
-
getIdentity() {
|
|
2589
|
-
const store = this._storage.getStore();
|
|
2590
|
-
if (!import_shared55.Guards.isDefined(store)) return void 0;
|
|
2591
|
-
return Object.freeze(store.context?.identity);
|
|
2592
|
-
}
|
|
2593
|
-
getScope() {
|
|
2594
|
-
const store = this._storage.getStore();
|
|
2595
|
-
if (!import_shared55.Guards.isDefined(store)) return void 0;
|
|
2596
|
-
return store.scope;
|
|
2597
|
-
}
|
|
2598
|
-
getNetworkContext() {
|
|
2599
|
-
const store = this._storage.getStore();
|
|
2600
|
-
if (!import_shared55.Guards.isDefined(store)) return void 0;
|
|
2601
|
-
return Object.freeze(store.context?.network);
|
|
2602
|
-
}
|
|
2603
2309
|
};
|
|
2604
2310
|
}
|
|
2605
2311
|
});
|
|
2606
2312
|
|
|
2607
|
-
// src/infrastructure/factories/
|
|
2608
|
-
var
|
|
2609
|
-
__export(
|
|
2610
|
-
|
|
2313
|
+
// src/infrastructure/factories/pino-logger.factory.ts
|
|
2314
|
+
var pino_logger_factory_exports = {};
|
|
2315
|
+
__export(pino_logger_factory_exports, {
|
|
2316
|
+
PinoLoggerFactory: () => PinoLoggerFactory
|
|
2611
2317
|
});
|
|
2612
|
-
var
|
|
2613
|
-
var
|
|
2614
|
-
"src/infrastructure/factories/
|
|
2318
|
+
var import_shared50, import_pino, PinoLoggerFactory;
|
|
2319
|
+
var init_pino_logger_factory = __esm({
|
|
2320
|
+
"src/infrastructure/factories/pino-logger.factory.ts"() {
|
|
2615
2321
|
"use strict";
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2322
|
+
import_shared50 = require("@xeno-js/shared");
|
|
2323
|
+
import_pino = __toESM(require("pino"), 1);
|
|
2324
|
+
init_pino_logger();
|
|
2325
|
+
PinoLoggerFactory = class {
|
|
2326
|
+
create(config) {
|
|
2327
|
+
const level = config.level ?? import_shared50.LOG_LEVEL.DEBUG;
|
|
2328
|
+
const env = config.pino.config?.env ?? process.env.NODE_ENV ?? "development";
|
|
2329
|
+
const destinationType = config.pino.config?.destination ?? "stdout";
|
|
2330
|
+
const filePath = config.pino.config?.filePath ?? "logs/app.log";
|
|
2331
|
+
const prettyPrint = config.pino.config?.prettyPrint ?? env === "development";
|
|
2332
|
+
const options = {
|
|
2333
|
+
level: "trace",
|
|
2334
|
+
serializers: {
|
|
2335
|
+
err: import_pino.default.stdSerializers.err
|
|
2336
|
+
},
|
|
2337
|
+
timestamp: import_pino.default.stdTimeFunctions.isoTime,
|
|
2338
|
+
redact: {
|
|
2339
|
+
paths: ["password", "token", "secret", "authorization", "headers.authorization"],
|
|
2340
|
+
censor: "***"
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
if (prettyPrint) {
|
|
2344
|
+
return new PinoLogger(
|
|
2345
|
+
(0, import_pino.default)({
|
|
2346
|
+
...options,
|
|
2347
|
+
transport: {
|
|
2348
|
+
target: "pino-pretty",
|
|
2349
|
+
options: {
|
|
2350
|
+
colorize: true,
|
|
2351
|
+
ignore: "pid,hostname",
|
|
2352
|
+
translateTime: "SYS:standard"
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}),
|
|
2356
|
+
level
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
if (destinationType === "file") {
|
|
2360
|
+
const destination = import_pino.default.destination({ dest: filePath, sync: false });
|
|
2361
|
+
return new PinoLogger((0, import_pino.default)(options, destination), level);
|
|
2362
|
+
} else {
|
|
2363
|
+
const stream = import_pino.default.destination({ dest: 1, sync: false });
|
|
2364
|
+
return new PinoLogger((0, import_pino.default)(options, stream), level);
|
|
2365
|
+
}
|
|
2626
2366
|
}
|
|
2627
2367
|
};
|
|
2628
2368
|
}
|
|
2629
2369
|
});
|
|
2630
2370
|
|
|
2631
|
-
// src/infrastructure/
|
|
2632
|
-
var
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
});
|
|
2636
|
-
var ServiceScopeFactory;
|
|
2637
|
-
var init_service_scope_factory = __esm({
|
|
2638
|
-
"src/infrastructure/factories/service-scope.factory.ts"() {
|
|
2371
|
+
// src/infrastructure/cache/redis.cache.ts
|
|
2372
|
+
var import_shared51, RedisCache;
|
|
2373
|
+
var init_redis_cache = __esm({
|
|
2374
|
+
"src/infrastructure/cache/redis.cache.ts"() {
|
|
2639
2375
|
"use strict";
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2376
|
+
import_shared51 = require("@xeno-js/shared");
|
|
2377
|
+
RedisCache = class {
|
|
2378
|
+
/**
|
|
2379
|
+
* @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.
|
|
2380
|
+
* @param _redisClient An instance of the Redis client from the ioredis library, used to perform caching operations in the Redis database.
|
|
2381
|
+
|
|
2382
|
+
*
|
|
2383
|
+
* @author Xeno
|
|
2384
|
+
* @version 1.0.0
|
|
2385
|
+
* @since 2025-09-30
|
|
2386
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
2387
|
+
*/
|
|
2388
|
+
constructor(_redisClient) {
|
|
2389
|
+
this._redisClient = _redisClient;
|
|
2643
2390
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2391
|
+
_redisClient;
|
|
2392
|
+
async increment(key, ttlSeconds) {
|
|
2393
|
+
const multi = this._redisClient.multi();
|
|
2394
|
+
multi.incr(key);
|
|
2395
|
+
multi.expire(key, ttlSeconds ?? 60);
|
|
2396
|
+
const results = await multi.exec();
|
|
2397
|
+
return results?.[0]?.[1] ?? 1;
|
|
2647
2398
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
__export(sql_light_db_client_factory_exports, {
|
|
2655
|
-
DbSqlLiteClientFactory: () => DbSqlLiteClientFactory
|
|
2656
|
-
});
|
|
2657
|
-
var import_client, import_libsql, DbSqlLiteClientFactory;
|
|
2658
|
-
var init_sql_light_db_client_factory = __esm({
|
|
2659
|
-
"src/infrastructure/factories/sql-light-db-client.factory.ts"() {
|
|
2660
|
-
"use strict";
|
|
2661
|
-
import_client = require("@libsql/client");
|
|
2662
|
-
import_libsql = require("drizzle-orm/libsql");
|
|
2663
|
-
DbSqlLiteClientFactory = class {
|
|
2664
|
-
create(opts) {
|
|
2665
|
-
const client = (0, import_client.createClient)({ url: opts.connectionString });
|
|
2666
|
-
return (0, import_libsql.drizzle)({ client });
|
|
2399
|
+
async get(key) {
|
|
2400
|
+
const value = await this._redisClient.get(key);
|
|
2401
|
+
if (!import_shared51.Guards.isDefined(value)) {
|
|
2402
|
+
return void 0;
|
|
2403
|
+
}
|
|
2404
|
+
return JSON.parse(value);
|
|
2667
2405
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
// src/infrastructure/factories/supabase.factory.ts
|
|
2673
|
-
var import_ssr, import_shared56, SupabaseServerAuthFactory;
|
|
2674
|
-
var init_supabase_factory = __esm({
|
|
2675
|
-
"src/infrastructure/factories/supabase.factory.ts"() {
|
|
2676
|
-
"use strict";
|
|
2677
|
-
import_ssr = require("@supabase/ssr");
|
|
2678
|
-
import_shared56 = require("@xeno-js/shared");
|
|
2679
|
-
init_services();
|
|
2680
|
-
SupabaseServerAuthFactory = class {
|
|
2681
|
-
create({
|
|
2682
|
-
config,
|
|
2683
|
-
container
|
|
2684
|
-
}) {
|
|
2685
|
-
const cookieService = this._getCookieSsr(config.ssrOpts, container, config.cookieOpts);
|
|
2686
|
-
const client = (0, import_ssr.createServerClient)(config.url, config.key, {
|
|
2687
|
-
...config.opts,
|
|
2688
|
-
cookies: cookieService
|
|
2689
|
-
});
|
|
2690
|
-
const mapper = new import_shared56.SupabaseClaimsMapper();
|
|
2691
|
-
const sessionMapper = new import_shared56.SupabaseSessionMapper(mapper);
|
|
2692
|
-
return new import_shared56.SupabaseAuthService(client, mapper, sessionMapper, config);
|
|
2406
|
+
async set(key, value, ttl) {
|
|
2407
|
+
const stringValue = import_shared51.StringHelper.safeStringify(value);
|
|
2408
|
+
const ttlOption = import_shared51.Guards.isDefined(ttl) ? ttl : 86400;
|
|
2409
|
+
await this._redisClient.set(key, stringValue, "EX", ttlOption);
|
|
2693
2410
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2411
|
+
async setIfAbsent(key, value, ttl) {
|
|
2412
|
+
const stringValue = import_shared51.StringHelper.safeStringify(value);
|
|
2413
|
+
const ttlOption = import_shared51.Guards.isDefined(ttl) ? ttl : 300;
|
|
2414
|
+
const result = await this._redisClient.set(key, stringValue, "EX", ttlOption, "NX");
|
|
2415
|
+
return result === "OK";
|
|
2416
|
+
}
|
|
2417
|
+
async remove(key) {
|
|
2418
|
+
await this._redisClient.del(key);
|
|
2419
|
+
}
|
|
2420
|
+
async has(key) {
|
|
2421
|
+
const exists = await this._redisClient.exists(key);
|
|
2422
|
+
return exists === 1;
|
|
2423
|
+
}
|
|
2424
|
+
async clear() {
|
|
2425
|
+
await this._redisClient.flushdb();
|
|
2704
2426
|
}
|
|
2705
2427
|
};
|
|
2706
2428
|
}
|
|
2707
2429
|
});
|
|
2708
2430
|
|
|
2709
|
-
// src/infrastructure/factories/
|
|
2710
|
-
var
|
|
2711
|
-
__export(
|
|
2712
|
-
|
|
2431
|
+
// src/infrastructure/factories/redis-cache.factory.ts
|
|
2432
|
+
var redis_cache_factory_exports = {};
|
|
2433
|
+
__export(redis_cache_factory_exports, {
|
|
2434
|
+
RedisCacheFactory: () => RedisCacheFactory
|
|
2713
2435
|
});
|
|
2714
|
-
var
|
|
2715
|
-
var
|
|
2716
|
-
"src/infrastructure/factories/
|
|
2436
|
+
var import_shared52, import_ioredis, RedisCacheFactory;
|
|
2437
|
+
var init_redis_cache_factory = __esm({
|
|
2438
|
+
"src/infrastructure/factories/redis-cache.factory.ts"() {
|
|
2717
2439
|
"use strict";
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2440
|
+
import_shared52 = require("@xeno-js/shared");
|
|
2441
|
+
import_ioredis = require("ioredis");
|
|
2442
|
+
init_redis_cache();
|
|
2443
|
+
RedisCacheFactory = class {
|
|
2444
|
+
create(config) {
|
|
2445
|
+
const host = config?.host ?? "localhost";
|
|
2446
|
+
const port = config?.port ?? 6379;
|
|
2447
|
+
const password = config?.password;
|
|
2448
|
+
const username = config?.username;
|
|
2449
|
+
const useTls = config?.tls ?? false;
|
|
2450
|
+
const maxRetries = config?.maxRetriesPerRequest ?? 3;
|
|
2451
|
+
const redisOptions = {
|
|
2452
|
+
host,
|
|
2453
|
+
port,
|
|
2454
|
+
maxRetriesPerRequest: maxRetries,
|
|
2455
|
+
// Strategia di riconnessione esponenziale per garantire resilienza
|
|
2456
|
+
retryStrategy(times) {
|
|
2457
|
+
const delay = Math.min(times * 50, 2e3);
|
|
2458
|
+
return delay;
|
|
2459
|
+
}
|
|
2737
2460
|
};
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2461
|
+
if (import_shared52.Guards.isDefined(password)) {
|
|
2462
|
+
redisOptions.password = password;
|
|
2463
|
+
}
|
|
2464
|
+
if (import_shared52.Guards.isDefined(username)) {
|
|
2465
|
+
redisOptions.username = username;
|
|
2466
|
+
}
|
|
2467
|
+
if (useTls) {
|
|
2468
|
+
redisOptions.tls = {};
|
|
2469
|
+
}
|
|
2470
|
+
const nativeRedisInstance = new import_ioredis.Redis(redisOptions);
|
|
2471
|
+
nativeRedisInstance.on("error", (err) => {
|
|
2472
|
+
console.error("\u274C [Redis Error]:", err.message);
|
|
2473
|
+
});
|
|
2474
|
+
return new RedisCache(nativeRedisInstance);
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
}
|
|
2478
|
+
});
|
|
2479
|
+
|
|
2480
|
+
// src/infrastructure/loggers/sentry.logger.ts
|
|
2481
|
+
var import_shared53, SentryLogger;
|
|
2482
|
+
var init_sentry_logger = __esm({
|
|
2483
|
+
"src/infrastructure/loggers/sentry.logger.ts"() {
|
|
2484
|
+
"use strict";
|
|
2485
|
+
import_shared53 = require("@xeno-js/shared");
|
|
2486
|
+
SentryLogger = class {
|
|
2487
|
+
constructor(_client, _minLevel) {
|
|
2488
|
+
this._client = _client;
|
|
2489
|
+
this._minLevel = _minLevel;
|
|
2490
|
+
}
|
|
2491
|
+
_client;
|
|
2492
|
+
_minLevel;
|
|
2493
|
+
track(level, message, context = void 0, error = void 0) {
|
|
2494
|
+
if (level < this._minLevel) return;
|
|
2495
|
+
if (level === import_shared53.LOG_LEVEL.ERROR || level === import_shared53.LOG_LEVEL.WARN) {
|
|
2496
|
+
this._client.withScope((scope) => {
|
|
2497
|
+
if (import_shared53.Guards.isDefined(context)) scope.setExtras(context);
|
|
2498
|
+
if (import_shared53.Guards.isDefined(error)) {
|
|
2499
|
+
this._client.captureException(error);
|
|
2500
|
+
} else {
|
|
2501
|
+
this._client.captureMessage(message, "warning");
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
});
|
|
2509
|
+
|
|
2510
|
+
// src/infrastructure/factories/sentry-logger.factory.ts
|
|
2511
|
+
var sentry_logger_factory_exports = {};
|
|
2512
|
+
__export(sentry_logger_factory_exports, {
|
|
2513
|
+
SentryLoggerFactory: () => SentryLoggerFactory
|
|
2514
|
+
});
|
|
2515
|
+
var Sentry, import_shared54, SentryLoggerFactory;
|
|
2516
|
+
var init_sentry_logger_factory = __esm({
|
|
2517
|
+
"src/infrastructure/factories/sentry-logger.factory.ts"() {
|
|
2518
|
+
"use strict";
|
|
2519
|
+
Sentry = __toESM(require("@sentry/node"), 1);
|
|
2520
|
+
import_shared54 = require("@xeno-js/shared");
|
|
2521
|
+
init_sentry_logger();
|
|
2522
|
+
SentryLoggerFactory = class {
|
|
2523
|
+
create(config) {
|
|
2524
|
+
const level = config.level ?? import_shared54.LOG_LEVEL.WARN;
|
|
2525
|
+
const sentryConfig = config.sentry?.config;
|
|
2526
|
+
const env = sentryConfig?.environment ?? process.env.NODE_ENV ?? "development";
|
|
2527
|
+
if (!import_shared54.Guards.isDefined(sentryConfig))
|
|
2528
|
+
throw new Error("Sentry configuration is required when Sentry logging is enabled.");
|
|
2529
|
+
if (!import_shared54.Guards.isDefined(sentryConfig.dsn))
|
|
2530
|
+
throw new Error("Sentry DSN is required when Sentry logging is enabled.");
|
|
2531
|
+
Sentry.init({
|
|
2532
|
+
dsn: sentryConfig.dsn,
|
|
2533
|
+
environment: env,
|
|
2534
|
+
tracesSampleRate: env === "production" ? 0.1 : 1,
|
|
2535
|
+
integrations: [Sentry.httpIntegration()],
|
|
2536
|
+
beforeSend(event, hint) {
|
|
2537
|
+
const error = hint.originalException;
|
|
2538
|
+
if (error instanceof Error && error.name === "ZodError") {
|
|
2539
|
+
return null;
|
|
2540
|
+
}
|
|
2541
|
+
return event;
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
return new SentryLogger(Sentry, level);
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
});
|
|
2549
|
+
|
|
2550
|
+
// src/infrastructure/factories/sql-light-db-client.factory.ts
|
|
2551
|
+
var sql_light_db_client_factory_exports = {};
|
|
2552
|
+
__export(sql_light_db_client_factory_exports, {
|
|
2553
|
+
DbSqlLiteClientFactory: () => DbSqlLiteClientFactory
|
|
2554
|
+
});
|
|
2555
|
+
var import_client, import_libsql, DbSqlLiteClientFactory;
|
|
2556
|
+
var init_sql_light_db_client_factory = __esm({
|
|
2557
|
+
"src/infrastructure/factories/sql-light-db-client.factory.ts"() {
|
|
2558
|
+
"use strict";
|
|
2559
|
+
import_client = require("@libsql/client");
|
|
2560
|
+
import_libsql = require("drizzle-orm/libsql");
|
|
2561
|
+
DbSqlLiteClientFactory = class {
|
|
2562
|
+
create(opts) {
|
|
2563
|
+
const client = (0, import_client.createClient)({ url: opts.connectionString });
|
|
2564
|
+
return (0, import_libsql.drizzle)({ client });
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
});
|
|
2569
|
+
|
|
2570
|
+
// src/infrastructure/factories/supabase.factory.ts
|
|
2571
|
+
var import_ssr, import_shared55, SupabaseServerAuthFactory;
|
|
2572
|
+
var init_supabase_factory = __esm({
|
|
2573
|
+
"src/infrastructure/factories/supabase.factory.ts"() {
|
|
2574
|
+
"use strict";
|
|
2575
|
+
import_ssr = require("@supabase/ssr");
|
|
2576
|
+
import_shared55 = require("@xeno-js/shared");
|
|
2577
|
+
init_services();
|
|
2578
|
+
SupabaseServerAuthFactory = class {
|
|
2579
|
+
create({
|
|
2580
|
+
config,
|
|
2581
|
+
container
|
|
2582
|
+
}) {
|
|
2583
|
+
const cookieService = this._getCookieSsr(config.ssrOpts, container, config.cookieOpts);
|
|
2584
|
+
const client = (0, import_ssr.createServerClient)(config.url, config.key, {
|
|
2585
|
+
...config.opts,
|
|
2586
|
+
cookies: cookieService
|
|
2587
|
+
});
|
|
2588
|
+
const mapper = new import_shared55.SupabaseClaimsMapper();
|
|
2589
|
+
const sessionMapper = new import_shared55.SupabaseSessionMapper(mapper);
|
|
2590
|
+
return new import_shared55.SupabaseAuthService(client, mapper, sessionMapper, config);
|
|
2591
|
+
}
|
|
2592
|
+
_getCookieSsr(ssrOpts, container, config) {
|
|
2593
|
+
if (import_shared55.Guards.isDefined(ssrOpts)) {
|
|
2594
|
+
return ssrOpts(container);
|
|
2595
|
+
} else {
|
|
2596
|
+
return new CookieHandler(
|
|
2597
|
+
container.resolve(import_shared55.TOKENS.REQUEST_CONTEXT),
|
|
2598
|
+
container.resolve(import_shared55.TOKENS.CONFIGURATION_SERVICE),
|
|
2599
|
+
config
|
|
2600
|
+
);
|
|
2742
2601
|
}
|
|
2743
|
-
return output;
|
|
2744
2602
|
}
|
|
2745
2603
|
};
|
|
2746
2604
|
}
|
|
2747
2605
|
});
|
|
2748
2606
|
|
|
2749
2607
|
// src/infrastructure/factories/zod-validator.factory.ts
|
|
2750
|
-
var
|
|
2608
|
+
var import_shared56, ZodValidatorFactory;
|
|
2751
2609
|
var init_zod_validator_factory = __esm({
|
|
2752
2610
|
"src/infrastructure/factories/zod-validator.factory.ts"() {
|
|
2753
2611
|
"use strict";
|
|
2754
|
-
|
|
2612
|
+
import_shared56 = require("@xeno-js/shared");
|
|
2755
2613
|
ZodValidatorFactory = class {
|
|
2756
2614
|
create(opts) {
|
|
2757
|
-
const validatorService = new
|
|
2615
|
+
const validatorService = new import_shared56.ZodValidatorService(/* @__PURE__ */ new Map(), opts.logger);
|
|
2758
2616
|
for (const [intentKey, schema] of Object.entries(opts.schemas)) {
|
|
2759
2617
|
validatorService.addSchema(intentKey, schema);
|
|
2760
2618
|
}
|
|
@@ -2824,8 +2682,8 @@ var init_auth_utils = __esm({
|
|
|
2824
2682
|
async addAuthZ(container, opts) {
|
|
2825
2683
|
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2826
2684
|
const strategies = [];
|
|
2827
|
-
const { Guards:
|
|
2828
|
-
if (
|
|
2685
|
+
const { Guards: Guards49 } = await import("@xeno-js/shared");
|
|
2686
|
+
if (Guards49.isDefined(opts.policies)) {
|
|
2829
2687
|
const { PolicyRegistry: PolicyRegistry2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2830
2688
|
const policyRegistry = opts.policies;
|
|
2831
2689
|
const registryInstance = new PolicyRegistry2();
|
|
@@ -2834,16 +2692,16 @@ var init_auth_utils = __esm({
|
|
|
2834
2692
|
for (const [intent, policy] of Object.entries(policyRegistry)) {
|
|
2835
2693
|
const intentLower = intent.toLowerCase();
|
|
2836
2694
|
registryInstance.addPolicy(intentLower, policy);
|
|
2837
|
-
if (!
|
|
2695
|
+
if (!Guards49.isNullOrEmpty(policy.roles)) {
|
|
2838
2696
|
Policies.add("roles");
|
|
2839
2697
|
}
|
|
2840
|
-
if (!
|
|
2698
|
+
if (!Guards49.isNullOrEmpty(policy.permissions)) {
|
|
2841
2699
|
Policies.add("permissions");
|
|
2842
2700
|
}
|
|
2843
|
-
if (!
|
|
2701
|
+
if (!Guards49.isNullOrEmpty(policy.userId)) {
|
|
2844
2702
|
Policies.add("userId");
|
|
2845
2703
|
}
|
|
2846
|
-
if (!
|
|
2704
|
+
if (!Guards49.isNullOrEmpty(policy.tenantId)) {
|
|
2847
2705
|
Policies.add("tenantId");
|
|
2848
2706
|
}
|
|
2849
2707
|
}
|
|
@@ -2864,10 +2722,10 @@ var init_auth_utils = __esm({
|
|
|
2864
2722
|
strategies.push(new TenantAuthorizationStrategy2(registryInstance, ctxAccessor));
|
|
2865
2723
|
}
|
|
2866
2724
|
}
|
|
2867
|
-
if (!
|
|
2725
|
+
if (!Guards49.isNullOrEmpty(opts.customAuthorizationStrategy)) {
|
|
2868
2726
|
const customStrategies = opts.customAuthorizationStrategy;
|
|
2869
2727
|
customStrategies.forEach((strategyToken) => {
|
|
2870
|
-
if (
|
|
2728
|
+
if (Guards49.isDefined(strategyToken)) {
|
|
2871
2729
|
strategies.push(strategyToken(container));
|
|
2872
2730
|
}
|
|
2873
2731
|
});
|
|
@@ -2887,8 +2745,8 @@ var init_auth_utils = __esm({
|
|
|
2887
2745
|
* @link https://github.com/xeno-js/xeno-js
|
|
2888
2746
|
*/
|
|
2889
2747
|
async addAuthN(container, opts) {
|
|
2890
|
-
const { Guards:
|
|
2891
|
-
if (
|
|
2748
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2749
|
+
if (Guards49.isDefined(opts.customAuth)) {
|
|
2892
2750
|
const authService = opts.customAuth.authExtendedService();
|
|
2893
2751
|
container.addScoped(TOKENS5.AUTH_SERVICE, () => {
|
|
2894
2752
|
return authService;
|
|
@@ -2912,326 +2770,69 @@ var init_auth_utils = __esm({
|
|
|
2912
2770
|
}
|
|
2913
2771
|
});
|
|
2914
2772
|
|
|
2915
|
-
// src/infrastructure/modules/utils/
|
|
2916
|
-
var
|
|
2917
|
-
__export(
|
|
2918
|
-
|
|
2773
|
+
// src/infrastructure/modules/utils/validation.utils.ts
|
|
2774
|
+
var validation_utils_exports = {};
|
|
2775
|
+
__export(validation_utils_exports, {
|
|
2776
|
+
ValidationUtils: () => ValidationUtils
|
|
2919
2777
|
});
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
2922
|
-
"src/infrastructure/modules/utils/
|
|
2778
|
+
var ValidationUtils;
|
|
2779
|
+
var init_validation_utils = __esm({
|
|
2780
|
+
"src/infrastructure/modules/utils/validation.utils.ts"() {
|
|
2923
2781
|
"use strict";
|
|
2924
|
-
|
|
2782
|
+
ValidationUtils = Object.freeze({
|
|
2925
2783
|
/**
|
|
2926
|
-
* @description
|
|
2927
|
-
*
|
|
2928
|
-
* @
|
|
2929
|
-
* @returns A new instance of a database client configured for SQLite, ready for use in the application.
|
|
2784
|
+
* @description Checks if the provided validation configuration requires any validation strategies.
|
|
2785
|
+
* @param validationConfig The validation configuration to check.
|
|
2786
|
+
* @returns True if any validation strategies are required, false otherwise.
|
|
2930
2787
|
*
|
|
2931
2788
|
* @author Xeno
|
|
2932
2789
|
* @version 1.0.0
|
|
2933
2790
|
* @since 2025-09-30
|
|
2934
2791
|
* @link https://github.com/xeno-js/xeno-js
|
|
2935
2792
|
*/
|
|
2936
|
-
async
|
|
2937
|
-
const {
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2793
|
+
async addValidation(container, opts, logger) {
|
|
2794
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
2795
|
+
if (!Guards49.isDefined(opts.zod) && Guards49.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
const validationStrategies = [];
|
|
2799
|
+
if (Guards49.isDefined(opts.zod)) {
|
|
2800
|
+
const config = opts.zod;
|
|
2801
|
+
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
2802
|
+
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2803
|
+
const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
|
|
2804
|
+
container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
|
|
2805
|
+
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
2806
|
+
}
|
|
2807
|
+
if (!Guards49.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
2808
|
+
for (const strategyToken of opts.customValidationStrategy) {
|
|
2809
|
+
if (Guards49.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
2813
|
+
return new ValidationPipeline2(validationStrategies);
|
|
2952
2814
|
}
|
|
2953
2815
|
});
|
|
2954
2816
|
}
|
|
2955
2817
|
});
|
|
2956
2818
|
|
|
2957
|
-
// src/infrastructure/
|
|
2958
|
-
var
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
});
|
|
2962
|
-
var TransactionState;
|
|
2963
|
-
var init_transaction_state = __esm({
|
|
2964
|
-
"src/infrastructure/transaction/transaction-state.ts"() {
|
|
2819
|
+
// src/infrastructure/idempotency/idempotency-store.ts
|
|
2820
|
+
var import_shared57, IdempotencyStore;
|
|
2821
|
+
var init_idempotency_store = __esm({
|
|
2822
|
+
"src/infrastructure/idempotency/idempotency-store.ts"() {
|
|
2965
2823
|
"use strict";
|
|
2966
|
-
|
|
2824
|
+
import_shared57 = require("@xeno-js/shared");
|
|
2825
|
+
IdempotencyStore = class {
|
|
2967
2826
|
/**
|
|
2968
|
-
* The
|
|
2827
|
+
* @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.
|
|
2828
|
+
* @param _cache An instance of ICache that provides methods to interact with the underlying caching system, used to store locks and results of idempotent commands.
|
|
2829
|
+
* @param _identityAccessor An instance of IIdentityAccessor that allows access to the user's identity context, used to build contextual keys for idempotent commands, supporting multi-tenant scenarios.
|
|
2830
|
+
|
|
2831
|
+
*
|
|
2969
2832
|
* @author Xeno
|
|
2970
2833
|
* @version 1.0.0
|
|
2971
2834
|
* @since 2025-09-30
|
|
2972
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
2973
|
-
*/
|
|
2974
|
-
_state = null;
|
|
2975
|
-
/**
|
|
2976
|
-
* Creates an instance of TransactionState.
|
|
2977
|
-
* @param initialState - The initial state of the transaction, which can be either a specific transaction type or null.
|
|
2978
|
-
* @author Xeno
|
|
2979
|
-
* @version 1.0.0
|
|
2980
|
-
* @since 2025-09-30
|
|
2981
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
2982
|
-
*/
|
|
2983
|
-
constructor(initialState = null) {
|
|
2984
|
-
this._state = initialState;
|
|
2985
|
-
}
|
|
2986
|
-
get state() {
|
|
2987
|
-
return this._state;
|
|
2988
|
-
}
|
|
2989
|
-
set state(value) {
|
|
2990
|
-
this._state = value;
|
|
2991
|
-
}
|
|
2992
|
-
};
|
|
2993
|
-
}
|
|
2994
|
-
});
|
|
2995
|
-
|
|
2996
|
-
// src/infrastructure/transaction/unit-of-work.ts
|
|
2997
|
-
var unit_of_work_exports = {};
|
|
2998
|
-
__export(unit_of_work_exports, {
|
|
2999
|
-
UnitOfWork: () => UnitOfWork
|
|
3000
|
-
});
|
|
3001
|
-
var import_shared59, import_shared60, UnitOfWork;
|
|
3002
|
-
var init_unit_of_work = __esm({
|
|
3003
|
-
"src/infrastructure/transaction/unit-of-work.ts"() {
|
|
3004
|
-
"use strict";
|
|
3005
|
-
import_shared59 = require("@xeno-js/shared");
|
|
3006
|
-
import_shared60 = require("@xeno-js/shared");
|
|
3007
|
-
UnitOfWork = class {
|
|
3008
|
-
/**
|
|
3009
|
-
* Creates an instance of UnitOfWork.
|
|
3010
|
-
* @param _dbContext - The database context used for managing transactions.
|
|
3011
|
-
* @param _ttx - The transaction state, which can be either a specific transaction type or null.
|
|
3012
|
-
*
|
|
3013
|
-
* @author Xeno
|
|
3014
|
-
* @version 1.0.0
|
|
3015
|
-
* @since 2025-09-30
|
|
3016
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
3017
|
-
*/
|
|
3018
|
-
constructor(_dbContext, _ttx) {
|
|
3019
|
-
this._dbContext = _dbContext;
|
|
3020
|
-
this._ttx = _ttx;
|
|
3021
|
-
}
|
|
3022
|
-
_dbContext;
|
|
3023
|
-
_ttx;
|
|
3024
|
-
async runInTransaction(callback, signal) {
|
|
3025
|
-
import_shared59.AppError.throwIfAborted(signal, "UnitOfWork.runInTransaction");
|
|
3026
|
-
return this._dbContext.transaction(async (tx) => {
|
|
3027
|
-
this._ttx.state = tx;
|
|
3028
|
-
try {
|
|
3029
|
-
const result = await callback();
|
|
3030
|
-
return result;
|
|
3031
|
-
} finally {
|
|
3032
|
-
this._ttx.state = null;
|
|
3033
|
-
}
|
|
3034
|
-
});
|
|
3035
|
-
}
|
|
3036
|
-
async dispose() {
|
|
3037
|
-
if (import_shared60.Guards.isDefined(this._ttx.state)) {
|
|
3038
|
-
try {
|
|
3039
|
-
if (import_shared60.Guards.hasMethod(this._ttx.state, "rollback")) {
|
|
3040
|
-
await this._ttx.state.rollback();
|
|
3041
|
-
}
|
|
3042
|
-
} finally {
|
|
3043
|
-
this._ttx.state = null;
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
};
|
|
3048
|
-
}
|
|
3049
|
-
});
|
|
3050
|
-
|
|
3051
|
-
// src/infrastructure/modules/db.module.ts
|
|
3052
|
-
var db_module_exports = {};
|
|
3053
|
-
__export(db_module_exports, {
|
|
3054
|
-
DbModule: () => DbModule
|
|
3055
|
-
});
|
|
3056
|
-
var DbModule;
|
|
3057
|
-
var init_db_module = __esm({
|
|
3058
|
-
"src/infrastructure/modules/db.module.ts"() {
|
|
3059
|
-
"use strict";
|
|
3060
|
-
DbModule = class {
|
|
3061
|
-
async configure(container, opts) {
|
|
3062
|
-
const { Guards: Guards47, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3063
|
-
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3064
|
-
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3065
|
-
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
3066
|
-
container.addScoped("TRANSACTION_STATE", () => {
|
|
3067
|
-
return new TransactionState2();
|
|
3068
|
-
});
|
|
3069
|
-
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3070
|
-
container.addScoped(TOKENS5.UNIT_OF_WORK, (c) => {
|
|
3071
|
-
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3072
|
-
return new UnitOfWork2(db, ttx);
|
|
3073
|
-
});
|
|
3074
|
-
container.addScoped(TOKENS5.DB_CONTEXT, (c) => {
|
|
3075
|
-
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3076
|
-
return new Proxy(db, {
|
|
3077
|
-
get(_target, prop, receiver) {
|
|
3078
|
-
const activeState = ttx.state;
|
|
3079
|
-
if (Guards47.isDefined(activeState)) {
|
|
3080
|
-
if (prop === "transaction") {
|
|
3081
|
-
return activeState.transaction.bind(activeState);
|
|
3082
|
-
}
|
|
3083
|
-
return Reflect.get(activeState, prop, receiver);
|
|
3084
|
-
}
|
|
3085
|
-
return Reflect.get(db, prop, receiver);
|
|
3086
|
-
}
|
|
3087
|
-
});
|
|
3088
|
-
});
|
|
3089
|
-
}
|
|
3090
|
-
};
|
|
3091
|
-
}
|
|
3092
|
-
});
|
|
3093
|
-
|
|
3094
|
-
// src/infrastructure/modules/utils/http.utils.ts
|
|
3095
|
-
var http_utils_exports = {};
|
|
3096
|
-
__export(http_utils_exports, {
|
|
3097
|
-
HttpUtils: () => HttpUtils
|
|
3098
|
-
});
|
|
3099
|
-
var HttpUtils;
|
|
3100
|
-
var init_http_utils = __esm({
|
|
3101
|
-
"src/infrastructure/modules/utils/http.utils.ts"() {
|
|
3102
|
-
"use strict";
|
|
3103
|
-
HttpUtils = Object.freeze({
|
|
3104
|
-
/**
|
|
3105
|
-
* @description Utility function to create a query string from an object of query parameters. It takes an object where the keys are the parameter names and the values are the parameter values, and returns a properly encoded query string that can be appended to a URL for making HTTP requests.
|
|
3106
|
-
* @param params - An object containing the query parameters as key-value pairs. The keys represent the parameter names, and the values represent the parameter values.
|
|
3107
|
-
* @returns A string representing the encoded query string that can be appended to a URL for making HTTP requests.
|
|
3108
|
-
*
|
|
3109
|
-
* @author Xeno
|
|
3110
|
-
* @version 1.0.0
|
|
3111
|
-
* @since 2025-09-30
|
|
3112
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
3113
|
-
*/
|
|
3114
|
-
async addAxios(container, opts) {
|
|
3115
|
-
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3116
|
-
const { Guards: Guards47 } = await import("@xeno-js/shared");
|
|
3117
|
-
if (!Guards47.isDefined(opts.token)) {
|
|
3118
|
-
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3119
|
-
}
|
|
3120
|
-
container.addSingleton(opts.token, () => {
|
|
3121
|
-
const factory = new NodeAxiosFactory2();
|
|
3122
|
-
const instance = factory.create(opts.client);
|
|
3123
|
-
if (!Guards47.hasMethod(instance, "get") || !Guards47.hasMethod(instance, "post") || !Guards47.hasMethod(instance, "put") || !Guards47.hasMethod(instance, "patch") || !Guards47.hasMethod(instance, "delete")) {
|
|
3124
|
-
throw new Error(
|
|
3125
|
-
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3126
|
-
);
|
|
3127
|
-
}
|
|
3128
|
-
return instance;
|
|
3129
|
-
});
|
|
3130
|
-
},
|
|
3131
|
-
/**
|
|
3132
|
-
* @description Utility function to add resilience features to the service container. It takes a ResilienceConfig object that specifies whether resilience features are enabled and provides the necessary settings for implementing resilience strategies such as retries, circuit breakers, and timeouts. If resilience is enabled, it registers a singleton factory in the service container that creates an instance of the resilience client based on the provided configuration.
|
|
3133
|
-
* @param container - The service container to register the resilience client with.
|
|
3134
|
-
* @param opts - The ResilienceConfig options that determine whether resilience features are enabled and provide the necessary settings for implementing resilience strategies.
|
|
3135
|
-
*
|
|
3136
|
-
* @author Xeno
|
|
3137
|
-
* @version 1.0.0
|
|
3138
|
-
* @since 2025-09-30
|
|
3139
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
3140
|
-
*/
|
|
3141
|
-
async addResilience(container, opts) {
|
|
3142
|
-
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3143
|
-
const { CockatielResilienceFactory: CockatielResilienceFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3144
|
-
container.addSingleton(TOKENS5.RESILIENCE_CLIENT, () => {
|
|
3145
|
-
const factory = new CockatielResilienceFactory2();
|
|
3146
|
-
return factory.create(opts);
|
|
3147
|
-
});
|
|
3148
|
-
}
|
|
3149
|
-
});
|
|
3150
|
-
}
|
|
3151
|
-
});
|
|
3152
|
-
|
|
3153
|
-
// src/infrastructure/modules/http-core.module.ts
|
|
3154
|
-
var http_core_module_exports = {};
|
|
3155
|
-
__export(http_core_module_exports, {
|
|
3156
|
-
HttpCoreModule: () => HttpCoreModule
|
|
3157
|
-
});
|
|
3158
|
-
var HttpCoreModule;
|
|
3159
|
-
var init_http_core_module = __esm({
|
|
3160
|
-
"src/infrastructure/modules/http-core.module.ts"() {
|
|
3161
|
-
"use strict";
|
|
3162
|
-
HttpCoreModule = class {
|
|
3163
|
-
async configure(container, opts) {
|
|
3164
|
-
const { HttpUtils: HttpUtils2 } = await Promise.resolve().then(() => (init_http_utils(), http_utils_exports));
|
|
3165
|
-
await HttpUtils2.addAxios(container, opts.http);
|
|
3166
|
-
await HttpUtils2.addResilience(container, opts.resilience);
|
|
3167
|
-
}
|
|
3168
|
-
};
|
|
3169
|
-
}
|
|
3170
|
-
});
|
|
3171
|
-
|
|
3172
|
-
// src/infrastructure/modules/utils/validation.utils.ts
|
|
3173
|
-
var validation_utils_exports = {};
|
|
3174
|
-
__export(validation_utils_exports, {
|
|
3175
|
-
ValidationUtils: () => ValidationUtils
|
|
3176
|
-
});
|
|
3177
|
-
var ValidationUtils;
|
|
3178
|
-
var init_validation_utils = __esm({
|
|
3179
|
-
"src/infrastructure/modules/utils/validation.utils.ts"() {
|
|
3180
|
-
"use strict";
|
|
3181
|
-
ValidationUtils = Object.freeze({
|
|
3182
|
-
/**
|
|
3183
|
-
* @description Checks if the provided validation configuration requires any validation strategies.
|
|
3184
|
-
* @param validationConfig The validation configuration to check.
|
|
3185
|
-
* @returns True if any validation strategies are required, false otherwise.
|
|
3186
|
-
*
|
|
3187
|
-
* @author Xeno
|
|
3188
|
-
* @version 1.0.0
|
|
3189
|
-
* @since 2025-09-30
|
|
3190
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
3191
|
-
*/
|
|
3192
|
-
async addValidation(container, opts, logger) {
|
|
3193
|
-
const { Guards: Guards47, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3194
|
-
if (!Guards47.isDefined(opts.zod) && Guards47.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3195
|
-
return;
|
|
3196
|
-
}
|
|
3197
|
-
const validationStrategies = [];
|
|
3198
|
-
if (Guards47.isDefined(opts.zod)) {
|
|
3199
|
-
const config = opts.zod;
|
|
3200
|
-
const { ZodValidatorFactory: ZodValidatorFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3201
|
-
const { SchemaValidationStrategy: SchemaValidationStrategy2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3202
|
-
const validatorService = new ZodValidatorFactory2().create({ ...config, logger });
|
|
3203
|
-
container.addSingleton(TOKENS5.VALIDATOR_SERVICE, () => validatorService);
|
|
3204
|
-
validationStrategies.push(new SchemaValidationStrategy2(validatorService));
|
|
3205
|
-
}
|
|
3206
|
-
if (!Guards47.isNullOrEmpty(opts.customValidationStrategy)) {
|
|
3207
|
-
for (const strategyToken of opts.customValidationStrategy) {
|
|
3208
|
-
if (Guards47.isDefined(strategyToken)) validationStrategies.push(strategyToken(container));
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
|
-
const { ValidationPipeline: ValidationPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3212
|
-
return new ValidationPipeline2(validationStrategies);
|
|
3213
|
-
}
|
|
3214
|
-
});
|
|
3215
|
-
}
|
|
3216
|
-
});
|
|
3217
|
-
|
|
3218
|
-
// src/infrastructure/idempotency/idempotency-store.ts
|
|
3219
|
-
var import_shared61, IdempotencyStore;
|
|
3220
|
-
var init_idempotency_store = __esm({
|
|
3221
|
-
"src/infrastructure/idempotency/idempotency-store.ts"() {
|
|
3222
|
-
"use strict";
|
|
3223
|
-
import_shared61 = require("@xeno-js/shared");
|
|
3224
|
-
IdempotencyStore = class {
|
|
3225
|
-
/**
|
|
3226
|
-
* @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.
|
|
3227
|
-
* @param _cache An instance of ICache that provides methods to interact with the underlying caching system, used to store locks and results of idempotent commands.
|
|
3228
|
-
* @param _identityAccessor An instance of IIdentityAccessor that allows access to the user's identity context, used to build contextual keys for idempotent commands, supporting multi-tenant scenarios.
|
|
3229
|
-
|
|
3230
|
-
*
|
|
3231
|
-
* @author Xeno
|
|
3232
|
-
* @version 1.0.0
|
|
3233
|
-
* @since 2025-09-30
|
|
3234
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
2835
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3235
2836
|
*/
|
|
3236
2837
|
constructor(_cache, _cacheKeyBuilder) {
|
|
3237
2838
|
this._cache = _cache;
|
|
@@ -3242,31 +2843,31 @@ var init_idempotency_store = __esm({
|
|
|
3242
2843
|
async acquireLock(requestId, ttlSeconds) {
|
|
3243
2844
|
const key = this._cacheKeyBuilder.buildContextualKey(`command:${requestId}`);
|
|
3244
2845
|
return await this._cache.setIfAbsent(
|
|
3245
|
-
`${
|
|
3246
|
-
|
|
2846
|
+
`${import_shared57.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`,
|
|
2847
|
+
import_shared57.IDEMPOTENCY_CONSTANTS.LOCKED_VALUE,
|
|
3247
2848
|
ttlSeconds
|
|
3248
2849
|
);
|
|
3249
2850
|
}
|
|
3250
2851
|
async hasBeenProcessed(commandId) {
|
|
3251
2852
|
const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
|
|
3252
|
-
return await this._cache.has(`${
|
|
2853
|
+
return await this._cache.has(`${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
|
|
3253
2854
|
}
|
|
3254
2855
|
async markAsProcessed(commandId, payload, ttlSeconds) {
|
|
3255
2856
|
const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
|
|
3256
2857
|
await this._cache.set(
|
|
3257
|
-
`${
|
|
2858
|
+
`${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`,
|
|
3258
2859
|
payload,
|
|
3259
2860
|
ttlSeconds
|
|
3260
2861
|
);
|
|
3261
2862
|
}
|
|
3262
2863
|
async getPayload(commandId) {
|
|
3263
2864
|
const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
|
|
3264
|
-
const payload = await this._cache.get(`${
|
|
2865
|
+
const payload = await this._cache.get(`${import_shared57.IDEMPOTENCY_CONSTANTS.PROCESSED_KEY_PREFIX}${key}`);
|
|
3265
2866
|
return payload;
|
|
3266
2867
|
}
|
|
3267
2868
|
async releaseLock(commandId) {
|
|
3268
2869
|
const key = this._cacheKeyBuilder.buildContextualKey(`command:${commandId}`);
|
|
3269
|
-
await this._cache.remove(`${
|
|
2870
|
+
await this._cache.remove(`${import_shared57.IDEMPOTENCY_CONSTANTS.LOCK_KEY_PREFIX}${key}`);
|
|
3270
2871
|
}
|
|
3271
2872
|
};
|
|
3272
2873
|
}
|
|
@@ -3305,9 +2906,9 @@ var init_pipeline_utils = __esm({
|
|
|
3305
2906
|
* @link https://github.com/xeno-js/xeno-js
|
|
3306
2907
|
*/
|
|
3307
2908
|
async addCommand(container, opts) {
|
|
3308
|
-
const { Guards:
|
|
2909
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3309
2910
|
const pipelines = [];
|
|
3310
|
-
if (
|
|
2911
|
+
if (Guards49.isDefined(opts.idempotency)) {
|
|
3311
2912
|
const { IdempotencyStore: IdempotencyStore2 } = await Promise.resolve().then(() => (init_idempotency(), idempotency_exports));
|
|
3312
2913
|
const imdStore = new IdempotencyStore2(
|
|
3313
2914
|
container.resolve(TOKENS5.CACHE),
|
|
@@ -3325,7 +2926,7 @@ var init_pipeline_utils = __esm({
|
|
|
3325
2926
|
)
|
|
3326
2927
|
);
|
|
3327
2928
|
}
|
|
3328
|
-
if (
|
|
2929
|
+
if (Guards49.isDefined(opts.concurrency)) {
|
|
3329
2930
|
const { ConcurrencyRetryPipeline: ConcurrencyRetryPipeline2 } = await Promise.resolve().then(() => (init_application(), application_exports));
|
|
3330
2931
|
const config = opts.concurrency;
|
|
3331
2932
|
pipelines.push(new ConcurrencyRetryPipeline2(config?.maxRetries, config?.delayConfig));
|
|
@@ -3382,24 +2983,24 @@ var init_cqrs_module = __esm({
|
|
|
3382
2983
|
new LoggingPipeline2(logger),
|
|
3383
2984
|
new PerformancePipeline2(logger, thresholdMs)
|
|
3384
2985
|
];
|
|
3385
|
-
const { Guards:
|
|
3386
|
-
if (
|
|
2986
|
+
const { Guards: Guards49 } = await import("@xeno-js/shared");
|
|
2987
|
+
if (Guards49.isDefined(opts.authorization.policies) || Guards49.isDefined(opts.authorization.customAuthorizationStrategy)) {
|
|
3387
2988
|
const { AuthUtils: AuthUtils2 } = await Promise.resolve().then(() => (init_auth_utils(), auth_utils_exports));
|
|
3388
2989
|
const authPipelines = await AuthUtils2.addAuthZ(container, opts.authorization);
|
|
3389
2990
|
pipelines.push(authPipelines);
|
|
3390
2991
|
}
|
|
3391
|
-
if (
|
|
2992
|
+
if (Guards49.isDefined(opts.validation.zod) || Guards49.isDefined(opts.validation.customValidationStrategy)) {
|
|
3392
2993
|
const { ValidationUtils: ValidationUtils2 } = await Promise.resolve().then(() => (init_validation_utils(), validation_utils_exports));
|
|
3393
2994
|
const validationPipelines = await ValidationUtils2.addValidation(
|
|
3394
2995
|
container,
|
|
3395
2996
|
opts.validation,
|
|
3396
2997
|
logger
|
|
3397
2998
|
);
|
|
3398
|
-
if (
|
|
2999
|
+
if (Guards49.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3399
3000
|
}
|
|
3400
3001
|
const commandPipelines = [...pipelines];
|
|
3401
3002
|
const queryPipelines = [...pipelines];
|
|
3402
|
-
if (
|
|
3003
|
+
if (Guards49.isDefined(opts.commandBus.idempotency) || Guards49.isDefined(opts.commandBus.concurrency)) {
|
|
3403
3004
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3404
3005
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
3405
3006
|
commandPipelines.push(...newCommandPipelines);
|
|
@@ -3413,10 +3014,459 @@ var init_cqrs_module = __esm({
|
|
|
3413
3014
|
container.addSingleton(TOKENS5.COMMAND_PIPELINES_BEHAVIOR, () => {
|
|
3414
3015
|
return new CompositePipeline2(commandPipelines);
|
|
3415
3016
|
});
|
|
3416
|
-
container.addSingleton(TOKENS5.QUERY_PIPELINES_BEHAVIOR, () => {
|
|
3417
|
-
return new CompositePipeline2(queryPipelines);
|
|
3017
|
+
container.addSingleton(TOKENS5.QUERY_PIPELINES_BEHAVIOR, () => {
|
|
3018
|
+
return new CompositePipeline2(queryPipelines);
|
|
3019
|
+
});
|
|
3020
|
+
}
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
|
|
3025
|
+
// src/infrastructure/modules/utils/db.utils.ts
|
|
3026
|
+
var db_utils_exports = {};
|
|
3027
|
+
__export(db_utils_exports, {
|
|
3028
|
+
DbUtils: () => DbUtils
|
|
3029
|
+
});
|
|
3030
|
+
var DbUtils;
|
|
3031
|
+
var init_db_utils = __esm({
|
|
3032
|
+
"src/infrastructure/modules/utils/db.utils.ts"() {
|
|
3033
|
+
"use strict";
|
|
3034
|
+
DbUtils = Object.freeze({
|
|
3035
|
+
/**
|
|
3036
|
+
* @description Creates a new instance of a database client configured for SQLite using the provided database configuration options. This utility function encapsulates the logic for initializing a SQLite database client, allowing for easy integration with the application's dependency injection system. It ensures that the necessary connection string and other configuration parameters are correctly applied to create a functional database client instance.
|
|
3037
|
+
*
|
|
3038
|
+
* @param opts - The database configuration options, including the connection string and any other relevant settings required for establishing a connection to the SQLite database.
|
|
3039
|
+
* @returns A new instance of a database client configured for SQLite, ready for use in the application.
|
|
3040
|
+
*
|
|
3041
|
+
* @author Xeno
|
|
3042
|
+
* @version 1.0.0
|
|
3043
|
+
* @since 2025-09-30
|
|
3044
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3045
|
+
*/
|
|
3046
|
+
async addSqlLite(opts) {
|
|
3047
|
+
const { DbSqlLiteClientFactory: DbSqlLiteClientFactory2 } = await Promise.resolve().then(() => (init_sql_light_db_client_factory(), sql_light_db_client_factory_exports));
|
|
3048
|
+
return new DbSqlLiteClientFactory2().create(opts);
|
|
3049
|
+
},
|
|
3050
|
+
/**
|
|
3051
|
+
* @description Creates a new instance of a database client based on the provided database configuration options. This utility function encapsulates the logic for initializing a database client, allowing for easy integration with the application's dependency injection system. It ensures that the necessary connection string and other configuration parameters are correctly applied to create a functional database client instance.
|
|
3052
|
+
* @param opts - The database configuration options, including the connection string and any other relevant settings required for establishing a connection to the database.
|
|
3053
|
+
* @returns A new instance of a database client, ready for use in the application.
|
|
3054
|
+
* @author Xeno
|
|
3055
|
+
* @version 1.0.0
|
|
3056
|
+
* @since 2025-09-30
|
|
3057
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3058
|
+
*/
|
|
3059
|
+
async addDbClient(opts) {
|
|
3060
|
+
const { DbClientFactory: DbClientFactory2 } = await Promise.resolve().then(() => (init_db_client_factory(), db_client_factory_exports));
|
|
3061
|
+
return new DbClientFactory2().create(opts);
|
|
3062
|
+
}
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
3066
|
+
|
|
3067
|
+
// src/infrastructure/transaction/transaction-state.ts
|
|
3068
|
+
var transaction_state_exports = {};
|
|
3069
|
+
__export(transaction_state_exports, {
|
|
3070
|
+
TransactionState: () => TransactionState
|
|
3071
|
+
});
|
|
3072
|
+
var TransactionState;
|
|
3073
|
+
var init_transaction_state = __esm({
|
|
3074
|
+
"src/infrastructure/transaction/transaction-state.ts"() {
|
|
3075
|
+
"use strict";
|
|
3076
|
+
TransactionState = class {
|
|
3077
|
+
/**
|
|
3078
|
+
* The current state of the transaction, which can be either a specific transaction type or null.
|
|
3079
|
+
* @author Xeno
|
|
3080
|
+
* @version 1.0.0
|
|
3081
|
+
* @since 2025-09-30
|
|
3082
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3083
|
+
*/
|
|
3084
|
+
_state = null;
|
|
3085
|
+
/**
|
|
3086
|
+
* Creates an instance of TransactionState.
|
|
3087
|
+
* @param initialState - The initial state of the transaction, which can be either a specific transaction type or null.
|
|
3088
|
+
* @author Xeno
|
|
3089
|
+
* @version 1.0.0
|
|
3090
|
+
* @since 2025-09-30
|
|
3091
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3092
|
+
*/
|
|
3093
|
+
constructor(initialState = null) {
|
|
3094
|
+
this._state = initialState;
|
|
3095
|
+
}
|
|
3096
|
+
get state() {
|
|
3097
|
+
return this._state;
|
|
3098
|
+
}
|
|
3099
|
+
set state(value) {
|
|
3100
|
+
this._state = value;
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
}
|
|
3104
|
+
});
|
|
3105
|
+
|
|
3106
|
+
// src/infrastructure/transaction/unit-of-work.ts
|
|
3107
|
+
var unit_of_work_exports = {};
|
|
3108
|
+
__export(unit_of_work_exports, {
|
|
3109
|
+
UnitOfWork: () => UnitOfWork
|
|
3110
|
+
});
|
|
3111
|
+
var import_shared58, import_shared59, UnitOfWork;
|
|
3112
|
+
var init_unit_of_work = __esm({
|
|
3113
|
+
"src/infrastructure/transaction/unit-of-work.ts"() {
|
|
3114
|
+
"use strict";
|
|
3115
|
+
import_shared58 = require("@xeno-js/shared");
|
|
3116
|
+
import_shared59 = require("@xeno-js/shared");
|
|
3117
|
+
UnitOfWork = class {
|
|
3118
|
+
/**
|
|
3119
|
+
* Creates an instance of UnitOfWork.
|
|
3120
|
+
* @param _dbContext - The database context used for managing transactions.
|
|
3121
|
+
* @param _ttx - The transaction state, which can be either a specific transaction type or null.
|
|
3122
|
+
*
|
|
3123
|
+
* @author Xeno
|
|
3124
|
+
* @version 1.0.0
|
|
3125
|
+
* @since 2025-09-30
|
|
3126
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3127
|
+
*/
|
|
3128
|
+
constructor(_dbContext, _ttx) {
|
|
3129
|
+
this._dbContext = _dbContext;
|
|
3130
|
+
this._ttx = _ttx;
|
|
3131
|
+
}
|
|
3132
|
+
_dbContext;
|
|
3133
|
+
_ttx;
|
|
3134
|
+
async runInTransaction(callback, signal) {
|
|
3135
|
+
import_shared58.AppError.throwIfAborted(signal, "UnitOfWork.runInTransaction");
|
|
3136
|
+
return this._dbContext.transaction(async (tx) => {
|
|
3137
|
+
this._ttx.state = tx;
|
|
3138
|
+
try {
|
|
3139
|
+
const result = await callback();
|
|
3140
|
+
return result;
|
|
3141
|
+
} finally {
|
|
3142
|
+
this._ttx.state = null;
|
|
3143
|
+
}
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
async dispose() {
|
|
3147
|
+
if (import_shared59.Guards.isDefined(this._ttx.state)) {
|
|
3148
|
+
try {
|
|
3149
|
+
if (import_shared59.Guards.hasMethod(this._ttx.state, "rollback")) {
|
|
3150
|
+
await this._ttx.state.rollback();
|
|
3151
|
+
}
|
|
3152
|
+
} finally {
|
|
3153
|
+
this._ttx.state = null;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
});
|
|
3160
|
+
|
|
3161
|
+
// src/infrastructure/modules/db.module.ts
|
|
3162
|
+
var db_module_exports = {};
|
|
3163
|
+
__export(db_module_exports, {
|
|
3164
|
+
DbModule: () => DbModule
|
|
3165
|
+
});
|
|
3166
|
+
var DbModule;
|
|
3167
|
+
var init_db_module = __esm({
|
|
3168
|
+
"src/infrastructure/modules/db.module.ts"() {
|
|
3169
|
+
"use strict";
|
|
3170
|
+
DbModule = class {
|
|
3171
|
+
async configure(container, opts) {
|
|
3172
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3173
|
+
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3174
|
+
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3175
|
+
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
3176
|
+
container.addScoped("TRANSACTION_STATE", () => {
|
|
3177
|
+
return new TransactionState2();
|
|
3178
|
+
});
|
|
3179
|
+
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3180
|
+
container.addScoped(TOKENS5.UNIT_OF_WORK, (c) => {
|
|
3181
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3182
|
+
return new UnitOfWork2(db, ttx);
|
|
3183
|
+
});
|
|
3184
|
+
container.addScoped(TOKENS5.DB_CONTEXT, (c) => {
|
|
3185
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3186
|
+
return new Proxy(db, {
|
|
3187
|
+
get(_target, prop, receiver) {
|
|
3188
|
+
const activeState = ttx.state;
|
|
3189
|
+
if (Guards49.isDefined(activeState)) {
|
|
3190
|
+
if (prop === "transaction") {
|
|
3191
|
+
return activeState.transaction.bind(activeState);
|
|
3192
|
+
}
|
|
3193
|
+
return Reflect.get(activeState, prop, receiver);
|
|
3194
|
+
}
|
|
3195
|
+
return Reflect.get(db, prop, receiver);
|
|
3196
|
+
}
|
|
3197
|
+
});
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
};
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3203
|
+
|
|
3204
|
+
// src/infrastructure/http/base.http-adapter.ts
|
|
3205
|
+
var import_shared60, BaseHttpAdapter;
|
|
3206
|
+
var init_base_http_adapter = __esm({
|
|
3207
|
+
"src/infrastructure/http/base.http-adapter.ts"() {
|
|
3208
|
+
"use strict";
|
|
3209
|
+
import_shared60 = require("@xeno-js/shared");
|
|
3210
|
+
BaseHttpAdapter = class {
|
|
3211
|
+
/**
|
|
3212
|
+
* @description Parse the URL from the request.
|
|
3213
|
+
* @param rawUrl The raw URL.
|
|
3214
|
+
* @param headers The headers.
|
|
3215
|
+
* @param queryParams The query parameters.
|
|
3216
|
+
* @returns The parsed URL.
|
|
3217
|
+
*/
|
|
3218
|
+
parseUrl(rawUrl = "/", headers, queryParams) {
|
|
3219
|
+
const protocol = import_shared60.StringHelper.getSingleValue(headers["x-forwarded-proto"]) ?? "https";
|
|
3220
|
+
const host = import_shared60.StringHelper.safeStringify(headers["host"]) ?? "localhost";
|
|
3221
|
+
const cleanHost = host.replace(/['"]/g, "");
|
|
3222
|
+
const url = new URL(rawUrl, `${protocol}://${cleanHost}`);
|
|
3223
|
+
if (!import_shared60.Guards.isNullOrEmpty(queryParams)) {
|
|
3224
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
3225
|
+
if (import_shared60.Guards.isArray(value)) {
|
|
3226
|
+
value.forEach((v) => url.searchParams.append(key, String(v)));
|
|
3227
|
+
} else if (import_shared60.Guards.isDefined(value)) {
|
|
3228
|
+
url.searchParams.set(key, String(value));
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
return url;
|
|
3233
|
+
}
|
|
3234
|
+
/**
|
|
3235
|
+
* @description Parses the headers.
|
|
3236
|
+
* @param rawHeaders The raw headers.
|
|
3237
|
+
* @returns The parsed headers.
|
|
3238
|
+
*/
|
|
3239
|
+
parseHeaders(rawHeaders) {
|
|
3240
|
+
const headers = new Headers();
|
|
3241
|
+
for (const [key, value] of Object.entries(rawHeaders)) {
|
|
3242
|
+
if (import_shared60.Guards.isDefined(value)) {
|
|
3243
|
+
if (import_shared60.Guards.isArray(value)) {
|
|
3244
|
+
value.forEach((v) => headers.append(key, String(v)));
|
|
3245
|
+
} else {
|
|
3246
|
+
headers.set(key, String(value));
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
return headers;
|
|
3251
|
+
}
|
|
3252
|
+
/**
|
|
3253
|
+
* @description Parses the body.
|
|
3254
|
+
* @param method The method.
|
|
3255
|
+
* @param rawBody The raw body.
|
|
3256
|
+
* @returns The parsed body.
|
|
3257
|
+
*/
|
|
3258
|
+
parseBody(method, rawBody) {
|
|
3259
|
+
if (!import_shared60.Guards.isDefined(method) || !["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase()) || !import_shared60.Guards.isDefined(rawBody))
|
|
3260
|
+
return void 0;
|
|
3261
|
+
if (import_shared60.Guards.isObject(rawBody)) return JSON.stringify(rawBody);
|
|
3262
|
+
if (import_shared60.Guards.isString(rawBody) || rawBody instanceof Blob || rawBody instanceof ArrayBuffer || ArrayBuffer.isView(rawBody) || rawBody instanceof URLSearchParams || rawBody instanceof FormData)
|
|
3263
|
+
return rawBody;
|
|
3264
|
+
return String(rawBody);
|
|
3265
|
+
}
|
|
3266
|
+
/**
|
|
3267
|
+
* @description Creates the XenoWebTransport.
|
|
3268
|
+
* @param url The url.
|
|
3269
|
+
* @param method The method.
|
|
3270
|
+
* @param headers The headers.
|
|
3271
|
+
* @param body The body.
|
|
3272
|
+
* @returns The XenoWebTransport.
|
|
3273
|
+
*/
|
|
3274
|
+
createXenoWebTransport(url, method = "GET", headers, body = void 0) {
|
|
3275
|
+
const init2 = {
|
|
3276
|
+
method: method.toUpperCase(),
|
|
3277
|
+
headers
|
|
3278
|
+
};
|
|
3279
|
+
const parsedBody = this.parseBody(method, body);
|
|
3280
|
+
if (import_shared60.Guards.isDefined(parsedBody)) {
|
|
3281
|
+
init2.body = parsedBody;
|
|
3282
|
+
init2.duplex = "half";
|
|
3283
|
+
}
|
|
3284
|
+
return {
|
|
3285
|
+
request: {
|
|
3286
|
+
...new Request(url, init2),
|
|
3287
|
+
path: url.pathname
|
|
3288
|
+
},
|
|
3289
|
+
response: new Response()
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
});
|
|
3295
|
+
|
|
3296
|
+
// src/infrastructure/http/fastify.http-adapter.ts
|
|
3297
|
+
var FastifyHttpAdapter;
|
|
3298
|
+
var init_fastify_http_adapter = __esm({
|
|
3299
|
+
"src/infrastructure/http/fastify.http-adapter.ts"() {
|
|
3300
|
+
"use strict";
|
|
3301
|
+
init_base_http_adapter();
|
|
3302
|
+
FastifyHttpAdapter = class extends BaseHttpAdapter {
|
|
3303
|
+
adapt(req, _res) {
|
|
3304
|
+
const headers = this.parseHeaders(req.headers);
|
|
3305
|
+
const url = this.parseUrl(req.url, req.headers, req.query);
|
|
3306
|
+
const body = req.body;
|
|
3307
|
+
return this.createXenoWebTransport(url, req.method, headers, body);
|
|
3308
|
+
}
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
});
|
|
3312
|
+
|
|
3313
|
+
// src/infrastructure/http/native.http-adapter.ts
|
|
3314
|
+
var NativeHttpAdapter;
|
|
3315
|
+
var init_native_http_adapter = __esm({
|
|
3316
|
+
"src/infrastructure/http/native.http-adapter.ts"() {
|
|
3317
|
+
"use strict";
|
|
3318
|
+
init_base_http_adapter();
|
|
3319
|
+
NativeHttpAdapter = class extends BaseHttpAdapter {
|
|
3320
|
+
adapt(req, res) {
|
|
3321
|
+
return {
|
|
3322
|
+
request: {
|
|
3323
|
+
...req,
|
|
3324
|
+
path: new URL(req.url).pathname
|
|
3325
|
+
},
|
|
3326
|
+
response: res
|
|
3327
|
+
};
|
|
3328
|
+
}
|
|
3329
|
+
};
|
|
3330
|
+
}
|
|
3331
|
+
});
|
|
3332
|
+
|
|
3333
|
+
// src/infrastructure/http/vercel.http-adapter.ts
|
|
3334
|
+
var VercelHttpAdapter;
|
|
3335
|
+
var init_vercel_http_adapter = __esm({
|
|
3336
|
+
"src/infrastructure/http/vercel.http-adapter.ts"() {
|
|
3337
|
+
"use strict";
|
|
3338
|
+
init_base_http_adapter();
|
|
3339
|
+
VercelHttpAdapter = class extends BaseHttpAdapter {
|
|
3340
|
+
adapt(req, _res) {
|
|
3341
|
+
const headers = this.parseHeaders(req.headers);
|
|
3342
|
+
const url = this.parseUrl(req.url, req.headers, req.query);
|
|
3343
|
+
return this.createXenoWebTransport(url, req.method, headers, req.body);
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
});
|
|
3348
|
+
|
|
3349
|
+
// src/infrastructure/http/index.ts
|
|
3350
|
+
var http_exports = {};
|
|
3351
|
+
__export(http_exports, {
|
|
3352
|
+
BaseHttpAdapter: () => BaseHttpAdapter,
|
|
3353
|
+
FastifyHttpAdapter: () => FastifyHttpAdapter,
|
|
3354
|
+
NativeHttpAdapter: () => NativeHttpAdapter,
|
|
3355
|
+
VercelHttpAdapter: () => VercelHttpAdapter
|
|
3356
|
+
});
|
|
3357
|
+
var init_http = __esm({
|
|
3358
|
+
"src/infrastructure/http/index.ts"() {
|
|
3359
|
+
"use strict";
|
|
3360
|
+
init_base_http_adapter();
|
|
3361
|
+
init_fastify_http_adapter();
|
|
3362
|
+
init_native_http_adapter();
|
|
3363
|
+
init_vercel_http_adapter();
|
|
3364
|
+
}
|
|
3365
|
+
});
|
|
3366
|
+
|
|
3367
|
+
// src/infrastructure/modules/http-adapter.module.ts
|
|
3368
|
+
var import_shared61, HttpAdapterModule;
|
|
3369
|
+
var init_http_adapter_module = __esm({
|
|
3370
|
+
"src/infrastructure/modules/http-adapter.module.ts"() {
|
|
3371
|
+
"use strict";
|
|
3372
|
+
import_shared61 = require("@xeno-js/shared");
|
|
3373
|
+
HttpAdapterModule = class {
|
|
3374
|
+
async configure(container, opts) {
|
|
3375
|
+
const adapter = await this._getAdapter(opts);
|
|
3376
|
+
container.addSingleton("HTTP_ADAPTER", () => adapter);
|
|
3377
|
+
}
|
|
3378
|
+
async _getAdapter(opts) {
|
|
3379
|
+
if (opts.vercel) {
|
|
3380
|
+
const { VercelHttpAdapter: VercelHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3381
|
+
return new VercelHttpAdapter2();
|
|
3382
|
+
} else if (opts.fastify) {
|
|
3383
|
+
const { FastifyHttpAdapter: FastifyHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3384
|
+
return new FastifyHttpAdapter2();
|
|
3385
|
+
} else if (import_shared61.Guards.isDefined(opts.custom)) {
|
|
3386
|
+
return opts.custom();
|
|
3387
|
+
} else {
|
|
3388
|
+
const { NativeHttpAdapter: NativeHttpAdapter2 } = await Promise.resolve().then(() => (init_http(), http_exports));
|
|
3389
|
+
return new NativeHttpAdapter2();
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
};
|
|
3393
|
+
}
|
|
3394
|
+
});
|
|
3395
|
+
|
|
3396
|
+
// src/infrastructure/modules/utils/http.utils.ts
|
|
3397
|
+
var http_utils_exports = {};
|
|
3398
|
+
__export(http_utils_exports, {
|
|
3399
|
+
HttpUtils: () => HttpUtils
|
|
3400
|
+
});
|
|
3401
|
+
var HttpUtils;
|
|
3402
|
+
var init_http_utils = __esm({
|
|
3403
|
+
"src/infrastructure/modules/utils/http.utils.ts"() {
|
|
3404
|
+
"use strict";
|
|
3405
|
+
HttpUtils = Object.freeze({
|
|
3406
|
+
/**
|
|
3407
|
+
* @description Utility function to create a query string from an object of query parameters. It takes an object where the keys are the parameter names and the values are the parameter values, and returns a properly encoded query string that can be appended to a URL for making HTTP requests.
|
|
3408
|
+
* @param params - An object containing the query parameters as key-value pairs. The keys represent the parameter names, and the values represent the parameter values.
|
|
3409
|
+
* @returns A string representing the encoded query string that can be appended to a URL for making HTTP requests.
|
|
3410
|
+
*
|
|
3411
|
+
* @author Xeno
|
|
3412
|
+
* @version 1.0.0
|
|
3413
|
+
* @since 2025-09-30
|
|
3414
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3415
|
+
*/
|
|
3416
|
+
async addAxios(container, opts) {
|
|
3417
|
+
const { NodeAxiosFactory: NodeAxiosFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3418
|
+
const { Guards: Guards49 } = await import("@xeno-js/shared");
|
|
3419
|
+
if (!Guards49.isDefined(opts.token)) {
|
|
3420
|
+
throw new Error("HttpConfig.token is required and must be defined.");
|
|
3421
|
+
}
|
|
3422
|
+
container.addSingleton(opts.token, () => {
|
|
3423
|
+
const factory = new NodeAxiosFactory2();
|
|
3424
|
+
const instance = factory.create(opts.client);
|
|
3425
|
+
if (!Guards49.hasMethod(instance, "get") || !Guards49.hasMethod(instance, "post") || !Guards49.hasMethod(instance, "put") || !Guards49.hasMethod(instance, "patch") || !Guards49.hasMethod(instance, "delete")) {
|
|
3426
|
+
throw new Error(
|
|
3427
|
+
"The created HTTP client instance does not implement the required methods of IHttpClient."
|
|
3428
|
+
);
|
|
3429
|
+
}
|
|
3430
|
+
return instance;
|
|
3431
|
+
});
|
|
3432
|
+
},
|
|
3433
|
+
/**
|
|
3434
|
+
* @description Utility function to add resilience features to the service container. It takes a ResilienceConfig object that specifies whether resilience features are enabled and provides the necessary settings for implementing resilience strategies such as retries, circuit breakers, and timeouts. If resilience is enabled, it registers a singleton factory in the service container that creates an instance of the resilience client based on the provided configuration.
|
|
3435
|
+
* @param container - The service container to register the resilience client with.
|
|
3436
|
+
* @param opts - The ResilienceConfig options that determine whether resilience features are enabled and provide the necessary settings for implementing resilience strategies.
|
|
3437
|
+
*
|
|
3438
|
+
* @author Xeno
|
|
3439
|
+
* @version 1.0.0
|
|
3440
|
+
* @since 2025-09-30
|
|
3441
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
3442
|
+
*/
|
|
3443
|
+
async addResilience(container, opts) {
|
|
3444
|
+
const { TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
3445
|
+
const { CockatielResilienceFactory: CockatielResilienceFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
3446
|
+
container.addSingleton(TOKENS5.RESILIENCE_CLIENT, () => {
|
|
3447
|
+
const factory = new CockatielResilienceFactory2();
|
|
3448
|
+
return factory.create(opts);
|
|
3418
3449
|
});
|
|
3419
3450
|
}
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
});
|
|
3454
|
+
|
|
3455
|
+
// src/infrastructure/modules/http-core.module.ts
|
|
3456
|
+
var http_core_module_exports = {};
|
|
3457
|
+
__export(http_core_module_exports, {
|
|
3458
|
+
HttpCoreModule: () => HttpCoreModule
|
|
3459
|
+
});
|
|
3460
|
+
var HttpCoreModule;
|
|
3461
|
+
var init_http_core_module = __esm({
|
|
3462
|
+
"src/infrastructure/modules/http-core.module.ts"() {
|
|
3463
|
+
"use strict";
|
|
3464
|
+
HttpCoreModule = class {
|
|
3465
|
+
async configure(container, opts) {
|
|
3466
|
+
const { HttpUtils: HttpUtils2 } = await Promise.resolve().then(() => (init_http_utils(), http_utils_exports));
|
|
3467
|
+
await HttpUtils2.addAxios(container, opts.http);
|
|
3468
|
+
await HttpUtils2.addResilience(container, opts.resilience);
|
|
3469
|
+
}
|
|
3420
3470
|
};
|
|
3421
3471
|
}
|
|
3422
3472
|
});
|
|
@@ -4149,12 +4199,34 @@ var init_presentation = __esm({
|
|
|
4149
4199
|
}
|
|
4150
4200
|
});
|
|
4151
4201
|
|
|
4202
|
+
// src/infrastructure/cache/inmemory.cache.ts
|
|
4203
|
+
var inmemory_cache_exports = {};
|
|
4204
|
+
__export(inmemory_cache_exports, {
|
|
4205
|
+
InMemoryCacheExtended: () => InMemoryCacheExtended
|
|
4206
|
+
});
|
|
4207
|
+
var import_shared73, InMemoryCacheExtended;
|
|
4208
|
+
var init_inmemory_cache = __esm({
|
|
4209
|
+
"src/infrastructure/cache/inmemory.cache.ts"() {
|
|
4210
|
+
"use strict";
|
|
4211
|
+
import_shared73 = require("@xeno-js/shared");
|
|
4212
|
+
InMemoryCacheExtended = class extends import_shared73.InMemoryCache {
|
|
4213
|
+
async increment(key, ttlSeconds) {
|
|
4214
|
+
const current = await this.get(key) ?? 0;
|
|
4215
|
+
const next = Number(current) + 1;
|
|
4216
|
+
const ttl = import_shared73.Guards.isDefined(ttlSeconds) ? Number(ttlSeconds) : 60;
|
|
4217
|
+
await this.set(key, next, ttl);
|
|
4218
|
+
return next;
|
|
4219
|
+
}
|
|
4220
|
+
};
|
|
4221
|
+
}
|
|
4222
|
+
});
|
|
4223
|
+
|
|
4152
4224
|
// src/infrastructure/cache/rate-limit-key-builder.cache.ts
|
|
4153
|
-
var
|
|
4225
|
+
var import_shared74, RateLimitKeyBuilder;
|
|
4154
4226
|
var init_rate_limit_key_builder_cache = __esm({
|
|
4155
4227
|
"src/infrastructure/cache/rate-limit-key-builder.cache.ts"() {
|
|
4156
4228
|
"use strict";
|
|
4157
|
-
|
|
4229
|
+
import_shared74 = require("@xeno-js/shared");
|
|
4158
4230
|
RateLimitKeyBuilder = class {
|
|
4159
4231
|
constructor(_contextAccessor) {
|
|
4160
4232
|
this._contextAccessor = _contextAccessor;
|
|
@@ -4165,12 +4237,12 @@ var init_rate_limit_key_builder_cache = __esm({
|
|
|
4165
4237
|
const tenantId = ctx?.identity?.tenantId;
|
|
4166
4238
|
const userId = ctx?.identity?.userId;
|
|
4167
4239
|
const clientIp = ctx?.network?.clientIp;
|
|
4168
|
-
if (!
|
|
4240
|
+
if (!import_shared74.Guards.isNullOrEmpty(tenantId) && !import_shared74.Guards.isNullOrEmpty(userId))
|
|
4169
4241
|
return `ratelimit:tenant:${tenantId}:user:${userId}:${resource}`;
|
|
4170
|
-
if (!
|
|
4242
|
+
if (!import_shared74.Guards.isNullOrEmpty(tenantId) && !import_shared74.Guards.isNullOrEmpty(clientIp))
|
|
4171
4243
|
return `ratelimit:tenant:${tenantId}:ip:${clientIp}:${resource}`;
|
|
4172
|
-
if (!
|
|
4173
|
-
if (!
|
|
4244
|
+
if (!import_shared74.Guards.isNullOrEmpty(userId)) return `ratelimit:user:${userId}:${resource}`;
|
|
4245
|
+
if (!import_shared74.Guards.isNullOrEmpty(clientIp)) return `ratelimit:ip:${clientIp}:${resource}`;
|
|
4174
4246
|
return void 0;
|
|
4175
4247
|
}
|
|
4176
4248
|
};
|
|
@@ -4204,7 +4276,7 @@ var init_middleware_module = __esm({
|
|
|
4204
4276
|
"use strict";
|
|
4205
4277
|
MiddlewareModule = class {
|
|
4206
4278
|
async configure(container, opts) {
|
|
4207
|
-
const { Guards:
|
|
4279
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4208
4280
|
const { HttpCookieExtractor: HttpCookieExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4209
4281
|
const { HttpHeaderExtractor: HttpHeaderExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4210
4282
|
const tokenExtractor = await this._getTokenExtractor(
|
|
@@ -4234,7 +4306,7 @@ var init_middleware_module = __esm({
|
|
|
4234
4306
|
logger
|
|
4235
4307
|
)
|
|
4236
4308
|
);
|
|
4237
|
-
if (!
|
|
4309
|
+
if (!Guards49.isNullOrEmpty(opts.allowOrigins)) {
|
|
4238
4310
|
if (opts.withCredentials && opts.allowOrigins.includes("*"))
|
|
4239
4311
|
throw new Error(
|
|
4240
4312
|
"Wildcard CORS origin is not allowed when withCredentials is set to true in addHttpCore"
|
|
@@ -4260,7 +4332,7 @@ var init_middleware_module = __esm({
|
|
|
4260
4332
|
const { CORSMiddleware: CORSMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4261
4333
|
middlewares.push(new CORSMiddleware2(requestContext, withCredentials));
|
|
4262
4334
|
}
|
|
4263
|
-
if (
|
|
4335
|
+
if (Guards49.isDefined(opts.routeRegistry)) {
|
|
4264
4336
|
const { MethodCheckMiddleware: MethodCheckMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4265
4337
|
middlewares.push(new MethodCheckMiddleware2(requestContext, allowMethod));
|
|
4266
4338
|
}
|
|
@@ -4287,13 +4359,13 @@ var init_middleware_module = __esm({
|
|
|
4287
4359
|
)
|
|
4288
4360
|
);
|
|
4289
4361
|
}
|
|
4290
|
-
if (
|
|
4362
|
+
if (Guards49.isDefined(opts.rateLimite.maxRequests) || Guards49.isDefined(opts.rateLimite.windowSeconds)) {
|
|
4291
4363
|
const maxRequests = opts.rateLimite.maxRequests ?? 30;
|
|
4292
|
-
|
|
4293
|
-
|
|
4364
|
+
Guards49.throwIfNegative(maxRequests, "MaxRequests must be positive");
|
|
4365
|
+
Guards49.throwIfNotInteger(maxRequests, "MaxRequests must be an integer");
|
|
4294
4366
|
const windowSeconds = opts.rateLimite.windowSeconds ?? 30;
|
|
4295
|
-
|
|
4296
|
-
|
|
4367
|
+
Guards49.throwIfNegative(windowSeconds, "WindowSeconds must be positive");
|
|
4368
|
+
Guards49.throwIfNotInteger(windowSeconds, "WindowSeconds must be an integer");
|
|
4297
4369
|
const { RateLimitKeyBuilder: RateLimitKeyBuilder2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
4298
4370
|
const { RateLimitMiddleware: RateLimitMiddleware2 } = await Promise.resolve().then(() => (init_presentation(), presentation_exports));
|
|
4299
4371
|
middlewares.push(
|
|
@@ -4306,7 +4378,7 @@ var init_middleware_module = __esm({
|
|
|
4306
4378
|
)
|
|
4307
4379
|
);
|
|
4308
4380
|
}
|
|
4309
|
-
if (
|
|
4381
|
+
if (Guards49.isDefined(opts.csrf)) {
|
|
4310
4382
|
const csrf = opts.csrf;
|
|
4311
4383
|
const { EdgeCryptoService: EdgeCryptoService2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4312
4384
|
container.addSingleton("CRYPTO_SERVICE", () => new EdgeCryptoService2());
|
|
@@ -4331,8 +4403,8 @@ var init_middleware_module = __esm({
|
|
|
4331
4403
|
});
|
|
4332
4404
|
}
|
|
4333
4405
|
async _getTokenExtractor(isSSR, cookieName, customTokenExtractor) {
|
|
4334
|
-
const { Guards:
|
|
4335
|
-
if (
|
|
4406
|
+
const { Guards: Guards49 } = await import("@xeno-js/shared");
|
|
4407
|
+
if (Guards49.isDefined(customTokenExtractor)) return customTokenExtractor();
|
|
4336
4408
|
if (isSSR) {
|
|
4337
4409
|
const { SupabaseSsrTokenExtractor: SupabaseSsrTokenExtractor2 } = await Promise.resolve().then(() => (init_services(), services_exports));
|
|
4338
4410
|
return new SupabaseSsrTokenExtractor2();
|
|
@@ -4342,8 +4414,8 @@ var init_middleware_module = __esm({
|
|
|
4342
4414
|
}
|
|
4343
4415
|
}
|
|
4344
4416
|
async _getAllowMethod(configure, opts) {
|
|
4345
|
-
const { Guards:
|
|
4346
|
-
if (!configure || !
|
|
4417
|
+
const { Guards: Guards49 } = await import("@xeno-js/shared");
|
|
4418
|
+
if (!configure || !Guards49.isDefined(opts)) return void 0;
|
|
4347
4419
|
const { AllowMethodFactory: AllowMethodFactory2 } = await Promise.resolve().then(() => (init_factories(), factories_exports));
|
|
4348
4420
|
return new AllowMethodFactory2().create(opts);
|
|
4349
4421
|
}
|
|
@@ -4351,37 +4423,203 @@ var init_middleware_module = __esm({
|
|
|
4351
4423
|
}
|
|
4352
4424
|
});
|
|
4353
4425
|
|
|
4354
|
-
// src/infrastructure/modules/
|
|
4355
|
-
var
|
|
4356
|
-
__export(
|
|
4357
|
-
|
|
4426
|
+
// src/infrastructure/modules/utils/cache.utils.ts
|
|
4427
|
+
var cache_utils_exports = {};
|
|
4428
|
+
__export(cache_utils_exports, {
|
|
4429
|
+
CacheUtils: () => CacheUtils
|
|
4358
4430
|
});
|
|
4359
|
-
var
|
|
4360
|
-
var
|
|
4361
|
-
"src/infrastructure/modules/
|
|
4431
|
+
var CacheUtils;
|
|
4432
|
+
var init_cache_utils = __esm({
|
|
4433
|
+
"src/infrastructure/modules/utils/cache.utils.ts"() {
|
|
4362
4434
|
"use strict";
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
const {
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4435
|
+
CacheUtils = Object.freeze({
|
|
4436
|
+
/**
|
|
4437
|
+
* @description Checks if the provided cache configuration requires any cache strategies.
|
|
4438
|
+
* @param container The service container to which the cache strategies will be added.
|
|
4439
|
+
* @param opts The cache configuration options.
|
|
4440
|
+
* @returns True if any cache strategies are required, false otherwise.
|
|
4441
|
+
*
|
|
4442
|
+
* @author Xeno
|
|
4443
|
+
* @version 1.0.0
|
|
4444
|
+
* @since 2025-09-30
|
|
4445
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4446
|
+
*/
|
|
4447
|
+
async addCache(container, opts) {
|
|
4448
|
+
const { Guards: Guards49, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4449
|
+
if (!opts.inMemory && !Guards49.isDefined(opts.redis)) {
|
|
4450
|
+
throw new Error(
|
|
4451
|
+
"No cache strategies are configured. Please provide at least one cache strategy."
|
|
4452
|
+
);
|
|
4453
|
+
}
|
|
4454
|
+
const { CacheKeyBuilder } = await import("@xeno-js/shared");
|
|
4455
|
+
container.addSingleton(
|
|
4456
|
+
TOKENS5.CACHE_KEY_BUILDER,
|
|
4457
|
+
(c) => new CacheKeyBuilder(c.resolve(TOKENS5.IDENTITY_ACCESSOR))
|
|
4458
|
+
);
|
|
4459
|
+
if (opts.inMemory || !Guards49.isDefined(opts.redis)) {
|
|
4460
|
+
const { InMemoryCacheExtended: InMemoryCacheExtended2 } = await Promise.resolve().then(() => (init_inmemory_cache(), inmemory_cache_exports));
|
|
4461
|
+
container.addSingleton(TOKENS5.CACHE, () => new InMemoryCacheExtended2());
|
|
4462
|
+
return;
|
|
4463
|
+
}
|
|
4464
|
+
if (Guards49.isDefined(opts.redis)) {
|
|
4465
|
+
const { RedisCacheFactory: RedisCacheFactory2 } = await Promise.resolve().then(() => (init_redis_cache_factory(), redis_cache_factory_exports));
|
|
4466
|
+
container.addSingleton(TOKENS5.CACHE, () => {
|
|
4467
|
+
const config = opts.redis;
|
|
4468
|
+
return new RedisCacheFactory2().create(config);
|
|
4469
|
+
});
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
});
|
|
4473
|
+
}
|
|
4474
|
+
});
|
|
4475
|
+
|
|
4476
|
+
// src/infrastructure/loggers/console.logger.ts
|
|
4477
|
+
var console_logger_exports = {};
|
|
4478
|
+
__export(console_logger_exports, {
|
|
4479
|
+
ConsoleLogger: () => ConsoleLogger
|
|
4480
|
+
});
|
|
4481
|
+
var import_shared75, ConsoleLogger;
|
|
4482
|
+
var init_console_logger = __esm({
|
|
4483
|
+
"src/infrastructure/loggers/console.logger.ts"() {
|
|
4484
|
+
"use strict";
|
|
4485
|
+
import_shared75 = require("@xeno-js/shared");
|
|
4486
|
+
ConsoleLogger = class {
|
|
4487
|
+
/**
|
|
4488
|
+
* 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.
|
|
4489
|
+
* @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.
|
|
4490
|
+
|
|
4491
|
+
*
|
|
4492
|
+
* @author Xeno
|
|
4493
|
+
* @version 1.0.0
|
|
4494
|
+
* @since 2025-09-30
|
|
4495
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4496
|
+
*/
|
|
4497
|
+
constructor(_minLevel = import_shared75.LOG_LEVEL.DEBUG) {
|
|
4498
|
+
this._minLevel = _minLevel;
|
|
4499
|
+
}
|
|
4500
|
+
_minLevel;
|
|
4501
|
+
track(level, message, context, error = void 0) {
|
|
4502
|
+
if (level < this._minLevel) return;
|
|
4503
|
+
const logMessage = `[${level}] ${message}`;
|
|
4504
|
+
const payload = import_shared75.Guards.isDefined(error) ? { ...context, error } : context;
|
|
4505
|
+
switch (level) {
|
|
4506
|
+
case import_shared75.LOG_LEVEL.ERROR:
|
|
4507
|
+
console.error(logMessage, payload ?? {});
|
|
4508
|
+
break;
|
|
4509
|
+
case import_shared75.LOG_LEVEL.WARN:
|
|
4510
|
+
console.warn(logMessage, payload ?? {});
|
|
4511
|
+
break;
|
|
4512
|
+
case import_shared75.LOG_LEVEL.DEBUG:
|
|
4513
|
+
console.debug(logMessage, payload ?? {});
|
|
4514
|
+
break;
|
|
4515
|
+
default:
|
|
4516
|
+
console.info(logMessage, payload ?? {});
|
|
4517
|
+
break;
|
|
4518
|
+
}
|
|
4380
4519
|
}
|
|
4381
4520
|
};
|
|
4382
4521
|
}
|
|
4383
4522
|
});
|
|
4384
4523
|
|
|
4524
|
+
// src/infrastructure/modules/utils/logger.utils.ts
|
|
4525
|
+
var logger_utils_exports = {};
|
|
4526
|
+
__export(logger_utils_exports, {
|
|
4527
|
+
LoggerUtils: () => LoggerUtils
|
|
4528
|
+
});
|
|
4529
|
+
var LoggerUtils;
|
|
4530
|
+
var init_logger_utils = __esm({
|
|
4531
|
+
"src/infrastructure/modules/utils/logger.utils.ts"() {
|
|
4532
|
+
"use strict";
|
|
4533
|
+
LoggerUtils = Object.freeze({
|
|
4534
|
+
/**
|
|
4535
|
+
* @description Configures and registers the logging services in the dependency injection container based on the provided LoggerConfig options. It dynamically imports the necessary logger implementations (e.g., ConsoleLogger, SentryLogger, PinoLogger) and registers them with the container, allowing for flexible and modular logging configuration in the application.
|
|
4536
|
+
*
|
|
4537
|
+
* @param container - The service container to register logging services with.
|
|
4538
|
+
* @param opts - The LoggerConfig options to determine which loggers to enable and their configurations.
|
|
4539
|
+
|
|
4540
|
+
*
|
|
4541
|
+
* @author Xeno
|
|
4542
|
+
* @version 1.0.0
|
|
4543
|
+
* @since 2025-09-30
|
|
4544
|
+
* @link https://github.com/xeno-js/xeno-js
|
|
4545
|
+
*/
|
|
4546
|
+
async addLogger(container, opts) {
|
|
4547
|
+
const loggerDependencies = [];
|
|
4548
|
+
const { Guards: Guards49, LOG_LEVEL: LOG_LEVEL7, TOKENS: TOKENS5 } = await import("@xeno-js/shared");
|
|
4549
|
+
if (!Guards49.isDefined(opts) || opts.console) {
|
|
4550
|
+
const { ConsoleLogger: ConsoleLogger2 } = await Promise.resolve().then(() => (init_console_logger(), console_logger_exports));
|
|
4551
|
+
loggerDependencies.push(new ConsoleLogger2(opts?.level));
|
|
4552
|
+
}
|
|
4553
|
+
if (Guards49.isDefined(opts)) {
|
|
4554
|
+
if (Guards49.isDefined(opts.sentry.config)) {
|
|
4555
|
+
const { SentryLoggerFactory: SentryLoggerFactory2 } = await Promise.resolve().then(() => (init_sentry_logger_factory(), sentry_logger_factory_exports));
|
|
4556
|
+
loggerDependencies.push(new SentryLoggerFactory2().create(opts));
|
|
4557
|
+
}
|
|
4558
|
+
if (Guards49.isDefined(opts.pino.config)) {
|
|
4559
|
+
const { PinoLoggerFactory: PinoLoggerFactory2 } = await Promise.resolve().then(() => (init_pino_logger_factory(), pino_logger_factory_exports));
|
|
4560
|
+
loggerDependencies.push(new PinoLoggerFactory2().create(opts));
|
|
4561
|
+
}
|
|
4562
|
+
if (!Guards49.isNullOrEmpty(opts.customLoggers)) {
|
|
4563
|
+
const customLoggers = opts.customLoggers;
|
|
4564
|
+
customLoggers.forEach((fn) => {
|
|
4565
|
+
if (Guards49.isDefined(fn)) loggerDependencies.push(fn(container));
|
|
4566
|
+
});
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
const { BaseLogger } = await import("@xeno-js/shared");
|
|
4570
|
+
container.addSingleton(TOKENS5.LOGGER, (c) => {
|
|
4571
|
+
const context = c.resolve(TOKENS5.CONTEXT_ACCESSOR);
|
|
4572
|
+
return new BaseLogger(context, opts?.level ?? LOG_LEVEL7.DEBUG, loggerDependencies);
|
|
4573
|
+
});
|
|
4574
|
+
}
|
|
4575
|
+
});
|
|
4576
|
+
}
|
|
4577
|
+
});
|
|
4578
|
+
|
|
4579
|
+
// src/infrastructure/modules/utils/index.ts
|
|
4580
|
+
var init_utils2 = __esm({
|
|
4581
|
+
"src/infrastructure/modules/utils/index.ts"() {
|
|
4582
|
+
"use strict";
|
|
4583
|
+
init_auth_utils();
|
|
4584
|
+
init_cache_utils();
|
|
4585
|
+
init_db_utils();
|
|
4586
|
+
init_http_utils();
|
|
4587
|
+
init_logger_utils();
|
|
4588
|
+
init_pipeline_utils();
|
|
4589
|
+
init_validation_utils();
|
|
4590
|
+
}
|
|
4591
|
+
});
|
|
4592
|
+
|
|
4593
|
+
// src/infrastructure/modules/index.ts
|
|
4594
|
+
var modules_exports = {};
|
|
4595
|
+
__export(modules_exports, {
|
|
4596
|
+
AuthUtils: () => AuthUtils,
|
|
4597
|
+
CacheUtils: () => CacheUtils,
|
|
4598
|
+
ContextModule: () => ContextModule,
|
|
4599
|
+
CqrsModule: () => CqrsModule,
|
|
4600
|
+
DbModule: () => DbModule,
|
|
4601
|
+
DbUtils: () => DbUtils,
|
|
4602
|
+
HttpAdapterModule: () => HttpAdapterModule,
|
|
4603
|
+
HttpCoreModule: () => HttpCoreModule,
|
|
4604
|
+
HttpUtils: () => HttpUtils,
|
|
4605
|
+
LoggerUtils: () => LoggerUtils,
|
|
4606
|
+
MiddlewareModule: () => MiddlewareModule,
|
|
4607
|
+
PipelineUtils: () => PipelineUtils,
|
|
4608
|
+
ValidationUtils: () => ValidationUtils
|
|
4609
|
+
});
|
|
4610
|
+
var init_modules = __esm({
|
|
4611
|
+
"src/infrastructure/modules/index.ts"() {
|
|
4612
|
+
"use strict";
|
|
4613
|
+
init_context_module();
|
|
4614
|
+
init_cqrs_module();
|
|
4615
|
+
init_db_module();
|
|
4616
|
+
init_http_adapter_module();
|
|
4617
|
+
init_http_core_module();
|
|
4618
|
+
init_middleware_module();
|
|
4619
|
+
init_utils2();
|
|
4620
|
+
}
|
|
4621
|
+
});
|
|
4622
|
+
|
|
4385
4623
|
// src/index.ts
|
|
4386
4624
|
var index_exports = {};
|
|
4387
4625
|
__export(index_exports, {
|
|
@@ -4390,7 +4628,7 @@ __export(index_exports, {
|
|
|
4390
4628
|
BaseController: () => BaseController,
|
|
4391
4629
|
BaseHandler: () => BaseHandler,
|
|
4392
4630
|
BasePostgresSqlDataSource: () => BasePostgresSqlDataSource,
|
|
4393
|
-
BaseQuery: () =>
|
|
4631
|
+
BaseQuery: () => import_shared82.Query,
|
|
4394
4632
|
BaseSqliteSqlDataSource: () => BaseSqliteSqlDataSource,
|
|
4395
4633
|
ContainerUtils: () => ContainerUtils,
|
|
4396
4634
|
ReadDao: () => ReadDao,
|
|
@@ -4402,7 +4640,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
4402
4640
|
init_application();
|
|
4403
4641
|
|
|
4404
4642
|
// src/infrastructure/builder/app.builder.ts
|
|
4405
|
-
var
|
|
4643
|
+
var import_shared76 = require("@xeno-js/shared");
|
|
4406
4644
|
|
|
4407
4645
|
// src/infrastructure/configuration/configuration.ts
|
|
4408
4646
|
var import_shared32 = require("@xeno-js/shared");
|
|
@@ -4681,10 +4919,10 @@ var AppBuilder = class {
|
|
|
4681
4919
|
constructor(container) {
|
|
4682
4920
|
this._container = container ?? new ServiceContainer();
|
|
4683
4921
|
this._container.addSingleton(
|
|
4684
|
-
|
|
4922
|
+
import_shared76.TOKENS.CONFIGURATION_SERVICE,
|
|
4685
4923
|
() => new EnvironmentConfigurationService()
|
|
4686
4924
|
);
|
|
4687
|
-
this._configuration = this._container.resolve(
|
|
4925
|
+
this._configuration = this._container.resolve(import_shared76.TOKENS.CONFIGURATION_SERVICE);
|
|
4688
4926
|
this._middlewareConfig.allowOrigins?.push(
|
|
4689
4927
|
this._configuration.get("APP_URL") ?? `http://localhost:${this._configuration.getNumber("PORT", 3e3)}`
|
|
4690
4928
|
);
|
|
@@ -4693,6 +4931,12 @@ var AppBuilder = class {
|
|
|
4693
4931
|
// --- Module Configurations ---
|
|
4694
4932
|
_modules = [];
|
|
4695
4933
|
// --- Specific Configurations ---
|
|
4934
|
+
_adapterConfig = {
|
|
4935
|
+
native: true,
|
|
4936
|
+
vercel: false,
|
|
4937
|
+
fastify: false,
|
|
4938
|
+
custom: void 0
|
|
4939
|
+
};
|
|
4696
4940
|
_pipelineConfig = {
|
|
4697
4941
|
performance: { thresholdMs: 500 },
|
|
4698
4942
|
authorization: {
|
|
@@ -4761,7 +5005,7 @@ var AppBuilder = class {
|
|
|
4761
5005
|
resilience: { retry: {}, circuitBreaker: {}, bulkhead: {} }
|
|
4762
5006
|
};
|
|
4763
5007
|
_loggerConfig = {
|
|
4764
|
-
level:
|
|
5008
|
+
level: import_shared76.LOG_LEVEL.DEBUG,
|
|
4765
5009
|
console: true,
|
|
4766
5010
|
sentry: { config: void 0 },
|
|
4767
5011
|
pino: { config: void 0 },
|
|
@@ -4776,9 +5020,24 @@ var AppBuilder = class {
|
|
|
4776
5020
|
_isDbContextModuleQueued = false;
|
|
4777
5021
|
_isConcurrencyServiceQueued = false;
|
|
4778
5022
|
_isCacheModuleQueued = false;
|
|
5023
|
+
_isAdapterModuleQueued = false;
|
|
4779
5024
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
4780
5025
|
// Application Modules Configuration
|
|
4781
5026
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
5027
|
+
addAdapter(setupAction) {
|
|
5028
|
+
if (this._isAdapterModuleQueued) return this;
|
|
5029
|
+
setupAction(this._adapterConfig, this._configuration);
|
|
5030
|
+
this._isAdapterModuleQueued = true;
|
|
5031
|
+
this._modules.push({
|
|
5032
|
+
priority: 50,
|
|
5033
|
+
name: "AdapterModule",
|
|
5034
|
+
action: async () => {
|
|
5035
|
+
const { HttpAdapterModule: HttpAdapterModule2 } = await Promise.resolve().then(() => (init_modules(), modules_exports));
|
|
5036
|
+
await new HttpAdapterModule2().configure(this._container, this._adapterConfig);
|
|
5037
|
+
}
|
|
5038
|
+
});
|
|
5039
|
+
return this;
|
|
5040
|
+
}
|
|
4782
5041
|
/**
|
|
4783
5042
|
* @description Enables the use of middlewares in the application. Middlewares can be used for cross-cutting concerns such as logging, authentication, and request/response manipulation.
|
|
4784
5043
|
* @returns The current instance of AppBuilder for method chaining.
|
|
@@ -4819,7 +5078,7 @@ var AppBuilder = class {
|
|
|
4819
5078
|
* @link https://github.com/xeno-js/xeno-js
|
|
4820
5079
|
*/
|
|
4821
5080
|
addLogger(setupAction) {
|
|
4822
|
-
if (
|
|
5081
|
+
if (import_shared76.Guards.isDefined(setupAction)) setupAction(this._loggerConfig, this._configuration);
|
|
4823
5082
|
if (this._isLoggerModuleQueued) return this;
|
|
4824
5083
|
this._isLoggerModuleQueued = true;
|
|
4825
5084
|
this._modules.push({
|
|
@@ -4844,7 +5103,7 @@ var AppBuilder = class {
|
|
|
4844
5103
|
* @link https://github.com/xeno-js/xeno-js
|
|
4845
5104
|
*/
|
|
4846
5105
|
addCache(setupAction) {
|
|
4847
|
-
if (
|
|
5106
|
+
if (import_shared76.Guards.isDefined(setupAction)) setupAction(this._config, this._configuration);
|
|
4848
5107
|
if (this._isCacheModuleQueued) return this;
|
|
4849
5108
|
this._isCacheModuleQueued = true;
|
|
4850
5109
|
this._modules.push({
|
|
@@ -4947,7 +5206,7 @@ var AppBuilder = class {
|
|
|
4947
5206
|
* @link https://github.com/xeno-js/xeno-js
|
|
4948
5207
|
*/
|
|
4949
5208
|
addPipeline(setupAction) {
|
|
4950
|
-
if (
|
|
5209
|
+
if (import_shared76.Guards.isDefined(setupAction)) {
|
|
4951
5210
|
setupAction(this._pipelineConfig, this._configuration);
|
|
4952
5211
|
}
|
|
4953
5212
|
this._queuePipelineModule();
|
|
@@ -5068,7 +5327,7 @@ var AppBuilder = class {
|
|
|
5068
5327
|
console.error(`\u{1F449} Module: **${queued.name}**`);
|
|
5069
5328
|
console.error(`\u{1F4DD} Reason: ${errorMessage}
|
|
5070
5329
|
`);
|
|
5071
|
-
if (error instanceof Error &&
|
|
5330
|
+
if (error instanceof Error && import_shared76.Guards.isDefined(error.stack)) {
|
|
5072
5331
|
console.error(error.stack);
|
|
5073
5332
|
}
|
|
5074
5333
|
throw new Error(`Bootstrap failed at [${queued.name}]: ${errorMessage}`, { cause: error });
|
|
@@ -5196,7 +5455,7 @@ var BaseSqliteSqlDataSource = class {
|
|
|
5196
5455
|
};
|
|
5197
5456
|
|
|
5198
5457
|
// src/infrastructure/datasources/remote.datasource.ts
|
|
5199
|
-
var
|
|
5458
|
+
var import_shared77 = require("@xeno-js/shared");
|
|
5200
5459
|
|
|
5201
5460
|
// src/infrastructure/index.ts
|
|
5202
5461
|
init_factories();
|
|
@@ -5207,25 +5466,12 @@ init_console_logger();
|
|
|
5207
5466
|
init_pino_logger();
|
|
5208
5467
|
init_sentry_logger();
|
|
5209
5468
|
|
|
5210
|
-
// src/infrastructure/
|
|
5211
|
-
|
|
5212
|
-
init_cqrs_module();
|
|
5213
|
-
init_db_module();
|
|
5214
|
-
init_http_core_module();
|
|
5215
|
-
init_middleware_module();
|
|
5216
|
-
|
|
5217
|
-
// src/infrastructure/modules/utils/index.ts
|
|
5218
|
-
init_auth_utils();
|
|
5219
|
-
init_cache_utils();
|
|
5220
|
-
init_db_utils();
|
|
5221
|
-
init_http_utils();
|
|
5222
|
-
init_logger_utils();
|
|
5223
|
-
init_pipeline_utils();
|
|
5224
|
-
init_validation_utils();
|
|
5469
|
+
// src/infrastructure/index.ts
|
|
5470
|
+
init_modules();
|
|
5225
5471
|
|
|
5226
5472
|
// src/infrastructure/repositories/read-dao.ts
|
|
5227
|
-
var
|
|
5228
|
-
var
|
|
5473
|
+
var import_shared78 = require("@xeno-js/shared");
|
|
5474
|
+
var import_shared79 = require("@xeno-js/shared");
|
|
5229
5475
|
var ReadDao = class {
|
|
5230
5476
|
/**
|
|
5231
5477
|
* Constructs a new ReadDao instance.
|
|
@@ -5245,23 +5491,23 @@ var ReadDao = class {
|
|
|
5245
5491
|
_dataSource;
|
|
5246
5492
|
_mapper;
|
|
5247
5493
|
async findById(id, ctx, signal) {
|
|
5248
|
-
|
|
5494
|
+
import_shared78.AppError.throwIfAborted(signal, "ReadDao.findById");
|
|
5249
5495
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5250
|
-
if (
|
|
5496
|
+
if (import_shared79.Guards.isNullOrEmpty(result)) return import_shared78.Result.ok();
|
|
5251
5497
|
const entity = this._mapper.toEntity(result);
|
|
5252
|
-
return
|
|
5498
|
+
return import_shared78.Result.ok(entity);
|
|
5253
5499
|
}
|
|
5254
5500
|
async findAll(ctx, signal) {
|
|
5255
|
-
|
|
5501
|
+
import_shared78.AppError.throwIfAborted(signal, "ReadDao.findAll");
|
|
5256
5502
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5257
5503
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5258
|
-
return
|
|
5504
|
+
return import_shared78.Result.ok(entities);
|
|
5259
5505
|
}
|
|
5260
5506
|
};
|
|
5261
5507
|
|
|
5262
5508
|
// src/infrastructure/repositories/repository.ts
|
|
5263
|
-
var
|
|
5264
|
-
var
|
|
5509
|
+
var import_shared80 = require("@xeno-js/shared");
|
|
5510
|
+
var import_shared81 = require("@xeno-js/shared");
|
|
5265
5511
|
var Repository = class {
|
|
5266
5512
|
/**
|
|
5267
5513
|
* Constructs a new Repository instance.
|
|
@@ -5281,35 +5527,35 @@ var Repository = class {
|
|
|
5281
5527
|
_dataSource;
|
|
5282
5528
|
_mapper;
|
|
5283
5529
|
async findById(id, ctx, signal) {
|
|
5284
|
-
|
|
5530
|
+
import_shared80.AppError.throwIfAborted(signal, "Repository.findById");
|
|
5285
5531
|
const result = await this._dataSource.findById(id, ctx, signal);
|
|
5286
|
-
if (
|
|
5532
|
+
if (import_shared81.Guards.isNullOrEmpty(result)) return import_shared80.Result.ok();
|
|
5287
5533
|
const entity = this._mapper.toEntity(result);
|
|
5288
|
-
return
|
|
5534
|
+
return import_shared80.Result.ok(entity);
|
|
5289
5535
|
}
|
|
5290
5536
|
async findAll(ctx, signal) {
|
|
5291
|
-
|
|
5537
|
+
import_shared80.AppError.throwIfAborted(signal, "Repository.findAll");
|
|
5292
5538
|
const results = await this._dataSource.findAll(ctx, signal);
|
|
5293
5539
|
const entities = results.map((result) => this._mapper.toEntity(result));
|
|
5294
|
-
return
|
|
5540
|
+
return import_shared80.Result.ok(entities);
|
|
5295
5541
|
}
|
|
5296
5542
|
async save(entity, signal) {
|
|
5297
5543
|
const dto = this._mapper.toDto(entity);
|
|
5298
|
-
|
|
5544
|
+
import_shared80.AppError.throwIfAborted(signal, "Repository.save");
|
|
5299
5545
|
await this._dataSource.insert(dto, signal);
|
|
5300
|
-
return
|
|
5546
|
+
return import_shared80.Result.ok();
|
|
5301
5547
|
}
|
|
5302
5548
|
async delete(entity, ctx, signal) {
|
|
5303
5549
|
const dto = this._mapper.toDto(entity);
|
|
5304
|
-
|
|
5550
|
+
import_shared80.AppError.throwIfAborted(signal, "Repository.delete");
|
|
5305
5551
|
await this._dataSource.delete(dto, ctx, signal);
|
|
5306
|
-
return
|
|
5552
|
+
return import_shared80.Result.ok();
|
|
5307
5553
|
}
|
|
5308
5554
|
async update(id, entity, ctx, signal) {
|
|
5309
5555
|
const dto = this._mapper.toPartialDto(entity);
|
|
5310
|
-
|
|
5556
|
+
import_shared80.AppError.throwIfAborted(signal, "Repository.update");
|
|
5311
5557
|
await this._dataSource.update(id, dto, ctx, signal);
|
|
5312
|
-
return
|
|
5558
|
+
return import_shared80.Result.ok();
|
|
5313
5559
|
}
|
|
5314
5560
|
};
|
|
5315
5561
|
|
|
@@ -5327,7 +5573,7 @@ __reExport(drizzle_types_exports, require("drizzle-orm"));
|
|
|
5327
5573
|
__reExport(index_exports, drizzle_types_exports, module.exports);
|
|
5328
5574
|
init_presentation();
|
|
5329
5575
|
__reExport(index_exports, require("@xeno-js/shared"), module.exports);
|
|
5330
|
-
var
|
|
5576
|
+
var import_shared82 = require("@xeno-js/shared");
|
|
5331
5577
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5332
5578
|
0 && (module.exports = {
|
|
5333
5579
|
AppBuilder,
|