@vritti/api-sdk 0.1.6 → 0.1.8
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/README.md +22 -6
- package/dist/index.cjs +620 -492
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +422 -244
- package/dist/index.d.ts +422 -244
- package/dist/index.js +581 -456
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4
4
|
// src/auth/auth-config.module.ts
|
|
5
5
|
import { Global as Global2, Module as Module2 } from "@nestjs/common";
|
|
6
6
|
import { ConfigModule, ConfigService as ConfigService2 } from "@nestjs/config";
|
|
7
|
-
import { APP_GUARD } from "@nestjs/core";
|
|
7
|
+
import { APP_GUARD, Reflector as Reflector2 } from "@nestjs/core";
|
|
8
8
|
import { JwtModule } from "@nestjs/jwt";
|
|
9
9
|
|
|
10
10
|
// src/request/request.module.ts
|
|
@@ -217,11 +217,16 @@ RequestModule = _ts_decorate2([
|
|
|
217
217
|
], RequestModule);
|
|
218
218
|
|
|
219
219
|
// src/auth/guards/vritti-auth.guard.ts
|
|
220
|
-
import { Injectable as Injectable3, Logger as Logger3, Scope as Scope2, UnauthorizedException } from "@nestjs/common";
|
|
220
|
+
import { ForbiddenException, Injectable as Injectable3, Logger as Logger3, Scope as Scope2, UnauthorizedException } from "@nestjs/common";
|
|
221
221
|
import { ConfigService } from "@nestjs/config";
|
|
222
222
|
import { Reflector } from "@nestjs/core";
|
|
223
223
|
import { JwtService } from "@nestjs/jwt";
|
|
224
224
|
|
|
225
|
+
// src/auth/decorators/skip-csrf.decorator.ts
|
|
226
|
+
import { SetMetadata } from "@nestjs/common";
|
|
227
|
+
var SKIP_CSRF_KEY = "skipCsrf";
|
|
228
|
+
var SkipCsrf = /* @__PURE__ */ __name(() => SetMetadata(SKIP_CSRF_KEY, true), "SkipCsrf");
|
|
229
|
+
|
|
225
230
|
// src/database/services/primary-database.service.ts
|
|
226
231
|
import { Inject as Inject2, Injectable as Injectable2, InternalServerErrorException, Logger as Logger2 } from "@nestjs/common";
|
|
227
232
|
import { eq, or } from "drizzle-orm";
|
|
@@ -503,6 +508,14 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
503
508
|
}
|
|
504
509
|
async canActivate(context) {
|
|
505
510
|
const request = context.switchToHttp().getRequest();
|
|
511
|
+
const reply = context.switchToHttp().getResponse();
|
|
512
|
+
const skipCsrf = this.reflector.getAllAndOverride(SKIP_CSRF_KEY, [
|
|
513
|
+
context.getHandler(),
|
|
514
|
+
context.getClass()
|
|
515
|
+
]);
|
|
516
|
+
if (!skipCsrf) {
|
|
517
|
+
await this.validateCsrf(request, reply);
|
|
518
|
+
}
|
|
506
519
|
const isPublic = this.reflector.getAllAndOverride("isPublic", [
|
|
507
520
|
context.getHandler(),
|
|
508
521
|
context.getClass()
|
|
@@ -648,6 +661,52 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
648
661
|
}
|
|
649
662
|
this.logger.debug("Token binding validated successfully");
|
|
650
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Validate CSRF token for state-changing requests
|
|
666
|
+
* Uses Fastify's csrf-protection plugin for token validation
|
|
667
|
+
*
|
|
668
|
+
* @param request - Fastify request object
|
|
669
|
+
* @param reply - Fastify reply object
|
|
670
|
+
* @throws ForbiddenException if CSRF validation fails
|
|
671
|
+
*/
|
|
672
|
+
async validateCsrf(request, reply) {
|
|
673
|
+
const safeMethods = [
|
|
674
|
+
"GET",
|
|
675
|
+
"HEAD",
|
|
676
|
+
"OPTIONS"
|
|
677
|
+
];
|
|
678
|
+
if (safeMethods.includes(request.method)) {
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
try {
|
|
682
|
+
const fastifyInstance = request.server;
|
|
683
|
+
if (!fastifyInstance.csrfProtection) {
|
|
684
|
+
this.logger.error("CSRF protection plugin not found. Ensure @fastify/csrf-protection is registered.");
|
|
685
|
+
throw new ForbiddenException("CSRF protection not configured");
|
|
686
|
+
}
|
|
687
|
+
await new Promise((resolve, reject) => {
|
|
688
|
+
fastifyInstance.csrfProtection(request, reply, (err) => {
|
|
689
|
+
if (err) {
|
|
690
|
+
reject(err);
|
|
691
|
+
} else {
|
|
692
|
+
resolve();
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
this.logger.debug(`CSRF validation successful for ${request.method} ${request.url}`);
|
|
697
|
+
} catch (error) {
|
|
698
|
+
this.logger.warn(`CSRF validation failed for ${request.method} ${request.url}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
699
|
+
throw new ForbiddenException({
|
|
700
|
+
errors: [
|
|
701
|
+
{
|
|
702
|
+
field: "csrf",
|
|
703
|
+
message: "Invalid or missing CSRF token"
|
|
704
|
+
}
|
|
705
|
+
],
|
|
706
|
+
message: "CSRF validation failed"
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
651
710
|
};
|
|
652
711
|
VrittiAuthGuard = _ts_decorate4([
|
|
653
712
|
Injectable3({
|
|
@@ -707,6 +766,11 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
707
766
|
})
|
|
708
767
|
],
|
|
709
768
|
providers: [
|
|
769
|
+
// Required for external packages - NestJS global Reflector not available
|
|
770
|
+
{
|
|
771
|
+
provide: Reflector2,
|
|
772
|
+
useClass: Reflector2
|
|
773
|
+
},
|
|
710
774
|
{
|
|
711
775
|
provide: APP_GUARD,
|
|
712
776
|
useClass: VrittiAuthGuard
|
|
@@ -724,12 +788,12 @@ AuthConfigModule = _ts_decorate5([
|
|
|
724
788
|
], AuthConfigModule);
|
|
725
789
|
|
|
726
790
|
// src/auth/decorators/onboarding.decorator.ts
|
|
727
|
-
import { SetMetadata } from "@nestjs/common";
|
|
728
|
-
var Onboarding = /* @__PURE__ */ __name(() =>
|
|
791
|
+
import { SetMetadata as SetMetadata2 } from "@nestjs/common";
|
|
792
|
+
var Onboarding = /* @__PURE__ */ __name(() => SetMetadata2("isOnboarding", true), "Onboarding");
|
|
729
793
|
|
|
730
794
|
// src/auth/decorators/public.decorator.ts
|
|
731
|
-
import { SetMetadata as
|
|
732
|
-
var Public = /* @__PURE__ */ __name(() =>
|
|
795
|
+
import { SetMetadata as SetMetadata3 } from "@nestjs/common";
|
|
796
|
+
var Public = /* @__PURE__ */ __name(() => SetMetadata3("isPublic", true), "Public");
|
|
733
797
|
|
|
734
798
|
// src/auth/decorators/user-id.decorator.ts
|
|
735
799
|
import { createParamDecorator } from "@nestjs/common";
|
|
@@ -742,23 +806,123 @@ var UserId = createParamDecorator((_data, ctx) => {
|
|
|
742
806
|
return user.id;
|
|
743
807
|
});
|
|
744
808
|
|
|
809
|
+
// src/auth/guards/sse-auth.guard.ts
|
|
810
|
+
import { Injectable as Injectable4, Logger as Logger4, Scope as Scope3, UnauthorizedException as UnauthorizedException2 } from "@nestjs/common";
|
|
811
|
+
import { JwtService as JwtService2 } from "@nestjs/jwt";
|
|
812
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
813
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
814
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
815
|
+
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;
|
|
816
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
817
|
+
}
|
|
818
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
819
|
+
function _ts_metadata4(k, v) {
|
|
820
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
821
|
+
}
|
|
822
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
823
|
+
var SSE_ALLOWED_ORIGINS = [
|
|
824
|
+
"http://localhost:5173",
|
|
825
|
+
"http://localhost:3001",
|
|
826
|
+
"http://localhost:3012",
|
|
827
|
+
"http://localhost:5174",
|
|
828
|
+
"http://local.vrittiai.com:3012",
|
|
829
|
+
"http://cloud.local.vrittiai.com:3012",
|
|
830
|
+
"https://local.vrittiai.com:3012",
|
|
831
|
+
"https://cloud.local.vrittiai.com:3012"
|
|
832
|
+
];
|
|
833
|
+
var SseAuthGuard = class _SseAuthGuard {
|
|
834
|
+
static {
|
|
835
|
+
__name(this, "SseAuthGuard");
|
|
836
|
+
}
|
|
837
|
+
jwtService;
|
|
838
|
+
logger = new Logger4(_SseAuthGuard.name);
|
|
839
|
+
constructor(jwtService) {
|
|
840
|
+
this.jwtService = jwtService;
|
|
841
|
+
}
|
|
842
|
+
async canActivate(context) {
|
|
843
|
+
const request = context.switchToHttp().getRequest();
|
|
844
|
+
const response = context.switchToHttp().getResponse();
|
|
845
|
+
this.setCorsHeaders(request, response);
|
|
846
|
+
const token = request.query?.token;
|
|
847
|
+
if (!token) {
|
|
848
|
+
this.logger.warn("SSE authentication failed: token not found in query params");
|
|
849
|
+
throw new UnauthorizedException2("Authentication required");
|
|
850
|
+
}
|
|
851
|
+
try {
|
|
852
|
+
const decodedToken = this.jwtService.decode(token);
|
|
853
|
+
if (!decodedToken) {
|
|
854
|
+
this.logger.warn("SSE authentication failed: invalid token format");
|
|
855
|
+
throw new UnauthorizedException2("Invalid token format");
|
|
856
|
+
}
|
|
857
|
+
if (decodedToken.type !== "onboarding") {
|
|
858
|
+
this.logger.warn("SSE authentication failed: endpoint requires onboarding token");
|
|
859
|
+
throw new UnauthorizedException2("This endpoint requires an onboarding token");
|
|
860
|
+
}
|
|
861
|
+
const validatedToken = this.jwtService.verify(token);
|
|
862
|
+
this.logger.debug(`SSE token validated for user: ${validatedToken.userId}`);
|
|
863
|
+
request.user = {
|
|
864
|
+
id: validatedToken.userId
|
|
865
|
+
};
|
|
866
|
+
return true;
|
|
867
|
+
} catch (error) {
|
|
868
|
+
if (error instanceof UnauthorizedException2) {
|
|
869
|
+
throw error;
|
|
870
|
+
}
|
|
871
|
+
const jwtError = error;
|
|
872
|
+
if (jwtError?.name === "TokenExpiredError") {
|
|
873
|
+
this.logger.warn("SSE authentication failed: token expired");
|
|
874
|
+
throw new UnauthorizedException2("Token has expired");
|
|
875
|
+
}
|
|
876
|
+
if (jwtError?.name === "JsonWebTokenError") {
|
|
877
|
+
this.logger.warn(`SSE authentication failed: ${jwtError?.message}`);
|
|
878
|
+
throw new UnauthorizedException2("Invalid token");
|
|
879
|
+
}
|
|
880
|
+
this.logger.error("Unexpected error in SSE auth guard", error);
|
|
881
|
+
throw new UnauthorizedException2("Authentication failed");
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Set CORS headers for SSE responses
|
|
886
|
+
* Must be called before any potential exceptions
|
|
887
|
+
*/
|
|
888
|
+
setCorsHeaders(request, response) {
|
|
889
|
+
const origin = request.headers.origin;
|
|
890
|
+
if (origin && SSE_ALLOWED_ORIGINS.includes(origin)) {
|
|
891
|
+
response.header("Access-Control-Allow-Origin", origin);
|
|
892
|
+
response.header("Access-Control-Allow-Credentials", "true");
|
|
893
|
+
this.logger.debug(`CORS headers set for origin: ${origin}`);
|
|
894
|
+
} else if (origin) {
|
|
895
|
+
this.logger.warn(`SSE request from unauthorized origin: ${origin}`);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
SseAuthGuard = _ts_decorate6([
|
|
900
|
+
Injectable4({
|
|
901
|
+
scope: Scope3.REQUEST
|
|
902
|
+
}),
|
|
903
|
+
_ts_metadata4("design:type", Function),
|
|
904
|
+
_ts_metadata4("design:paramtypes", [
|
|
905
|
+
typeof JwtService2 === "undefined" ? Object : JwtService2
|
|
906
|
+
])
|
|
907
|
+
], SseAuthGuard);
|
|
908
|
+
|
|
745
909
|
// src/database/database.module.ts
|
|
746
910
|
import { Global as Global3, Module as Module3 } from "@nestjs/common";
|
|
747
|
-
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
911
|
+
import { APP_INTERCEPTOR, Reflector as Reflector4 } from "@nestjs/core";
|
|
748
912
|
|
|
749
913
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
750
|
-
import { Injectable as
|
|
914
|
+
import { Injectable as Injectable6, Logger as Logger5, Scope as Scope5 } from "@nestjs/common";
|
|
751
915
|
import { tap } from "rxjs/operators";
|
|
752
916
|
|
|
753
917
|
// src/database/services/tenant-context.service.ts
|
|
754
|
-
import { Injectable as
|
|
755
|
-
function
|
|
918
|
+
import { Injectable as Injectable5, Scope as Scope4, UnauthorizedException as UnauthorizedException3 } from "@nestjs/common";
|
|
919
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
756
920
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
757
921
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
758
922
|
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;
|
|
759
923
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
760
924
|
}
|
|
761
|
-
__name(
|
|
925
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
762
926
|
var TenantContextService = class {
|
|
763
927
|
static {
|
|
764
928
|
__name(this, "TenantContextService");
|
|
@@ -789,7 +953,7 @@ var TenantContextService = class {
|
|
|
789
953
|
*/
|
|
790
954
|
getTenant() {
|
|
791
955
|
if (!this.tenantInfo) {
|
|
792
|
-
throw new
|
|
956
|
+
throw new UnauthorizedException3("Tenant context not set");
|
|
793
957
|
}
|
|
794
958
|
return this.tenantInfo;
|
|
795
959
|
}
|
|
@@ -830,30 +994,30 @@ var TenantContextService = class {
|
|
|
830
994
|
return this.tenantInfo?.subdomain ?? null;
|
|
831
995
|
}
|
|
832
996
|
};
|
|
833
|
-
TenantContextService =
|
|
834
|
-
|
|
835
|
-
scope:
|
|
997
|
+
TenantContextService = _ts_decorate7([
|
|
998
|
+
Injectable5({
|
|
999
|
+
scope: Scope4.REQUEST
|
|
836
1000
|
})
|
|
837
1001
|
], TenantContextService);
|
|
838
1002
|
|
|
839
1003
|
// src/database/interceptors/message-tenant-context.interceptor.ts
|
|
840
|
-
function
|
|
1004
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
841
1005
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
842
1006
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
843
1007
|
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;
|
|
844
1008
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
845
1009
|
}
|
|
846
|
-
__name(
|
|
847
|
-
function
|
|
1010
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1011
|
+
function _ts_metadata5(k, v) {
|
|
848
1012
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
849
1013
|
}
|
|
850
|
-
__name(
|
|
1014
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
851
1015
|
var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
852
1016
|
static {
|
|
853
1017
|
__name(this, "MessageTenantContextInterceptor");
|
|
854
1018
|
}
|
|
855
1019
|
tenantContext;
|
|
856
|
-
logger = new
|
|
1020
|
+
logger = new Logger5(_MessageTenantContextInterceptor.name);
|
|
857
1021
|
constructor(tenantContext) {
|
|
858
1022
|
this.tenantContext = tenantContext;
|
|
859
1023
|
}
|
|
@@ -898,30 +1062,30 @@ var MessageTenantContextInterceptor = class _MessageTenantContextInterceptor {
|
|
|
898
1062
|
}
|
|
899
1063
|
}
|
|
900
1064
|
};
|
|
901
|
-
MessageTenantContextInterceptor =
|
|
902
|
-
|
|
903
|
-
scope:
|
|
1065
|
+
MessageTenantContextInterceptor = _ts_decorate8([
|
|
1066
|
+
Injectable6({
|
|
1067
|
+
scope: Scope5.REQUEST
|
|
904
1068
|
}),
|
|
905
|
-
|
|
906
|
-
|
|
1069
|
+
_ts_metadata5("design:type", Function),
|
|
1070
|
+
_ts_metadata5("design:paramtypes", [
|
|
907
1071
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
908
1072
|
])
|
|
909
1073
|
], MessageTenantContextInterceptor);
|
|
910
1074
|
|
|
911
1075
|
// src/database/interceptors/tenant-context.interceptor.ts
|
|
912
|
-
import { Injectable as
|
|
913
|
-
import { Reflector as
|
|
914
|
-
function
|
|
1076
|
+
import { Injectable as Injectable7, Logger as Logger6, Scope as Scope6, UnauthorizedException as UnauthorizedException4 } from "@nestjs/common";
|
|
1077
|
+
import { Reflector as Reflector3 } from "@nestjs/core";
|
|
1078
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
915
1079
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
916
1080
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
917
1081
|
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;
|
|
918
1082
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
919
1083
|
}
|
|
920
|
-
__name(
|
|
921
|
-
function
|
|
1084
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1085
|
+
function _ts_metadata6(k, v) {
|
|
922
1086
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
923
1087
|
}
|
|
924
|
-
__name(
|
|
1088
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
925
1089
|
var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
926
1090
|
static {
|
|
927
1091
|
__name(this, "TenantContextInterceptor");
|
|
@@ -930,7 +1094,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
930
1094
|
tenantContext;
|
|
931
1095
|
primaryDatabase;
|
|
932
1096
|
requestService;
|
|
933
|
-
logger = new
|
|
1097
|
+
logger = new Logger6(_TenantContextInterceptor.name);
|
|
934
1098
|
constructor(reflector, tenantContext, primaryDatabase, requestService) {
|
|
935
1099
|
this.reflector = reflector;
|
|
936
1100
|
this.tenantContext = tenantContext;
|
|
@@ -951,7 +1115,7 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
951
1115
|
return next.handle();
|
|
952
1116
|
}
|
|
953
1117
|
if (!tenantIdentifier) {
|
|
954
|
-
throw new
|
|
1118
|
+
throw new UnauthorizedException4("Tenant identifier not found in request");
|
|
955
1119
|
}
|
|
956
1120
|
this.logger.debug(`Tenant identifier extracted: ${tenantIdentifier}`);
|
|
957
1121
|
if (tenantIdentifier === "cloud") {
|
|
@@ -961,11 +1125,11 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
961
1125
|
const tenantInfo = await this.primaryDatabase.getTenantInfo(tenantIdentifier);
|
|
962
1126
|
if (!tenantInfo) {
|
|
963
1127
|
this.logger.warn(`Invalid tenant: ${tenantIdentifier}`);
|
|
964
|
-
throw new
|
|
1128
|
+
throw new UnauthorizedException4("Invalid tenant");
|
|
965
1129
|
}
|
|
966
1130
|
if (tenantInfo.status !== "ACTIVE") {
|
|
967
1131
|
this.logger.warn(`Tenant ${tenantIdentifier} has status: ${tenantInfo.status}`);
|
|
968
|
-
throw new
|
|
1132
|
+
throw new UnauthorizedException4(`Tenant is ${tenantInfo.status}`);
|
|
969
1133
|
}
|
|
970
1134
|
this.logger.debug(`Tenant config loaded: ${tenantInfo.subdomain} (${tenantInfo.type})`);
|
|
971
1135
|
this.tenantContext.setTenant(tenantInfo);
|
|
@@ -978,13 +1142,13 @@ var TenantContextInterceptor = class _TenantContextInterceptor {
|
|
|
978
1142
|
return next.handle();
|
|
979
1143
|
}
|
|
980
1144
|
};
|
|
981
|
-
TenantContextInterceptor =
|
|
982
|
-
|
|
983
|
-
scope:
|
|
1145
|
+
TenantContextInterceptor = _ts_decorate9([
|
|
1146
|
+
Injectable7({
|
|
1147
|
+
scope: Scope6.REQUEST
|
|
984
1148
|
}),
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
typeof
|
|
1149
|
+
_ts_metadata6("design:type", Function),
|
|
1150
|
+
_ts_metadata6("design:paramtypes", [
|
|
1151
|
+
typeof Reflector3 === "undefined" ? Object : Reflector3,
|
|
988
1152
|
typeof TenantContextService === "undefined" ? Object : TenantContextService,
|
|
989
1153
|
typeof PrimaryDatabaseService === "undefined" ? Object : PrimaryDatabaseService,
|
|
990
1154
|
typeof RequestService === "undefined" ? Object : RequestService
|
|
@@ -992,20 +1156,20 @@ TenantContextInterceptor = _ts_decorate8([
|
|
|
992
1156
|
], TenantContextInterceptor);
|
|
993
1157
|
|
|
994
1158
|
// src/database/services/tenant-database.service.ts
|
|
995
|
-
import { Inject as Inject3, Injectable as
|
|
1159
|
+
import { Inject as Inject3, Injectable as Injectable8, InternalServerErrorException as InternalServerErrorException2, Logger as Logger7 } from "@nestjs/common";
|
|
996
1160
|
import { drizzle as drizzle2 } from "drizzle-orm/node-postgres";
|
|
997
1161
|
import { Pool as Pool2 } from "pg";
|
|
998
|
-
function
|
|
1162
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
999
1163
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1000
1164
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1001
1165
|
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;
|
|
1002
1166
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1003
1167
|
}
|
|
1004
|
-
__name(
|
|
1005
|
-
function
|
|
1168
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
1169
|
+
function _ts_metadata7(k, v) {
|
|
1006
1170
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1007
1171
|
}
|
|
1008
|
-
__name(
|
|
1172
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1009
1173
|
function _ts_param3(paramIndex, decorator) {
|
|
1010
1174
|
return function(target, key) {
|
|
1011
1175
|
decorator(target, key, paramIndex);
|
|
@@ -1018,7 +1182,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1018
1182
|
}
|
|
1019
1183
|
options;
|
|
1020
1184
|
tenantContext;
|
|
1021
|
-
logger = new
|
|
1185
|
+
logger = new Logger7(_TenantDatabaseService.name);
|
|
1022
1186
|
/** Connection pool: Map<cacheKey, TenantConnection> */
|
|
1023
1187
|
clients = /* @__PURE__ */ new Map();
|
|
1024
1188
|
/** Track last usage time for idle connection cleanup */
|
|
@@ -1187,24 +1351,24 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1187
1351
|
this.logger.log("All database connections closed");
|
|
1188
1352
|
}
|
|
1189
1353
|
};
|
|
1190
|
-
TenantDatabaseService =
|
|
1191
|
-
|
|
1354
|
+
TenantDatabaseService = _ts_decorate10([
|
|
1355
|
+
Injectable8(),
|
|
1192
1356
|
_ts_param3(0, Inject3(DATABASE_MODULE_OPTIONS)),
|
|
1193
|
-
|
|
1194
|
-
|
|
1357
|
+
_ts_metadata7("design:type", Function),
|
|
1358
|
+
_ts_metadata7("design:paramtypes", [
|
|
1195
1359
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
1196
1360
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
1197
1361
|
])
|
|
1198
1362
|
], TenantDatabaseService);
|
|
1199
1363
|
|
|
1200
1364
|
// src/database/database.module.ts
|
|
1201
|
-
function
|
|
1365
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1202
1366
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1203
1367
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1204
1368
|
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;
|
|
1205
1369
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1206
1370
|
}
|
|
1207
|
-
__name(
|
|
1371
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1208
1372
|
var DatabaseModule = class _DatabaseModule {
|
|
1209
1373
|
static {
|
|
1210
1374
|
__name(this, "DatabaseModule");
|
|
@@ -1275,6 +1439,11 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1275
1439
|
inject: options.inject || []
|
|
1276
1440
|
};
|
|
1277
1441
|
const providers = [
|
|
1442
|
+
// Required for external packages - NestJS global Reflector not available
|
|
1443
|
+
{
|
|
1444
|
+
provide: Reflector4,
|
|
1445
|
+
useClass: Reflector4
|
|
1446
|
+
},
|
|
1278
1447
|
asyncProvider,
|
|
1279
1448
|
TenantContextService,
|
|
1280
1449
|
PrimaryDatabaseService,
|
|
@@ -1306,7 +1475,7 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1306
1475
|
};
|
|
1307
1476
|
}
|
|
1308
1477
|
};
|
|
1309
|
-
DatabaseModule =
|
|
1478
|
+
DatabaseModule = _ts_decorate11([
|
|
1310
1479
|
Global3(),
|
|
1311
1480
|
Module3({})
|
|
1312
1481
|
], DatabaseModule);
|
|
@@ -1323,7 +1492,7 @@ var Tenant = createParamDecorator2((_data, ctx) => {
|
|
|
1323
1492
|
});
|
|
1324
1493
|
|
|
1325
1494
|
// src/database/repositories/primary-base.repository.ts
|
|
1326
|
-
import { Logger as
|
|
1495
|
+
import { Logger as Logger8 } from "@nestjs/common";
|
|
1327
1496
|
import { eq as eq2, getTableName, sql } from "drizzle-orm";
|
|
1328
1497
|
function snakeToCamel(str) {
|
|
1329
1498
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1394,7 +1563,7 @@ var PrimaryBaseRepository = class {
|
|
|
1394
1563
|
this.table = table;
|
|
1395
1564
|
const dbTableName = getTableName(table);
|
|
1396
1565
|
this.tableName = snakeToCamel(dbTableName);
|
|
1397
|
-
this.logger = new
|
|
1566
|
+
this.logger = new Logger8(this.constructor.name);
|
|
1398
1567
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1399
1568
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1400
1569
|
}
|
|
@@ -1634,7 +1803,7 @@ var PrimaryBaseRepository = class {
|
|
|
1634
1803
|
};
|
|
1635
1804
|
|
|
1636
1805
|
// src/database/repositories/tenant-base.repository.ts
|
|
1637
|
-
import { Logger as
|
|
1806
|
+
import { Logger as Logger9 } from "@nestjs/common";
|
|
1638
1807
|
import { eq as eq3, getTableName as getTableName2, sql as sql2 } from "drizzle-orm";
|
|
1639
1808
|
var TenantBaseRepository = class {
|
|
1640
1809
|
static {
|
|
@@ -1691,7 +1860,7 @@ var TenantBaseRepository = class {
|
|
|
1691
1860
|
this.database = database;
|
|
1692
1861
|
this.table = table;
|
|
1693
1862
|
this.tableName = getTableName2(table);
|
|
1694
|
-
this.logger = new
|
|
1863
|
+
this.logger = new Logger9(this.constructor.name);
|
|
1695
1864
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1696
1865
|
}
|
|
1697
1866
|
/**
|
|
@@ -1924,402 +2093,235 @@ var TenantBaseRepository = class {
|
|
|
1924
2093
|
};
|
|
1925
2094
|
|
|
1926
2095
|
// src/exceptions/bad-gateway.exception.ts
|
|
1927
|
-
import { HttpStatus
|
|
2096
|
+
import { HttpStatus } from "@nestjs/common";
|
|
1928
2097
|
|
|
1929
2098
|
// src/exceptions/base-field.exception.ts
|
|
1930
|
-
import { HttpException
|
|
1931
|
-
var
|
|
2099
|
+
import { HttpException } from "@nestjs/common";
|
|
2100
|
+
var HttpProblemException = class extends HttpException {
|
|
1932
2101
|
static {
|
|
1933
|
-
__name(this, "
|
|
1934
|
-
}
|
|
1935
|
-
constructor(
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
{
|
|
1946
|
-
field: statusOrMessageOrErrors,
|
|
1947
|
-
message: messageOrStatus
|
|
1948
|
-
}
|
|
1949
|
-
];
|
|
1950
|
-
httpStatus = statusOrDetail;
|
|
1951
|
-
finalDetail = detail;
|
|
1952
|
-
} else if (typeof statusOrMessageOrErrors === "string") {
|
|
1953
|
-
errors = [
|
|
1954
|
-
{
|
|
1955
|
-
message: statusOrMessageOrErrors
|
|
1956
|
-
}
|
|
1957
|
-
];
|
|
1958
|
-
httpStatus = messageOrStatus;
|
|
1959
|
-
finalDetail = typeof statusOrDetail === "string" ? statusOrDetail : void 0;
|
|
1960
|
-
} else {
|
|
1961
|
-
errors = [
|
|
1962
|
-
{
|
|
1963
|
-
message: "An error occurred"
|
|
1964
|
-
}
|
|
1965
|
-
];
|
|
1966
|
-
httpStatus = statusOrMessageOrErrors;
|
|
1967
|
-
finalDetail = void 0;
|
|
1968
|
-
}
|
|
1969
|
-
const response = finalDetail !== void 0 ? {
|
|
1970
|
-
errors,
|
|
1971
|
-
detail: finalDetail
|
|
1972
|
-
} : {
|
|
1973
|
-
errors
|
|
1974
|
-
};
|
|
1975
|
-
super(response, httpStatus);
|
|
2102
|
+
__name(this, "HttpProblemException");
|
|
2103
|
+
}
|
|
2104
|
+
constructor(detailOrOptions, httpStatus) {
|
|
2105
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
2106
|
+
detail: detailOrOptions
|
|
2107
|
+
} : detailOrOptions;
|
|
2108
|
+
super({
|
|
2109
|
+
type: options.type ?? "about:blank",
|
|
2110
|
+
label: options.label,
|
|
2111
|
+
detail: options.detail,
|
|
2112
|
+
errors: options.errors ?? []
|
|
2113
|
+
}, httpStatus);
|
|
1976
2114
|
}
|
|
1977
2115
|
};
|
|
1978
2116
|
|
|
1979
2117
|
// src/exceptions/bad-gateway.exception.ts
|
|
1980
|
-
var BadGatewayException = class extends
|
|
2118
|
+
var BadGatewayException = class extends HttpProblemException {
|
|
1981
2119
|
static {
|
|
1982
2120
|
__name(this, "BadGatewayException");
|
|
1983
2121
|
}
|
|
1984
|
-
constructor(
|
|
1985
|
-
|
|
1986
|
-
super(messageOrField, HttpStatus2.BAD_GATEWAY, fieldMessageOrDetail);
|
|
1987
|
-
} else if (detail !== void 0) {
|
|
1988
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus2.BAD_GATEWAY, detail);
|
|
1989
|
-
} else if (fieldMessageOrDetail) {
|
|
1990
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus2.BAD_GATEWAY);
|
|
1991
|
-
} else {
|
|
1992
|
-
super(messageOrField, HttpStatus2.BAD_GATEWAY);
|
|
1993
|
-
}
|
|
2122
|
+
constructor(detailOrOptions) {
|
|
2123
|
+
super(detailOrOptions ?? "Bad Gateway", HttpStatus.BAD_GATEWAY);
|
|
1994
2124
|
}
|
|
1995
2125
|
};
|
|
1996
2126
|
|
|
1997
2127
|
// src/exceptions/bad-request.exception.ts
|
|
1998
|
-
import { HttpStatus as
|
|
1999
|
-
var BadRequestException = class extends
|
|
2128
|
+
import { HttpStatus as HttpStatus2 } from "@nestjs/common";
|
|
2129
|
+
var BadRequestException = class extends HttpProblemException {
|
|
2000
2130
|
static {
|
|
2001
2131
|
__name(this, "BadRequestException");
|
|
2002
2132
|
}
|
|
2003
|
-
constructor(
|
|
2004
|
-
|
|
2005
|
-
super(messageOrField, HttpStatus3.BAD_REQUEST, fieldMessageOrDetail);
|
|
2006
|
-
} else if (detail !== void 0) {
|
|
2007
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus3.BAD_REQUEST, detail);
|
|
2008
|
-
} else if (fieldMessageOrDetail) {
|
|
2009
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus3.BAD_REQUEST);
|
|
2010
|
-
} else {
|
|
2011
|
-
super(messageOrField, HttpStatus3.BAD_REQUEST);
|
|
2012
|
-
}
|
|
2133
|
+
constructor(detailOrOptions) {
|
|
2134
|
+
super(detailOrOptions ?? "Bad Request", HttpStatus2.BAD_REQUEST);
|
|
2013
2135
|
}
|
|
2014
2136
|
};
|
|
2015
2137
|
|
|
2016
2138
|
// src/exceptions/conflict.exception.ts
|
|
2017
|
-
import { HttpStatus as
|
|
2018
|
-
var ConflictException = class extends
|
|
2139
|
+
import { HttpStatus as HttpStatus3 } from "@nestjs/common";
|
|
2140
|
+
var ConflictException = class extends HttpProblemException {
|
|
2019
2141
|
static {
|
|
2020
2142
|
__name(this, "ConflictException");
|
|
2021
2143
|
}
|
|
2022
|
-
constructor(
|
|
2023
|
-
|
|
2024
|
-
super(messageOrField, HttpStatus4.CONFLICT, fieldMessageOrDetail);
|
|
2025
|
-
} else if (detail !== void 0) {
|
|
2026
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus4.CONFLICT, detail);
|
|
2027
|
-
} else if (fieldMessageOrDetail) {
|
|
2028
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus4.CONFLICT);
|
|
2029
|
-
} else {
|
|
2030
|
-
super(messageOrField, HttpStatus4.CONFLICT);
|
|
2031
|
-
}
|
|
2144
|
+
constructor(detailOrOptions) {
|
|
2145
|
+
super(detailOrOptions ?? "Conflict", HttpStatus3.CONFLICT);
|
|
2032
2146
|
}
|
|
2033
2147
|
};
|
|
2034
2148
|
|
|
2035
2149
|
// src/exceptions/forbidden.exception.ts
|
|
2036
|
-
import { HttpStatus as
|
|
2037
|
-
var
|
|
2150
|
+
import { HttpStatus as HttpStatus4 } from "@nestjs/common";
|
|
2151
|
+
var ForbiddenException2 = class extends HttpProblemException {
|
|
2038
2152
|
static {
|
|
2039
2153
|
__name(this, "ForbiddenException");
|
|
2040
2154
|
}
|
|
2041
|
-
constructor(
|
|
2042
|
-
|
|
2043
|
-
super(messageOrField, HttpStatus5.FORBIDDEN, fieldMessageOrDetail);
|
|
2044
|
-
} else if (detail !== void 0) {
|
|
2045
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus5.FORBIDDEN, detail);
|
|
2046
|
-
} else if (fieldMessageOrDetail) {
|
|
2047
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus5.FORBIDDEN);
|
|
2048
|
-
} else {
|
|
2049
|
-
super(messageOrField, HttpStatus5.FORBIDDEN);
|
|
2050
|
-
}
|
|
2155
|
+
constructor(detailOrOptions) {
|
|
2156
|
+
super(detailOrOptions ?? "Forbidden", HttpStatus4.FORBIDDEN);
|
|
2051
2157
|
}
|
|
2052
2158
|
};
|
|
2053
2159
|
|
|
2054
2160
|
// src/exceptions/gone.exception.ts
|
|
2055
|
-
import { HttpStatus as
|
|
2056
|
-
var GoneException = class extends
|
|
2161
|
+
import { HttpStatus as HttpStatus5 } from "@nestjs/common";
|
|
2162
|
+
var GoneException = class extends HttpProblemException {
|
|
2057
2163
|
static {
|
|
2058
2164
|
__name(this, "GoneException");
|
|
2059
2165
|
}
|
|
2060
|
-
constructor(
|
|
2061
|
-
|
|
2062
|
-
super(messageOrField, HttpStatus6.GONE, fieldMessageOrDetail);
|
|
2063
|
-
} else if (detail !== void 0) {
|
|
2064
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus6.GONE, detail);
|
|
2065
|
-
} else if (fieldMessageOrDetail) {
|
|
2066
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus6.GONE);
|
|
2067
|
-
} else {
|
|
2068
|
-
super(messageOrField, HttpStatus6.GONE);
|
|
2069
|
-
}
|
|
2166
|
+
constructor(detailOrOptions) {
|
|
2167
|
+
super(detailOrOptions ?? "Gone", HttpStatus5.GONE);
|
|
2070
2168
|
}
|
|
2071
2169
|
};
|
|
2072
2170
|
|
|
2073
2171
|
// src/exceptions/internal-server-error.exception.ts
|
|
2074
|
-
import { HttpStatus as
|
|
2075
|
-
var InternalServerErrorException3 = class extends
|
|
2172
|
+
import { HttpStatus as HttpStatus6 } from "@nestjs/common";
|
|
2173
|
+
var InternalServerErrorException3 = class extends HttpProblemException {
|
|
2076
2174
|
static {
|
|
2077
2175
|
__name(this, "InternalServerErrorException");
|
|
2078
2176
|
}
|
|
2079
|
-
constructor(
|
|
2080
|
-
|
|
2081
|
-
super(messageOrField, HttpStatus7.INTERNAL_SERVER_ERROR, fieldMessageOrDetail);
|
|
2082
|
-
} else if (detail !== void 0) {
|
|
2083
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus7.INTERNAL_SERVER_ERROR, detail);
|
|
2084
|
-
} else if (fieldMessageOrDetail) {
|
|
2085
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus7.INTERNAL_SERVER_ERROR);
|
|
2086
|
-
} else {
|
|
2087
|
-
super(messageOrField, HttpStatus7.INTERNAL_SERVER_ERROR);
|
|
2088
|
-
}
|
|
2177
|
+
constructor(detailOrOptions) {
|
|
2178
|
+
super(detailOrOptions ?? "Internal Server Error", HttpStatus6.INTERNAL_SERVER_ERROR);
|
|
2089
2179
|
}
|
|
2090
2180
|
};
|
|
2091
2181
|
|
|
2092
2182
|
// src/exceptions/method-not-allowed.exception.ts
|
|
2093
|
-
import { HttpStatus as
|
|
2094
|
-
var MethodNotAllowedException = class extends
|
|
2183
|
+
import { HttpStatus as HttpStatus7 } from "@nestjs/common";
|
|
2184
|
+
var MethodNotAllowedException = class extends HttpProblemException {
|
|
2095
2185
|
static {
|
|
2096
2186
|
__name(this, "MethodNotAllowedException");
|
|
2097
2187
|
}
|
|
2098
|
-
constructor(
|
|
2099
|
-
|
|
2100
|
-
super(messageOrField, HttpStatus8.METHOD_NOT_ALLOWED, fieldMessageOrDetail);
|
|
2101
|
-
} else if (detail !== void 0) {
|
|
2102
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus8.METHOD_NOT_ALLOWED, detail);
|
|
2103
|
-
} else if (fieldMessageOrDetail) {
|
|
2104
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus8.METHOD_NOT_ALLOWED);
|
|
2105
|
-
} else {
|
|
2106
|
-
super(messageOrField, HttpStatus8.METHOD_NOT_ALLOWED);
|
|
2107
|
-
}
|
|
2188
|
+
constructor(detailOrOptions) {
|
|
2189
|
+
super(detailOrOptions ?? "Method Not Allowed", HttpStatus7.METHOD_NOT_ALLOWED);
|
|
2108
2190
|
}
|
|
2109
2191
|
};
|
|
2110
2192
|
|
|
2111
2193
|
// src/exceptions/not-acceptable.exception.ts
|
|
2112
|
-
import { HttpStatus as
|
|
2113
|
-
var NotAcceptableException = class extends
|
|
2194
|
+
import { HttpStatus as HttpStatus8 } from "@nestjs/common";
|
|
2195
|
+
var NotAcceptableException = class extends HttpProblemException {
|
|
2114
2196
|
static {
|
|
2115
2197
|
__name(this, "NotAcceptableException");
|
|
2116
2198
|
}
|
|
2117
|
-
constructor(
|
|
2118
|
-
|
|
2119
|
-
super(messageOrField, HttpStatus9.NOT_ACCEPTABLE, fieldMessageOrDetail);
|
|
2120
|
-
} else if (detail !== void 0) {
|
|
2121
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus9.NOT_ACCEPTABLE, detail);
|
|
2122
|
-
} else if (fieldMessageOrDetail) {
|
|
2123
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus9.NOT_ACCEPTABLE);
|
|
2124
|
-
} else {
|
|
2125
|
-
super(messageOrField, HttpStatus9.NOT_ACCEPTABLE);
|
|
2126
|
-
}
|
|
2199
|
+
constructor(detailOrOptions) {
|
|
2200
|
+
super(detailOrOptions ?? "Not Acceptable", HttpStatus8.NOT_ACCEPTABLE);
|
|
2127
2201
|
}
|
|
2128
2202
|
};
|
|
2129
2203
|
|
|
2130
2204
|
// src/exceptions/not-found.exception.ts
|
|
2131
|
-
import { HttpStatus as
|
|
2132
|
-
var NotFoundException = class extends
|
|
2205
|
+
import { HttpStatus as HttpStatus9 } from "@nestjs/common";
|
|
2206
|
+
var NotFoundException = class extends HttpProblemException {
|
|
2133
2207
|
static {
|
|
2134
2208
|
__name(this, "NotFoundException");
|
|
2135
2209
|
}
|
|
2136
|
-
constructor(
|
|
2137
|
-
|
|
2138
|
-
super(messageOrField, HttpStatus10.NOT_FOUND, fieldMessageOrDetail);
|
|
2139
|
-
} else if (detail !== void 0) {
|
|
2140
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus10.NOT_FOUND, detail);
|
|
2141
|
-
} else if (fieldMessageOrDetail) {
|
|
2142
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus10.NOT_FOUND);
|
|
2143
|
-
} else {
|
|
2144
|
-
super(messageOrField, HttpStatus10.NOT_FOUND);
|
|
2145
|
-
}
|
|
2210
|
+
constructor(detailOrOptions) {
|
|
2211
|
+
super(detailOrOptions ?? "Not Found", HttpStatus9.NOT_FOUND);
|
|
2146
2212
|
}
|
|
2147
2213
|
};
|
|
2148
2214
|
|
|
2149
2215
|
// src/exceptions/not-implemented.exception.ts
|
|
2150
|
-
import { HttpStatus as
|
|
2151
|
-
var NotImplementedException = class extends
|
|
2216
|
+
import { HttpStatus as HttpStatus10 } from "@nestjs/common";
|
|
2217
|
+
var NotImplementedException = class extends HttpProblemException {
|
|
2152
2218
|
static {
|
|
2153
2219
|
__name(this, "NotImplementedException");
|
|
2154
2220
|
}
|
|
2155
|
-
constructor(
|
|
2156
|
-
|
|
2157
|
-
super(messageOrField, HttpStatus11.NOT_IMPLEMENTED, fieldMessageOrDetail);
|
|
2158
|
-
} else if (detail !== void 0) {
|
|
2159
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus11.NOT_IMPLEMENTED, detail);
|
|
2160
|
-
} else if (fieldMessageOrDetail) {
|
|
2161
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus11.NOT_IMPLEMENTED);
|
|
2162
|
-
} else {
|
|
2163
|
-
super(messageOrField, HttpStatus11.NOT_IMPLEMENTED);
|
|
2164
|
-
}
|
|
2221
|
+
constructor(detailOrOptions) {
|
|
2222
|
+
super(detailOrOptions ?? "Not Implemented", HttpStatus10.NOT_IMPLEMENTED);
|
|
2165
2223
|
}
|
|
2166
2224
|
};
|
|
2167
2225
|
|
|
2168
2226
|
// src/exceptions/payload-too-large.exception.ts
|
|
2169
|
-
import { HttpStatus as
|
|
2170
|
-
var PayloadTooLargeException = class extends
|
|
2227
|
+
import { HttpStatus as HttpStatus11 } from "@nestjs/common";
|
|
2228
|
+
var PayloadTooLargeException = class extends HttpProblemException {
|
|
2171
2229
|
static {
|
|
2172
2230
|
__name(this, "PayloadTooLargeException");
|
|
2173
2231
|
}
|
|
2174
|
-
constructor(
|
|
2175
|
-
|
|
2176
|
-
super(messageOrField, HttpStatus12.PAYLOAD_TOO_LARGE, fieldMessageOrDetail);
|
|
2177
|
-
} else if (detail !== void 0) {
|
|
2178
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus12.PAYLOAD_TOO_LARGE, detail);
|
|
2179
|
-
} else if (fieldMessageOrDetail) {
|
|
2180
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus12.PAYLOAD_TOO_LARGE);
|
|
2181
|
-
} else {
|
|
2182
|
-
super(messageOrField, HttpStatus12.PAYLOAD_TOO_LARGE);
|
|
2183
|
-
}
|
|
2232
|
+
constructor(detailOrOptions) {
|
|
2233
|
+
super(detailOrOptions ?? "Payload Too Large", HttpStatus11.PAYLOAD_TOO_LARGE);
|
|
2184
2234
|
}
|
|
2185
2235
|
};
|
|
2186
2236
|
|
|
2187
2237
|
// src/exceptions/request-timeout.exception.ts
|
|
2188
|
-
import { HttpStatus as
|
|
2189
|
-
var RequestTimeoutException = class extends
|
|
2238
|
+
import { HttpStatus as HttpStatus12 } from "@nestjs/common";
|
|
2239
|
+
var RequestTimeoutException = class extends HttpProblemException {
|
|
2190
2240
|
static {
|
|
2191
2241
|
__name(this, "RequestTimeoutException");
|
|
2192
2242
|
}
|
|
2193
|
-
constructor(
|
|
2194
|
-
|
|
2195
|
-
super(messageOrField, HttpStatus13.REQUEST_TIMEOUT, fieldMessageOrDetail);
|
|
2196
|
-
} else if (detail !== void 0) {
|
|
2197
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus13.REQUEST_TIMEOUT, detail);
|
|
2198
|
-
} else if (fieldMessageOrDetail) {
|
|
2199
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus13.REQUEST_TIMEOUT);
|
|
2200
|
-
} else {
|
|
2201
|
-
super(messageOrField, HttpStatus13.REQUEST_TIMEOUT);
|
|
2202
|
-
}
|
|
2243
|
+
constructor(detailOrOptions) {
|
|
2244
|
+
super(detailOrOptions ?? "Request Timeout", HttpStatus12.REQUEST_TIMEOUT);
|
|
2203
2245
|
}
|
|
2204
2246
|
};
|
|
2205
2247
|
|
|
2206
2248
|
// src/exceptions/service-unavailable.exception.ts
|
|
2207
|
-
import { HttpStatus as
|
|
2208
|
-
var ServiceUnavailableException = class extends
|
|
2249
|
+
import { HttpStatus as HttpStatus13 } from "@nestjs/common";
|
|
2250
|
+
var ServiceUnavailableException = class extends HttpProblemException {
|
|
2209
2251
|
static {
|
|
2210
2252
|
__name(this, "ServiceUnavailableException");
|
|
2211
2253
|
}
|
|
2212
|
-
constructor(
|
|
2213
|
-
|
|
2214
|
-
super(messageOrField, HttpStatus14.SERVICE_UNAVAILABLE, fieldMessageOrDetail);
|
|
2215
|
-
} else if (detail !== void 0) {
|
|
2216
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus14.SERVICE_UNAVAILABLE, detail);
|
|
2217
|
-
} else if (fieldMessageOrDetail) {
|
|
2218
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus14.SERVICE_UNAVAILABLE);
|
|
2219
|
-
} else {
|
|
2220
|
-
super(messageOrField, HttpStatus14.SERVICE_UNAVAILABLE);
|
|
2221
|
-
}
|
|
2254
|
+
constructor(detailOrOptions) {
|
|
2255
|
+
super(detailOrOptions ?? "Service Unavailable", HttpStatus13.SERVICE_UNAVAILABLE);
|
|
2222
2256
|
}
|
|
2223
2257
|
};
|
|
2224
2258
|
|
|
2225
2259
|
// src/exceptions/too-many-requests.exception.ts
|
|
2226
|
-
import { HttpStatus as
|
|
2227
|
-
var TooManyRequestsException = class extends
|
|
2260
|
+
import { HttpStatus as HttpStatus14 } from "@nestjs/common";
|
|
2261
|
+
var TooManyRequestsException = class extends HttpProblemException {
|
|
2228
2262
|
static {
|
|
2229
2263
|
__name(this, "TooManyRequestsException");
|
|
2230
2264
|
}
|
|
2231
|
-
constructor(
|
|
2232
|
-
|
|
2233
|
-
super(messageOrField, HttpStatus15.TOO_MANY_REQUESTS, fieldMessageOrDetail);
|
|
2234
|
-
} else if (detail !== void 0) {
|
|
2235
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus15.TOO_MANY_REQUESTS, detail);
|
|
2236
|
-
} else if (fieldMessageOrDetail) {
|
|
2237
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus15.TOO_MANY_REQUESTS);
|
|
2238
|
-
} else {
|
|
2239
|
-
super(messageOrField, HttpStatus15.TOO_MANY_REQUESTS);
|
|
2240
|
-
}
|
|
2265
|
+
constructor(detailOrOptions) {
|
|
2266
|
+
super(detailOrOptions ?? "Too Many Requests", HttpStatus14.TOO_MANY_REQUESTS);
|
|
2241
2267
|
}
|
|
2242
2268
|
};
|
|
2243
2269
|
|
|
2244
2270
|
// src/exceptions/unauthorized.exception.ts
|
|
2245
|
-
import { HttpStatus as
|
|
2246
|
-
var
|
|
2271
|
+
import { HttpStatus as HttpStatus15 } from "@nestjs/common";
|
|
2272
|
+
var UnauthorizedException5 = class extends HttpProblemException {
|
|
2247
2273
|
static {
|
|
2248
2274
|
__name(this, "UnauthorizedException");
|
|
2249
2275
|
}
|
|
2250
|
-
constructor(
|
|
2251
|
-
|
|
2252
|
-
super(messageOrField, HttpStatus16.UNAUTHORIZED, fieldMessageOrDetail);
|
|
2253
|
-
} else if (detail !== void 0) {
|
|
2254
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus16.UNAUTHORIZED, detail);
|
|
2255
|
-
} else if (fieldMessageOrDetail) {
|
|
2256
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus16.UNAUTHORIZED);
|
|
2257
|
-
} else {
|
|
2258
|
-
super(messageOrField, HttpStatus16.UNAUTHORIZED);
|
|
2259
|
-
}
|
|
2276
|
+
constructor(detailOrOptions) {
|
|
2277
|
+
super(detailOrOptions ?? "Unauthorized", HttpStatus15.UNAUTHORIZED);
|
|
2260
2278
|
}
|
|
2261
2279
|
};
|
|
2262
2280
|
|
|
2263
2281
|
// src/exceptions/unprocessable-entity.exception.ts
|
|
2264
|
-
import { HttpStatus as
|
|
2265
|
-
var UnprocessableEntityException = class extends
|
|
2282
|
+
import { HttpStatus as HttpStatus16 } from "@nestjs/common";
|
|
2283
|
+
var UnprocessableEntityException = class extends HttpProblemException {
|
|
2266
2284
|
static {
|
|
2267
2285
|
__name(this, "UnprocessableEntityException");
|
|
2268
2286
|
}
|
|
2269
|
-
constructor(
|
|
2270
|
-
|
|
2271
|
-
super(messageOrField, HttpStatus17.UNPROCESSABLE_ENTITY, fieldMessageOrDetail);
|
|
2272
|
-
} else if (detail !== void 0) {
|
|
2273
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus17.UNPROCESSABLE_ENTITY, detail);
|
|
2274
|
-
} else if (fieldMessageOrDetail) {
|
|
2275
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus17.UNPROCESSABLE_ENTITY);
|
|
2276
|
-
} else {
|
|
2277
|
-
super(messageOrField, HttpStatus17.UNPROCESSABLE_ENTITY);
|
|
2278
|
-
}
|
|
2287
|
+
constructor(detailOrOptions) {
|
|
2288
|
+
super(detailOrOptions ?? "Unprocessable Entity", HttpStatus16.UNPROCESSABLE_ENTITY);
|
|
2279
2289
|
}
|
|
2280
2290
|
};
|
|
2281
2291
|
|
|
2282
2292
|
// src/exceptions/unsupported-media-type.exception.ts
|
|
2283
|
-
import { HttpStatus as
|
|
2284
|
-
var UnsupportedMediaTypeException = class extends
|
|
2293
|
+
import { HttpStatus as HttpStatus17 } from "@nestjs/common";
|
|
2294
|
+
var UnsupportedMediaTypeException = class extends HttpProblemException {
|
|
2285
2295
|
static {
|
|
2286
2296
|
__name(this, "UnsupportedMediaTypeException");
|
|
2287
2297
|
}
|
|
2288
|
-
constructor(
|
|
2289
|
-
|
|
2290
|
-
super(messageOrField, HttpStatus18.UNSUPPORTED_MEDIA_TYPE, fieldMessageOrDetail);
|
|
2291
|
-
} else if (detail !== void 0) {
|
|
2292
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus18.UNSUPPORTED_MEDIA_TYPE, detail);
|
|
2293
|
-
} else if (fieldMessageOrDetail) {
|
|
2294
|
-
super(messageOrField, fieldMessageOrDetail, HttpStatus18.UNSUPPORTED_MEDIA_TYPE);
|
|
2295
|
-
} else {
|
|
2296
|
-
super(messageOrField, HttpStatus18.UNSUPPORTED_MEDIA_TYPE);
|
|
2297
|
-
}
|
|
2298
|
+
constructor(detailOrOptions) {
|
|
2299
|
+
super(detailOrOptions ?? "Unsupported Media Type", HttpStatus17.UNSUPPORTED_MEDIA_TYPE);
|
|
2298
2300
|
}
|
|
2299
2301
|
};
|
|
2300
2302
|
|
|
2301
2303
|
// src/exceptions/validation.exception.ts
|
|
2302
|
-
import { HttpStatus as
|
|
2303
|
-
var ValidationException = class extends
|
|
2304
|
+
import { HttpStatus as HttpStatus18 } from "@nestjs/common";
|
|
2305
|
+
var ValidationException = class extends HttpProblemException {
|
|
2304
2306
|
static {
|
|
2305
2307
|
__name(this, "ValidationException");
|
|
2306
2308
|
}
|
|
2307
|
-
constructor(
|
|
2308
|
-
super(
|
|
2309
|
+
constructor(detailOrOptions) {
|
|
2310
|
+
super(detailOrOptions ?? "Validation Failed", HttpStatus18.BAD_REQUEST);
|
|
2309
2311
|
}
|
|
2310
2312
|
};
|
|
2311
2313
|
|
|
2312
2314
|
// src/filters/http-exception.filter.ts
|
|
2313
|
-
import { Catch, HttpException as HttpException2, HttpStatus as
|
|
2314
|
-
function
|
|
2315
|
+
import { Catch, HttpException as HttpException2, HttpStatus as HttpStatus19, Logger as Logger10 } from "@nestjs/common";
|
|
2316
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2315
2317
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2316
2318
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2317
2319
|
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;
|
|
2318
2320
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2319
2321
|
}
|
|
2320
|
-
__name(
|
|
2322
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
2321
2323
|
function getHttpStatusTitle(status) {
|
|
2322
|
-
const enumKey = Object.entries(
|
|
2324
|
+
const enumKey = Object.entries(HttpStatus19).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2323
2325
|
if (!enumKey) {
|
|
2324
2326
|
return "Error";
|
|
2325
2327
|
}
|
|
@@ -2330,21 +2332,27 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2330
2332
|
static {
|
|
2331
2333
|
__name(this, "HttpExceptionFilter");
|
|
2332
2334
|
}
|
|
2333
|
-
logger = new
|
|
2335
|
+
logger = new Logger10(_HttpExceptionFilter.name);
|
|
2334
2336
|
catch(exception, host) {
|
|
2335
2337
|
const ctx = host.switchToHttp();
|
|
2336
2338
|
const response = ctx.getResponse();
|
|
2337
|
-
|
|
2338
|
-
let
|
|
2339
|
+
const request = ctx.getRequest();
|
|
2340
|
+
let status = HttpStatus19.INTERNAL_SERVER_ERROR;
|
|
2341
|
+
let type = "about:blank";
|
|
2342
|
+
let label;
|
|
2339
2343
|
let detail = "Internal server error";
|
|
2344
|
+
let errors = [];
|
|
2340
2345
|
if (exception instanceof HttpException2) {
|
|
2341
2346
|
status = exception.getStatus();
|
|
2342
2347
|
const exceptionResponse = exception.getResponse();
|
|
2343
2348
|
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
2344
2349
|
const responseObj = exceptionResponse;
|
|
2345
|
-
if ("
|
|
2346
|
-
|
|
2347
|
-
|
|
2350
|
+
if ("type" in responseObj || "label" in responseObj || "errors" in responseObj) {
|
|
2351
|
+
const problemResponse = responseObj;
|
|
2352
|
+
type = problemResponse.type ?? "about:blank";
|
|
2353
|
+
label = problemResponse.label;
|
|
2354
|
+
detail = problemResponse.detail ?? exception.message ?? getHttpStatusTitle(status);
|
|
2355
|
+
errors = problemResponse.errors ?? [];
|
|
2348
2356
|
} else if ("message" in responseObj && Array.isArray(responseObj.message)) {
|
|
2349
2357
|
errors = responseObj.message.map((msg) => {
|
|
2350
2358
|
if (typeof msg === "object" && "property" in msg && "constraints" in msg) {
|
|
@@ -2354,135 +2362,249 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2354
2362
|
message: constraintValues[0] ?? "Validation failed"
|
|
2355
2363
|
};
|
|
2356
2364
|
}
|
|
2357
|
-
return
|
|
2358
|
-
|
|
2359
|
-
};
|
|
2360
|
-
});
|
|
2365
|
+
return null;
|
|
2366
|
+
}).filter((error) => error !== null);
|
|
2361
2367
|
detail = "Validation failed";
|
|
2362
2368
|
} else if ("message" in responseObj) {
|
|
2363
2369
|
const message = responseObj.message;
|
|
2364
|
-
|
|
2365
|
-
{
|
|
2366
|
-
message: Array.isArray(message) ? message.join(", ") : message
|
|
2367
|
-
}
|
|
2368
|
-
];
|
|
2369
|
-
detail = ("error" in responseObj ? responseObj.error : void 0) || exception.message;
|
|
2370
|
+
detail = Array.isArray(message) ? message.join(", ") : message;
|
|
2370
2371
|
}
|
|
2371
2372
|
} else if (typeof exceptionResponse === "string") {
|
|
2372
|
-
errors = [
|
|
2373
|
-
{
|
|
2374
|
-
message: exceptionResponse
|
|
2375
|
-
}
|
|
2376
|
-
];
|
|
2377
2373
|
detail = exceptionResponse;
|
|
2378
2374
|
}
|
|
2379
2375
|
} else {
|
|
2380
2376
|
const errorMessage = exception instanceof Error ? exception.message : "Unknown error";
|
|
2381
2377
|
const stack = exception instanceof Error ? exception.stack : void 0;
|
|
2382
2378
|
this.logger.error(`Unexpected error: ${errorMessage}`, stack);
|
|
2383
|
-
|
|
2384
|
-
{
|
|
2385
|
-
message: "An unexpected error occurred"
|
|
2386
|
-
}
|
|
2387
|
-
];
|
|
2379
|
+
detail = "An unexpected error occurred";
|
|
2388
2380
|
}
|
|
2389
2381
|
const problemDetails = {
|
|
2382
|
+
type,
|
|
2390
2383
|
title: getHttpStatusTitle(status),
|
|
2391
2384
|
status,
|
|
2385
|
+
...label && {
|
|
2386
|
+
label
|
|
2387
|
+
},
|
|
2392
2388
|
detail,
|
|
2389
|
+
instance: request.url,
|
|
2393
2390
|
errors
|
|
2394
2391
|
};
|
|
2395
|
-
response.status(status).send(problemDetails);
|
|
2392
|
+
response.header("Content-Type", "application/problem+json").status(status).send(problemDetails);
|
|
2396
2393
|
}
|
|
2397
2394
|
};
|
|
2398
|
-
HttpExceptionFilter =
|
|
2395
|
+
HttpExceptionFilter = _ts_decorate12([
|
|
2399
2396
|
Catch()
|
|
2400
2397
|
], HttpExceptionFilter);
|
|
2401
2398
|
|
|
2402
|
-
// src/
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2399
|
+
// src/utils/phone.utils.ts
|
|
2400
|
+
var CALLING_CODE_TO_COUNTRY = {
|
|
2401
|
+
// 3-digit codes
|
|
2402
|
+
"355": "AL",
|
|
2403
|
+
"213": "DZ",
|
|
2404
|
+
"376": "AD",
|
|
2405
|
+
"244": "AO",
|
|
2406
|
+
"672": "AQ",
|
|
2407
|
+
"374": "AM",
|
|
2408
|
+
"297": "AW",
|
|
2409
|
+
"994": "AZ",
|
|
2410
|
+
"973": "BH",
|
|
2411
|
+
"880": "BD",
|
|
2412
|
+
"375": "BY",
|
|
2413
|
+
"501": "BZ",
|
|
2414
|
+
"229": "BJ",
|
|
2415
|
+
"975": "BT",
|
|
2416
|
+
"591": "BO",
|
|
2417
|
+
"387": "BA",
|
|
2418
|
+
"267": "BW",
|
|
2419
|
+
"673": "BN",
|
|
2420
|
+
"359": "BG",
|
|
2421
|
+
"226": "BF",
|
|
2422
|
+
"257": "BI",
|
|
2423
|
+
"855": "KH",
|
|
2424
|
+
"237": "CM",
|
|
2425
|
+
"238": "CV",
|
|
2426
|
+
"236": "CF",
|
|
2427
|
+
"235": "TD",
|
|
2428
|
+
"269": "KM",
|
|
2429
|
+
"242": "CG",
|
|
2430
|
+
"243": "CD",
|
|
2431
|
+
"506": "CR",
|
|
2432
|
+
"385": "HR",
|
|
2433
|
+
"357": "CY",
|
|
2434
|
+
"420": "CZ",
|
|
2435
|
+
"253": "DJ",
|
|
2436
|
+
"593": "EC",
|
|
2437
|
+
"503": "SV",
|
|
2438
|
+
"240": "GQ",
|
|
2439
|
+
"291": "ER",
|
|
2440
|
+
"372": "EE",
|
|
2441
|
+
"251": "ET",
|
|
2442
|
+
"679": "FJ",
|
|
2443
|
+
"358": "FI",
|
|
2444
|
+
"241": "GA",
|
|
2445
|
+
"220": "GM",
|
|
2446
|
+
"995": "GE",
|
|
2447
|
+
"233": "GH",
|
|
2448
|
+
"350": "GI",
|
|
2449
|
+
"299": "GL",
|
|
2450
|
+
"502": "GT",
|
|
2451
|
+
"224": "GN",
|
|
2452
|
+
"245": "GW",
|
|
2453
|
+
"592": "GY",
|
|
2454
|
+
"509": "HT",
|
|
2455
|
+
"504": "HN",
|
|
2456
|
+
"354": "IS",
|
|
2457
|
+
"964": "IQ",
|
|
2458
|
+
"353": "IE",
|
|
2459
|
+
"972": "IL",
|
|
2460
|
+
"225": "CI",
|
|
2461
|
+
"962": "JO",
|
|
2462
|
+
"254": "KE",
|
|
2463
|
+
"686": "KI",
|
|
2464
|
+
"965": "KW",
|
|
2465
|
+
"996": "KG",
|
|
2466
|
+
"856": "LA",
|
|
2467
|
+
"371": "LV",
|
|
2468
|
+
"961": "LB",
|
|
2469
|
+
"266": "LS",
|
|
2470
|
+
"231": "LR",
|
|
2471
|
+
"218": "LY",
|
|
2472
|
+
"423": "LI",
|
|
2473
|
+
"370": "LT",
|
|
2474
|
+
"352": "LU",
|
|
2475
|
+
"389": "MK",
|
|
2476
|
+
"261": "MG",
|
|
2477
|
+
"265": "MW",
|
|
2478
|
+
"960": "MV",
|
|
2479
|
+
"223": "ML",
|
|
2480
|
+
"356": "MT",
|
|
2481
|
+
"692": "MH",
|
|
2482
|
+
"222": "MR",
|
|
2483
|
+
"230": "MU",
|
|
2484
|
+
"262": "YT",
|
|
2485
|
+
"691": "FM",
|
|
2486
|
+
"373": "MD",
|
|
2487
|
+
"377": "MC",
|
|
2488
|
+
"976": "MN",
|
|
2489
|
+
"382": "ME",
|
|
2490
|
+
"258": "MZ",
|
|
2491
|
+
"264": "NA",
|
|
2492
|
+
"674": "NR",
|
|
2493
|
+
"977": "NP",
|
|
2494
|
+
"505": "NI",
|
|
2495
|
+
"227": "NE",
|
|
2496
|
+
"234": "NG",
|
|
2497
|
+
"683": "NU",
|
|
2498
|
+
"968": "OM",
|
|
2499
|
+
"680": "PW",
|
|
2500
|
+
"970": "PS",
|
|
2501
|
+
"507": "PA",
|
|
2502
|
+
"675": "PG",
|
|
2503
|
+
"595": "PY",
|
|
2504
|
+
"351": "PT",
|
|
2505
|
+
"974": "QA",
|
|
2506
|
+
"250": "RW",
|
|
2507
|
+
"685": "WS",
|
|
2508
|
+
"378": "SM",
|
|
2509
|
+
"239": "ST",
|
|
2510
|
+
"966": "SA",
|
|
2511
|
+
"221": "SN",
|
|
2512
|
+
"381": "RS",
|
|
2513
|
+
"248": "SC",
|
|
2514
|
+
"232": "SL",
|
|
2515
|
+
"421": "SK",
|
|
2516
|
+
"386": "SI",
|
|
2517
|
+
"677": "SB",
|
|
2518
|
+
"252": "SO",
|
|
2519
|
+
"211": "SS",
|
|
2520
|
+
"249": "SD",
|
|
2521
|
+
"597": "SR",
|
|
2522
|
+
"268": "SZ",
|
|
2523
|
+
"963": "SY",
|
|
2524
|
+
"992": "TJ",
|
|
2525
|
+
"255": "TZ",
|
|
2526
|
+
"228": "TG",
|
|
2527
|
+
"676": "TO",
|
|
2528
|
+
"216": "TN",
|
|
2529
|
+
"993": "TM",
|
|
2530
|
+
"688": "TV",
|
|
2531
|
+
"256": "UG",
|
|
2532
|
+
"380": "UA",
|
|
2533
|
+
"971": "AE",
|
|
2534
|
+
"598": "UY",
|
|
2535
|
+
"998": "UZ",
|
|
2536
|
+
"678": "VU",
|
|
2537
|
+
"379": "VA",
|
|
2538
|
+
"967": "YE",
|
|
2539
|
+
"260": "ZM",
|
|
2540
|
+
"263": "ZW",
|
|
2541
|
+
// 2-digit codes
|
|
2542
|
+
"93": "AF",
|
|
2543
|
+
"54": "AR",
|
|
2544
|
+
"61": "AU",
|
|
2545
|
+
"43": "AT",
|
|
2546
|
+
"32": "BE",
|
|
2547
|
+
"55": "BR",
|
|
2548
|
+
"56": "CL",
|
|
2549
|
+
"86": "CN",
|
|
2550
|
+
"57": "CO",
|
|
2551
|
+
"53": "CU",
|
|
2552
|
+
"45": "DK",
|
|
2553
|
+
"20": "EG",
|
|
2554
|
+
"33": "FR",
|
|
2555
|
+
"49": "DE",
|
|
2556
|
+
"30": "GR",
|
|
2557
|
+
"36": "HU",
|
|
2558
|
+
"91": "IN",
|
|
2559
|
+
"62": "ID",
|
|
2560
|
+
"98": "IR",
|
|
2561
|
+
"39": "IT",
|
|
2562
|
+
"81": "JP",
|
|
2563
|
+
"82": "KR",
|
|
2564
|
+
"60": "MY",
|
|
2565
|
+
"52": "MX",
|
|
2566
|
+
"31": "NL",
|
|
2567
|
+
"64": "NZ",
|
|
2568
|
+
"47": "NO",
|
|
2569
|
+
"92": "PK",
|
|
2570
|
+
"51": "PE",
|
|
2571
|
+
"63": "PH",
|
|
2572
|
+
"48": "PL",
|
|
2573
|
+
"40": "RO",
|
|
2574
|
+
"65": "SG",
|
|
2575
|
+
"27": "ZA",
|
|
2576
|
+
"34": "ES",
|
|
2577
|
+
"94": "LK",
|
|
2578
|
+
"46": "SE",
|
|
2579
|
+
"41": "CH",
|
|
2580
|
+
"66": "TH",
|
|
2581
|
+
"90": "TR",
|
|
2582
|
+
"44": "GB",
|
|
2583
|
+
"58": "VE",
|
|
2584
|
+
"84": "VN",
|
|
2585
|
+
// 1-digit codes (shared codes default to most common country)
|
|
2586
|
+
"1": "US",
|
|
2587
|
+
"7": "RU"
|
|
2457
2588
|
};
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2589
|
+
function extractCountryFromPhone(phone) {
|
|
2590
|
+
const digits = phone.startsWith("+") ? phone.slice(1) : phone;
|
|
2591
|
+
for (const length of [
|
|
2592
|
+
3,
|
|
2593
|
+
2,
|
|
2594
|
+
1
|
|
2595
|
+
]) {
|
|
2596
|
+
const prefix = digits.slice(0, length);
|
|
2597
|
+
if (CALLING_CODE_TO_COUNTRY[prefix]) {
|
|
2598
|
+
return CALLING_CODE_TO_COUNTRY[prefix];
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
return void 0;
|
|
2469
2602
|
}
|
|
2470
|
-
__name(
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
};
|
|
2476
|
-
HttpModule = _ts_decorate13([
|
|
2477
|
-
Module4({
|
|
2478
|
-
providers: [
|
|
2479
|
-
CsrfGuard
|
|
2480
|
-
],
|
|
2481
|
-
exports: [
|
|
2482
|
-
CsrfGuard
|
|
2483
|
-
]
|
|
2484
|
-
})
|
|
2485
|
-
], HttpModule);
|
|
2603
|
+
__name(extractCountryFromPhone, "extractCountryFromPhone");
|
|
2604
|
+
function normalizePhoneNumber(phone) {
|
|
2605
|
+
return phone.startsWith("+") ? phone : `+${phone}`;
|
|
2606
|
+
}
|
|
2607
|
+
__name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
2486
2608
|
|
|
2487
2609
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2488
2610
|
import { Injectable as Injectable10, Optional as Optional2 } from "@nestjs/common";
|
|
@@ -2527,17 +2649,17 @@ function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_C
|
|
|
2527
2649
|
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2528
2650
|
|
|
2529
2651
|
// src/logger/services/logger.service.ts
|
|
2530
|
-
function
|
|
2652
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2531
2653
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2532
2654
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2533
2655
|
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;
|
|
2534
2656
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2535
2657
|
}
|
|
2536
|
-
__name(
|
|
2537
|
-
function
|
|
2658
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2659
|
+
function _ts_metadata8(k, v) {
|
|
2538
2660
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2539
2661
|
}
|
|
2540
|
-
__name(
|
|
2662
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2541
2663
|
function _ts_param4(paramIndex, decorator) {
|
|
2542
2664
|
return function(target, key) {
|
|
2543
2665
|
decorator(target, key, paramIndex);
|
|
@@ -2745,29 +2867,29 @@ ${trace}`;
|
|
|
2745
2867
|
return childLogger;
|
|
2746
2868
|
}
|
|
2747
2869
|
};
|
|
2748
|
-
LoggerService =
|
|
2870
|
+
LoggerService = _ts_decorate13([
|
|
2749
2871
|
Injectable9(),
|
|
2750
2872
|
_ts_param4(0, Optional()),
|
|
2751
2873
|
_ts_param4(1, Optional()),
|
|
2752
|
-
|
|
2753
|
-
|
|
2874
|
+
_ts_metadata8("design:type", Function),
|
|
2875
|
+
_ts_metadata8("design:paramtypes", [
|
|
2754
2876
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2755
2877
|
typeof Logger === "undefined" ? Object : Logger
|
|
2756
2878
|
])
|
|
2757
2879
|
], LoggerService);
|
|
2758
2880
|
|
|
2759
2881
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2760
|
-
function
|
|
2882
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2761
2883
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2762
2884
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2763
2885
|
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;
|
|
2764
2886
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2765
2887
|
}
|
|
2766
|
-
__name(
|
|
2767
|
-
function
|
|
2888
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2889
|
+
function _ts_metadata9(k, v) {
|
|
2768
2890
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2769
2891
|
}
|
|
2770
|
-
__name(
|
|
2892
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2771
2893
|
function _ts_param5(paramIndex, decorator) {
|
|
2772
2894
|
return function(target, key) {
|
|
2773
2895
|
decorator(target, key, paramIndex);
|
|
@@ -2875,32 +2997,32 @@ var HttpLoggerInterceptor = class {
|
|
|
2875
2997
|
}
|
|
2876
2998
|
}
|
|
2877
2999
|
};
|
|
2878
|
-
HttpLoggerInterceptor =
|
|
3000
|
+
HttpLoggerInterceptor = _ts_decorate14([
|
|
2879
3001
|
Injectable10(),
|
|
2880
3002
|
_ts_param5(1, Optional2()),
|
|
2881
|
-
|
|
2882
|
-
|
|
3003
|
+
_ts_metadata9("design:type", Function),
|
|
3004
|
+
_ts_metadata9("design:paramtypes", [
|
|
2883
3005
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
2884
3006
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
2885
3007
|
])
|
|
2886
3008
|
], HttpLoggerInterceptor);
|
|
2887
3009
|
|
|
2888
3010
|
// src/logger/logger.module.ts
|
|
2889
|
-
import { Global as Global4, Logger as Logger11, Module as
|
|
3011
|
+
import { Global as Global4, Logger as Logger11, Module as Module4 } from "@nestjs/common";
|
|
2890
3012
|
|
|
2891
3013
|
// src/logger/middleware/correlation-id.middleware.ts
|
|
2892
3014
|
import { Injectable as Injectable11 } from "@nestjs/common";
|
|
2893
|
-
function
|
|
3015
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2894
3016
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2895
3017
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2896
3018
|
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;
|
|
2897
3019
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2898
3020
|
}
|
|
2899
|
-
__name(
|
|
2900
|
-
function
|
|
3021
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3022
|
+
function _ts_metadata10(k, v) {
|
|
2901
3023
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2902
3024
|
}
|
|
2903
|
-
__name(
|
|
3025
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2904
3026
|
var CorrelationIdMiddleware = class {
|
|
2905
3027
|
static {
|
|
2906
3028
|
__name(this, "CorrelationIdMiddleware");
|
|
@@ -2943,22 +3065,22 @@ var CorrelationIdMiddleware = class {
|
|
|
2943
3065
|
}
|
|
2944
3066
|
}
|
|
2945
3067
|
};
|
|
2946
|
-
CorrelationIdMiddleware =
|
|
3068
|
+
CorrelationIdMiddleware = _ts_decorate15([
|
|
2947
3069
|
Injectable11(),
|
|
2948
|
-
|
|
2949
|
-
|
|
3070
|
+
_ts_metadata10("design:type", Function),
|
|
3071
|
+
_ts_metadata10("design:paramtypes", [
|
|
2950
3072
|
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
2951
3073
|
])
|
|
2952
3074
|
], CorrelationIdMiddleware);
|
|
2953
3075
|
|
|
2954
3076
|
// src/logger/logger.module.ts
|
|
2955
|
-
function
|
|
3077
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2956
3078
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2957
3079
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2958
3080
|
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;
|
|
2959
3081
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2960
3082
|
}
|
|
2961
|
-
__name(
|
|
3083
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2962
3084
|
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
2963
3085
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
2964
3086
|
provider: "winston",
|
|
@@ -3361,25 +3483,23 @@ var LoggerModule = class _LoggerModule {
|
|
|
3361
3483
|
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3362
3484
|
}
|
|
3363
3485
|
};
|
|
3364
|
-
LoggerModule =
|
|
3486
|
+
LoggerModule = _ts_decorate16([
|
|
3365
3487
|
Global4(),
|
|
3366
|
-
|
|
3488
|
+
Module4({})
|
|
3367
3489
|
], LoggerModule);
|
|
3368
3490
|
export {
|
|
3369
3491
|
AuthConfigModule,
|
|
3370
3492
|
BadGatewayException,
|
|
3371
3493
|
BadRequestException,
|
|
3372
|
-
BaseFieldException,
|
|
3373
3494
|
ConflictException,
|
|
3374
3495
|
CorrelationIdMiddleware,
|
|
3375
|
-
CsrfGuard,
|
|
3376
3496
|
DEFAULT_CORRELATION_HEADER,
|
|
3377
3497
|
DatabaseModule,
|
|
3378
|
-
ForbiddenException,
|
|
3498
|
+
ForbiddenException2 as ForbiddenException,
|
|
3379
3499
|
GoneException,
|
|
3380
3500
|
HttpExceptionFilter,
|
|
3381
3501
|
HttpLoggerInterceptor,
|
|
3382
|
-
|
|
3502
|
+
HttpProblemException,
|
|
3383
3503
|
InternalServerErrorException3 as InternalServerErrorException,
|
|
3384
3504
|
LOGGER_MODULE_OPTIONS,
|
|
3385
3505
|
LoggerModule,
|
|
@@ -3394,13 +3514,16 @@ export {
|
|
|
3394
3514
|
PrimaryDatabaseService,
|
|
3395
3515
|
Public,
|
|
3396
3516
|
RequestTimeoutException,
|
|
3517
|
+
SKIP_CSRF_KEY,
|
|
3397
3518
|
ServiceUnavailableException,
|
|
3519
|
+
SkipCsrf,
|
|
3520
|
+
SseAuthGuard,
|
|
3398
3521
|
Tenant,
|
|
3399
3522
|
TenantBaseRepository,
|
|
3400
3523
|
TenantContextService,
|
|
3401
3524
|
TenantDatabaseService,
|
|
3402
3525
|
TooManyRequestsException,
|
|
3403
|
-
|
|
3526
|
+
UnauthorizedException5 as UnauthorizedException,
|
|
3404
3527
|
UnprocessableEntityException,
|
|
3405
3528
|
UnsupportedMediaTypeException,
|
|
3406
3529
|
UserId,
|
|
@@ -3410,6 +3533,7 @@ export {
|
|
|
3410
3533
|
configureApiSdk,
|
|
3411
3534
|
correlationStorage,
|
|
3412
3535
|
defineConfig,
|
|
3536
|
+
extractCountryFromPhone,
|
|
3413
3537
|
generateCorrelationId,
|
|
3414
3538
|
getConfig,
|
|
3415
3539
|
getCorrelationContext,
|
|
@@ -3417,6 +3541,7 @@ export {
|
|
|
3417
3541
|
getJwtExpiry,
|
|
3418
3542
|
getRefreshCookieOptions,
|
|
3419
3543
|
hashToken,
|
|
3544
|
+
normalizePhoneNumber,
|
|
3420
3545
|
resetConfig,
|
|
3421
3546
|
runWithCorrelationContext,
|
|
3422
3547
|
updateCorrelationContext,
|