@saultechitsolutions/gighub-shared-core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/audit.module.d.ts +2 -0
- package/dist/audit/audit.module.js +25 -0
- package/dist/audit/audit.module.js.map +1 -0
- package/dist/audit/audit.service.d.ts +16 -0
- package/dist/audit/audit.service.js +95 -0
- package/dist/audit/audit.service.js.map +1 -0
- package/dist/audit/interfaces/audit-log.interface.d.ts +36 -0
- package/dist/audit/interfaces/audit-log.interface.js +3 -0
- package/dist/audit/interfaces/audit-log.interface.js.map +1 -0
- package/dist/context/geolocation.service.d.ts +19 -0
- package/dist/context/geolocation.service.js +87 -0
- package/dist/context/geolocation.service.js.map +1 -0
- package/dist/context/interfaces/request-context.interface.d.ts +29 -0
- package/dist/context/interfaces/request-context.interface.js +3 -0
- package/dist/context/interfaces/request-context.interface.js.map +1 -0
- package/dist/context/request-context.middleware.d.ts +11 -0
- package/dist/context/request-context.middleware.js +88 -0
- package/dist/context/request-context.middleware.js.map +1 -0
- package/dist/context/request-context.module.d.ts +4 -0
- package/dist/context/request-context.module.js +27 -0
- package/dist/context/request-context.module.js.map +1 -0
- package/dist/context/request-context.service.d.ts +24 -0
- package/dist/context/request-context.service.js +150 -0
- package/dist/context/request-context.service.js.map +1 -0
- package/dist/decorators/current-user.decorator.d.ts +1 -0
- package/dist/decorators/current-user.decorator.js +10 -0
- package/dist/decorators/current-user.decorator.js.map +1 -0
- package/dist/decorators/public.decorator.d.ts +2 -0
- package/dist/decorators/public.decorator.js +8 -0
- package/dist/decorators/public.decorator.js.map +1 -0
- package/dist/decorators/roles.decorator.d.ts +2 -0
- package/dist/decorators/roles.decorator.js +8 -0
- package/dist/decorators/roles.decorator.js.map +1 -0
- package/dist/dto/api-response.dto.d.ts +25 -0
- package/dist/dto/api-response.dto.js +87 -0
- package/dist/dto/api-response.dto.js.map +1 -0
- package/dist/dto/base.dto.d.ts +5 -0
- package/dist/dto/base.dto.js +7 -0
- package/dist/dto/base.dto.js.map +1 -0
- package/dist/dto/pagination.dto.d.ts +14 -0
- package/dist/dto/pagination.dto.js +59 -0
- package/dist/dto/pagination.dto.js.map +1 -0
- package/dist/exceptions/api.exception.d.ts +10 -0
- package/dist/exceptions/api.exception.js +31 -0
- package/dist/exceptions/api.exception.js.map +1 -0
- package/dist/exceptions/business.exception.d.ts +12 -0
- package/dist/exceptions/business.exception.js +37 -0
- package/dist/exceptions/business.exception.js.map +1 -0
- package/dist/exceptions/database.exception.d.ts +11 -0
- package/dist/exceptions/database.exception.js +34 -0
- package/dist/exceptions/database.exception.js.map +1 -0
- package/dist/filters/global-exception.filter.d.ts +10 -0
- package/dist/filters/global-exception.filter.js +131 -0
- package/dist/filters/global-exception.filter.js.map +1 -0
- package/dist/filters/http-exception.filter.d.ts +8 -0
- package/dist/filters/http-exception.filter.js +48 -0
- package/dist/filters/http-exception.filter.js.map +1 -0
- package/dist/guards/auth.guard.d.ts +12 -0
- package/dist/guards/auth.guard.js +63 -0
- package/dist/guards/auth.guard.js.map +1 -0
- package/dist/guards/interfaces/endpoint-permission.interface.d.ts +24 -0
- package/dist/guards/interfaces/endpoint-permission.interface.js +3 -0
- package/dist/guards/interfaces/endpoint-permission.interface.js.map +1 -0
- package/dist/guards/interfaces/permission-provider.interface.d.ts +5 -0
- package/dist/guards/interfaces/permission-provider.interface.js +3 -0
- package/dist/guards/interfaces/permission-provider.interface.js.map +1 -0
- package/dist/guards/interfaces/user.auth.d.ts +22 -0
- package/dist/guards/interfaces/user.auth.js +13 -0
- package/dist/guards/interfaces/user.auth.js.map +1 -0
- package/dist/guards/roles.guard.d.ts +17 -0
- package/dist/guards/roles.guard.js +111 -0
- package/dist/guards/roles.guard.js.map +1 -0
- package/dist/guards/roles.module.d.ts +8 -0
- package/dist/guards/roles.module.js +36 -0
- package/dist/guards/roles.module.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/logging.interceptor.d.ts +14 -0
- package/dist/interceptors/logging.interceptor.js +102 -0
- package/dist/interceptors/logging.interceptor.js.map +1 -0
- package/dist/interceptors/transform.interceptor.d.ts +12 -0
- package/dist/interceptors/transform.interceptor.js +29 -0
- package/dist/interceptors/transform.interceptor.js.map +1 -0
- package/dist/kafka/interfaces/kafka-config.interface.d.ts +20 -0
- package/dist/kafka/interfaces/kafka-config.interface.js +3 -0
- package/dist/kafka/interfaces/kafka-config.interface.js.map +1 -0
- package/dist/kafka/kafka.module.d.ts +9 -0
- package/dist/kafka/kafka.module.js +47 -0
- package/dist/kafka/kafka.module.js.map +1 -0
- package/dist/kafka/kafka.service.d.ts +24 -0
- package/dist/kafka/kafka.service.js +237 -0
- package/dist/kafka/kafka.service.js.map +1 -0
- package/dist/redis/interfaces/redis-config.interface.d.ts +6 -0
- package/dist/redis/interfaces/redis-config.interface.js +3 -0
- package/dist/redis/interfaces/redis-config.interface.js.map +1 -0
- package/dist/redis/redis.module.d.ts +5 -0
- package/dist/redis/redis.module.js +33 -0
- package/dist/redis/redis.module.js.map +1 -0
- package/dist/redis/redis.service.d.ts +17 -0
- package/dist/redis/redis.service.js +78 -0
- package/dist/redis/redis.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var RequestContextService_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RequestContextService = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const cls = require("cls-hooked");
|
|
13
|
+
let RequestContextService = RequestContextService_1 = class RequestContextService {
|
|
14
|
+
static getNamespace() {
|
|
15
|
+
return this.namespace;
|
|
16
|
+
}
|
|
17
|
+
set(key, value) {
|
|
18
|
+
RequestContextService_1.namespace.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
return RequestContextService_1.namespace.get(key);
|
|
22
|
+
}
|
|
23
|
+
setContext(context) {
|
|
24
|
+
Object.entries(context).forEach(([key, value]) => {
|
|
25
|
+
this.set(key, value);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getContext() {
|
|
29
|
+
return {
|
|
30
|
+
correlationId: this.getCorrelationId() || '',
|
|
31
|
+
requestId: this.get('requestId'),
|
|
32
|
+
userId: this.getUserId(),
|
|
33
|
+
userEmail: this.getUserEmail(),
|
|
34
|
+
userRole: this.getUserRole(),
|
|
35
|
+
userType: this.getUserType(),
|
|
36
|
+
roles: this.getRoles(),
|
|
37
|
+
ip: this.getIp() || 'unknown',
|
|
38
|
+
userAgent: this.getUserAgent() || 'unknown',
|
|
39
|
+
device: this.getDevice(),
|
|
40
|
+
location: this.getLocation(),
|
|
41
|
+
path: this.get('path'),
|
|
42
|
+
method: this.get('method'),
|
|
43
|
+
timestamp: this.get('timestamp'),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
getCorrelationId() {
|
|
47
|
+
return this.get('correlationId');
|
|
48
|
+
}
|
|
49
|
+
getUserId() {
|
|
50
|
+
return this.get('userId');
|
|
51
|
+
}
|
|
52
|
+
getUserEmail() {
|
|
53
|
+
return this.get('userEmail');
|
|
54
|
+
}
|
|
55
|
+
getUserRole() {
|
|
56
|
+
return this.get('userRole');
|
|
57
|
+
}
|
|
58
|
+
getUserType() {
|
|
59
|
+
return this.get('userType');
|
|
60
|
+
}
|
|
61
|
+
getRoles() {
|
|
62
|
+
return this.get('roles');
|
|
63
|
+
}
|
|
64
|
+
getIp() {
|
|
65
|
+
return this.get('ip');
|
|
66
|
+
}
|
|
67
|
+
getUserAgent() {
|
|
68
|
+
return this.get('userAgent');
|
|
69
|
+
}
|
|
70
|
+
getDevice() {
|
|
71
|
+
return this.get('device');
|
|
72
|
+
}
|
|
73
|
+
getLocation() {
|
|
74
|
+
return this.get('location');
|
|
75
|
+
}
|
|
76
|
+
parseDevice(userAgent) {
|
|
77
|
+
const ua = userAgent.toLowerCase();
|
|
78
|
+
const device = {
|
|
79
|
+
type: 'desktop',
|
|
80
|
+
};
|
|
81
|
+
if (/(bot|crawl|spider|slurp)/i.test(userAgent)) {
|
|
82
|
+
device.type = 'bot';
|
|
83
|
+
}
|
|
84
|
+
else if (/mobile|android|iphone|ipod|blackberry|iemobile|opera mini/i.test(ua)) {
|
|
85
|
+
device.type = 'mobile';
|
|
86
|
+
}
|
|
87
|
+
else if (/tablet|ipad|playbook|silk/i.test(ua)) {
|
|
88
|
+
device.type = 'tablet';
|
|
89
|
+
}
|
|
90
|
+
if (/windows/i.test(ua)) {
|
|
91
|
+
device.os = 'Windows';
|
|
92
|
+
}
|
|
93
|
+
else if (/macintosh|mac os x/i.test(ua)) {
|
|
94
|
+
device.os = 'macOS';
|
|
95
|
+
}
|
|
96
|
+
else if (/linux/i.test(ua)) {
|
|
97
|
+
device.os = 'Linux';
|
|
98
|
+
}
|
|
99
|
+
else if (/android/i.test(ua)) {
|
|
100
|
+
device.os = 'Android';
|
|
101
|
+
}
|
|
102
|
+
else if (/iphone|ipad|ipod/i.test(ua)) {
|
|
103
|
+
device.os = 'iOS';
|
|
104
|
+
}
|
|
105
|
+
if (/edg/i.test(ua)) {
|
|
106
|
+
device.browser = 'Edge';
|
|
107
|
+
}
|
|
108
|
+
else if (/chrome/i.test(ua)) {
|
|
109
|
+
device.browser = 'Chrome';
|
|
110
|
+
}
|
|
111
|
+
else if (/safari/i.test(ua)) {
|
|
112
|
+
device.browser = 'Safari';
|
|
113
|
+
}
|
|
114
|
+
else if (/firefox/i.test(ua)) {
|
|
115
|
+
device.browser = 'Firefox';
|
|
116
|
+
}
|
|
117
|
+
else if (/opera|opr/i.test(ua)) {
|
|
118
|
+
device.browser = 'Opera';
|
|
119
|
+
}
|
|
120
|
+
else if (/msie|trident/i.test(ua)) {
|
|
121
|
+
device.browser = 'Internet Explorer';
|
|
122
|
+
}
|
|
123
|
+
this.set('device', device);
|
|
124
|
+
}
|
|
125
|
+
isAuthenticated() {
|
|
126
|
+
const userId = this.getUserId();
|
|
127
|
+
return !!userId && userId !== 'anonymous';
|
|
128
|
+
}
|
|
129
|
+
hasRole(role) {
|
|
130
|
+
const roles = this.getRoles();
|
|
131
|
+
const userRole = this.getUserRole();
|
|
132
|
+
if (roles && roles.includes(role)) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return userRole === role;
|
|
136
|
+
}
|
|
137
|
+
hasAnyRole(roles) {
|
|
138
|
+
return roles.some(role => this.hasRole(role));
|
|
139
|
+
}
|
|
140
|
+
clear() {
|
|
141
|
+
const namespace = RequestContextService_1.namespace;
|
|
142
|
+
namespace.active = null;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
exports.RequestContextService = RequestContextService;
|
|
146
|
+
RequestContextService.namespace = cls.createNamespace('request-context');
|
|
147
|
+
exports.RequestContextService = RequestContextService = RequestContextService_1 = __decorate([
|
|
148
|
+
(0, common_1.Injectable)()
|
|
149
|
+
], RequestContextService);
|
|
150
|
+
//# sourceMappingURL=request-context.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.service.js","sourceRoot":"","sources":["../../src/context/request-context.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA4C;AAC5C,kCAAkC;AAI3B,IAAM,qBAAqB,6BAA3B,MAAM,qBAA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AAC;QAC7B,CAAC;aAAM,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAClC,MAAM,CAAC,OAAO,GAAG,mBAAmB,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAKD,eAAe;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,WAAW,CAAC;IAC9C,CAAC;IAKD,OAAO,CAAC,IAAY;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAEpC,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,QAAQ,KAAK,IAAI,CAAC;IAC7B,CAAC;IAKD,UAAU,CAAC,KAAe;QACtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAKD,KAAK;QACD,MAAM,SAAS,GAAG,uBAAqB,CAAC,SAAS,CAAC;QAClD,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC;IAC5B,CAAC;;AAnLQ,sDAAqB;AACf,+BAAS,GAAG,GAAG,CAAC,eAAe,CAAC,iBAAiB,CAAC,AAAzC,CAA0C;gCADzD,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAoLjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentUser: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
|
7
|
+
const user = request.user;
|
|
8
|
+
return data ? user?.[data] : user;
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=current-user.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC3C,CAAC,IAAwB,EAAE,GAAqB,EAAE,EAAE;IAChD,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1B,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC,CACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Public = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
6
|
+
const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.Public = Public;
|
|
8
|
+
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,qBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Roles = exports.ROLES_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.ROLES_KEY = 'roles';
|
|
6
|
+
const Roles = (...roles) => (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
|
|
7
|
+
exports.Roles = Roles;
|
|
8
|
+
//# sourceMappingURL=roles.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.decorator.js","sourceRoot":"","sources":["../../src/decorators/roles.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,SAAS,GAAG,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,iBAAS,EAAE,KAAK,CAAC,CAAC;AAA9D,QAAA,KAAK,SAAyD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class Meta {
|
|
2
|
+
total: number;
|
|
3
|
+
limit: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
page: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class APIResponse<T> {
|
|
8
|
+
statusCode: number;
|
|
9
|
+
message: string;
|
|
10
|
+
data?: T;
|
|
11
|
+
meta?: Meta;
|
|
12
|
+
private constructor();
|
|
13
|
+
static builder<T>(): APIResponseBuilder<T>;
|
|
14
|
+
static initialize<T>(): APIResponse<T>;
|
|
15
|
+
}
|
|
16
|
+
declare class APIResponseBuilder<T> {
|
|
17
|
+
private readonly instance;
|
|
18
|
+
constructor();
|
|
19
|
+
statusCode(statusCode: number): this;
|
|
20
|
+
message(message: string): this;
|
|
21
|
+
data(data: T): this;
|
|
22
|
+
meta(param: Meta): this;
|
|
23
|
+
build(): APIResponse<T>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.APIResponse = exports.Meta = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class Meta {
|
|
15
|
+
}
|
|
16
|
+
exports.Meta = Meta;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, swagger_1.ApiProperty)({ example: 100 }),
|
|
19
|
+
__metadata("design:type", Number)
|
|
20
|
+
], Meta.prototype, "total", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({ example: 10 }),
|
|
23
|
+
__metadata("design:type", Number)
|
|
24
|
+
], Meta.prototype, "limit", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)({ example: 10 }),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], Meta.prototype, "totalPages", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ example: 1 }),
|
|
31
|
+
__metadata("design:type", Number)
|
|
32
|
+
], Meta.prototype, "page", void 0);
|
|
33
|
+
class APIResponse {
|
|
34
|
+
constructor() { }
|
|
35
|
+
static builder() {
|
|
36
|
+
return new APIResponseBuilder();
|
|
37
|
+
}
|
|
38
|
+
static initialize() {
|
|
39
|
+
return new APIResponse();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.APIResponse = APIResponse;
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, swagger_1.ApiProperty)({ example: 200 }),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], APIResponse.prototype, "statusCode", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({ example: 'OK' }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], APIResponse.prototype, "message", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiPropertyOptional)({ type: 'object', additionalProperties: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], APIResponse.prototype, "data", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiPropertyOptional)({ type: Meta, additionalProperties: true }),
|
|
57
|
+
__metadata("design:type", Meta)
|
|
58
|
+
], APIResponse.prototype, "meta", void 0);
|
|
59
|
+
class APIResponseBuilder {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.instance = APIResponse.initialize();
|
|
62
|
+
}
|
|
63
|
+
statusCode(statusCode) {
|
|
64
|
+
this.instance.statusCode = statusCode;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
message(message) {
|
|
68
|
+
this.instance.message = message;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
data(data) {
|
|
72
|
+
this.instance.data = data;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
meta(param) {
|
|
76
|
+
this.instance.meta = param;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
build() {
|
|
80
|
+
if (this.instance.statusCode === undefined ||
|
|
81
|
+
this.instance.message === undefined) {
|
|
82
|
+
throw new Error('statusCode and message are required fields');
|
|
83
|
+
}
|
|
84
|
+
return this.instance;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=api-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-response.dto.js","sourceRoot":"","sources":["../../src/dto/api-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAiE;AAEjE,MAAa,IAAI;CAYhB;AAZD,oBAYC;AAVG;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;mCACf;AAGf;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;mCACd;AAGf;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;wCACT;AAGpB;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;kCACd;AAElB,MAAa,WAAW;IAapB,gBAAuB,CAAC;IAGxB,MAAM,CAAC,OAAO;QACV,OAAO,IAAI,kBAAkB,EAAK,CAAC;IACvC,CAAC;IAGD,MAAM,CAAC,UAAU;QACb,OAAO,IAAI,WAAW,EAAK,CAAC;IAChC,CAAC;CACJ;AAxBD,kCAwBC;AAtBG;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;;+CACV;AAGpB;IADC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;4CACd;AAGjB;IADC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;;yCAC3D;AAET;IADC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;8BACzD,IAAI;yCAAC;AAgBhB,MAAM,kBAAkB;IAGpB;QACI,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAK,CAAC;IAChD,CAAC;IAED,UAAU,CAAC,UAAkB;QACzB,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;QACtC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,OAAe;QACnB,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,IAAO;QACR,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,KAAW;QACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,IACI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS;YACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,EACrC,CAAC;YACC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.dto.js","sourceRoot":"","sources":["../../src/dto/base.dto.ts"],"names":[],"mappings":";;;AAAA,MAAa,OAAO;CAInB;AAJD,0BAIC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class PaginationDto {
|
|
2
|
+
page?: number;
|
|
3
|
+
limit?: number;
|
|
4
|
+
search?: string;
|
|
5
|
+
sortBy?: string;
|
|
6
|
+
sortOrder?: 'ASC' | 'DESC';
|
|
7
|
+
}
|
|
8
|
+
export declare class PaginationMeta {
|
|
9
|
+
total: number;
|
|
10
|
+
page: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
totalPages: number;
|
|
13
|
+
constructor(total: number, page: number, limit: number);
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PaginationMeta = exports.PaginationDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
class PaginationDto {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.page = 1;
|
|
18
|
+
this.limit = 20;
|
|
19
|
+
this.sortOrder = 'DESC';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PaginationDto = PaginationDto;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
26
|
+
(0, class_validator_1.IsInt)(),
|
|
27
|
+
(0, class_validator_1.Min)(1),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], PaginationDto.prototype, "page", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, class_validator_1.IsOptional)(),
|
|
32
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
33
|
+
(0, class_validator_1.IsInt)(),
|
|
34
|
+
(0, class_validator_1.Min)(1),
|
|
35
|
+
(0, class_validator_1.Max)(100),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], PaginationDto.prototype, "limit", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, class_validator_1.IsOptional)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], PaginationDto.prototype, "search", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], PaginationDto.prototype, "sortBy", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], PaginationDto.prototype, "sortOrder", void 0);
|
|
50
|
+
class PaginationMeta {
|
|
51
|
+
constructor(total, page, limit) {
|
|
52
|
+
this.total = total;
|
|
53
|
+
this.page = page;
|
|
54
|
+
this.limit = limit;
|
|
55
|
+
this.totalPages = Math.ceil(total / limit);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PaginationMeta = PaginationMeta;
|
|
59
|
+
//# sourceMappingURL=pagination.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.dto.js","sourceRoot":"","sources":["../../src/dto/pagination.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8D;AAC9D,yDAAyC;AAEzC,MAAa,aAAa;IAA1B;QAKI,SAAI,GAAY,CAAC,CAAC;QAOlB,UAAK,GAAY,EAAE,CAAC;QASpB,cAAS,GAAoB,MAAM,CAAC;IACxC,CAAC;CAAA;AAtBD,sCAsBC;AAjBG;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;2CACW;AAOlB;IALC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,qBAAG,EAAC,GAAG,CAAC;;4CACW;AAGpB;IADC,IAAA,4BAAU,GAAE;;6CACG;AAGhB;IADC,IAAA,4BAAU,GAAE;;6CACG;AAGhB;IADC,IAAA,4BAAU,GAAE;;gDACuB;AAGxC,MAAa,cAAc;IAMvB,YAAY,KAAa,EAAE,IAAY,EAAE,KAAa;QAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IAC/C,CAAC;CACJ;AAZD,wCAYC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
export declare class APIException extends HttpException {
|
|
3
|
+
errorCode: string;
|
|
4
|
+
details?: any;
|
|
5
|
+
constructor(message: string, errorCode: string, statusCode?: HttpStatus, details?: any);
|
|
6
|
+
static externalServiceError(service: string, reason?: string): APIException;
|
|
7
|
+
static rateLimitExceeded(limit: number, resetTime?: Date): APIException;
|
|
8
|
+
static invalidApiKey(): APIException;
|
|
9
|
+
static serviceUnavailable(service: string): APIException;
|
|
10
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APIException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class APIException extends common_1.HttpException {
|
|
6
|
+
constructor(message, errorCode, statusCode = common_1.HttpStatus.INTERNAL_SERVER_ERROR, details) {
|
|
7
|
+
super({
|
|
8
|
+
statusCode,
|
|
9
|
+
message,
|
|
10
|
+
error: 'API Error',
|
|
11
|
+
errorCode,
|
|
12
|
+
details,
|
|
13
|
+
}, statusCode);
|
|
14
|
+
this.errorCode = errorCode;
|
|
15
|
+
this.details = details;
|
|
16
|
+
}
|
|
17
|
+
static externalServiceError(service, reason) {
|
|
18
|
+
return new APIException(`External service '${service}' error${reason ? `: ${reason}` : ''}`, 'API_EXTERNAL_SERVICE_ERROR', common_1.HttpStatus.BAD_GATEWAY, { service, reason });
|
|
19
|
+
}
|
|
20
|
+
static rateLimitExceeded(limit, resetTime) {
|
|
21
|
+
return new APIException(`Rate limit exceeded. Maximum ${limit} requests allowed`, 'API_RATE_LIMIT_EXCEEDED', common_1.HttpStatus.TOO_MANY_REQUESTS, { limit, resetTime });
|
|
22
|
+
}
|
|
23
|
+
static invalidApiKey() {
|
|
24
|
+
return new APIException('Invalid or missing API key', 'API_INVALID_KEY', common_1.HttpStatus.UNAUTHORIZED);
|
|
25
|
+
}
|
|
26
|
+
static serviceUnavailable(service) {
|
|
27
|
+
return new APIException(`Service '${service}' is temporarily unavailable`, 'API_SERVICE_UNAVAILABLE', common_1.HttpStatus.SERVICE_UNAVAILABLE, { service });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.APIException = APIException;
|
|
31
|
+
//# sourceMappingURL=api.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.exception.js","sourceRoot":"","sources":["../../src/exceptions/api.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,MAAa,YAAa,SAAQ,sBAAa;IAI3C,YACI,OAAe,EACf,SAAiB,EACjB,aAAyB,mBAAU,CAAC,qBAAqB,EACzD,OAAa;QAEb,KAAK,CACD;YACI,UAAU;YACV,OAAO;YACP,KAAK,EAAE,WAAW;YAClB,SAAS;YACT,OAAO;SACV,EACD,UAAU,CACb,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAGD,MAAM,CAAC,oBAAoB,CAAC,OAAe,EAAE,MAAe;QACxD,OAAO,IAAI,YAAY,CACnB,qBAAqB,OAAO,UAAU,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EACnE,4BAA4B,EAC5B,mBAAU,CAAC,WAAW,EACtB,EAAE,OAAO,EAAE,MAAM,EAAE,CACtB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,KAAa,EAAE,SAAgB;QACpD,OAAO,IAAI,YAAY,CACnB,gCAAgC,KAAK,mBAAmB,EACxD,yBAAyB,EACzB,mBAAU,CAAC,iBAAiB,EAC5B,EAAE,KAAK,EAAE,SAAS,EAAE,CACvB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,aAAa;QAChB,OAAO,IAAI,YAAY,CACnB,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAU,CAAC,YAAY,CAC1B,CAAC;IACN,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,OAAe;QACrC,OAAO,IAAI,YAAY,CACnB,YAAY,OAAO,8BAA8B,EACjD,yBAAyB,EACzB,mBAAU,CAAC,mBAAmB,EAC9B,EAAE,OAAO,EAAE,CACd,CAAC;IACN,CAAC;CACJ;AA3DD,oCA2DC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
export declare class BusinessException extends HttpException {
|
|
3
|
+
errorCode: string;
|
|
4
|
+
details?: any;
|
|
5
|
+
constructor(message: string, errorCode: string, statusCode?: HttpStatus, details?: any);
|
|
6
|
+
static invalidOperation(operation: string, reason: string): BusinessException;
|
|
7
|
+
static resourceNotFound(resource: string, id: string | number): BusinessException;
|
|
8
|
+
static duplicateResource(resource: string, field: string, value: string): BusinessException;
|
|
9
|
+
static insufficientPermissions(action: string): BusinessException;
|
|
10
|
+
static validationFailed(errors: Record<string, string[]>): BusinessException;
|
|
11
|
+
static stateConflict(currentState: string, requiredState: string): BusinessException;
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BusinessException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class BusinessException extends common_1.HttpException {
|
|
6
|
+
constructor(message, errorCode, statusCode = common_1.HttpStatus.BAD_REQUEST, details) {
|
|
7
|
+
super({
|
|
8
|
+
statusCode,
|
|
9
|
+
message,
|
|
10
|
+
error: 'Business Logic Error',
|
|
11
|
+
errorCode,
|
|
12
|
+
details,
|
|
13
|
+
}, statusCode);
|
|
14
|
+
this.errorCode = errorCode;
|
|
15
|
+
this.details = details;
|
|
16
|
+
}
|
|
17
|
+
static invalidOperation(operation, reason) {
|
|
18
|
+
return new BusinessException(`Cannot ${operation}: ${reason}`, 'BUSINESS_INVALID_OPERATION', common_1.HttpStatus.BAD_REQUEST, { operation, reason });
|
|
19
|
+
}
|
|
20
|
+
static resourceNotFound(resource, id) {
|
|
21
|
+
return new BusinessException(`${resource} with id '${id}' not found`, 'BUSINESS_RESOURCE_NOT_FOUND', common_1.HttpStatus.NOT_FOUND, { resource, id });
|
|
22
|
+
}
|
|
23
|
+
static duplicateResource(resource, field, value) {
|
|
24
|
+
return new BusinessException(`${resource} with ${field} '${value}' already exists`, 'BUSINESS_DUPLICATE_RESOURCE', common_1.HttpStatus.CONFLICT, { resource, field, value });
|
|
25
|
+
}
|
|
26
|
+
static insufficientPermissions(action) {
|
|
27
|
+
return new BusinessException(`Insufficient permissions to ${action}`, 'BUSINESS_INSUFFICIENT_PERMISSIONS', common_1.HttpStatus.FORBIDDEN, { action });
|
|
28
|
+
}
|
|
29
|
+
static validationFailed(errors) {
|
|
30
|
+
return new BusinessException('Validation failed', 'BUSINESS_VALIDATION_FAILED', common_1.HttpStatus.BAD_REQUEST, { errors });
|
|
31
|
+
}
|
|
32
|
+
static stateConflict(currentState, requiredState) {
|
|
33
|
+
return new BusinessException(`Invalid state transition from '${currentState}' to '${requiredState}'`, 'BUSINESS_STATE_CONFLICT', common_1.HttpStatus.CONFLICT, { currentState, requiredState });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.BusinessException = BusinessException;
|
|
37
|
+
//# sourceMappingURL=business.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"business.exception.js","sourceRoot":"","sources":["../../src/exceptions/business.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,MAAa,iBAAkB,SAAQ,sBAAa;IAIhD,YACI,OAAe,EACf,SAAiB,EACjB,aAAyB,mBAAU,CAAC,WAAW,EAC/C,OAAa;QAEb,KAAK,CACD;YACI,UAAU;YACV,OAAO;YACP,KAAK,EAAE,sBAAsB;YAC7B,SAAS;YACT,OAAO;SACV,EACD,UAAU,CACb,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAGD,MAAM,CAAC,gBAAgB,CAAC,SAAiB,EAAE,MAAc;QACrD,OAAO,IAAI,iBAAiB,CACxB,UAAU,SAAS,KAAK,MAAM,EAAE,EAChC,4BAA4B,EAC5B,mBAAU,CAAC,WAAW,EACtB,EAAE,SAAS,EAAE,MAAM,EAAE,CACxB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,QAAgB,EAAE,EAAmB;QACzD,OAAO,IAAI,iBAAiB,CACxB,GAAG,QAAQ,aAAa,EAAE,aAAa,EACvC,6BAA6B,EAC7B,mBAAU,CAAC,SAAS,EACpB,EAAE,QAAQ,EAAE,EAAE,EAAE,CACnB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,QAAgB,EAAE,KAAa,EAAE,KAAa;QACnE,OAAO,IAAI,iBAAiB,CACxB,GAAG,QAAQ,SAAS,KAAK,KAAK,KAAK,kBAAkB,EACrD,6BAA6B,EAC7B,mBAAU,CAAC,QAAQ,EACnB,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAC7B,CAAC;IACN,CAAC;IAED,MAAM,CAAC,uBAAuB,CAAC,MAAc;QACzC,OAAO,IAAI,iBAAiB,CACxB,+BAA+B,MAAM,EAAE,EACvC,mCAAmC,EACnC,mBAAU,CAAC,SAAS,EACpB,EAAE,MAAM,EAAE,CACb,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAgC;QACpD,OAAO,IAAI,iBAAiB,CACxB,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAU,CAAC,WAAW,EACtB,EAAE,MAAM,EAAE,CACb,CAAC;IACN,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,YAAoB,EAAE,aAAqB;QAC5D,OAAO,IAAI,iBAAiB,CACxB,kCAAkC,YAAY,SAAS,aAAa,GAAG,EACvE,yBAAyB,EACzB,mBAAU,CAAC,QAAQ,EACnB,EAAE,YAAY,EAAE,aAAa,EAAE,CAClC,CAAC;IACN,CAAC;CACJ;AA9ED,8CA8EC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
2
|
+
export declare class DatabaseException extends HttpException {
|
|
3
|
+
errorCode: string;
|
|
4
|
+
details?: any;
|
|
5
|
+
constructor(message: string, errorCode: string, statusCode?: HttpStatus, details?: any);
|
|
6
|
+
static uniqueViolation(field: string, value: string): DatabaseException;
|
|
7
|
+
static foreignKeyViolation(entity: string, id: string | number): DatabaseException;
|
|
8
|
+
static notFound(entity: string, id: string | number): DatabaseException;
|
|
9
|
+
static connectionError(reason?: string): DatabaseException;
|
|
10
|
+
static queryTimeout(): DatabaseException;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class DatabaseException extends common_1.HttpException {
|
|
6
|
+
constructor(message, errorCode, statusCode = common_1.HttpStatus.INTERNAL_SERVER_ERROR, details) {
|
|
7
|
+
super({
|
|
8
|
+
statusCode,
|
|
9
|
+
message,
|
|
10
|
+
error: 'Database Error',
|
|
11
|
+
errorCode,
|
|
12
|
+
details,
|
|
13
|
+
}, statusCode);
|
|
14
|
+
this.errorCode = errorCode;
|
|
15
|
+
this.details = details;
|
|
16
|
+
}
|
|
17
|
+
static uniqueViolation(field, value) {
|
|
18
|
+
return new DatabaseException(`${field} '${value}' already exists`, 'DB_UNIQUE_VIOLATION', common_1.HttpStatus.CONFLICT, { field, value });
|
|
19
|
+
}
|
|
20
|
+
static foreignKeyViolation(entity, id) {
|
|
21
|
+
return new DatabaseException(`Referenced ${entity} with id '${id}' does not exist`, 'DB_FOREIGN_KEY_VIOLATION', common_1.HttpStatus.BAD_REQUEST, { entity, id });
|
|
22
|
+
}
|
|
23
|
+
static notFound(entity, id) {
|
|
24
|
+
return new DatabaseException(`${entity} with id '${id}' not found`, 'DB_NOT_FOUND', common_1.HttpStatus.NOT_FOUND, { entity, id });
|
|
25
|
+
}
|
|
26
|
+
static connectionError(reason) {
|
|
27
|
+
return new DatabaseException(`Database connection error${reason ? `: ${reason}` : ''}`, 'DB_CONNECTION_ERROR', common_1.HttpStatus.SERVICE_UNAVAILABLE, { reason });
|
|
28
|
+
}
|
|
29
|
+
static queryTimeout() {
|
|
30
|
+
return new DatabaseException('Database query timeout', 'DB_QUERY_TIMEOUT', common_1.HttpStatus.REQUEST_TIMEOUT);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.DatabaseException = DatabaseException;
|
|
34
|
+
//# sourceMappingURL=database.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.exception.js","sourceRoot":"","sources":["../../src/exceptions/database.exception.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAE3D,MAAa,iBAAkB,SAAQ,sBAAa;IAIhD,YACI,OAAe,EACf,SAAiB,EACjB,aAAyB,mBAAU,CAAC,qBAAqB,EACzD,OAAa;QAEb,KAAK,CACD;YACI,UAAU;YACV,OAAO;YACP,KAAK,EAAE,gBAAgB;YACvB,SAAS;YACT,OAAO;SACV,EACD,UAAU,CACb,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAGD,MAAM,CAAC,eAAe,CAAC,KAAa,EAAE,KAAa;QAC/C,OAAO,IAAI,iBAAiB,CACxB,GAAG,KAAK,KAAK,KAAK,kBAAkB,EACpC,qBAAqB,EACrB,mBAAU,CAAC,QAAQ,EACnB,EAAE,KAAK,EAAE,KAAK,EAAE,CACnB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAc,EAAE,EAAmB;QAC1D,OAAO,IAAI,iBAAiB,CACxB,cAAc,MAAM,aAAa,EAAE,kBAAkB,EACrD,0BAA0B,EAC1B,mBAAU,CAAC,WAAW,EACtB,EAAE,MAAM,EAAE,EAAE,EAAE,CACjB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAc,EAAE,EAAmB;QAC/C,OAAO,IAAI,iBAAiB,CACxB,GAAG,MAAM,aAAa,EAAE,aAAa,EACrC,cAAc,EACd,mBAAU,CAAC,SAAS,EACpB,EAAE,MAAM,EAAE,EAAE,EAAE,CACjB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,MAAe;QAClC,OAAO,IAAI,iBAAiB,CACxB,4BAA4B,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EACzD,qBAAqB,EACrB,mBAAU,CAAC,mBAAmB,EAC9B,EAAE,MAAM,EAAE,CACb,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY;QACf,OAAO,IAAI,iBAAiB,CACxB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAU,CAAC,eAAe,CAC7B,CAAC;IACN,CAAC;CACJ;AApED,8CAoEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { RequestContextService } from '../context/request-context.service';
|
|
3
|
+
export declare class GlobalExceptionFilter implements ExceptionFilter {
|
|
4
|
+
private readonly contextService;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(contextService: RequestContextService);
|
|
7
|
+
catch(exception: unknown, host: ArgumentsHost): void;
|
|
8
|
+
private buildErrorResponse;
|
|
9
|
+
private logError;
|
|
10
|
+
}
|