@vritti/api-sdk 0.1.2 → 0.1.4
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 +521 -529
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1026 -1029
- package/dist/index.d.ts +1026 -1029
- package/dist/index.js +507 -515
- package/dist/index.js.map +1 -1
- package/package.json +9 -15
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
CsrfGuard: () => CsrfGuard,
|
|
41
41
|
DEFAULT_CORRELATION_HEADER: () => DEFAULT_CORRELATION_HEADER,
|
|
42
42
|
DatabaseModule: () => DatabaseModule,
|
|
43
|
-
ForbiddenException: () =>
|
|
43
|
+
ForbiddenException: () => ForbiddenException,
|
|
44
44
|
GoneException: () => GoneException,
|
|
45
45
|
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
46
46
|
HttpLoggerInterceptor: () => HttpLoggerInterceptor,
|
|
@@ -48,7 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
InternalServerErrorException: () => InternalServerErrorException3,
|
|
49
49
|
LOGGER_MODULE_OPTIONS: () => LOGGER_MODULE_OPTIONS,
|
|
50
50
|
LoggerModule: () => LoggerModule,
|
|
51
|
-
LoggerService: () =>
|
|
51
|
+
LoggerService: () => LoggerService,
|
|
52
52
|
MethodNotAllowedException: () => MethodNotAllowedException,
|
|
53
53
|
NotAcceptableException: () => NotAcceptableException,
|
|
54
54
|
NotFoundException: () => NotFoundException,
|
|
@@ -88,6 +88,19 @@ __export(index_exports, {
|
|
|
88
88
|
});
|
|
89
89
|
module.exports = __toCommonJS(index_exports);
|
|
90
90
|
|
|
91
|
+
// src/auth/auth-config.module.ts
|
|
92
|
+
var import_common5 = require("@nestjs/common");
|
|
93
|
+
var import_config4 = require("@nestjs/config");
|
|
94
|
+
var import_core3 = require("@nestjs/core");
|
|
95
|
+
var import_jwt2 = require("@nestjs/jwt");
|
|
96
|
+
|
|
97
|
+
// src/request/request.module.ts
|
|
98
|
+
var import_common2 = require("@nestjs/common");
|
|
99
|
+
|
|
100
|
+
// src/request/services/request.service.ts
|
|
101
|
+
var import_common = require("@nestjs/common");
|
|
102
|
+
var import_core = require("@nestjs/core");
|
|
103
|
+
|
|
91
104
|
// src/config/index.ts
|
|
92
105
|
var defaultConfig = {
|
|
93
106
|
cookie: {
|
|
@@ -162,31 +175,7 @@ function getJwtExpiry() {
|
|
|
162
175
|
}
|
|
163
176
|
__name(getJwtExpiry, "getJwtExpiry");
|
|
164
177
|
|
|
165
|
-
// src/auth/utils/token-hash.util.ts
|
|
166
|
-
var crypto = __toESM(require("crypto"), 1);
|
|
167
|
-
function hashToken(token) {
|
|
168
|
-
return crypto.createHash("sha256").update(token).digest("hex");
|
|
169
|
-
}
|
|
170
|
-
__name(hashToken, "hashToken");
|
|
171
|
-
function verifyTokenHash(token, expectedHash) {
|
|
172
|
-
const computedHash = hashToken(token);
|
|
173
|
-
if (computedHash.length !== expectedHash.length) return false;
|
|
174
|
-
return crypto.timingSafeEqual(Buffer.from(computedHash, "hex"), Buffer.from(expectedHash, "hex"));
|
|
175
|
-
}
|
|
176
|
-
__name(verifyTokenHash, "verifyTokenHash");
|
|
177
|
-
|
|
178
|
-
// src/auth/auth-config.module.ts
|
|
179
|
-
var import_common5 = require("@nestjs/common");
|
|
180
|
-
var import_config4 = require("@nestjs/config");
|
|
181
|
-
var import_core3 = require("@nestjs/core");
|
|
182
|
-
var import_jwt2 = require("@nestjs/jwt");
|
|
183
|
-
|
|
184
|
-
// src/request/request.module.ts
|
|
185
|
-
var import_common2 = require("@nestjs/common");
|
|
186
|
-
|
|
187
178
|
// src/request/services/request.service.ts
|
|
188
|
-
var import_common = require("@nestjs/common");
|
|
189
|
-
var import_core = require("@nestjs/core");
|
|
190
179
|
function _ts_decorate(decorators, target, key, desc) {
|
|
191
180
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
192
181
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -253,7 +242,7 @@ var RequestService = class {
|
|
|
253
242
|
}
|
|
254
243
|
}
|
|
255
244
|
return null;
|
|
256
|
-
} catch (
|
|
245
|
+
} catch (_error) {
|
|
257
246
|
return null;
|
|
258
247
|
}
|
|
259
248
|
}
|
|
@@ -317,9 +306,9 @@ var import_jwt = require("@nestjs/jwt");
|
|
|
317
306
|
|
|
318
307
|
// src/database/services/primary-database.service.ts
|
|
319
308
|
var import_common3 = require("@nestjs/common");
|
|
320
|
-
var import_pg = require("pg");
|
|
321
|
-
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
322
309
|
var import_drizzle_orm = require("drizzle-orm");
|
|
310
|
+
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
311
|
+
var import_pg = require("pg");
|
|
323
312
|
|
|
324
313
|
// src/database/constants.ts
|
|
325
314
|
var DATABASE_MODULE_OPTIONS = Symbol("DATABASE_MODULE_OPTIONS");
|
|
@@ -552,6 +541,19 @@ PrimaryDatabaseService = _ts_decorate3([
|
|
|
552
541
|
])
|
|
553
542
|
], PrimaryDatabaseService);
|
|
554
543
|
|
|
544
|
+
// src/auth/utils/token-hash.util.ts
|
|
545
|
+
var crypto = __toESM(require("crypto"), 1);
|
|
546
|
+
function hashToken(token) {
|
|
547
|
+
return crypto.createHash("sha256").update(token).digest("hex");
|
|
548
|
+
}
|
|
549
|
+
__name(hashToken, "hashToken");
|
|
550
|
+
function verifyTokenHash(token, expectedHash) {
|
|
551
|
+
const computedHash = hashToken(token);
|
|
552
|
+
if (computedHash.length !== expectedHash.length) return false;
|
|
553
|
+
return crypto.timingSafeEqual(Buffer.from(computedHash, "hex"), Buffer.from(expectedHash, "hex"));
|
|
554
|
+
}
|
|
555
|
+
__name(verifyTokenHash, "verifyTokenHash");
|
|
556
|
+
|
|
555
557
|
// src/auth/guards/vritti-auth.guard.ts
|
|
556
558
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
557
559
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -569,14 +571,14 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
569
571
|
__name(this, "VrittiAuthGuard");
|
|
570
572
|
}
|
|
571
573
|
reflector;
|
|
572
|
-
|
|
574
|
+
_configService;
|
|
573
575
|
jwtService;
|
|
574
576
|
primaryDatabase;
|
|
575
577
|
requestService;
|
|
576
578
|
logger = new import_common4.Logger(_VrittiAuthGuard.name);
|
|
577
|
-
constructor(reflector,
|
|
579
|
+
constructor(reflector, _configService, jwtService, primaryDatabase, requestService) {
|
|
578
580
|
this.reflector = reflector;
|
|
579
|
-
this.
|
|
581
|
+
this._configService = _configService;
|
|
580
582
|
this.jwtService = jwtService;
|
|
581
583
|
this.primaryDatabase = primaryDatabase;
|
|
582
584
|
this.requestService = requestService;
|
|
@@ -803,16 +805,24 @@ AuthConfigModule = _ts_decorate5([
|
|
|
803
805
|
(0, import_common5.Module)({})
|
|
804
806
|
], AuthConfigModule);
|
|
805
807
|
|
|
808
|
+
// src/auth/decorators/onboarding.decorator.ts
|
|
809
|
+
var import_common6 = require("@nestjs/common");
|
|
810
|
+
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common6.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
811
|
+
|
|
812
|
+
// src/auth/decorators/public.decorator.ts
|
|
813
|
+
var import_common7 = require("@nestjs/common");
|
|
814
|
+
var Public = /* @__PURE__ */ __name(() => (0, import_common7.SetMetadata)("isPublic", true), "Public");
|
|
815
|
+
|
|
806
816
|
// src/database/database.module.ts
|
|
807
|
-
var
|
|
817
|
+
var import_common12 = require("@nestjs/common");
|
|
808
818
|
var import_core5 = require("@nestjs/core");
|
|
809
819
|
|
|
810
820
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
811
|
-
var
|
|
821
|
+
var import_common9 = require("@nestjs/common");
|
|
812
822
|
var import_operators = require("rxjs/operators");
|
|
813
823
|
|
|
814
824
|
// src/database/services/tenant-context.service.ts
|
|
815
|
-
var
|
|
825
|
+
var import_common8 = require("@nestjs/common");
|
|
816
826
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
817
827
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
818
828
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -850,7 +860,7 @@ var TenantContextService = class {
|
|
|
850
860
|
*/
|
|
851
861
|
getTenant() {
|
|
852
862
|
if (!this.tenantInfo) {
|
|
853
|
-
throw new
|
|
863
|
+
throw new import_common8.UnauthorizedException("Tenant context not set");
|
|
854
864
|
}
|
|
855
865
|
return this.tenantInfo;
|
|
856
866
|
}
|
|
@@ -892,8 +902,8 @@ var TenantContextService = class {
|
|
|
892
902
|
}
|
|
893
903
|
};
|
|
894
904
|
TenantContextService = _ts_decorate6([
|
|
895
|
-
(0,
|
|
896
|
-
scope:
|
|
905
|
+
(0, import_common8.Injectable)({
|
|
906
|
+
scope: import_common8.Scope.REQUEST
|
|
897
907
|
})
|
|
898
908
|
], TenantContextService);
|
|
899
909
|
|
|
@@ -914,7 +924,7 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
914
924
|
__name(this, "MessageTenantContextInterceptor");
|
|
915
925
|
}
|
|
916
926
|
tenantContext;
|
|
917
|
-
logger = new
|
|
927
|
+
logger = new import_common9.Logger(_MessageTenantContextInterceptor.name);
|
|
918
928
|
constructor(tenantContext) {
|
|
919
929
|
this.tenantContext = tenantContext;
|
|
920
930
|
}
|
|
@@ -923,7 +933,7 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
923
933
|
if (contextType === "rpc") {
|
|
924
934
|
const rpcContext = context.switchToRpc();
|
|
925
935
|
const payload = rpcContext.getData();
|
|
926
|
-
if (payload
|
|
936
|
+
if (payload?.tenant) {
|
|
927
937
|
const tenant = payload.tenant;
|
|
928
938
|
this.logger.debug(`Setting tenant context from message: ${tenant.subdomain}`);
|
|
929
939
|
try {
|
|
@@ -960,8 +970,8 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
960
970
|
}
|
|
961
971
|
};
|
|
962
972
|
MessageTenantContextInterceptor = _ts_decorate7([
|
|
963
|
-
(0,
|
|
964
|
-
scope:
|
|
973
|
+
(0, import_common9.Injectable)({
|
|
974
|
+
scope: import_common9.Scope.REQUEST
|
|
965
975
|
}),
|
|
966
976
|
_ts_metadata4("design:type", Function),
|
|
967
977
|
_ts_metadata4("design:paramtypes", [
|
|
@@ -970,7 +980,7 @@ MessageTenantContextInterceptor = _ts_decorate7([
|
|
|
970
980
|
], MessageTenantContextInterceptor);
|
|
971
981
|
|
|
972
982
|
// src/database/interceptors/tenant-context.interceptor.ts
|
|
973
|
-
var
|
|
983
|
+
var import_common10 = require("@nestjs/common");
|
|
974
984
|
var import_core4 = require("@nestjs/core");
|
|
975
985
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
976
986
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -991,7 +1001,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
991
1001
|
tenantContext;
|
|
992
1002
|
primaryDatabase;
|
|
993
1003
|
requestService;
|
|
994
|
-
logger = new
|
|
1004
|
+
logger = new import_common10.Logger(_TenantContextInterceptor.name);
|
|
995
1005
|
constructor(reflector, tenantContext, primaryDatabase, requestService) {
|
|
996
1006
|
this.reflector = reflector;
|
|
997
1007
|
this.tenantContext = tenantContext;
|
|
@@ -1012,7 +1022,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1012
1022
|
return next.handle();
|
|
1013
1023
|
}
|
|
1014
1024
|
if (!tenantIdentifier) {
|
|
1015
|
-
throw new
|
|
1025
|
+
throw new import_common10.UnauthorizedException("Tenant identifier not found in request");
|
|
1016
1026
|
}
|
|
1017
1027
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
1018
1028
|
if (tenantIdentifier === "cloud") {
|
|
@@ -1022,11 +1032,11 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1022
1032
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
1023
1033
|
if (!tenantInfo) {
|
|
1024
1034
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
1025
|
-
throw new
|
|
1035
|
+
throw new import_common10.UnauthorizedException("Invalid tenant");
|
|
1026
1036
|
}
|
|
1027
1037
|
if (tenantInfo.status !== "ACTIVE") {
|
|
1028
1038
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
1029
|
-
throw new
|
|
1039
|
+
throw new import_common10.UnauthorizedException(`Tenant is ${tenantInfo.status}`);
|
|
1030
1040
|
}
|
|
1031
1041
|
this.logger.debug(`Tenant config loaded: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
1032
1042
|
this.tenantContext.setTenant(tenantInfo);
|
|
@@ -1040,8 +1050,8 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
1040
1050
|
}
|
|
1041
1051
|
};
|
|
1042
1052
|
TenantContextInterceptor = _ts_decorate8([
|
|
1043
|
-
(0,
|
|
1044
|
-
scope:
|
|
1053
|
+
(0, import_common10.Injectable)({
|
|
1054
|
+
scope: import_common10.Scope.REQUEST
|
|
1045
1055
|
}),
|
|
1046
1056
|
_ts_metadata5("design:type", Function),
|
|
1047
1057
|
_ts_metadata5("design:paramtypes", [
|
|
@@ -1053,9 +1063,9 @@ TenantContextInterceptor = _ts_decorate8([
|
|
|
1053
1063
|
], TenantContextInterceptor);
|
|
1054
1064
|
|
|
1055
1065
|
// src/database/services/tenant-database.service.ts
|
|
1056
|
-
var
|
|
1057
|
-
var import_pg2 = require("pg");
|
|
1066
|
+
var import_common11 = require("@nestjs/common");
|
|
1058
1067
|
var import_node_postgres2 = require("drizzle-orm/node-postgres");
|
|
1068
|
+
var import_pg2 = require("pg");
|
|
1059
1069
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1060
1070
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1061
1071
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1079,7 +1089,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1079
1089
|
}
|
|
1080
1090
|
options;
|
|
1081
1091
|
tenantContext;
|
|
1082
|
-
logger = new
|
|
1092
|
+
logger = new import_common11.Logger(_TenantDatabaseService.name);
|
|
1083
1093
|
/** Connection pool: Map<cacheKey, TenantConnection> */
|
|
1084
1094
|
clients = /* @__PURE__ */ new Map();
|
|
1085
1095
|
/** Track last usage time for idle connection cleanup */
|
|
@@ -1156,7 +1166,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1156
1166
|
};
|
|
1157
1167
|
} catch (error) {
|
|
1158
1168
|
this.logger.error(`Failed to create database connection for tenant: ${tenant.subdomain}`, error);
|
|
1159
|
-
throw new
|
|
1169
|
+
throw new import_common11.InternalServerErrorException("Failed to connect to tenant database");
|
|
1160
1170
|
}
|
|
1161
1171
|
}
|
|
1162
1172
|
/**
|
|
@@ -1249,8 +1259,8 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1249
1259
|
}
|
|
1250
1260
|
};
|
|
1251
1261
|
TenantDatabaseService = _ts_decorate9([
|
|
1252
|
-
(0,
|
|
1253
|
-
_ts_param3(0, (0,
|
|
1262
|
+
(0, import_common11.Injectable)(),
|
|
1263
|
+
_ts_param3(0, (0, import_common11.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1254
1264
|
_ts_metadata6("design:type", Function),
|
|
1255
1265
|
_ts_metadata6("design:paramtypes", [
|
|
1256
1266
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
@@ -1298,7 +1308,7 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1298
1308
|
* })
|
|
1299
1309
|
*/
|
|
1300
1310
|
static forServer(options) {
|
|
1301
|
-
return
|
|
1311
|
+
return _DatabaseModule.createDynamicModule(options, "server");
|
|
1302
1312
|
}
|
|
1303
1313
|
/**
|
|
1304
1314
|
* Configure DatabaseModule for Microservice/Messaging mode (RabbitMQ workers)
|
|
@@ -1320,7 +1330,7 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1320
1330
|
* })
|
|
1321
1331
|
*/
|
|
1322
1332
|
static forMicroservice(options) {
|
|
1323
|
-
return
|
|
1333
|
+
return _DatabaseModule.createDynamicModule(options, "microservice");
|
|
1324
1334
|
}
|
|
1325
1335
|
/**
|
|
1326
1336
|
* Internal helper to create dynamic module with conditional interceptor registration
|
|
@@ -1368,12 +1378,23 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1368
1378
|
}
|
|
1369
1379
|
};
|
|
1370
1380
|
DatabaseModule = _ts_decorate10([
|
|
1371
|
-
(0,
|
|
1372
|
-
(0,
|
|
1381
|
+
(0, import_common12.Global)(),
|
|
1382
|
+
(0, import_common12.Module)({})
|
|
1373
1383
|
], DatabaseModule);
|
|
1374
1384
|
|
|
1385
|
+
// src/database/decorators/tenant.decorator.ts
|
|
1386
|
+
var import_common13 = require("@nestjs/common");
|
|
1387
|
+
var Tenant = (0, import_common13.createParamDecorator)((_data, ctx) => {
|
|
1388
|
+
const request = ctx.switchToHttp().getRequest();
|
|
1389
|
+
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1390
|
+
if (!tenantContext) {
|
|
1391
|
+
throw new Error("TenantContextService not found.");
|
|
1392
|
+
}
|
|
1393
|
+
return tenantContext.getTenant();
|
|
1394
|
+
});
|
|
1395
|
+
|
|
1375
1396
|
// src/database/repositories/primary-base.repository.ts
|
|
1376
|
-
var
|
|
1397
|
+
var import_common14 = require("@nestjs/common");
|
|
1377
1398
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
1378
1399
|
function snakeToCamel(str) {
|
|
1379
1400
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1444,7 +1465,7 @@ var PrimaryBaseRepository = class {
|
|
|
1444
1465
|
this.table = table;
|
|
1445
1466
|
const dbTableName = (0, import_drizzle_orm2.getTableName)(table);
|
|
1446
1467
|
this.tableName = snakeToCamel(dbTableName);
|
|
1447
|
-
this.logger = new
|
|
1468
|
+
this.logger = new import_common14.Logger(this.constructor.name);
|
|
1448
1469
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1449
1470
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1450
1471
|
}
|
|
@@ -1684,7 +1705,7 @@ var PrimaryBaseRepository = class {
|
|
|
1684
1705
|
};
|
|
1685
1706
|
|
|
1686
1707
|
// src/database/repositories/tenant-base.repository.ts
|
|
1687
|
-
var
|
|
1708
|
+
var import_common15 = require("@nestjs/common");
|
|
1688
1709
|
var import_drizzle_orm3 = require("drizzle-orm");
|
|
1689
1710
|
var TenantBaseRepository = class {
|
|
1690
1711
|
static {
|
|
@@ -1741,7 +1762,7 @@ var TenantBaseRepository = class {
|
|
|
1741
1762
|
this.database = database;
|
|
1742
1763
|
this.table = table;
|
|
1743
1764
|
this.tableName = (0, import_drizzle_orm3.getTableName)(table);
|
|
1744
|
-
this.logger = new
|
|
1765
|
+
this.logger = new import_common15.Logger(this.constructor.name);
|
|
1745
1766
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1746
1767
|
}
|
|
1747
1768
|
/**
|
|
@@ -1973,424 +1994,282 @@ var TenantBaseRepository = class {
|
|
|
1973
1994
|
}
|
|
1974
1995
|
};
|
|
1975
1996
|
|
|
1976
|
-
// src/
|
|
1977
|
-
var import_common13 = require("@nestjs/common");
|
|
1978
|
-
var Tenant = (0, import_common13.createParamDecorator)((data, ctx) => {
|
|
1979
|
-
const request = ctx.switchToHttp().getRequest();
|
|
1980
|
-
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1981
|
-
if (!tenantContext) {
|
|
1982
|
-
throw new Error("TenantContextService not found.");
|
|
1983
|
-
}
|
|
1984
|
-
return tenantContext.getTenant();
|
|
1985
|
-
});
|
|
1986
|
-
|
|
1987
|
-
// src/auth/decorators/onboarding.decorator.ts
|
|
1988
|
-
var import_common14 = require("@nestjs/common");
|
|
1989
|
-
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common14.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
1990
|
-
|
|
1991
|
-
// src/auth/decorators/public.decorator.ts
|
|
1992
|
-
var import_common15 = require("@nestjs/common");
|
|
1993
|
-
var Public = /* @__PURE__ */ __name(() => (0, import_common15.SetMetadata)("isPublic", true), "Public");
|
|
1994
|
-
|
|
1995
|
-
// src/http/http.module.ts
|
|
1997
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
1996
1998
|
var import_common17 = require("@nestjs/common");
|
|
1997
1999
|
|
|
1998
|
-
// src/
|
|
2000
|
+
// src/exceptions/base-field.exception.ts
|
|
1999
2001
|
var import_common16 = require("@nestjs/common");
|
|
2000
|
-
var
|
|
2001
|
-
function _ts_decorate11(decorators, target, key, desc) {
|
|
2002
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2003
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2004
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2005
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2006
|
-
}
|
|
2007
|
-
__name(_ts_decorate11, "_ts_decorate");
|
|
2008
|
-
function _ts_metadata7(k, v) {
|
|
2009
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2010
|
-
}
|
|
2011
|
-
__name(_ts_metadata7, "_ts_metadata");
|
|
2012
|
-
var CsrfGuard = class _CsrfGuard {
|
|
2002
|
+
var BaseFieldException = class extends import_common16.HttpException {
|
|
2013
2003
|
static {
|
|
2014
|
-
__name(this, "
|
|
2015
|
-
}
|
|
2016
|
-
reflector;
|
|
2017
|
-
logger = new import_common16.Logger(_CsrfGuard.name);
|
|
2018
|
-
constructor(reflector) {
|
|
2019
|
-
this.reflector = reflector;
|
|
2004
|
+
__name(this, "BaseFieldException");
|
|
2020
2005
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
if (
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
field: "csrf",
|
|
2055
|
-
message: "Invalid or missing CSRF token"
|
|
2056
|
-
}
|
|
2057
|
-
],
|
|
2058
|
-
message: "CSRF validation failed"
|
|
2059
|
-
});
|
|
2006
|
+
constructor(statusOrMessageOrErrors, messageOrStatus, statusOrDetail, detail) {
|
|
2007
|
+
let errors;
|
|
2008
|
+
let httpStatus;
|
|
2009
|
+
let finalDetail;
|
|
2010
|
+
if (Array.isArray(statusOrMessageOrErrors)) {
|
|
2011
|
+
errors = statusOrMessageOrErrors;
|
|
2012
|
+
httpStatus = messageOrStatus || import_common16.HttpStatus.BAD_REQUEST;
|
|
2013
|
+
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2014
|
+
} else if (typeof statusOrMessageOrErrors === "string" && typeof messageOrStatus === "string") {
|
|
2015
|
+
errors = [
|
|
2016
|
+
{
|
|
2017
|
+
field: statusOrMessageOrErrors,
|
|
2018
|
+
message: messageOrStatus
|
|
2019
|
+
}
|
|
2020
|
+
];
|
|
2021
|
+
httpStatus = statusOrDetail;
|
|
2022
|
+
finalDetail = detail;
|
|
2023
|
+
} else if (typeof statusOrMessageOrErrors === "string") {
|
|
2024
|
+
errors = [
|
|
2025
|
+
{
|
|
2026
|
+
message: statusOrMessageOrErrors
|
|
2027
|
+
}
|
|
2028
|
+
];
|
|
2029
|
+
httpStatus = messageOrStatus;
|
|
2030
|
+
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2031
|
+
} else {
|
|
2032
|
+
errors = [
|
|
2033
|
+
{
|
|
2034
|
+
message: "An error occurred"
|
|
2035
|
+
}
|
|
2036
|
+
];
|
|
2037
|
+
httpStatus = statusOrMessageOrErrors;
|
|
2038
|
+
finalDetail = void 0;
|
|
2060
2039
|
}
|
|
2040
|
+
const response = finalDetail !== void 0 ? {
|
|
2041
|
+
errors,
|
|
2042
|
+
detail: finalDetail
|
|
2043
|
+
} : {
|
|
2044
|
+
errors
|
|
2045
|
+
};
|
|
2046
|
+
super(response, httpStatus);
|
|
2061
2047
|
}
|
|
2062
2048
|
};
|
|
2063
|
-
CsrfGuard = _ts_decorate11([
|
|
2064
|
-
(0, import_common16.Injectable)(),
|
|
2065
|
-
_ts_metadata7("design:type", Function),
|
|
2066
|
-
_ts_metadata7("design:paramtypes", [
|
|
2067
|
-
typeof import_core6.Reflector === "undefined" ? Object : import_core6.Reflector
|
|
2068
|
-
])
|
|
2069
|
-
], CsrfGuard);
|
|
2070
2049
|
|
|
2071
|
-
// src/
|
|
2072
|
-
|
|
2073
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2074
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2075
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2076
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2077
|
-
}
|
|
2078
|
-
__name(_ts_decorate12, "_ts_decorate");
|
|
2079
|
-
var HttpModule = class {
|
|
2050
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
2051
|
+
var BadGatewayException = class extends BaseFieldException {
|
|
2080
2052
|
static {
|
|
2081
|
-
__name(this, "
|
|
2053
|
+
__name(this, "BadGatewayException");
|
|
2054
|
+
}
|
|
2055
|
+
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2056
|
+
if (Array.isArray(messageOrField)) {
|
|
2057
|
+
super(messageOrField, import_common17.HttpStatus.BAD_GATEWAY, fieldMessageOrDetail);
|
|
2058
|
+
} else if (detail !== void 0) {
|
|
2059
|
+
super(messageOrField, fieldMessageOrDetail, import_common17.HttpStatus.BAD_GATEWAY, detail);
|
|
2060
|
+
} else if (fieldMessageOrDetail) {
|
|
2061
|
+
super(messageOrField, fieldMessageOrDetail, import_common17.HttpStatus.BAD_GATEWAY);
|
|
2062
|
+
} else {
|
|
2063
|
+
super(messageOrField, import_common17.HttpStatus.BAD_GATEWAY);
|
|
2064
|
+
}
|
|
2082
2065
|
}
|
|
2083
2066
|
};
|
|
2084
|
-
HttpModule = _ts_decorate12([
|
|
2085
|
-
(0, import_common17.Module)({
|
|
2086
|
-
providers: [
|
|
2087
|
-
CsrfGuard
|
|
2088
|
-
],
|
|
2089
|
-
exports: [
|
|
2090
|
-
CsrfGuard
|
|
2091
|
-
]
|
|
2092
|
-
})
|
|
2093
|
-
], HttpModule);
|
|
2094
2067
|
|
|
2095
|
-
// src/
|
|
2068
|
+
// src/exceptions/bad-request.exception.ts
|
|
2096
2069
|
var import_common18 = require("@nestjs/common");
|
|
2097
|
-
|
|
2098
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2099
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2100
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2101
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2102
|
-
}
|
|
2103
|
-
__name(_ts_decorate13, "_ts_decorate");
|
|
2104
|
-
function getHttpStatusTitle(status) {
|
|
2105
|
-
const enumKey = Object.entries(import_common18.HttpStatus).find(([key, value]) => value === status && isNaN(Number(key)))?.[0];
|
|
2106
|
-
if (!enumKey) {
|
|
2107
|
-
return "Error";
|
|
2108
|
-
}
|
|
2109
|
-
return enumKey.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
2110
|
-
}
|
|
2111
|
-
__name(getHttpStatusTitle, "getHttpStatusTitle");
|
|
2112
|
-
var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
2070
|
+
var BadRequestException = class extends BaseFieldException {
|
|
2113
2071
|
static {
|
|
2114
|
-
__name(this, "
|
|
2072
|
+
__name(this, "BadRequestException");
|
|
2115
2073
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
if (exception instanceof import_common18.HttpException) {
|
|
2124
|
-
status = exception.getStatus();
|
|
2125
|
-
const exceptionResponse = exception.getResponse();
|
|
2126
|
-
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
2127
|
-
const responseObj = exceptionResponse;
|
|
2128
|
-
if ("errors" in responseObj && Array.isArray(responseObj.errors)) {
|
|
2129
|
-
errors = responseObj.errors;
|
|
2130
|
-
detail = ("detail" in responseObj ? responseObj.detail : void 0) || exception.message;
|
|
2131
|
-
} else if ("message" in responseObj && Array.isArray(responseObj.message)) {
|
|
2132
|
-
errors = responseObj.message.map((msg) => {
|
|
2133
|
-
if (typeof msg === "object" && "property" in msg && "constraints" in msg) {
|
|
2134
|
-
const constraintValues = Object.values(msg.constraints);
|
|
2135
|
-
return {
|
|
2136
|
-
field: msg.property,
|
|
2137
|
-
message: constraintValues[0] ?? "Validation failed"
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
return {
|
|
2141
|
-
message: typeof msg === "string" ? msg : JSON.stringify(msg)
|
|
2142
|
-
};
|
|
2143
|
-
});
|
|
2144
|
-
detail = "Validation failed";
|
|
2145
|
-
} else if ("message" in responseObj) {
|
|
2146
|
-
const message = responseObj.message;
|
|
2147
|
-
errors = [
|
|
2148
|
-
{
|
|
2149
|
-
message: Array.isArray(message) ? message.join(", ") : message
|
|
2150
|
-
}
|
|
2151
|
-
];
|
|
2152
|
-
detail = ("error" in responseObj ? responseObj.error : void 0) || exception.message;
|
|
2153
|
-
}
|
|
2154
|
-
} else if (typeof exceptionResponse === "string") {
|
|
2155
|
-
errors = [
|
|
2156
|
-
{
|
|
2157
|
-
message: exceptionResponse
|
|
2158
|
-
}
|
|
2159
|
-
];
|
|
2160
|
-
detail = exceptionResponse;
|
|
2161
|
-
}
|
|
2074
|
+
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2075
|
+
if (Array.isArray(messageOrField)) {
|
|
2076
|
+
super(messageOrField, import_common18.HttpStatus.BAD_REQUEST, fieldMessageOrDetail);
|
|
2077
|
+
} else if (detail !== void 0) {
|
|
2078
|
+
super(messageOrField, fieldMessageOrDetail, import_common18.HttpStatus.BAD_REQUEST, detail);
|
|
2079
|
+
} else if (fieldMessageOrDetail) {
|
|
2080
|
+
super(messageOrField, fieldMessageOrDetail, import_common18.HttpStatus.BAD_REQUEST);
|
|
2162
2081
|
} else {
|
|
2163
|
-
|
|
2164
|
-
const stack = exception instanceof Error ? exception.stack : void 0;
|
|
2165
|
-
this.logger.error(`Unexpected error: ${errorMessage}`, stack);
|
|
2166
|
-
errors = [
|
|
2167
|
-
{
|
|
2168
|
-
message: "An unexpected error occurred"
|
|
2169
|
-
}
|
|
2170
|
-
];
|
|
2082
|
+
super(messageOrField, import_common18.HttpStatus.BAD_REQUEST);
|
|
2171
2083
|
}
|
|
2172
|
-
const problemDetails = {
|
|
2173
|
-
title: getHttpStatusTitle(status),
|
|
2174
|
-
status,
|
|
2175
|
-
detail,
|
|
2176
|
-
errors
|
|
2177
|
-
};
|
|
2178
|
-
response.status(status).send(problemDetails);
|
|
2179
2084
|
}
|
|
2180
2085
|
};
|
|
2181
|
-
HttpExceptionFilter = _ts_decorate13([
|
|
2182
|
-
(0, import_common18.Catch)()
|
|
2183
|
-
], HttpExceptionFilter);
|
|
2184
2086
|
|
|
2185
|
-
// src/exceptions/
|
|
2087
|
+
// src/exceptions/conflict.exception.ts
|
|
2186
2088
|
var import_common19 = require("@nestjs/common");
|
|
2187
|
-
var
|
|
2089
|
+
var ConflictException = class extends BaseFieldException {
|
|
2188
2090
|
static {
|
|
2189
|
-
__name(this, "
|
|
2091
|
+
__name(this, "ConflictException");
|
|
2190
2092
|
}
|
|
2191
|
-
constructor(
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2199
|
-
} else if (typeof statusOrMessageOrErrors === "string" && typeof messageOrStatus === "string") {
|
|
2200
|
-
errors = [
|
|
2201
|
-
{
|
|
2202
|
-
field: statusOrMessageOrErrors,
|
|
2203
|
-
message: messageOrStatus
|
|
2204
|
-
}
|
|
2205
|
-
];
|
|
2206
|
-
httpStatus = statusOrDetail;
|
|
2207
|
-
finalDetail = detail;
|
|
2208
|
-
} else if (typeof statusOrMessageOrErrors === "string") {
|
|
2209
|
-
errors = [
|
|
2210
|
-
{
|
|
2211
|
-
message: statusOrMessageOrErrors
|
|
2212
|
-
}
|
|
2213
|
-
];
|
|
2214
|
-
httpStatus = messageOrStatus;
|
|
2215
|
-
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
2093
|
+
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2094
|
+
if (Array.isArray(messageOrField)) {
|
|
2095
|
+
super(messageOrField, import_common19.HttpStatus.CONFLICT, fieldMessageOrDetail);
|
|
2096
|
+
} else if (detail !== void 0) {
|
|
2097
|
+
super(messageOrField, fieldMessageOrDetail, import_common19.HttpStatus.CONFLICT, detail);
|
|
2098
|
+
} else if (fieldMessageOrDetail) {
|
|
2099
|
+
super(messageOrField, fieldMessageOrDetail, import_common19.HttpStatus.CONFLICT);
|
|
2216
2100
|
} else {
|
|
2217
|
-
|
|
2218
|
-
{
|
|
2219
|
-
message: "An error occurred"
|
|
2220
|
-
}
|
|
2221
|
-
];
|
|
2222
|
-
httpStatus = statusOrMessageOrErrors;
|
|
2223
|
-
finalDetail = void 0;
|
|
2101
|
+
super(messageOrField, import_common19.HttpStatus.CONFLICT);
|
|
2224
2102
|
}
|
|
2225
|
-
const response = finalDetail !== void 0 ? {
|
|
2226
|
-
errors,
|
|
2227
|
-
detail: finalDetail
|
|
2228
|
-
} : {
|
|
2229
|
-
errors
|
|
2230
|
-
};
|
|
2231
|
-
super(response, httpStatus);
|
|
2232
2103
|
}
|
|
2233
2104
|
};
|
|
2234
2105
|
|
|
2235
|
-
// src/exceptions/
|
|
2106
|
+
// src/exceptions/forbidden.exception.ts
|
|
2236
2107
|
var import_common20 = require("@nestjs/common");
|
|
2237
|
-
var
|
|
2108
|
+
var ForbiddenException = class extends BaseFieldException {
|
|
2238
2109
|
static {
|
|
2239
|
-
__name(this, "
|
|
2110
|
+
__name(this, "ForbiddenException");
|
|
2240
2111
|
}
|
|
2241
2112
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2242
2113
|
if (Array.isArray(messageOrField)) {
|
|
2243
|
-
super(messageOrField, import_common20.HttpStatus.
|
|
2114
|
+
super(messageOrField, import_common20.HttpStatus.FORBIDDEN, fieldMessageOrDetail);
|
|
2244
2115
|
} else if (detail !== void 0) {
|
|
2245
|
-
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.
|
|
2116
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.FORBIDDEN, detail);
|
|
2246
2117
|
} else if (fieldMessageOrDetail) {
|
|
2247
|
-
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.
|
|
2118
|
+
super(messageOrField, fieldMessageOrDetail, import_common20.HttpStatus.FORBIDDEN);
|
|
2248
2119
|
} else {
|
|
2249
|
-
super(messageOrField, import_common20.HttpStatus.
|
|
2120
|
+
super(messageOrField, import_common20.HttpStatus.FORBIDDEN);
|
|
2250
2121
|
}
|
|
2251
2122
|
}
|
|
2252
2123
|
};
|
|
2253
2124
|
|
|
2254
|
-
// src/exceptions/
|
|
2125
|
+
// src/exceptions/gone.exception.ts
|
|
2255
2126
|
var import_common21 = require("@nestjs/common");
|
|
2256
|
-
var
|
|
2127
|
+
var GoneException = class extends BaseFieldException {
|
|
2257
2128
|
static {
|
|
2258
|
-
__name(this, "
|
|
2129
|
+
__name(this, "GoneException");
|
|
2259
2130
|
}
|
|
2260
2131
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2261
2132
|
if (Array.isArray(messageOrField)) {
|
|
2262
|
-
super(messageOrField, import_common21.HttpStatus.
|
|
2133
|
+
super(messageOrField, import_common21.HttpStatus.GONE, fieldMessageOrDetail);
|
|
2263
2134
|
} else if (detail !== void 0) {
|
|
2264
|
-
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.
|
|
2135
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.GONE, detail);
|
|
2265
2136
|
} else if (fieldMessageOrDetail) {
|
|
2266
|
-
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.
|
|
2137
|
+
super(messageOrField, fieldMessageOrDetail, import_common21.HttpStatus.GONE);
|
|
2267
2138
|
} else {
|
|
2268
|
-
super(messageOrField, import_common21.HttpStatus.
|
|
2139
|
+
super(messageOrField, import_common21.HttpStatus.GONE);
|
|
2269
2140
|
}
|
|
2270
2141
|
}
|
|
2271
2142
|
};
|
|
2272
2143
|
|
|
2273
|
-
// src/exceptions/
|
|
2144
|
+
// src/exceptions/internal-server-error.exception.ts
|
|
2274
2145
|
var import_common22 = require("@nestjs/common");
|
|
2275
|
-
var
|
|
2146
|
+
var InternalServerErrorException3 = class extends BaseFieldException {
|
|
2276
2147
|
static {
|
|
2277
|
-
__name(this, "
|
|
2148
|
+
__name(this, "InternalServerErrorException");
|
|
2278
2149
|
}
|
|
2279
2150
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2280
2151
|
if (Array.isArray(messageOrField)) {
|
|
2281
|
-
super(messageOrField, import_common22.HttpStatus.
|
|
2152
|
+
super(messageOrField, import_common22.HttpStatus.INTERNAL_SERVER_ERROR, fieldMessageOrDetail);
|
|
2282
2153
|
} else if (detail !== void 0) {
|
|
2283
|
-
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.
|
|
2154
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.INTERNAL_SERVER_ERROR, detail);
|
|
2284
2155
|
} else if (fieldMessageOrDetail) {
|
|
2285
|
-
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.
|
|
2156
|
+
super(messageOrField, fieldMessageOrDetail, import_common22.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2286
2157
|
} else {
|
|
2287
|
-
super(messageOrField, import_common22.HttpStatus.
|
|
2158
|
+
super(messageOrField, import_common22.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2288
2159
|
}
|
|
2289
2160
|
}
|
|
2290
2161
|
};
|
|
2291
2162
|
|
|
2292
|
-
// src/exceptions/not-
|
|
2163
|
+
// src/exceptions/method-not-allowed.exception.ts
|
|
2293
2164
|
var import_common23 = require("@nestjs/common");
|
|
2294
|
-
var
|
|
2165
|
+
var MethodNotAllowedException = class extends BaseFieldException {
|
|
2295
2166
|
static {
|
|
2296
|
-
__name(this, "
|
|
2167
|
+
__name(this, "MethodNotAllowedException");
|
|
2297
2168
|
}
|
|
2298
2169
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2299
2170
|
if (Array.isArray(messageOrField)) {
|
|
2300
|
-
super(messageOrField, import_common23.HttpStatus.
|
|
2171
|
+
super(messageOrField, import_common23.HttpStatus.METHOD_NOT_ALLOWED, fieldMessageOrDetail);
|
|
2301
2172
|
} else if (detail !== void 0) {
|
|
2302
|
-
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.
|
|
2173
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.METHOD_NOT_ALLOWED, detail);
|
|
2303
2174
|
} else if (fieldMessageOrDetail) {
|
|
2304
|
-
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.
|
|
2175
|
+
super(messageOrField, fieldMessageOrDetail, import_common23.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2305
2176
|
} else {
|
|
2306
|
-
super(messageOrField, import_common23.HttpStatus.
|
|
2177
|
+
super(messageOrField, import_common23.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2307
2178
|
}
|
|
2308
2179
|
}
|
|
2309
2180
|
};
|
|
2310
2181
|
|
|
2311
|
-
// src/exceptions/
|
|
2182
|
+
// src/exceptions/not-acceptable.exception.ts
|
|
2312
2183
|
var import_common24 = require("@nestjs/common");
|
|
2313
|
-
var
|
|
2184
|
+
var NotAcceptableException = class extends BaseFieldException {
|
|
2314
2185
|
static {
|
|
2315
|
-
__name(this, "
|
|
2186
|
+
__name(this, "NotAcceptableException");
|
|
2316
2187
|
}
|
|
2317
2188
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2318
2189
|
if (Array.isArray(messageOrField)) {
|
|
2319
|
-
super(messageOrField, import_common24.HttpStatus.
|
|
2190
|
+
super(messageOrField, import_common24.HttpStatus.NOT_ACCEPTABLE, fieldMessageOrDetail);
|
|
2320
2191
|
} else if (detail !== void 0) {
|
|
2321
|
-
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.
|
|
2192
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.NOT_ACCEPTABLE, detail);
|
|
2322
2193
|
} else if (fieldMessageOrDetail) {
|
|
2323
|
-
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.
|
|
2194
|
+
super(messageOrField, fieldMessageOrDetail, import_common24.HttpStatus.NOT_ACCEPTABLE);
|
|
2324
2195
|
} else {
|
|
2325
|
-
super(messageOrField, import_common24.HttpStatus.
|
|
2196
|
+
super(messageOrField, import_common24.HttpStatus.NOT_ACCEPTABLE);
|
|
2326
2197
|
}
|
|
2327
2198
|
}
|
|
2328
2199
|
};
|
|
2329
2200
|
|
|
2330
|
-
// src/exceptions/
|
|
2201
|
+
// src/exceptions/not-found.exception.ts
|
|
2331
2202
|
var import_common25 = require("@nestjs/common");
|
|
2332
|
-
var
|
|
2203
|
+
var NotFoundException = class extends BaseFieldException {
|
|
2333
2204
|
static {
|
|
2334
|
-
__name(this, "
|
|
2205
|
+
__name(this, "NotFoundException");
|
|
2335
2206
|
}
|
|
2336
2207
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2337
2208
|
if (Array.isArray(messageOrField)) {
|
|
2338
|
-
super(messageOrField, import_common25.HttpStatus.
|
|
2209
|
+
super(messageOrField, import_common25.HttpStatus.NOT_FOUND, fieldMessageOrDetail);
|
|
2339
2210
|
} else if (detail !== void 0) {
|
|
2340
|
-
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.
|
|
2211
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.NOT_FOUND, detail);
|
|
2341
2212
|
} else if (fieldMessageOrDetail) {
|
|
2342
|
-
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.
|
|
2213
|
+
super(messageOrField, fieldMessageOrDetail, import_common25.HttpStatus.NOT_FOUND);
|
|
2343
2214
|
} else {
|
|
2344
|
-
super(messageOrField, import_common25.HttpStatus.
|
|
2215
|
+
super(messageOrField, import_common25.HttpStatus.NOT_FOUND);
|
|
2345
2216
|
}
|
|
2346
2217
|
}
|
|
2347
2218
|
};
|
|
2348
2219
|
|
|
2349
|
-
// src/exceptions/
|
|
2220
|
+
// src/exceptions/not-implemented.exception.ts
|
|
2350
2221
|
var import_common26 = require("@nestjs/common");
|
|
2351
|
-
var
|
|
2222
|
+
var NotImplementedException = class extends BaseFieldException {
|
|
2352
2223
|
static {
|
|
2353
|
-
__name(this, "
|
|
2224
|
+
__name(this, "NotImplementedException");
|
|
2354
2225
|
}
|
|
2355
|
-
constructor(
|
|
2356
|
-
|
|
2226
|
+
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2227
|
+
if (Array.isArray(messageOrField)) {
|
|
2228
|
+
super(messageOrField, import_common26.HttpStatus.NOT_IMPLEMENTED, fieldMessageOrDetail);
|
|
2229
|
+
} else if (detail !== void 0) {
|
|
2230
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.NOT_IMPLEMENTED, detail);
|
|
2231
|
+
} else if (fieldMessageOrDetail) {
|
|
2232
|
+
super(messageOrField, fieldMessageOrDetail, import_common26.HttpStatus.NOT_IMPLEMENTED);
|
|
2233
|
+
} else {
|
|
2234
|
+
super(messageOrField, import_common26.HttpStatus.NOT_IMPLEMENTED);
|
|
2235
|
+
}
|
|
2357
2236
|
}
|
|
2358
2237
|
};
|
|
2359
2238
|
|
|
2360
|
-
// src/exceptions/
|
|
2239
|
+
// src/exceptions/payload-too-large.exception.ts
|
|
2361
2240
|
var import_common27 = require("@nestjs/common");
|
|
2362
|
-
var
|
|
2241
|
+
var PayloadTooLargeException = class extends BaseFieldException {
|
|
2363
2242
|
static {
|
|
2364
|
-
__name(this, "
|
|
2243
|
+
__name(this, "PayloadTooLargeException");
|
|
2365
2244
|
}
|
|
2366
2245
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2367
2246
|
if (Array.isArray(messageOrField)) {
|
|
2368
|
-
super(messageOrField, import_common27.HttpStatus.
|
|
2247
|
+
super(messageOrField, import_common27.HttpStatus.PAYLOAD_TOO_LARGE, fieldMessageOrDetail);
|
|
2369
2248
|
} else if (detail !== void 0) {
|
|
2370
|
-
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.
|
|
2249
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.PAYLOAD_TOO_LARGE, detail);
|
|
2371
2250
|
} else if (fieldMessageOrDetail) {
|
|
2372
|
-
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.
|
|
2251
|
+
super(messageOrField, fieldMessageOrDetail, import_common27.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2373
2252
|
} else {
|
|
2374
|
-
super(messageOrField, import_common27.HttpStatus.
|
|
2253
|
+
super(messageOrField, import_common27.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2375
2254
|
}
|
|
2376
2255
|
}
|
|
2377
2256
|
};
|
|
2378
2257
|
|
|
2379
|
-
// src/exceptions/
|
|
2258
|
+
// src/exceptions/request-timeout.exception.ts
|
|
2380
2259
|
var import_common28 = require("@nestjs/common");
|
|
2381
|
-
var
|
|
2260
|
+
var RequestTimeoutException = class extends BaseFieldException {
|
|
2382
2261
|
static {
|
|
2383
|
-
__name(this, "
|
|
2262
|
+
__name(this, "RequestTimeoutException");
|
|
2384
2263
|
}
|
|
2385
2264
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2386
2265
|
if (Array.isArray(messageOrField)) {
|
|
2387
|
-
super(messageOrField, import_common28.HttpStatus.
|
|
2266
|
+
super(messageOrField, import_common28.HttpStatus.REQUEST_TIMEOUT, fieldMessageOrDetail);
|
|
2388
2267
|
} else if (detail !== void 0) {
|
|
2389
|
-
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.
|
|
2268
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.REQUEST_TIMEOUT, detail);
|
|
2390
2269
|
} else if (fieldMessageOrDetail) {
|
|
2391
|
-
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.
|
|
2270
|
+
super(messageOrField, fieldMessageOrDetail, import_common28.HttpStatus.REQUEST_TIMEOUT);
|
|
2392
2271
|
} else {
|
|
2393
|
-
super(messageOrField, import_common28.HttpStatus.
|
|
2272
|
+
super(messageOrField, import_common28.HttpStatus.REQUEST_TIMEOUT);
|
|
2394
2273
|
}
|
|
2395
2274
|
}
|
|
2396
2275
|
};
|
|
@@ -2414,160 +2293,271 @@ var ServiceUnavailableException = class extends BaseFieldException {
|
|
|
2414
2293
|
}
|
|
2415
2294
|
};
|
|
2416
2295
|
|
|
2417
|
-
// src/exceptions/
|
|
2296
|
+
// src/exceptions/too-many-requests.exception.ts
|
|
2418
2297
|
var import_common30 = require("@nestjs/common");
|
|
2419
|
-
var
|
|
2298
|
+
var TooManyRequestsException = class extends BaseFieldException {
|
|
2420
2299
|
static {
|
|
2421
|
-
__name(this, "
|
|
2300
|
+
__name(this, "TooManyRequestsException");
|
|
2422
2301
|
}
|
|
2423
2302
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2424
2303
|
if (Array.isArray(messageOrField)) {
|
|
2425
|
-
super(messageOrField, import_common30.HttpStatus.
|
|
2304
|
+
super(messageOrField, import_common30.HttpStatus.TOO_MANY_REQUESTS, fieldMessageOrDetail);
|
|
2426
2305
|
} else if (detail !== void 0) {
|
|
2427
|
-
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.
|
|
2306
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.TOO_MANY_REQUESTS, detail);
|
|
2428
2307
|
} else if (fieldMessageOrDetail) {
|
|
2429
|
-
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.
|
|
2308
|
+
super(messageOrField, fieldMessageOrDetail, import_common30.HttpStatus.TOO_MANY_REQUESTS);
|
|
2430
2309
|
} else {
|
|
2431
|
-
super(messageOrField, import_common30.HttpStatus.
|
|
2310
|
+
super(messageOrField, import_common30.HttpStatus.TOO_MANY_REQUESTS);
|
|
2432
2311
|
}
|
|
2433
2312
|
}
|
|
2434
2313
|
};
|
|
2435
2314
|
|
|
2436
|
-
// src/exceptions/
|
|
2315
|
+
// src/exceptions/unauthorized.exception.ts
|
|
2437
2316
|
var import_common31 = require("@nestjs/common");
|
|
2438
|
-
var
|
|
2317
|
+
var UnauthorizedException4 = class extends BaseFieldException {
|
|
2439
2318
|
static {
|
|
2440
|
-
__name(this, "
|
|
2319
|
+
__name(this, "UnauthorizedException");
|
|
2441
2320
|
}
|
|
2442
2321
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2443
2322
|
if (Array.isArray(messageOrField)) {
|
|
2444
|
-
super(messageOrField, import_common31.HttpStatus.
|
|
2323
|
+
super(messageOrField, import_common31.HttpStatus.UNAUTHORIZED, fieldMessageOrDetail);
|
|
2445
2324
|
} else if (detail !== void 0) {
|
|
2446
|
-
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.
|
|
2325
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.UNAUTHORIZED, detail);
|
|
2447
2326
|
} else if (fieldMessageOrDetail) {
|
|
2448
|
-
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.
|
|
2327
|
+
super(messageOrField, fieldMessageOrDetail, import_common31.HttpStatus.UNAUTHORIZED);
|
|
2449
2328
|
} else {
|
|
2450
|
-
super(messageOrField, import_common31.HttpStatus.
|
|
2329
|
+
super(messageOrField, import_common31.HttpStatus.UNAUTHORIZED);
|
|
2451
2330
|
}
|
|
2452
2331
|
}
|
|
2453
2332
|
};
|
|
2454
2333
|
|
|
2455
|
-
// src/exceptions/
|
|
2334
|
+
// src/exceptions/unprocessable-entity.exception.ts
|
|
2456
2335
|
var import_common32 = require("@nestjs/common");
|
|
2457
|
-
var
|
|
2336
|
+
var UnprocessableEntityException = class extends BaseFieldException {
|
|
2458
2337
|
static {
|
|
2459
|
-
__name(this, "
|
|
2338
|
+
__name(this, "UnprocessableEntityException");
|
|
2460
2339
|
}
|
|
2461
2340
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2462
2341
|
if (Array.isArray(messageOrField)) {
|
|
2463
|
-
super(messageOrField, import_common32.HttpStatus.
|
|
2342
|
+
super(messageOrField, import_common32.HttpStatus.UNPROCESSABLE_ENTITY, fieldMessageOrDetail);
|
|
2464
2343
|
} else if (detail !== void 0) {
|
|
2465
|
-
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.
|
|
2344
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.UNPROCESSABLE_ENTITY, detail);
|
|
2466
2345
|
} else if (fieldMessageOrDetail) {
|
|
2467
|
-
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.
|
|
2346
|
+
super(messageOrField, fieldMessageOrDetail, import_common32.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2468
2347
|
} else {
|
|
2469
|
-
super(messageOrField, import_common32.HttpStatus.
|
|
2348
|
+
super(messageOrField, import_common32.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2470
2349
|
}
|
|
2471
2350
|
}
|
|
2472
2351
|
};
|
|
2473
2352
|
|
|
2474
|
-
// src/exceptions/
|
|
2353
|
+
// src/exceptions/unsupported-media-type.exception.ts
|
|
2475
2354
|
var import_common33 = require("@nestjs/common");
|
|
2476
|
-
var
|
|
2355
|
+
var UnsupportedMediaTypeException = class extends BaseFieldException {
|
|
2477
2356
|
static {
|
|
2478
|
-
__name(this, "
|
|
2357
|
+
__name(this, "UnsupportedMediaTypeException");
|
|
2479
2358
|
}
|
|
2480
2359
|
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2481
2360
|
if (Array.isArray(messageOrField)) {
|
|
2482
|
-
super(messageOrField, import_common33.HttpStatus.
|
|
2361
|
+
super(messageOrField, import_common33.HttpStatus.UNSUPPORTED_MEDIA_TYPE, fieldMessageOrDetail);
|
|
2483
2362
|
} else if (detail !== void 0) {
|
|
2484
|
-
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.
|
|
2363
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.UNSUPPORTED_MEDIA_TYPE, detail);
|
|
2485
2364
|
} else if (fieldMessageOrDetail) {
|
|
2486
|
-
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.
|
|
2365
|
+
super(messageOrField, fieldMessageOrDetail, import_common33.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2487
2366
|
} else {
|
|
2488
|
-
super(messageOrField, import_common33.HttpStatus.
|
|
2367
|
+
super(messageOrField, import_common33.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2489
2368
|
}
|
|
2490
2369
|
}
|
|
2491
2370
|
};
|
|
2492
2371
|
|
|
2493
|
-
// src/exceptions/
|
|
2372
|
+
// src/exceptions/validation.exception.ts
|
|
2494
2373
|
var import_common34 = require("@nestjs/common");
|
|
2495
|
-
var
|
|
2374
|
+
var ValidationException = class extends BaseFieldException {
|
|
2496
2375
|
static {
|
|
2497
|
-
__name(this, "
|
|
2376
|
+
__name(this, "ValidationException");
|
|
2498
2377
|
}
|
|
2499
|
-
constructor(
|
|
2500
|
-
|
|
2501
|
-
super(messageOrField, import_common34.HttpStatus.PAYLOAD_TOO_LARGE, fieldMessageOrDetail);
|
|
2502
|
-
} else if (detail !== void 0) {
|
|
2503
|
-
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.PAYLOAD_TOO_LARGE, detail);
|
|
2504
|
-
} else if (fieldMessageOrDetail) {
|
|
2505
|
-
super(messageOrField, fieldMessageOrDetail, import_common34.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2506
|
-
} else {
|
|
2507
|
-
super(messageOrField, import_common34.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2508
|
-
}
|
|
2378
|
+
constructor(errors, detail) {
|
|
2379
|
+
super(errors, import_common34.HttpStatus.BAD_REQUEST, detail);
|
|
2509
2380
|
}
|
|
2510
2381
|
};
|
|
2511
2382
|
|
|
2512
|
-
// src/
|
|
2383
|
+
// src/filters/http-exception.filter.ts
|
|
2513
2384
|
var import_common35 = require("@nestjs/common");
|
|
2514
|
-
|
|
2385
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2386
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2387
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2388
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2389
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2390
|
+
}
|
|
2391
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2392
|
+
function getHttpStatusTitle(status) {
|
|
2393
|
+
const enumKey = Object.entries(import_common35.HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2394
|
+
if (!enumKey) {
|
|
2395
|
+
return "Error";
|
|
2396
|
+
}
|
|
2397
|
+
return enumKey.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
2398
|
+
}
|
|
2399
|
+
__name(getHttpStatusTitle, "getHttpStatusTitle");
|
|
2400
|
+
var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
2515
2401
|
static {
|
|
2516
|
-
__name(this, "
|
|
2402
|
+
__name(this, "HttpExceptionFilter");
|
|
2517
2403
|
}
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2404
|
+
logger = new import_common35.Logger(_HttpExceptionFilter.name);
|
|
2405
|
+
catch(exception, host) {
|
|
2406
|
+
const ctx = host.switchToHttp();
|
|
2407
|
+
const response = ctx.getResponse();
|
|
2408
|
+
let status = import_common35.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2409
|
+
let errors = [];
|
|
2410
|
+
let detail = "Internal server error";
|
|
2411
|
+
if (exception instanceof import_common35.HttpException) {
|
|
2412
|
+
status = exception.getStatus();
|
|
2413
|
+
const exceptionResponse = exception.getResponse();
|
|
2414
|
+
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
2415
|
+
const responseObj = exceptionResponse;
|
|
2416
|
+
if ("errors" in responseObj && Array.isArray(responseObj.errors)) {
|
|
2417
|
+
errors = responseObj.errors;
|
|
2418
|
+
detail = ("detail" in responseObj ? responseObj.detail : void 0) || exception.message;
|
|
2419
|
+
} else if ("message" in responseObj && Array.isArray(responseObj.message)) {
|
|
2420
|
+
errors = responseObj.message.map((msg) => {
|
|
2421
|
+
if (typeof msg === "object" && "property" in msg && "constraints" in msg) {
|
|
2422
|
+
const constraintValues = Object.values(msg.constraints);
|
|
2423
|
+
return {
|
|
2424
|
+
field: msg.property,
|
|
2425
|
+
message: constraintValues[0] ?? "Validation failed"
|
|
2426
|
+
};
|
|
2427
|
+
}
|
|
2428
|
+
return {
|
|
2429
|
+
message: typeof msg === "string" ? msg : JSON.stringify(msg)
|
|
2430
|
+
};
|
|
2431
|
+
});
|
|
2432
|
+
detail = "Validation failed";
|
|
2433
|
+
} else if ("message" in responseObj) {
|
|
2434
|
+
const message = responseObj.message;
|
|
2435
|
+
errors = [
|
|
2436
|
+
{
|
|
2437
|
+
message: Array.isArray(message) ? message.join(", ") : message
|
|
2438
|
+
}
|
|
2439
|
+
];
|
|
2440
|
+
detail = ("error" in responseObj ? responseObj.error : void 0) || exception.message;
|
|
2441
|
+
}
|
|
2442
|
+
} else if (typeof exceptionResponse === "string") {
|
|
2443
|
+
errors = [
|
|
2444
|
+
{
|
|
2445
|
+
message: exceptionResponse
|
|
2446
|
+
}
|
|
2447
|
+
];
|
|
2448
|
+
detail = exceptionResponse;
|
|
2449
|
+
}
|
|
2525
2450
|
} else {
|
|
2526
|
-
|
|
2451
|
+
const errorMessage = exception instanceof Error ? exception.message : "Unknown error";
|
|
2452
|
+
const stack = exception instanceof Error ? exception.stack : void 0;
|
|
2453
|
+
this.logger.error(`Unexpected error: ${errorMessage}`, stack);
|
|
2454
|
+
errors = [
|
|
2455
|
+
{
|
|
2456
|
+
message: "An unexpected error occurred"
|
|
2457
|
+
}
|
|
2458
|
+
];
|
|
2527
2459
|
}
|
|
2460
|
+
const problemDetails = {
|
|
2461
|
+
title: getHttpStatusTitle(status),
|
|
2462
|
+
status,
|
|
2463
|
+
detail,
|
|
2464
|
+
errors
|
|
2465
|
+
};
|
|
2466
|
+
response.status(status).send(problemDetails);
|
|
2528
2467
|
}
|
|
2529
2468
|
};
|
|
2469
|
+
HttpExceptionFilter = _ts_decorate11([
|
|
2470
|
+
(0, import_common35.Catch)()
|
|
2471
|
+
], HttpExceptionFilter);
|
|
2530
2472
|
|
|
2531
|
-
// src/
|
|
2473
|
+
// src/http/guards/csrf.guard.ts
|
|
2532
2474
|
var import_common36 = require("@nestjs/common");
|
|
2533
|
-
|
|
2475
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2476
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2477
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2478
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2479
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2480
|
+
}
|
|
2481
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2482
|
+
var CsrfGuard = class _CsrfGuard {
|
|
2534
2483
|
static {
|
|
2535
|
-
__name(this, "
|
|
2484
|
+
__name(this, "CsrfGuard");
|
|
2536
2485
|
}
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2486
|
+
logger = new import_common36.Logger(_CsrfGuard.name);
|
|
2487
|
+
async canActivate(context) {
|
|
2488
|
+
const request = context.switchToHttp().getRequest();
|
|
2489
|
+
const reply = context.switchToHttp().getResponse();
|
|
2490
|
+
const safeMethods = [
|
|
2491
|
+
"GET",
|
|
2492
|
+
"HEAD",
|
|
2493
|
+
"OPTIONS"
|
|
2494
|
+
];
|
|
2495
|
+
if (safeMethods.includes(request.method)) {
|
|
2496
|
+
return true;
|
|
2497
|
+
}
|
|
2498
|
+
try {
|
|
2499
|
+
const fastifyInstance = request.server;
|
|
2500
|
+
if (!fastifyInstance.csrfProtection) {
|
|
2501
|
+
this.logger.error("CSRF protection plugin not found. Ensure @fastify/csrf-protection is registered.");
|
|
2502
|
+
throw new import_common36.ForbiddenException("CSRF protection not configured");
|
|
2503
|
+
}
|
|
2504
|
+
await new Promise((resolve, reject) => {
|
|
2505
|
+
fastifyInstance.csrfProtection(request, reply, (err) => {
|
|
2506
|
+
if (err) {
|
|
2507
|
+
reject(err);
|
|
2508
|
+
} else {
|
|
2509
|
+
resolve();
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
});
|
|
2513
|
+
this.logger.debug(`CSRF validation successful for ${request.method} ${request.url}`);
|
|
2514
|
+
return true;
|
|
2515
|
+
} catch (error) {
|
|
2516
|
+
this.logger.warn(`CSRF validation failed for ${request.method} ${request.url}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2517
|
+
throw new import_common36.ForbiddenException({
|
|
2518
|
+
errors: [
|
|
2519
|
+
{
|
|
2520
|
+
field: "csrf",
|
|
2521
|
+
message: "Invalid or missing CSRF token"
|
|
2522
|
+
}
|
|
2523
|
+
],
|
|
2524
|
+
message: "CSRF validation failed"
|
|
2525
|
+
});
|
|
2546
2526
|
}
|
|
2547
2527
|
}
|
|
2548
2528
|
};
|
|
2529
|
+
CsrfGuard = _ts_decorate12([
|
|
2530
|
+
(0, import_common36.Injectable)()
|
|
2531
|
+
], CsrfGuard);
|
|
2549
2532
|
|
|
2550
|
-
// src/
|
|
2533
|
+
// src/http/http.module.ts
|
|
2551
2534
|
var import_common37 = require("@nestjs/common");
|
|
2552
|
-
|
|
2535
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2536
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2537
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2538
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2539
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2540
|
+
}
|
|
2541
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2542
|
+
var HttpModule = class {
|
|
2553
2543
|
static {
|
|
2554
|
-
__name(this, "
|
|
2555
|
-
}
|
|
2556
|
-
constructor(messageOrField, fieldMessageOrDetail, detail) {
|
|
2557
|
-
if (Array.isArray(messageOrField)) {
|
|
2558
|
-
super(messageOrField, import_common37.HttpStatus.BAD_GATEWAY, fieldMessageOrDetail);
|
|
2559
|
-
} else if (detail !== void 0) {
|
|
2560
|
-
super(messageOrField, fieldMessageOrDetail, import_common37.HttpStatus.BAD_GATEWAY, detail);
|
|
2561
|
-
} else if (fieldMessageOrDetail) {
|
|
2562
|
-
super(messageOrField, fieldMessageOrDetail, import_common37.HttpStatus.BAD_GATEWAY);
|
|
2563
|
-
} else {
|
|
2564
|
-
super(messageOrField, import_common37.HttpStatus.BAD_GATEWAY);
|
|
2565
|
-
}
|
|
2544
|
+
__name(this, "HttpModule");
|
|
2566
2545
|
}
|
|
2567
2546
|
};
|
|
2547
|
+
HttpModule = _ts_decorate13([
|
|
2548
|
+
(0, import_common37.Module)({
|
|
2549
|
+
providers: [
|
|
2550
|
+
CsrfGuard
|
|
2551
|
+
],
|
|
2552
|
+
exports: [
|
|
2553
|
+
CsrfGuard
|
|
2554
|
+
]
|
|
2555
|
+
})
|
|
2556
|
+
], HttpModule);
|
|
2568
2557
|
|
|
2569
|
-
// src/logger/logger.
|
|
2570
|
-
var
|
|
2558
|
+
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2559
|
+
var import_common39 = require("@nestjs/common");
|
|
2560
|
+
var import_operators2 = require("rxjs/operators");
|
|
2571
2561
|
|
|
2572
2562
|
// src/logger/services/logger.service.ts
|
|
2573
2563
|
var import_common38 = require("@nestjs/common");
|
|
@@ -2615,17 +2605,17 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2615
2605
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2616
2606
|
}
|
|
2617
2607
|
__name(_ts_decorate14, "_ts_decorate");
|
|
2618
|
-
function
|
|
2608
|
+
function _ts_metadata7(k, v) {
|
|
2619
2609
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2620
2610
|
}
|
|
2621
|
-
__name(
|
|
2611
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2622
2612
|
function _ts_param4(paramIndex, decorator) {
|
|
2623
2613
|
return function(target, key) {
|
|
2624
2614
|
decorator(target, key, paramIndex);
|
|
2625
2615
|
};
|
|
2626
2616
|
}
|
|
2627
2617
|
__name(_ts_param4, "_ts_param");
|
|
2628
|
-
var
|
|
2618
|
+
var LoggerService = class _LoggerService {
|
|
2629
2619
|
static {
|
|
2630
2620
|
__name(this, "LoggerService");
|
|
2631
2621
|
}
|
|
@@ -2677,7 +2667,8 @@ var LoggerService2 = class _LoggerService {
|
|
|
2677
2667
|
].filter(Boolean);
|
|
2678
2668
|
let output = parts.join(" ");
|
|
2679
2669
|
if (trace) {
|
|
2680
|
-
output +=
|
|
2670
|
+
output += `
|
|
2671
|
+
${trace}`;
|
|
2681
2672
|
}
|
|
2682
2673
|
return output;
|
|
2683
2674
|
}), import_winston.format.colorize({
|
|
@@ -2825,19 +2816,18 @@ var LoggerService2 = class _LoggerService {
|
|
|
2825
2816
|
return childLogger;
|
|
2826
2817
|
}
|
|
2827
2818
|
};
|
|
2828
|
-
|
|
2819
|
+
LoggerService = _ts_decorate14([
|
|
2829
2820
|
(0, import_common38.Injectable)(),
|
|
2830
2821
|
_ts_param4(0, (0, import_common38.Optional)()),
|
|
2831
2822
|
_ts_param4(1, (0, import_common38.Optional)()),
|
|
2832
|
-
|
|
2833
|
-
|
|
2823
|
+
_ts_metadata7("design:type", Function),
|
|
2824
|
+
_ts_metadata7("design:paramtypes", [
|
|
2834
2825
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2835
|
-
typeof
|
|
2826
|
+
typeof Logger === "undefined" ? Object : Logger
|
|
2836
2827
|
])
|
|
2837
|
-
],
|
|
2828
|
+
], LoggerService);
|
|
2838
2829
|
|
|
2839
|
-
// src/logger/
|
|
2840
|
-
var import_common39 = require("@nestjs/common");
|
|
2830
|
+
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2841
2831
|
function _ts_decorate15(decorators, target, key, desc) {
|
|
2842
2832
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2843
2833
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2845,74 +2835,10 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2845
2835
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2846
2836
|
}
|
|
2847
2837
|
__name(_ts_decorate15, "_ts_decorate");
|
|
2848
|
-
function
|
|
2849
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2850
|
-
}
|
|
2851
|
-
__name(_ts_metadata9, "_ts_metadata");
|
|
2852
|
-
var CorrelationIdMiddleware = class {
|
|
2853
|
-
static {
|
|
2854
|
-
__name(this, "CorrelationIdMiddleware");
|
|
2855
|
-
}
|
|
2856
|
-
includeInResponse;
|
|
2857
|
-
responseHeader;
|
|
2858
|
-
constructor(options = {}) {
|
|
2859
|
-
this.includeInResponse = options.includeInResponse ?? true;
|
|
2860
|
-
this.responseHeader = options.responseHeader ?? DEFAULT_CORRELATION_HEADER;
|
|
2861
|
-
}
|
|
2862
|
-
/**
|
|
2863
|
-
* Middleware handler for processing requests.
|
|
2864
|
-
*/
|
|
2865
|
-
use(req, reply, next) {
|
|
2866
|
-
const correlationId = generateCorrelationId();
|
|
2867
|
-
if (this.includeInResponse) {
|
|
2868
|
-
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
2869
|
-
}
|
|
2870
|
-
runWithCorrelationContext({
|
|
2871
|
-
correlationId
|
|
2872
|
-
}, () => {
|
|
2873
|
-
next();
|
|
2874
|
-
});
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* Fastify hook handler for onRequest.
|
|
2878
|
-
* This is an async function that returns a Promise, ensuring the AsyncLocalStorage
|
|
2879
|
-
* context persists throughout the entire request lifecycle.
|
|
2880
|
-
*/
|
|
2881
|
-
async onRequest(req, reply) {
|
|
2882
|
-
const correlationId = generateCorrelationId();
|
|
2883
|
-
if (this.includeInResponse) {
|
|
2884
|
-
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
2885
|
-
}
|
|
2886
|
-
const store = correlationStorage.getStore();
|
|
2887
|
-
if (!store) {
|
|
2888
|
-
correlationStorage.enterWith({
|
|
2889
|
-
correlationId
|
|
2890
|
-
});
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
CorrelationIdMiddleware = _ts_decorate15([
|
|
2895
|
-
(0, import_common39.Injectable)(),
|
|
2896
|
-
_ts_metadata9("design:type", Function),
|
|
2897
|
-
_ts_metadata9("design:paramtypes", [
|
|
2898
|
-
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
2899
|
-
])
|
|
2900
|
-
], CorrelationIdMiddleware);
|
|
2901
|
-
|
|
2902
|
-
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2903
|
-
var import_common40 = require("@nestjs/common");
|
|
2904
|
-
var import_operators2 = require("rxjs/operators");
|
|
2905
|
-
function _ts_decorate16(decorators, target, key, desc) {
|
|
2906
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2907
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2908
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2909
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2910
|
-
}
|
|
2911
|
-
__name(_ts_decorate16, "_ts_decorate");
|
|
2912
|
-
function _ts_metadata10(k, v) {
|
|
2838
|
+
function _ts_metadata8(k, v) {
|
|
2913
2839
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2914
2840
|
}
|
|
2915
|
-
__name(
|
|
2841
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2916
2842
|
function _ts_param5(paramIndex, decorator) {
|
|
2917
2843
|
return function(target, key) {
|
|
2918
2844
|
decorator(target, key, paramIndex);
|
|
@@ -3020,16 +2946,82 @@ var HttpLoggerInterceptor = class {
|
|
|
3020
2946
|
}
|
|
3021
2947
|
}
|
|
3022
2948
|
};
|
|
3023
|
-
HttpLoggerInterceptor =
|
|
3024
|
-
(0,
|
|
3025
|
-
_ts_param5(1, (0,
|
|
3026
|
-
|
|
3027
|
-
|
|
2949
|
+
HttpLoggerInterceptor = _ts_decorate15([
|
|
2950
|
+
(0, import_common39.Injectable)(),
|
|
2951
|
+
_ts_param5(1, (0, import_common39.Optional)()),
|
|
2952
|
+
_ts_metadata8("design:type", Function),
|
|
2953
|
+
_ts_metadata8("design:paramtypes", [
|
|
3028
2954
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
3029
2955
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
3030
2956
|
])
|
|
3031
2957
|
], HttpLoggerInterceptor);
|
|
3032
2958
|
|
|
2959
|
+
// src/logger/logger.module.ts
|
|
2960
|
+
var import_common41 = require("@nestjs/common");
|
|
2961
|
+
|
|
2962
|
+
// src/logger/middleware/correlation-id.middleware.ts
|
|
2963
|
+
var import_common40 = require("@nestjs/common");
|
|
2964
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2965
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2966
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2967
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2968
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2969
|
+
}
|
|
2970
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2971
|
+
function _ts_metadata9(k, v) {
|
|
2972
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2973
|
+
}
|
|
2974
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2975
|
+
var CorrelationIdMiddleware = class {
|
|
2976
|
+
static {
|
|
2977
|
+
__name(this, "CorrelationIdMiddleware");
|
|
2978
|
+
}
|
|
2979
|
+
includeInResponse;
|
|
2980
|
+
responseHeader;
|
|
2981
|
+
constructor(options = {}) {
|
|
2982
|
+
this.includeInResponse = options.includeInResponse ?? true;
|
|
2983
|
+
this.responseHeader = options.responseHeader ?? DEFAULT_CORRELATION_HEADER;
|
|
2984
|
+
}
|
|
2985
|
+
/**
|
|
2986
|
+
* Middleware handler for processing requests.
|
|
2987
|
+
*/
|
|
2988
|
+
use(_req, reply, next) {
|
|
2989
|
+
const correlationId = generateCorrelationId();
|
|
2990
|
+
if (this.includeInResponse) {
|
|
2991
|
+
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
2992
|
+
}
|
|
2993
|
+
runWithCorrelationContext({
|
|
2994
|
+
correlationId
|
|
2995
|
+
}, () => {
|
|
2996
|
+
next();
|
|
2997
|
+
});
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* Fastify hook handler for onRequest.
|
|
3001
|
+
* This is an async function that returns a Promise, ensuring the AsyncLocalStorage
|
|
3002
|
+
* context persists throughout the entire request lifecycle.
|
|
3003
|
+
*/
|
|
3004
|
+
async onRequest(_req, reply) {
|
|
3005
|
+
const correlationId = generateCorrelationId();
|
|
3006
|
+
if (this.includeInResponse) {
|
|
3007
|
+
addCorrelationIdToResponse(reply, correlationId, this.responseHeader);
|
|
3008
|
+
}
|
|
3009
|
+
const store = correlationStorage.getStore();
|
|
3010
|
+
if (!store) {
|
|
3011
|
+
correlationStorage.enterWith({
|
|
3012
|
+
correlationId
|
|
3013
|
+
});
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
CorrelationIdMiddleware = _ts_decorate16([
|
|
3018
|
+
(0, import_common40.Injectable)(),
|
|
3019
|
+
_ts_metadata9("design:type", Function),
|
|
3020
|
+
_ts_metadata9("design:paramtypes", [
|
|
3021
|
+
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
3022
|
+
])
|
|
3023
|
+
], CorrelationIdMiddleware);
|
|
3024
|
+
|
|
3033
3025
|
// src/logger/logger.module.ts
|
|
3034
3026
|
function _ts_decorate17(decorators, target, key, desc) {
|
|
3035
3027
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3151,9 +3143,9 @@ function createLoggerProviders(options = {}) {
|
|
|
3151
3143
|
providers.push(createDefaultLoggerProvider(mergedOptions));
|
|
3152
3144
|
}
|
|
3153
3145
|
providers.push({
|
|
3154
|
-
provide:
|
|
3146
|
+
provide: LoggerService,
|
|
3155
3147
|
useFactory: /* @__PURE__ */ __name((opts, defaultLogger) => {
|
|
3156
|
-
return new
|
|
3148
|
+
return new LoggerService(opts, defaultLogger);
|
|
3157
3149
|
}, "useFactory"),
|
|
3158
3150
|
inject: [
|
|
3159
3151
|
LOGGER_MODULE_OPTIONS,
|
|
@@ -3182,7 +3174,7 @@ function createLoggerProviders(options = {}) {
|
|
|
3182
3174
|
return new HttpLoggerInterceptor(logger, httpLoggerOptions);
|
|
3183
3175
|
}, "useFactory"),
|
|
3184
3176
|
inject: [
|
|
3185
|
-
|
|
3177
|
+
LoggerService,
|
|
3186
3178
|
LOGGER_MODULE_OPTIONS
|
|
3187
3179
|
]
|
|
3188
3180
|
});
|
|
@@ -3250,7 +3242,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3250
3242
|
module: _LoggerModule,
|
|
3251
3243
|
providers,
|
|
3252
3244
|
exports: [
|
|
3253
|
-
|
|
3245
|
+
LoggerService,
|
|
3254
3246
|
CorrelationIdMiddleware,
|
|
3255
3247
|
HttpLoggerInterceptor,
|
|
3256
3248
|
LOGGER_MODULE_OPTIONS
|
|
@@ -3301,7 +3293,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3301
3293
|
* ```
|
|
3302
3294
|
*/
|
|
3303
3295
|
static forRootAsync(options) {
|
|
3304
|
-
const asyncProviders =
|
|
3296
|
+
const asyncProviders = _LoggerModule.createAsyncProviders(options);
|
|
3305
3297
|
return {
|
|
3306
3298
|
module: _LoggerModule,
|
|
3307
3299
|
imports: options.imports || [],
|
|
@@ -3327,9 +3319,9 @@ var LoggerModule = class _LoggerModule {
|
|
|
3327
3319
|
},
|
|
3328
3320
|
// Unified logger service
|
|
3329
3321
|
{
|
|
3330
|
-
provide:
|
|
3322
|
+
provide: LoggerService,
|
|
3331
3323
|
useFactory: /* @__PURE__ */ __name((opts, defaultLogger) => {
|
|
3332
|
-
return new
|
|
3324
|
+
return new LoggerService(opts, defaultLogger);
|
|
3333
3325
|
}, "useFactory"),
|
|
3334
3326
|
inject: [
|
|
3335
3327
|
LOGGER_MODULE_OPTIONS,
|
|
@@ -3360,13 +3352,13 @@ var LoggerModule = class _LoggerModule {
|
|
|
3360
3352
|
return new HttpLoggerInterceptor(logger, httpLoggerOptions);
|
|
3361
3353
|
}, "useFactory"),
|
|
3362
3354
|
inject: [
|
|
3363
|
-
|
|
3355
|
+
LoggerService,
|
|
3364
3356
|
LOGGER_MODULE_OPTIONS
|
|
3365
3357
|
]
|
|
3366
3358
|
}
|
|
3367
3359
|
],
|
|
3368
3360
|
exports: [
|
|
3369
|
-
|
|
3361
|
+
LoggerService,
|
|
3370
3362
|
CorrelationIdMiddleware,
|
|
3371
3363
|
HttpLoggerInterceptor,
|
|
3372
3364
|
LOGGER_MODULE_OPTIONS
|
|
@@ -3377,7 +3369,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3377
3369
|
* Configures middleware for the module.
|
|
3378
3370
|
* Middleware is registered globally in main.ts using Fastify hooks.
|
|
3379
3371
|
*/
|
|
3380
|
-
configure(
|
|
3372
|
+
configure(_consumer) {
|
|
3381
3373
|
}
|
|
3382
3374
|
/**
|
|
3383
3375
|
* Creates async providers for dynamic module configuration.
|
|
@@ -3385,11 +3377,11 @@ var LoggerModule = class _LoggerModule {
|
|
|
3385
3377
|
static createAsyncProviders(options) {
|
|
3386
3378
|
if (options.useFactory) {
|
|
3387
3379
|
return [
|
|
3388
|
-
|
|
3380
|
+
_LoggerModule.createAsyncOptionsProvider(options)
|
|
3389
3381
|
];
|
|
3390
3382
|
}
|
|
3391
3383
|
const providers = [
|
|
3392
|
-
|
|
3384
|
+
_LoggerModule.createAsyncOptionsProvider(options)
|
|
3393
3385
|
];
|
|
3394
3386
|
if (options.useClass) {
|
|
3395
3387
|
providers.push({
|
|
@@ -3407,7 +3399,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3407
3399
|
return {
|
|
3408
3400
|
provide: LOGGER_MODULE_OPTIONS,
|
|
3409
3401
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
3410
|
-
const userOptions = await options.useFactory(...args);
|
|
3402
|
+
const userOptions = await options.useFactory?.(...args);
|
|
3411
3403
|
return mergeWithDefaults(userOptions);
|
|
3412
3404
|
}, "useFactory"),
|
|
3413
3405
|
inject: options.inject || []
|