@vritti/api-sdk 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1192 -686
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +146 -4
- package/dist/index.d.ts +146 -4
- package/dist/index.js +1130 -634
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -10,11 +10,11 @@ var __export = (target, all) => {
|
|
|
10
10
|
for (var name in all)
|
|
11
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
12
|
};
|
|
13
|
-
var __copyProps = (to, from, except,
|
|
13
|
+
var __copyProps = (to, from, except, desc2) => {
|
|
14
14
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
15
|
for (let key of __getOwnPropNames(from))
|
|
16
16
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
|
|
18
18
|
}
|
|
19
19
|
return to;
|
|
20
20
|
};
|
|
@@ -35,18 +35,23 @@ __export(index_exports, {
|
|
|
35
35
|
AuthConfigModule: () => AuthConfigModule,
|
|
36
36
|
BadGatewayException: () => BadGatewayException,
|
|
37
37
|
BadRequestException: () => BadRequestException,
|
|
38
|
+
CACHE_PROVIDER: () => CACHE_PROVIDER,
|
|
39
|
+
CacheModule: () => CacheModule,
|
|
40
|
+
CacheService: () => CacheService,
|
|
38
41
|
ConflictException: () => ConflictException,
|
|
42
|
+
CookieDomain: () => CookieDomain,
|
|
39
43
|
CorrelationIdMiddleware: () => CorrelationIdMiddleware,
|
|
40
44
|
DEFAULT_CORRELATION_HEADER: () => DEFAULT_CORRELATION_HEADER,
|
|
41
45
|
DatabaseModule: () => DatabaseModule,
|
|
42
46
|
EmailModule: () => EmailModule,
|
|
43
47
|
EmailService: () => EmailService,
|
|
44
|
-
|
|
48
|
+
FilterProcessor: () => FilterProcessor,
|
|
49
|
+
ForbiddenException: () => ForbiddenException,
|
|
45
50
|
GoneException: () => GoneException,
|
|
46
51
|
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
47
52
|
HttpLoggerInterceptor: () => HttpLoggerInterceptor,
|
|
48
53
|
HttpProblemException: () => HttpProblemException,
|
|
49
|
-
InternalServerErrorException: () =>
|
|
54
|
+
InternalServerErrorException: () => InternalServerErrorException,
|
|
50
55
|
JwtAuthService: () => JwtAuthService,
|
|
51
56
|
LOGGER_MODULE_OPTIONS: () => LOGGER_MODULE_OPTIONS,
|
|
52
57
|
LoggerModule: () => LoggerModule,
|
|
@@ -61,6 +66,8 @@ __export(index_exports, {
|
|
|
61
66
|
PrimaryDatabaseService: () => PrimaryDatabaseService,
|
|
62
67
|
Public: () => Public,
|
|
63
68
|
RESET_KEY: () => RESET_KEY,
|
|
69
|
+
RedisCacheProvider: () => RedisCacheProvider,
|
|
70
|
+
RefreshCookieOptions: () => RefreshCookieOptions,
|
|
64
71
|
RefreshTokenCookie: () => RefreshTokenCookie,
|
|
65
72
|
RequestTimeoutException: () => RequestTimeoutException,
|
|
66
73
|
Reset: () => Reset,
|
|
@@ -70,13 +77,15 @@ __export(index_exports, {
|
|
|
70
77
|
ServiceUnavailableException: () => ServiceUnavailableException,
|
|
71
78
|
SessionData: () => SessionData,
|
|
72
79
|
SkipCsrf: () => SkipCsrf,
|
|
80
|
+
SuccessResponseDto: () => SuccessResponseDto,
|
|
81
|
+
TableResponseDto: () => TableResponseDto,
|
|
73
82
|
Tenant: () => Tenant,
|
|
74
83
|
TenantBaseRepository: () => TenantBaseRepository,
|
|
75
84
|
TenantContextService: () => TenantContextService,
|
|
76
85
|
TenantDatabaseService: () => TenantDatabaseService,
|
|
77
86
|
TokenType: () => TokenType,
|
|
78
87
|
TooManyRequestsException: () => TooManyRequestsException,
|
|
79
|
-
UnauthorizedException: () =>
|
|
88
|
+
UnauthorizedException: () => UnauthorizedException,
|
|
80
89
|
UnprocessableEntityException: () => UnprocessableEntityException,
|
|
81
90
|
UnsupportedMediaTypeException: () => UnsupportedMediaTypeException,
|
|
82
91
|
UserId: () => UserId,
|
|
@@ -93,6 +102,7 @@ __export(index_exports, {
|
|
|
93
102
|
getHttpStatusTitle: () => getHttpStatusTitle,
|
|
94
103
|
getJwtExpiry: () => getJwtExpiry,
|
|
95
104
|
getRefreshCookieOptions: () => getRefreshCookieOptions,
|
|
105
|
+
getRefreshCookieOptionsForHost: () => getRefreshCookieOptionsForHost,
|
|
96
106
|
getTokenExpiry: () => getTokenExpiry,
|
|
97
107
|
hashToken: () => hashToken,
|
|
98
108
|
jwtConfigFactory: () => jwtConfigFactory,
|
|
@@ -106,18 +116,237 @@ __export(index_exports, {
|
|
|
106
116
|
module.exports = __toCommonJS(index_exports);
|
|
107
117
|
|
|
108
118
|
// src/auth/auth-config.module.ts
|
|
109
|
-
var
|
|
119
|
+
var import_common26 = require("@nestjs/common");
|
|
110
120
|
var import_config4 = require("@nestjs/config");
|
|
111
121
|
var import_core3 = require("@nestjs/core");
|
|
112
122
|
var import_jwt4 = require("@nestjs/jwt");
|
|
113
123
|
|
|
114
124
|
// src/request/request.module.ts
|
|
115
|
-
var
|
|
125
|
+
var import_common21 = require("@nestjs/common");
|
|
116
126
|
|
|
117
127
|
// src/request/services/request.service.ts
|
|
118
|
-
var
|
|
128
|
+
var import_common20 = require("@nestjs/common");
|
|
119
129
|
var import_core = require("@nestjs/core");
|
|
120
130
|
|
|
131
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
132
|
+
var import_common2 = require("@nestjs/common");
|
|
133
|
+
|
|
134
|
+
// src/exceptions/base-field.exception.ts
|
|
135
|
+
var import_common = require("@nestjs/common");
|
|
136
|
+
var HttpProblemException = class extends import_common.HttpException {
|
|
137
|
+
static {
|
|
138
|
+
__name(this, "HttpProblemException");
|
|
139
|
+
}
|
|
140
|
+
constructor(detailOrOptions, httpStatus) {
|
|
141
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
142
|
+
detail: detailOrOptions
|
|
143
|
+
} : detailOrOptions;
|
|
144
|
+
super({
|
|
145
|
+
type: options.type ?? "about:blank",
|
|
146
|
+
label: options.label,
|
|
147
|
+
detail: options.detail,
|
|
148
|
+
errors: options.errors ?? []
|
|
149
|
+
}, httpStatus);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
154
|
+
var BadGatewayException = class extends HttpProblemException {
|
|
155
|
+
static {
|
|
156
|
+
__name(this, "BadGatewayException");
|
|
157
|
+
}
|
|
158
|
+
constructor(detailOrOptions) {
|
|
159
|
+
super(detailOrOptions ?? "Bad Gateway", import_common2.HttpStatus.BAD_GATEWAY);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// src/exceptions/bad-request.exception.ts
|
|
164
|
+
var import_common3 = require("@nestjs/common");
|
|
165
|
+
var BadRequestException = class extends HttpProblemException {
|
|
166
|
+
static {
|
|
167
|
+
__name(this, "BadRequestException");
|
|
168
|
+
}
|
|
169
|
+
constructor(detailOrOptions) {
|
|
170
|
+
super(detailOrOptions ?? "Bad Request", import_common3.HttpStatus.BAD_REQUEST);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/exceptions/conflict.exception.ts
|
|
175
|
+
var import_common4 = require("@nestjs/common");
|
|
176
|
+
var ConflictException = class extends HttpProblemException {
|
|
177
|
+
static {
|
|
178
|
+
__name(this, "ConflictException");
|
|
179
|
+
}
|
|
180
|
+
constructor(detailOrOptions) {
|
|
181
|
+
super(detailOrOptions ?? "Conflict", import_common4.HttpStatus.CONFLICT);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/exceptions/forbidden.exception.ts
|
|
186
|
+
var import_common5 = require("@nestjs/common");
|
|
187
|
+
var ForbiddenException = class extends HttpProblemException {
|
|
188
|
+
static {
|
|
189
|
+
__name(this, "ForbiddenException");
|
|
190
|
+
}
|
|
191
|
+
constructor(detailOrOptions) {
|
|
192
|
+
super(detailOrOptions ?? "Forbidden", import_common5.HttpStatus.FORBIDDEN);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/exceptions/gone.exception.ts
|
|
197
|
+
var import_common6 = require("@nestjs/common");
|
|
198
|
+
var GoneException = class extends HttpProblemException {
|
|
199
|
+
static {
|
|
200
|
+
__name(this, "GoneException");
|
|
201
|
+
}
|
|
202
|
+
constructor(detailOrOptions) {
|
|
203
|
+
super(detailOrOptions ?? "Gone", import_common6.HttpStatus.GONE);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/exceptions/internal-server-error.exception.ts
|
|
208
|
+
var import_common7 = require("@nestjs/common");
|
|
209
|
+
var InternalServerErrorException = class extends HttpProblemException {
|
|
210
|
+
static {
|
|
211
|
+
__name(this, "InternalServerErrorException");
|
|
212
|
+
}
|
|
213
|
+
constructor(detailOrOptions) {
|
|
214
|
+
super(detailOrOptions ?? "Internal Server Error", import_common7.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// src/exceptions/method-not-allowed.exception.ts
|
|
219
|
+
var import_common8 = require("@nestjs/common");
|
|
220
|
+
var MethodNotAllowedException = class extends HttpProblemException {
|
|
221
|
+
static {
|
|
222
|
+
__name(this, "MethodNotAllowedException");
|
|
223
|
+
}
|
|
224
|
+
constructor(detailOrOptions) {
|
|
225
|
+
super(detailOrOptions ?? "Method Not Allowed", import_common8.HttpStatus.METHOD_NOT_ALLOWED);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// src/exceptions/not-acceptable.exception.ts
|
|
230
|
+
var import_common9 = require("@nestjs/common");
|
|
231
|
+
var NotAcceptableException = class extends HttpProblemException {
|
|
232
|
+
static {
|
|
233
|
+
__name(this, "NotAcceptableException");
|
|
234
|
+
}
|
|
235
|
+
constructor(detailOrOptions) {
|
|
236
|
+
super(detailOrOptions ?? "Not Acceptable", import_common9.HttpStatus.NOT_ACCEPTABLE);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// src/exceptions/not-found.exception.ts
|
|
241
|
+
var import_common10 = require("@nestjs/common");
|
|
242
|
+
var NotFoundException = class extends HttpProblemException {
|
|
243
|
+
static {
|
|
244
|
+
__name(this, "NotFoundException");
|
|
245
|
+
}
|
|
246
|
+
constructor(detailOrOptions) {
|
|
247
|
+
super(detailOrOptions ?? "Not Found", import_common10.HttpStatus.NOT_FOUND);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// src/exceptions/not-implemented.exception.ts
|
|
252
|
+
var import_common11 = require("@nestjs/common");
|
|
253
|
+
var NotImplementedException = class extends HttpProblemException {
|
|
254
|
+
static {
|
|
255
|
+
__name(this, "NotImplementedException");
|
|
256
|
+
}
|
|
257
|
+
constructor(detailOrOptions) {
|
|
258
|
+
super(detailOrOptions ?? "Not Implemented", import_common11.HttpStatus.NOT_IMPLEMENTED);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// src/exceptions/payload-too-large.exception.ts
|
|
263
|
+
var import_common12 = require("@nestjs/common");
|
|
264
|
+
var PayloadTooLargeException = class extends HttpProblemException {
|
|
265
|
+
static {
|
|
266
|
+
__name(this, "PayloadTooLargeException");
|
|
267
|
+
}
|
|
268
|
+
constructor(detailOrOptions) {
|
|
269
|
+
super(detailOrOptions ?? "Payload Too Large", import_common12.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/exceptions/request-timeout.exception.ts
|
|
274
|
+
var import_common13 = require("@nestjs/common");
|
|
275
|
+
var RequestTimeoutException = class extends HttpProblemException {
|
|
276
|
+
static {
|
|
277
|
+
__name(this, "RequestTimeoutException");
|
|
278
|
+
}
|
|
279
|
+
constructor(detailOrOptions) {
|
|
280
|
+
super(detailOrOptions ?? "Request Timeout", import_common13.HttpStatus.REQUEST_TIMEOUT);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/exceptions/service-unavailable.exception.ts
|
|
285
|
+
var import_common14 = require("@nestjs/common");
|
|
286
|
+
var ServiceUnavailableException = class extends HttpProblemException {
|
|
287
|
+
static {
|
|
288
|
+
__name(this, "ServiceUnavailableException");
|
|
289
|
+
}
|
|
290
|
+
constructor(detailOrOptions) {
|
|
291
|
+
super(detailOrOptions ?? "Service Unavailable", import_common14.HttpStatus.SERVICE_UNAVAILABLE);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// src/exceptions/too-many-requests.exception.ts
|
|
296
|
+
var import_common15 = require("@nestjs/common");
|
|
297
|
+
var TooManyRequestsException = class extends HttpProblemException {
|
|
298
|
+
static {
|
|
299
|
+
__name(this, "TooManyRequestsException");
|
|
300
|
+
}
|
|
301
|
+
constructor(detailOrOptions) {
|
|
302
|
+
super(detailOrOptions ?? "Too Many Requests", import_common15.HttpStatus.TOO_MANY_REQUESTS);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// src/exceptions/unauthorized.exception.ts
|
|
307
|
+
var import_common16 = require("@nestjs/common");
|
|
308
|
+
var UnauthorizedException = class extends HttpProblemException {
|
|
309
|
+
static {
|
|
310
|
+
__name(this, "UnauthorizedException");
|
|
311
|
+
}
|
|
312
|
+
constructor(detailOrOptions) {
|
|
313
|
+
super(detailOrOptions ?? "Unauthorized", import_common16.HttpStatus.UNAUTHORIZED);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
// src/exceptions/unprocessable-entity.exception.ts
|
|
318
|
+
var import_common17 = require("@nestjs/common");
|
|
319
|
+
var UnprocessableEntityException = class extends HttpProblemException {
|
|
320
|
+
static {
|
|
321
|
+
__name(this, "UnprocessableEntityException");
|
|
322
|
+
}
|
|
323
|
+
constructor(detailOrOptions) {
|
|
324
|
+
super(detailOrOptions ?? "Unprocessable Entity", import_common17.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// src/exceptions/unsupported-media-type.exception.ts
|
|
329
|
+
var import_common18 = require("@nestjs/common");
|
|
330
|
+
var UnsupportedMediaTypeException = class extends HttpProblemException {
|
|
331
|
+
static {
|
|
332
|
+
__name(this, "UnsupportedMediaTypeException");
|
|
333
|
+
}
|
|
334
|
+
constructor(detailOrOptions) {
|
|
335
|
+
super(detailOrOptions ?? "Unsupported Media Type", import_common18.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// src/exceptions/validation.exception.ts
|
|
340
|
+
var import_common19 = require("@nestjs/common");
|
|
341
|
+
var ValidationException = class extends HttpProblemException {
|
|
342
|
+
static {
|
|
343
|
+
__name(this, "ValidationException");
|
|
344
|
+
}
|
|
345
|
+
constructor(detailOrOptions) {
|
|
346
|
+
super(detailOrOptions ?? "Validation Failed", import_common19.HttpStatus.BAD_REQUEST);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
121
350
|
// src/config/index.ts
|
|
122
351
|
var defaultConfig = {
|
|
123
352
|
cookie: {
|
|
@@ -174,19 +403,36 @@ function resetConfig() {
|
|
|
174
403
|
}
|
|
175
404
|
__name(resetConfig, "resetConfig");
|
|
176
405
|
function getRefreshCookieOptions() {
|
|
177
|
-
|
|
406
|
+
return {
|
|
178
407
|
httpOnly: true,
|
|
179
408
|
secure: currentConfig.cookie.refreshCookieSecure,
|
|
180
409
|
sameSite: currentConfig.cookie.refreshCookieSameSite,
|
|
181
410
|
path: currentConfig.cookie.refreshCookiePath,
|
|
182
|
-
maxAge: currentConfig.cookie.refreshCookieMaxAge
|
|
411
|
+
maxAge: currentConfig.cookie.refreshCookieMaxAge,
|
|
412
|
+
...currentConfig.cookie.refreshCookieDomain && {
|
|
413
|
+
domain: currentConfig.cookie.refreshCookieDomain
|
|
414
|
+
}
|
|
183
415
|
};
|
|
184
|
-
if (currentConfig.cookie.refreshCookieDomain) {
|
|
185
|
-
options.domain = currentConfig.cookie.refreshCookieDomain;
|
|
186
|
-
}
|
|
187
|
-
return options;
|
|
188
416
|
}
|
|
189
417
|
__name(getRefreshCookieOptions, "getRefreshCookieOptions");
|
|
418
|
+
function getRefreshCookieOptionsForHost(hostname) {
|
|
419
|
+
const baseDomain = currentConfig.cookie.refreshCookieDomain;
|
|
420
|
+
if (!baseDomain) {
|
|
421
|
+
throw new Error("refreshCookieDomain must be configured before using getRefreshCookieOptionsForHost");
|
|
422
|
+
}
|
|
423
|
+
if (!hostname.endsWith(`.${baseDomain}`)) {
|
|
424
|
+
throw new UnauthorizedException("Invalid request host.");
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
httpOnly: true,
|
|
428
|
+
secure: currentConfig.cookie.refreshCookieSecure,
|
|
429
|
+
sameSite: currentConfig.cookie.refreshCookieSameSite,
|
|
430
|
+
path: currentConfig.cookie.refreshCookiePath,
|
|
431
|
+
maxAge: currentConfig.cookie.refreshCookieMaxAge,
|
|
432
|
+
domain: hostname
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
__name(getRefreshCookieOptionsForHost, "getRefreshCookieOptionsForHost");
|
|
190
436
|
function getJwtExpiry() {
|
|
191
437
|
return {
|
|
192
438
|
access: currentConfig.jwt.accessTokenExpiry,
|
|
@@ -197,9 +443,9 @@ function getJwtExpiry() {
|
|
|
197
443
|
__name(getJwtExpiry, "getJwtExpiry");
|
|
198
444
|
|
|
199
445
|
// src/request/services/request.service.ts
|
|
200
|
-
function _ts_decorate(decorators, target, key,
|
|
201
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
202
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
446
|
+
function _ts_decorate(decorators, target, key, desc2) {
|
|
447
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
448
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
203
449
|
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;
|
|
204
450
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
205
451
|
}
|
|
@@ -265,10 +511,10 @@ var RequestService = class {
|
|
|
265
511
|
}
|
|
266
512
|
};
|
|
267
513
|
RequestService = _ts_decorate([
|
|
268
|
-
(0,
|
|
269
|
-
scope:
|
|
514
|
+
(0, import_common20.Injectable)({
|
|
515
|
+
scope: import_common20.Scope.REQUEST
|
|
270
516
|
}),
|
|
271
|
-
_ts_param(0, (0,
|
|
517
|
+
_ts_param(0, (0, import_common20.Inject)(import_core.REQUEST)),
|
|
272
518
|
_ts_metadata("design:type", Function),
|
|
273
519
|
_ts_metadata("design:paramtypes", [
|
|
274
520
|
typeof FastifyRequest === "undefined" ? Object : FastifyRequest
|
|
@@ -276,9 +522,9 @@ RequestService = _ts_decorate([
|
|
|
276
522
|
], RequestService);
|
|
277
523
|
|
|
278
524
|
// src/request/request.module.ts
|
|
279
|
-
function _ts_decorate2(decorators, target, key,
|
|
280
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
281
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
525
|
+
function _ts_decorate2(decorators, target, key, desc2) {
|
|
526
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
527
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
282
528
|
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;
|
|
283
529
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
284
530
|
}
|
|
@@ -289,8 +535,8 @@ var RequestModule = class {
|
|
|
289
535
|
}
|
|
290
536
|
};
|
|
291
537
|
RequestModule = _ts_decorate2([
|
|
292
|
-
(0,
|
|
293
|
-
(0,
|
|
538
|
+
(0, import_common21.Global)(),
|
|
539
|
+
(0, import_common21.Module)({
|
|
294
540
|
providers: [
|
|
295
541
|
RequestService
|
|
296
542
|
],
|
|
@@ -301,21 +547,21 @@ RequestModule = _ts_decorate2([
|
|
|
301
547
|
], RequestModule);
|
|
302
548
|
|
|
303
549
|
// src/auth/guards/vritti-auth.guard.ts
|
|
304
|
-
var
|
|
550
|
+
var import_common24 = require("@nestjs/common");
|
|
305
551
|
var import_constants = require("@nestjs/common/constants");
|
|
306
552
|
var import_config2 = require("@nestjs/config");
|
|
307
553
|
var import_core2 = require("@nestjs/core");
|
|
308
554
|
var import_jwt = require("@nestjs/jwt");
|
|
309
555
|
|
|
310
556
|
// src/auth/decorators/reset.decorator.ts
|
|
311
|
-
var
|
|
557
|
+
var import_common22 = require("@nestjs/common");
|
|
312
558
|
var RESET_KEY = "isReset";
|
|
313
|
-
var Reset = /* @__PURE__ */ __name(() => (0,
|
|
559
|
+
var Reset = /* @__PURE__ */ __name(() => (0, import_common22.SetMetadata)(RESET_KEY, true), "Reset");
|
|
314
560
|
|
|
315
561
|
// src/auth/decorators/skip-csrf.decorator.ts
|
|
316
|
-
var
|
|
562
|
+
var import_common23 = require("@nestjs/common");
|
|
317
563
|
var SKIP_CSRF_KEY = "skipCsrf";
|
|
318
|
-
var SkipCsrf = /* @__PURE__ */ __name(() => (0,
|
|
564
|
+
var SkipCsrf = /* @__PURE__ */ __name(() => (0, import_common23.SetMetadata)(SKIP_CSRF_KEY, true), "SkipCsrf");
|
|
319
565
|
|
|
320
566
|
// src/auth/utils/token-hash.util.ts
|
|
321
567
|
var crypto = __toESM(require("crypto"), 1);
|
|
@@ -331,9 +577,9 @@ function verifyTokenHash(token, expectedHash) {
|
|
|
331
577
|
__name(verifyTokenHash, "verifyTokenHash");
|
|
332
578
|
|
|
333
579
|
// src/auth/guards/vritti-auth.guard.ts
|
|
334
|
-
function _ts_decorate3(decorators, target, key,
|
|
335
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
336
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
580
|
+
function _ts_decorate3(decorators, target, key, desc2) {
|
|
581
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
582
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
337
583
|
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;
|
|
338
584
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
339
585
|
}
|
|
@@ -350,7 +596,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
350
596
|
_configService;
|
|
351
597
|
jwtService;
|
|
352
598
|
requestService;
|
|
353
|
-
logger = new
|
|
599
|
+
logger = new import_common24.Logger(_VrittiAuthGuard.name);
|
|
354
600
|
constructor(reflector, _configService, jwtService, requestService) {
|
|
355
601
|
this.reflector = reflector;
|
|
356
602
|
this._configService = _configService;
|
|
@@ -389,21 +635,21 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
389
635
|
try {
|
|
390
636
|
const accessToken = this.requestService.getAccessToken();
|
|
391
637
|
if (!accessToken) {
|
|
392
|
-
throw new
|
|
638
|
+
throw new import_common24.UnauthorizedException("Access token not found");
|
|
393
639
|
}
|
|
394
640
|
const decodedAccessToken = this.validateAccessToken(accessToken);
|
|
395
641
|
if (decodedAccessToken.tokenType !== "access") {
|
|
396
|
-
throw new
|
|
642
|
+
throw new import_common24.UnauthorizedException("Invalid token type");
|
|
397
643
|
}
|
|
398
644
|
this.validateRefreshTokenBinding(decodedAccessToken);
|
|
399
645
|
if (isOnboarding && decodedAccessToken.sessionType !== "ONBOARDING") {
|
|
400
|
-
throw new
|
|
646
|
+
throw new import_common24.UnauthorizedException("This endpoint requires an onboarding session");
|
|
401
647
|
}
|
|
402
648
|
if (isReset && decodedAccessToken.sessionType !== "RESET") {
|
|
403
|
-
throw new
|
|
649
|
+
throw new import_common24.UnauthorizedException("This endpoint requires a reset session");
|
|
404
650
|
}
|
|
405
651
|
if (!isOnboarding && !isReset && (decodedAccessToken.sessionType === "ONBOARDING" || decodedAccessToken.sessionType === "RESET")) {
|
|
406
|
-
throw new
|
|
652
|
+
throw new import_common24.UnauthorizedException(`${decodedAccessToken.sessionType} sessions cannot access this endpoint`);
|
|
407
653
|
}
|
|
408
654
|
request.sessionInfo = {
|
|
409
655
|
userId: decodedAccessToken.userId,
|
|
@@ -412,11 +658,11 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
412
658
|
};
|
|
413
659
|
return true;
|
|
414
660
|
} catch (error) {
|
|
415
|
-
if (error instanceof
|
|
661
|
+
if (error instanceof import_common24.UnauthorizedException) {
|
|
416
662
|
throw error;
|
|
417
663
|
}
|
|
418
664
|
this.logger.error("Unexpected error in auth guard", error);
|
|
419
|
-
throw new
|
|
665
|
+
throw new import_common24.UnauthorizedException("Authentication failed");
|
|
420
666
|
}
|
|
421
667
|
}
|
|
422
668
|
// Validates JWT signature, expiry, and not-before claims
|
|
@@ -424,50 +670,50 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
424
670
|
try {
|
|
425
671
|
return this.jwtService.verify(token);
|
|
426
672
|
} catch (error) {
|
|
427
|
-
if (error instanceof
|
|
673
|
+
if (error instanceof import_common24.UnauthorizedException) throw error;
|
|
428
674
|
const jwtError = error;
|
|
429
675
|
if (jwtError?.name === "TokenExpiredError") {
|
|
430
|
-
throw new
|
|
676
|
+
throw new import_common24.UnauthorizedException("Access token has expired");
|
|
431
677
|
}
|
|
432
678
|
if (jwtError?.name === "JsonWebTokenError") {
|
|
433
|
-
throw new
|
|
679
|
+
throw new import_common24.UnauthorizedException("Invalid access token");
|
|
434
680
|
}
|
|
435
681
|
if (jwtError?.name === "NotBeforeError") {
|
|
436
|
-
throw new
|
|
682
|
+
throw new import_common24.UnauthorizedException("Access token not yet valid");
|
|
437
683
|
}
|
|
438
|
-
throw new
|
|
684
|
+
throw new import_common24.UnauthorizedException("Access token validation failed");
|
|
439
685
|
}
|
|
440
686
|
}
|
|
441
687
|
// Validates that the access token is bound to the refresh token in the cookie
|
|
442
688
|
validateRefreshTokenBinding(decodedAccessToken) {
|
|
443
689
|
if (!decodedAccessToken.refreshTokenHash) {
|
|
444
|
-
throw new
|
|
690
|
+
throw new import_common24.UnauthorizedException("Token missing refresh token binding");
|
|
445
691
|
}
|
|
446
692
|
const refreshToken = this.requestService.getRefreshToken();
|
|
447
693
|
if (!refreshToken) {
|
|
448
|
-
throw new
|
|
694
|
+
throw new import_common24.UnauthorizedException("Session validation failed");
|
|
449
695
|
}
|
|
450
696
|
if (!verifyTokenHash(refreshToken, decodedAccessToken.refreshTokenHash)) {
|
|
451
|
-
throw new
|
|
697
|
+
throw new import_common24.UnauthorizedException("Session validation failed");
|
|
452
698
|
}
|
|
453
699
|
}
|
|
454
700
|
// Authenticates SSE connections using the refresh token httpOnly cookie
|
|
455
701
|
handleSseAuth(request, isOnboarding) {
|
|
456
702
|
const refreshToken = this.requestService.getRefreshToken();
|
|
457
703
|
if (!refreshToken) {
|
|
458
|
-
throw new
|
|
704
|
+
throw new import_common24.UnauthorizedException("Authentication required");
|
|
459
705
|
}
|
|
460
706
|
let decoded;
|
|
461
707
|
try {
|
|
462
708
|
decoded = this.jwtService.verify(refreshToken);
|
|
463
709
|
} catch {
|
|
464
|
-
throw new
|
|
710
|
+
throw new import_common24.UnauthorizedException("Invalid or expired session");
|
|
465
711
|
}
|
|
466
712
|
if (decoded.tokenType !== "refresh") {
|
|
467
|
-
throw new
|
|
713
|
+
throw new import_common24.UnauthorizedException("Invalid token type");
|
|
468
714
|
}
|
|
469
715
|
if (isOnboarding && decoded.sessionType !== "ONBOARDING") {
|
|
470
|
-
throw new
|
|
716
|
+
throw new import_common24.UnauthorizedException("This endpoint requires an onboarding session");
|
|
471
717
|
}
|
|
472
718
|
request.sessionInfo = {
|
|
473
719
|
userId: decoded.userId,
|
|
@@ -488,7 +734,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
488
734
|
const fastifyInstance = request.server;
|
|
489
735
|
const csrfProtection = fastifyInstance.csrfProtection;
|
|
490
736
|
if (!csrfProtection) {
|
|
491
|
-
throw new
|
|
737
|
+
throw new import_common24.ForbiddenException("CSRF protection not configured");
|
|
492
738
|
}
|
|
493
739
|
await new Promise((resolve, reject) => {
|
|
494
740
|
const originalSend = reply.send.bind(reply);
|
|
@@ -504,7 +750,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
504
750
|
});
|
|
505
751
|
});
|
|
506
752
|
} catch (error) {
|
|
507
|
-
throw new
|
|
753
|
+
throw new import_common24.ForbiddenException({
|
|
508
754
|
errors: [
|
|
509
755
|
{
|
|
510
756
|
field: "csrf",
|
|
@@ -517,8 +763,8 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
517
763
|
}
|
|
518
764
|
};
|
|
519
765
|
VrittiAuthGuard = _ts_decorate3([
|
|
520
|
-
(0,
|
|
521
|
-
scope:
|
|
766
|
+
(0, import_common24.Injectable)({
|
|
767
|
+
scope: import_common24.Scope.REQUEST
|
|
522
768
|
}),
|
|
523
769
|
_ts_metadata2("design:type", Function),
|
|
524
770
|
_ts_metadata2("design:paramtypes", [
|
|
@@ -530,7 +776,7 @@ VrittiAuthGuard = _ts_decorate3([
|
|
|
530
776
|
], VrittiAuthGuard);
|
|
531
777
|
|
|
532
778
|
// src/auth/services/jwt-auth.service.ts
|
|
533
|
-
var
|
|
779
|
+
var import_common25 = require("@nestjs/common");
|
|
534
780
|
var import_config3 = require("@nestjs/config");
|
|
535
781
|
var import_jwt2 = require("@nestjs/jwt");
|
|
536
782
|
|
|
@@ -569,9 +815,9 @@ var TokenType = /* @__PURE__ */ (function(TokenType2) {
|
|
|
569
815
|
})({});
|
|
570
816
|
|
|
571
817
|
// src/auth/services/jwt-auth.service.ts
|
|
572
|
-
function _ts_decorate4(decorators, target, key,
|
|
573
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
574
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
818
|
+
function _ts_decorate4(decorators, target, key, desc2) {
|
|
819
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
820
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
575
821
|
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;
|
|
576
822
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
577
823
|
}
|
|
@@ -586,7 +832,7 @@ var JwtAuthService = class _JwtAuthService {
|
|
|
586
832
|
}
|
|
587
833
|
jwtService;
|
|
588
834
|
configService;
|
|
589
|
-
logger = new
|
|
835
|
+
logger = new import_common25.Logger(_JwtAuthService.name);
|
|
590
836
|
tokenExpiry;
|
|
591
837
|
constructor(jwtService, configService) {
|
|
592
838
|
this.jwtService = jwtService;
|
|
@@ -643,7 +889,7 @@ var JwtAuthService = class _JwtAuthService {
|
|
|
643
889
|
}
|
|
644
890
|
};
|
|
645
891
|
JwtAuthService = _ts_decorate4([
|
|
646
|
-
(0,
|
|
892
|
+
(0, import_common25.Injectable)(),
|
|
647
893
|
_ts_metadata3("design:type", Function),
|
|
648
894
|
_ts_metadata3("design:paramtypes", [
|
|
649
895
|
typeof import_jwt2.JwtService === "undefined" ? Object : import_jwt2.JwtService,
|
|
@@ -652,9 +898,9 @@ JwtAuthService = _ts_decorate4([
|
|
|
652
898
|
], JwtAuthService);
|
|
653
899
|
|
|
654
900
|
// src/auth/auth-config.module.ts
|
|
655
|
-
function _ts_decorate5(decorators, target, key,
|
|
656
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
657
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
901
|
+
function _ts_decorate5(decorators, target, key, desc2) {
|
|
902
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
903
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
658
904
|
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;
|
|
659
905
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
660
906
|
}
|
|
@@ -705,29 +951,52 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
705
951
|
}
|
|
706
952
|
};
|
|
707
953
|
AuthConfigModule = _ts_decorate5([
|
|
708
|
-
(0,
|
|
709
|
-
(0,
|
|
954
|
+
(0, import_common26.Global)(),
|
|
955
|
+
(0, import_common26.Module)({})
|
|
710
956
|
], AuthConfigModule);
|
|
711
957
|
|
|
712
958
|
// src/auth/decorators/access-token.decorator.ts
|
|
713
|
-
var
|
|
714
|
-
var AccessToken = (0,
|
|
959
|
+
var import_common27 = require("@nestjs/common");
|
|
960
|
+
var AccessToken = (0, import_common27.createParamDecorator)((_data, ctx) => {
|
|
715
961
|
const request = ctx.switchToHttp().getRequest();
|
|
716
962
|
const authHeader = request.headers.authorization;
|
|
717
963
|
return authHeader?.replace("Bearer ", "") || "";
|
|
718
964
|
});
|
|
719
965
|
|
|
966
|
+
// src/auth/decorators/cookie-domain.decorator.ts
|
|
967
|
+
var import_common28 = require("@nestjs/common");
|
|
968
|
+
var CookieDomain = (0, import_common28.createParamDecorator)((_data, ctx) => {
|
|
969
|
+
const request = ctx.switchToHttp().getRequest();
|
|
970
|
+
const forwarded = request.headers["x-forwarded-host"];
|
|
971
|
+
const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
972
|
+
const hostStr = raw ?? request.hostname;
|
|
973
|
+
const domain = hostStr.split(":")[0] ?? hostStr;
|
|
974
|
+
const baseDomain = getConfig().cookie.refreshCookieDomain ?? "";
|
|
975
|
+
return domain.endsWith(`.${baseDomain}`) ? domain : baseDomain;
|
|
976
|
+
});
|
|
977
|
+
|
|
720
978
|
// src/auth/decorators/onboarding.decorator.ts
|
|
721
|
-
var
|
|
722
|
-
var Onboarding = /* @__PURE__ */ __name(() => (0,
|
|
979
|
+
var import_common29 = require("@nestjs/common");
|
|
980
|
+
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common29.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
723
981
|
|
|
724
982
|
// src/auth/decorators/public.decorator.ts
|
|
725
|
-
var
|
|
726
|
-
var Public = /* @__PURE__ */ __name(() => (0,
|
|
983
|
+
var import_common30 = require("@nestjs/common");
|
|
984
|
+
var Public = /* @__PURE__ */ __name(() => (0, import_common30.SetMetadata)("isPublic", true), "Public");
|
|
985
|
+
|
|
986
|
+
// src/auth/decorators/refresh-cookie-options.decorator.ts
|
|
987
|
+
var import_common31 = require("@nestjs/common");
|
|
988
|
+
var RefreshCookieOptions = (0, import_common31.createParamDecorator)((_data, ctx) => {
|
|
989
|
+
const request = ctx.switchToHttp().getRequest();
|
|
990
|
+
const forwarded = request.headers["x-forwarded-host"];
|
|
991
|
+
const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
992
|
+
const hostStr = raw ?? request.hostname;
|
|
993
|
+
const domain = hostStr.split(":")[0] ?? hostStr;
|
|
994
|
+
return getRefreshCookieOptionsForHost(domain);
|
|
995
|
+
});
|
|
727
996
|
|
|
728
997
|
// src/auth/decorators/refresh-token-cookie.decorator.ts
|
|
729
|
-
var
|
|
730
|
-
var RefreshTokenCookie = (0,
|
|
998
|
+
var import_common32 = require("@nestjs/common");
|
|
999
|
+
var RefreshTokenCookie = (0, import_common32.createParamDecorator)((_data, ctx) => {
|
|
731
1000
|
const request = ctx.switchToHttp().getRequest();
|
|
732
1001
|
const cookies = request.cookies ?? {};
|
|
733
1002
|
const config = getConfig();
|
|
@@ -735,8 +1004,8 @@ var RefreshTokenCookie = (0, import_common11.createParamDecorator)((_data, ctx)
|
|
|
735
1004
|
});
|
|
736
1005
|
|
|
737
1006
|
// src/auth/decorators/session-data.decorator.ts
|
|
738
|
-
var
|
|
739
|
-
var SessionData = (0,
|
|
1007
|
+
var import_common33 = require("@nestjs/common");
|
|
1008
|
+
var SessionData = (0, import_common33.createParamDecorator)((_data, ctx) => {
|
|
740
1009
|
const request = ctx.switchToHttp().getRequest();
|
|
741
1010
|
const sessionInfo = request.sessionInfo;
|
|
742
1011
|
if (!sessionInfo?.sessionId) {
|
|
@@ -750,8 +1019,8 @@ var SessionData = (0, import_common12.createParamDecorator)((_data, ctx) => {
|
|
|
750
1019
|
});
|
|
751
1020
|
|
|
752
1021
|
// src/auth/decorators/user-id.decorator.ts
|
|
753
|
-
var
|
|
754
|
-
var UserId = (0,
|
|
1022
|
+
var import_common34 = require("@nestjs/common");
|
|
1023
|
+
var UserId = (0, import_common34.createParamDecorator)((_data, ctx) => {
|
|
755
1024
|
const request = ctx.switchToHttp().getRequest();
|
|
756
1025
|
const sessionInfo = request.sessionInfo;
|
|
757
1026
|
if (!sessionInfo?.userId) {
|
|
@@ -760,21 +1029,20 @@ var UserId = (0, import_common13.createParamDecorator)((_data, ctx) => {
|
|
|
760
1029
|
return sessionInfo.userId;
|
|
761
1030
|
});
|
|
762
1031
|
|
|
763
|
-
// src/
|
|
764
|
-
var
|
|
765
|
-
var
|
|
1032
|
+
// src/cache/cache.module.ts
|
|
1033
|
+
var import_common37 = require("@nestjs/common");
|
|
1034
|
+
var import_config9 = require("@nestjs/config");
|
|
766
1035
|
|
|
767
|
-
// src/
|
|
768
|
-
var
|
|
1036
|
+
// src/cache/cache.service.ts
|
|
1037
|
+
var import_common35 = require("@nestjs/common");
|
|
769
1038
|
|
|
770
|
-
// src/
|
|
771
|
-
var
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1039
|
+
// src/cache/constants.ts
|
|
1040
|
+
var CACHE_PROVIDER = Symbol("CACHE_PROVIDER");
|
|
1041
|
+
|
|
1042
|
+
// src/cache/cache.service.ts
|
|
1043
|
+
function _ts_decorate6(decorators, target, key, desc2) {
|
|
1044
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1045
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
778
1046
|
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;
|
|
779
1047
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
780
1048
|
}
|
|
@@ -789,12 +1057,218 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
789
1057
|
};
|
|
790
1058
|
}
|
|
791
1059
|
__name(_ts_param2, "_ts_param");
|
|
1060
|
+
var CacheService = class _CacheService {
|
|
1061
|
+
static {
|
|
1062
|
+
__name(this, "CacheService");
|
|
1063
|
+
}
|
|
1064
|
+
provider;
|
|
1065
|
+
logger = new import_common35.Logger(_CacheService.name);
|
|
1066
|
+
constructor(provider) {
|
|
1067
|
+
this.provider = provider;
|
|
1068
|
+
}
|
|
1069
|
+
// Stores a value with mandatory TTL — errors are logged and swallowed so DB writes still succeed
|
|
1070
|
+
async set(key, value, ttlSeconds) {
|
|
1071
|
+
try {
|
|
1072
|
+
await this.provider.set(key, value, ttlSeconds);
|
|
1073
|
+
} catch (err) {
|
|
1074
|
+
this.logger.error(`Cache set failed for key "${key}"`, err);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
// Returns cached value or null on miss or any Redis error — callers fall back to DB
|
|
1078
|
+
async get(key) {
|
|
1079
|
+
try {
|
|
1080
|
+
return await this.provider.get(key);
|
|
1081
|
+
} catch (err) {
|
|
1082
|
+
this.logger.error(`Cache get failed for key "${key}"`, err);
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
// Deletes one or more keys — errors are logged and swallowed
|
|
1087
|
+
async del(...keys) {
|
|
1088
|
+
try {
|
|
1089
|
+
await this.provider.del(...keys);
|
|
1090
|
+
} catch (err) {
|
|
1091
|
+
this.logger.error(`Cache del failed for keys "${keys.join(", ")}"`, err);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
// Returns all keys matching a glob pattern — returns empty array on error
|
|
1095
|
+
async scanKeys(pattern) {
|
|
1096
|
+
try {
|
|
1097
|
+
return await this.provider.scanKeys(pattern);
|
|
1098
|
+
} catch (err) {
|
|
1099
|
+
this.logger.error(`Cache scanKeys failed for pattern "${pattern}"`, err);
|
|
1100
|
+
return [];
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
// Returns raw memory info from the provider — returns empty string on error
|
|
1104
|
+
async getMemoryInfo() {
|
|
1105
|
+
try {
|
|
1106
|
+
return await this.provider.getMemoryInfo();
|
|
1107
|
+
} catch (err) {
|
|
1108
|
+
this.logger.error("Cache getMemoryInfo failed", err);
|
|
1109
|
+
return "";
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
CacheService = _ts_decorate6([
|
|
1114
|
+
(0, import_common35.Injectable)(),
|
|
1115
|
+
_ts_param2(0, (0, import_common35.Inject)(CACHE_PROVIDER)),
|
|
1116
|
+
_ts_metadata4("design:type", Function),
|
|
1117
|
+
_ts_metadata4("design:paramtypes", [
|
|
1118
|
+
typeof ICacheProvider === "undefined" ? Object : ICacheProvider
|
|
1119
|
+
])
|
|
1120
|
+
], CacheService);
|
|
1121
|
+
|
|
1122
|
+
// src/cache/providers/redis.provider.ts
|
|
1123
|
+
var import_common36 = require("@nestjs/common");
|
|
1124
|
+
var import_config8 = require("@nestjs/config");
|
|
1125
|
+
var import_ioredis = __toESM(require("ioredis"), 1);
|
|
1126
|
+
function _ts_decorate7(decorators, target, key, desc2) {
|
|
1127
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1128
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1129
|
+
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;
|
|
1130
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1131
|
+
}
|
|
1132
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1133
|
+
function _ts_metadata5(k, v) {
|
|
1134
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1135
|
+
}
|
|
1136
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1137
|
+
var RedisCacheProvider = class _RedisCacheProvider {
|
|
1138
|
+
static {
|
|
1139
|
+
__name(this, "RedisCacheProvider");
|
|
1140
|
+
}
|
|
1141
|
+
configService;
|
|
1142
|
+
logger = new import_common36.Logger(_RedisCacheProvider.name);
|
|
1143
|
+
client;
|
|
1144
|
+
constructor(configService) {
|
|
1145
|
+
this.configService = configService;
|
|
1146
|
+
}
|
|
1147
|
+
// Creates the ioredis client and attaches connection/error listeners
|
|
1148
|
+
onModuleInit() {
|
|
1149
|
+
const url = this.configService.getOrThrow("REDIS_URL");
|
|
1150
|
+
this.client = new import_ioredis.default(url, {
|
|
1151
|
+
lazyConnect: true,
|
|
1152
|
+
maxRetriesPerRequest: 3
|
|
1153
|
+
});
|
|
1154
|
+
this.client.on("connect", () => this.logger.log("Redis connected"));
|
|
1155
|
+
this.client.on("error", (err) => this.logger.error("Redis error", err));
|
|
1156
|
+
}
|
|
1157
|
+
// Gracefully closes the ioredis connection on app shutdown
|
|
1158
|
+
async onModuleDestroy() {
|
|
1159
|
+
await this.client.quit();
|
|
1160
|
+
this.logger.log("Redis disconnected");
|
|
1161
|
+
}
|
|
1162
|
+
// Serializes value to JSON and stores with a mandatory TTL
|
|
1163
|
+
async set(key, value, ttlSeconds) {
|
|
1164
|
+
const json = JSON.stringify(value);
|
|
1165
|
+
await this.client.setex(key, ttlSeconds, json);
|
|
1166
|
+
}
|
|
1167
|
+
// Reads the stored JSON string and parses back to the original type
|
|
1168
|
+
async get(key) {
|
|
1169
|
+
const json = await this.client.get(key);
|
|
1170
|
+
if (!json) return null;
|
|
1171
|
+
return JSON.parse(json);
|
|
1172
|
+
}
|
|
1173
|
+
// Deletes one or more keys in a single command
|
|
1174
|
+
async del(...keys) {
|
|
1175
|
+
if (keys.length > 0) {
|
|
1176
|
+
await this.client.del(...keys);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
// Cursor-iterates all keys matching a glob pattern — never uses KEYS command
|
|
1180
|
+
async scanKeys(pattern) {
|
|
1181
|
+
const keys = [];
|
|
1182
|
+
let cursor = "0";
|
|
1183
|
+
do {
|
|
1184
|
+
const [nextCursor, batch] = await this.client.scan(cursor, "MATCH", pattern, "COUNT", 100);
|
|
1185
|
+
cursor = nextCursor;
|
|
1186
|
+
keys.push(...batch);
|
|
1187
|
+
} while (cursor !== "0");
|
|
1188
|
+
return keys;
|
|
1189
|
+
}
|
|
1190
|
+
// Returns raw INFO memory output for memory monitoring
|
|
1191
|
+
async getMemoryInfo() {
|
|
1192
|
+
return this.client.info("memory");
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
RedisCacheProvider = _ts_decorate7([
|
|
1196
|
+
(0, import_common36.Injectable)(),
|
|
1197
|
+
_ts_metadata5("design:type", Function),
|
|
1198
|
+
_ts_metadata5("design:paramtypes", [
|
|
1199
|
+
typeof import_config8.ConfigService === "undefined" ? Object : import_config8.ConfigService
|
|
1200
|
+
])
|
|
1201
|
+
], RedisCacheProvider);
|
|
1202
|
+
|
|
1203
|
+
// src/cache/cache.module.ts
|
|
1204
|
+
function _ts_decorate8(decorators, target, key, desc2) {
|
|
1205
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1206
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1207
|
+
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;
|
|
1208
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1209
|
+
}
|
|
1210
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1211
|
+
var CacheModule = class {
|
|
1212
|
+
static {
|
|
1213
|
+
__name(this, "CacheModule");
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
CacheModule = _ts_decorate8([
|
|
1217
|
+
(0, import_common37.Module)({
|
|
1218
|
+
imports: [
|
|
1219
|
+
import_config9.ConfigModule
|
|
1220
|
+
],
|
|
1221
|
+
providers: [
|
|
1222
|
+
RedisCacheProvider,
|
|
1223
|
+
{
|
|
1224
|
+
provide: CACHE_PROVIDER,
|
|
1225
|
+
useExisting: RedisCacheProvider
|
|
1226
|
+
},
|
|
1227
|
+
CacheService
|
|
1228
|
+
],
|
|
1229
|
+
exports: [
|
|
1230
|
+
RedisCacheProvider,
|
|
1231
|
+
CACHE_PROVIDER,
|
|
1232
|
+
CacheService
|
|
1233
|
+
]
|
|
1234
|
+
})
|
|
1235
|
+
], CacheModule);
|
|
1236
|
+
|
|
1237
|
+
// src/database/database.module.ts
|
|
1238
|
+
var import_common41 = require("@nestjs/common");
|
|
1239
|
+
var import_core4 = require("@nestjs/core");
|
|
1240
|
+
|
|
1241
|
+
// src/database/constants.ts
|
|
1242
|
+
var DATABASE_MODULE_OPTIONS = Symbol("DATABASE_MODULE_OPTIONS");
|
|
1243
|
+
|
|
1244
|
+
// src/database/services/primary-database.service.ts
|
|
1245
|
+
var import_common38 = require("@nestjs/common");
|
|
1246
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
1247
|
+
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
1248
|
+
var import_pg = require("pg");
|
|
1249
|
+
function _ts_decorate9(decorators, target, key, desc2) {
|
|
1250
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1251
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1252
|
+
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;
|
|
1253
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1254
|
+
}
|
|
1255
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1256
|
+
function _ts_metadata6(k, v) {
|
|
1257
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1258
|
+
}
|
|
1259
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1260
|
+
function _ts_param3(paramIndex, decorator) {
|
|
1261
|
+
return function(target, key) {
|
|
1262
|
+
decorator(target, key, paramIndex);
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
__name(_ts_param3, "_ts_param");
|
|
792
1266
|
var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
793
1267
|
static {
|
|
794
1268
|
__name(this, "PrimaryDatabaseService");
|
|
795
1269
|
}
|
|
796
1270
|
options;
|
|
797
|
-
logger = new
|
|
1271
|
+
logger = new import_common38.Logger(_PrimaryDatabaseService.name);
|
|
798
1272
|
pool = null;
|
|
799
1273
|
db = null;
|
|
800
1274
|
tenantConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -828,7 +1302,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
828
1302
|
this.logger.log("Connected to primary database (tenant registry)");
|
|
829
1303
|
} catch (error) {
|
|
830
1304
|
this.logger.error("Failed to connect to primary database", error);
|
|
831
|
-
throw new
|
|
1305
|
+
throw new import_common38.InternalServerErrorException("Failed to initialize tenant registry");
|
|
832
1306
|
}
|
|
833
1307
|
}
|
|
834
1308
|
// Builds the PostgreSQL connection URL from primary database config properties
|
|
@@ -900,7 +1374,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
900
1374
|
return info;
|
|
901
1375
|
} catch (error) {
|
|
902
1376
|
this.logger.error(`Failed to fetch tenant info: ${tenantIdentifier}`, error);
|
|
903
|
-
throw new
|
|
1377
|
+
throw new import_common38.InternalServerErrorException("Failed to resolve tenant");
|
|
904
1378
|
}
|
|
905
1379
|
}
|
|
906
1380
|
// Caches tenant info by both ID and subdomain with TTL expiration
|
|
@@ -950,24 +1424,24 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
950
1424
|
}
|
|
951
1425
|
}
|
|
952
1426
|
};
|
|
953
|
-
PrimaryDatabaseService =
|
|
954
|
-
(0,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1427
|
+
PrimaryDatabaseService = _ts_decorate9([
|
|
1428
|
+
(0, import_common38.Injectable)(),
|
|
1429
|
+
_ts_param3(0, (0, import_common38.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1430
|
+
_ts_metadata6("design:type", Function),
|
|
1431
|
+
_ts_metadata6("design:paramtypes", [
|
|
958
1432
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions
|
|
959
1433
|
])
|
|
960
1434
|
], PrimaryDatabaseService);
|
|
961
1435
|
|
|
962
1436
|
// src/database/services/tenant-context.service.ts
|
|
963
|
-
var
|
|
964
|
-
function
|
|
965
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
966
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
1437
|
+
var import_common39 = require("@nestjs/common");
|
|
1438
|
+
function _ts_decorate10(decorators, target, key, desc2) {
|
|
1439
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1440
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
967
1441
|
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;
|
|
968
1442
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
969
1443
|
}
|
|
970
|
-
__name(
|
|
1444
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
971
1445
|
var TenantContextService = class {
|
|
972
1446
|
static {
|
|
973
1447
|
__name(this, "TenantContextService");
|
|
@@ -983,7 +1457,7 @@ var TenantContextService = class {
|
|
|
983
1457
|
// Returns the tenant info for this request, throwing if context is not set
|
|
984
1458
|
getTenant() {
|
|
985
1459
|
if (!this.tenantInfo) {
|
|
986
|
-
throw new
|
|
1460
|
+
throw new import_common39.UnauthorizedException("Tenant context not set");
|
|
987
1461
|
}
|
|
988
1462
|
return this.tenantInfo;
|
|
989
1463
|
}
|
|
@@ -1004,40 +1478,40 @@ var TenantContextService = class {
|
|
|
1004
1478
|
return this.tenantInfo?.subdomain ?? null;
|
|
1005
1479
|
}
|
|
1006
1480
|
};
|
|
1007
|
-
TenantContextService =
|
|
1008
|
-
(0,
|
|
1009
|
-
scope:
|
|
1481
|
+
TenantContextService = _ts_decorate10([
|
|
1482
|
+
(0, import_common39.Injectable)({
|
|
1483
|
+
scope: import_common39.Scope.REQUEST
|
|
1010
1484
|
})
|
|
1011
1485
|
], TenantContextService);
|
|
1012
1486
|
|
|
1013
1487
|
// src/database/services/tenant-database.service.ts
|
|
1014
|
-
var
|
|
1488
|
+
var import_common40 = require("@nestjs/common");
|
|
1015
1489
|
var import_node_postgres2 = require("drizzle-orm/node-postgres");
|
|
1016
1490
|
var import_pg2 = require("pg");
|
|
1017
|
-
function
|
|
1018
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1019
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
1491
|
+
function _ts_decorate11(decorators, target, key, desc2) {
|
|
1492
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1493
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1020
1494
|
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;
|
|
1021
1495
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1022
1496
|
}
|
|
1023
|
-
__name(
|
|
1024
|
-
function
|
|
1497
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1498
|
+
function _ts_metadata7(k, v) {
|
|
1025
1499
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1026
1500
|
}
|
|
1027
|
-
__name(
|
|
1028
|
-
function
|
|
1501
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1502
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1029
1503
|
return function(target, key) {
|
|
1030
1504
|
decorator(target, key, paramIndex);
|
|
1031
1505
|
};
|
|
1032
1506
|
}
|
|
1033
|
-
__name(
|
|
1507
|
+
__name(_ts_param4, "_ts_param");
|
|
1034
1508
|
var TenantDatabaseService = class _TenantDatabaseService {
|
|
1035
1509
|
static {
|
|
1036
1510
|
__name(this, "TenantDatabaseService");
|
|
1037
1511
|
}
|
|
1038
1512
|
options;
|
|
1039
1513
|
tenantContext;
|
|
1040
|
-
logger = new
|
|
1514
|
+
logger = new import_common40.Logger(_TenantDatabaseService.name);
|
|
1041
1515
|
clients = /* @__PURE__ */ new Map();
|
|
1042
1516
|
clientLastUsed = /* @__PURE__ */ new Map();
|
|
1043
1517
|
cleanupInterval;
|
|
@@ -1089,7 +1563,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1089
1563
|
};
|
|
1090
1564
|
} catch (error) {
|
|
1091
1565
|
this.logger.error(`Failed to create database connection for tenant: ${tenant.subdomain}`, error);
|
|
1092
|
-
throw new
|
|
1566
|
+
throw new import_common40.InternalServerErrorException("Failed to connect to tenant database");
|
|
1093
1567
|
}
|
|
1094
1568
|
}
|
|
1095
1569
|
// Builds the PostgreSQL connection URL for a dedicated tenant database
|
|
@@ -1169,24 +1643,24 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1169
1643
|
this.logger.log("All database connections closed");
|
|
1170
1644
|
}
|
|
1171
1645
|
};
|
|
1172
|
-
TenantDatabaseService =
|
|
1173
|
-
(0,
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1646
|
+
TenantDatabaseService = _ts_decorate11([
|
|
1647
|
+
(0, import_common40.Injectable)(),
|
|
1648
|
+
_ts_param4(0, (0, import_common40.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1649
|
+
_ts_metadata7("design:type", Function),
|
|
1650
|
+
_ts_metadata7("design:paramtypes", [
|
|
1177
1651
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
1178
1652
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
1179
1653
|
])
|
|
1180
1654
|
], TenantDatabaseService);
|
|
1181
1655
|
|
|
1182
1656
|
// src/database/database.module.ts
|
|
1183
|
-
function
|
|
1184
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1185
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
1657
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
1658
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1659
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1186
1660
|
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;
|
|
1187
1661
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1188
1662
|
}
|
|
1189
|
-
__name(
|
|
1663
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1190
1664
|
var DatabaseModule = class _DatabaseModule {
|
|
1191
1665
|
static {
|
|
1192
1666
|
__name(this, "DatabaseModule");
|
|
@@ -1232,14 +1706,14 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1232
1706
|
};
|
|
1233
1707
|
}
|
|
1234
1708
|
};
|
|
1235
|
-
DatabaseModule =
|
|
1236
|
-
(0,
|
|
1237
|
-
(0,
|
|
1709
|
+
DatabaseModule = _ts_decorate12([
|
|
1710
|
+
(0, import_common41.Global)(),
|
|
1711
|
+
(0, import_common41.Module)({})
|
|
1238
1712
|
], DatabaseModule);
|
|
1239
1713
|
|
|
1240
1714
|
// src/database/decorators/tenant.decorator.ts
|
|
1241
|
-
var
|
|
1242
|
-
var Tenant = (0,
|
|
1715
|
+
var import_common42 = require("@nestjs/common");
|
|
1716
|
+
var Tenant = (0, import_common42.createParamDecorator)((_data, ctx) => {
|
|
1243
1717
|
const request = ctx.switchToHttp().getRequest();
|
|
1244
1718
|
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1245
1719
|
if (!tenantContext) {
|
|
@@ -1252,17 +1726,17 @@ var Tenant = (0, import_common18.createParamDecorator)((_data, ctx) => {
|
|
|
1252
1726
|
var import_swagger = require("@nestjs/swagger");
|
|
1253
1727
|
var import_class_transformer = require("class-transformer");
|
|
1254
1728
|
var import_class_validator = require("class-validator");
|
|
1255
|
-
function
|
|
1256
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1257
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
1729
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
1730
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1731
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1258
1732
|
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;
|
|
1259
1733
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1260
1734
|
}
|
|
1261
|
-
__name(
|
|
1262
|
-
function
|
|
1735
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1736
|
+
function _ts_metadata8(k, v) {
|
|
1263
1737
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1264
1738
|
}
|
|
1265
|
-
__name(
|
|
1739
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1266
1740
|
var SelectOptionsQueryDto = class {
|
|
1267
1741
|
static {
|
|
1268
1742
|
__name(this, "SelectOptionsQueryDto");
|
|
@@ -1274,18 +1748,19 @@ var SelectOptionsQueryDto = class {
|
|
|
1274
1748
|
excludeIds;
|
|
1275
1749
|
valueKey;
|
|
1276
1750
|
labelKey;
|
|
1751
|
+
descriptionKey;
|
|
1277
1752
|
groupIdKey;
|
|
1278
1753
|
};
|
|
1279
|
-
|
|
1754
|
+
_ts_decorate13([
|
|
1280
1755
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1281
1756
|
description: "Search term to filter by label",
|
|
1282
1757
|
example: "united"
|
|
1283
1758
|
}),
|
|
1284
1759
|
(0, import_class_validator.IsOptional)(),
|
|
1285
1760
|
(0, import_class_validator.IsString)(),
|
|
1286
|
-
|
|
1761
|
+
_ts_metadata8("design:type", String)
|
|
1287
1762
|
], SelectOptionsQueryDto.prototype, "search", void 0);
|
|
1288
|
-
|
|
1763
|
+
_ts_decorate13([
|
|
1289
1764
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1290
1765
|
description: "Maximum number of results",
|
|
1291
1766
|
example: 20,
|
|
@@ -1295,9 +1770,9 @@ _ts_decorate10([
|
|
|
1295
1770
|
(0, import_class_transformer.Type)(() => Number),
|
|
1296
1771
|
(0, import_class_validator.IsInt)(),
|
|
1297
1772
|
(0, import_class_validator.Min)(1),
|
|
1298
|
-
|
|
1773
|
+
_ts_metadata8("design:type", Number)
|
|
1299
1774
|
], SelectOptionsQueryDto.prototype, "limit", void 0);
|
|
1300
|
-
|
|
1775
|
+
_ts_decorate13([
|
|
1301
1776
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1302
1777
|
description: "Number of results to skip",
|
|
1303
1778
|
example: 0,
|
|
@@ -1307,27 +1782,27 @@ _ts_decorate10([
|
|
|
1307
1782
|
(0, import_class_transformer.Type)(() => Number),
|
|
1308
1783
|
(0, import_class_validator.IsInt)(),
|
|
1309
1784
|
(0, import_class_validator.Min)(0),
|
|
1310
|
-
|
|
1785
|
+
_ts_metadata8("design:type", Number)
|
|
1311
1786
|
], SelectOptionsQueryDto.prototype, "offset", void 0);
|
|
1312
|
-
|
|
1787
|
+
_ts_decorate13([
|
|
1313
1788
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1314
1789
|
description: "Comma-separated values to fetch specific options",
|
|
1315
1790
|
example: "1,2,3"
|
|
1316
1791
|
}),
|
|
1317
1792
|
(0, import_class_validator.IsOptional)(),
|
|
1318
1793
|
(0, import_class_validator.IsString)(),
|
|
1319
|
-
|
|
1794
|
+
_ts_metadata8("design:type", String)
|
|
1320
1795
|
], SelectOptionsQueryDto.prototype, "values", void 0);
|
|
1321
|
-
|
|
1796
|
+
_ts_decorate13([
|
|
1322
1797
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1323
1798
|
description: "Comma-separated IDs to exclude from results (already selected)",
|
|
1324
1799
|
example: "5,10"
|
|
1325
1800
|
}),
|
|
1326
1801
|
(0, import_class_validator.IsOptional)(),
|
|
1327
1802
|
(0, import_class_validator.IsString)(),
|
|
1328
|
-
|
|
1803
|
+
_ts_metadata8("design:type", String)
|
|
1329
1804
|
], SelectOptionsQueryDto.prototype, "excludeIds", void 0);
|
|
1330
|
-
|
|
1805
|
+
_ts_decorate13([
|
|
1331
1806
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1332
1807
|
description: "Column name for option value",
|
|
1333
1808
|
example: "id",
|
|
@@ -1335,9 +1810,9 @@ _ts_decorate10([
|
|
|
1335
1810
|
}),
|
|
1336
1811
|
(0, import_class_validator.IsOptional)(),
|
|
1337
1812
|
(0, import_class_validator.IsString)(),
|
|
1338
|
-
|
|
1813
|
+
_ts_metadata8("design:type", String)
|
|
1339
1814
|
], SelectOptionsQueryDto.prototype, "valueKey", void 0);
|
|
1340
|
-
|
|
1815
|
+
_ts_decorate13([
|
|
1341
1816
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1342
1817
|
description: "Column name for option label",
|
|
1343
1818
|
example: "name",
|
|
@@ -1345,21 +1820,193 @@ _ts_decorate10([
|
|
|
1345
1820
|
}),
|
|
1346
1821
|
(0, import_class_validator.IsOptional)(),
|
|
1347
1822
|
(0, import_class_validator.IsString)(),
|
|
1348
|
-
|
|
1823
|
+
_ts_metadata8("design:type", String)
|
|
1349
1824
|
], SelectOptionsQueryDto.prototype, "labelKey", void 0);
|
|
1350
|
-
|
|
1825
|
+
_ts_decorate13([
|
|
1826
|
+
(0, import_swagger.ApiPropertyOptional)({
|
|
1827
|
+
description: "Column name for option description",
|
|
1828
|
+
example: "description"
|
|
1829
|
+
}),
|
|
1830
|
+
(0, import_class_validator.IsOptional)(),
|
|
1831
|
+
(0, import_class_validator.IsString)(),
|
|
1832
|
+
_ts_metadata8("design:type", String)
|
|
1833
|
+
], SelectOptionsQueryDto.prototype, "descriptionKey", void 0);
|
|
1834
|
+
_ts_decorate13([
|
|
1351
1835
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1352
1836
|
description: "Column name for group ID",
|
|
1353
1837
|
example: "regionId"
|
|
1354
1838
|
}),
|
|
1355
1839
|
(0, import_class_validator.IsOptional)(),
|
|
1356
1840
|
(0, import_class_validator.IsString)(),
|
|
1357
|
-
|
|
1841
|
+
_ts_metadata8("design:type", String)
|
|
1358
1842
|
], SelectOptionsQueryDto.prototype, "groupIdKey", void 0);
|
|
1359
1843
|
|
|
1360
|
-
// src/database/
|
|
1361
|
-
var
|
|
1844
|
+
// src/database/dto/success-response.dto.ts
|
|
1845
|
+
var import_swagger2 = require("@nestjs/swagger");
|
|
1846
|
+
var import_class_validator2 = require("class-validator");
|
|
1847
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
1848
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1849
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1850
|
+
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;
|
|
1851
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1852
|
+
}
|
|
1853
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1854
|
+
function _ts_metadata9(k, v) {
|
|
1855
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1856
|
+
}
|
|
1857
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1858
|
+
var SuccessResponseDto = class {
|
|
1859
|
+
static {
|
|
1860
|
+
__name(this, "SuccessResponseDto");
|
|
1861
|
+
}
|
|
1862
|
+
success;
|
|
1863
|
+
message;
|
|
1864
|
+
};
|
|
1865
|
+
_ts_decorate14([
|
|
1866
|
+
(0, import_swagger2.ApiProperty)({
|
|
1867
|
+
example: true
|
|
1868
|
+
}),
|
|
1869
|
+
(0, import_class_validator2.IsNotEmpty)(),
|
|
1870
|
+
(0, import_class_validator2.IsBoolean)(),
|
|
1871
|
+
_ts_metadata9("design:type", Boolean)
|
|
1872
|
+
], SuccessResponseDto.prototype, "success", void 0);
|
|
1873
|
+
_ts_decorate14([
|
|
1874
|
+
(0, import_swagger2.ApiProperty)({
|
|
1875
|
+
example: "Operation completed successfully"
|
|
1876
|
+
}),
|
|
1877
|
+
(0, import_class_validator2.IsNotEmpty)(),
|
|
1878
|
+
(0, import_class_validator2.IsString)(),
|
|
1879
|
+
_ts_metadata9("design:type", String)
|
|
1880
|
+
], SuccessResponseDto.prototype, "message", void 0);
|
|
1881
|
+
|
|
1882
|
+
// src/database/dto/table-response.dto.ts
|
|
1883
|
+
var import_swagger3 = require("@nestjs/swagger");
|
|
1884
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
1885
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1886
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1887
|
+
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;
|
|
1888
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1889
|
+
}
|
|
1890
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1891
|
+
function _ts_metadata10(k, v) {
|
|
1892
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1893
|
+
}
|
|
1894
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1895
|
+
var TableResponseDto = class {
|
|
1896
|
+
static {
|
|
1897
|
+
__name(this, "TableResponseDto");
|
|
1898
|
+
}
|
|
1899
|
+
result;
|
|
1900
|
+
count;
|
|
1901
|
+
state;
|
|
1902
|
+
activeViewId;
|
|
1903
|
+
};
|
|
1904
|
+
_ts_decorate15([
|
|
1905
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1906
|
+
_ts_metadata10("design:type", Array)
|
|
1907
|
+
], TableResponseDto.prototype, "result", void 0);
|
|
1908
|
+
_ts_decorate15([
|
|
1909
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1910
|
+
_ts_metadata10("design:type", Number)
|
|
1911
|
+
], TableResponseDto.prototype, "count", void 0);
|
|
1912
|
+
_ts_decorate15([
|
|
1913
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1914
|
+
_ts_metadata10("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
1915
|
+
], TableResponseDto.prototype, "state", void 0);
|
|
1916
|
+
_ts_decorate15([
|
|
1917
|
+
(0, import_swagger3.ApiPropertyOptional)({
|
|
1918
|
+
nullable: true
|
|
1919
|
+
}),
|
|
1920
|
+
_ts_metadata10("design:type", Object)
|
|
1921
|
+
], TableResponseDto.prototype, "activeViewId", void 0);
|
|
1922
|
+
|
|
1923
|
+
// src/database/filter/filter.processor.ts
|
|
1362
1924
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
1925
|
+
var FilterProcessor = class {
|
|
1926
|
+
static {
|
|
1927
|
+
__name(this, "FilterProcessor");
|
|
1928
|
+
}
|
|
1929
|
+
// Returns undefined if no conditions (Drizzle accepts undefined as "no WHERE")
|
|
1930
|
+
static buildWhere(filters = [], fieldMap) {
|
|
1931
|
+
const conditions = filters.flatMap((f) => {
|
|
1932
|
+
const def = fieldMap[f.field];
|
|
1933
|
+
if (!def) return [];
|
|
1934
|
+
if ("expression" in def) return [
|
|
1935
|
+
def.expression(f.value)
|
|
1936
|
+
];
|
|
1937
|
+
const { column: col } = def;
|
|
1938
|
+
const val = f.value;
|
|
1939
|
+
switch (f.operator) {
|
|
1940
|
+
case "equals":
|
|
1941
|
+
if (def.type === "boolean") return [
|
|
1942
|
+
(0, import_drizzle_orm2.eq)(col, val === "true" || val === 1)
|
|
1943
|
+
];
|
|
1944
|
+
return [
|
|
1945
|
+
(0, import_drizzle_orm2.eq)(col, val)
|
|
1946
|
+
];
|
|
1947
|
+
case "notEquals":
|
|
1948
|
+
if (def.type === "boolean") return [
|
|
1949
|
+
(0, import_drizzle_orm2.ne)(col, val === "true" || val === 1)
|
|
1950
|
+
];
|
|
1951
|
+
return [
|
|
1952
|
+
(0, import_drizzle_orm2.ne)(col, val)
|
|
1953
|
+
];
|
|
1954
|
+
case "contains":
|
|
1955
|
+
return [
|
|
1956
|
+
(0, import_drizzle_orm2.ilike)(col, `%${val}%`)
|
|
1957
|
+
];
|
|
1958
|
+
case "notContains":
|
|
1959
|
+
return [
|
|
1960
|
+
(0, import_drizzle_orm2.notIlike)(col, `%${val}%`)
|
|
1961
|
+
];
|
|
1962
|
+
case "gt":
|
|
1963
|
+
return [
|
|
1964
|
+
(0, import_drizzle_orm2.gt)(col, val)
|
|
1965
|
+
];
|
|
1966
|
+
case "gte":
|
|
1967
|
+
return [
|
|
1968
|
+
(0, import_drizzle_orm2.gte)(col, val)
|
|
1969
|
+
];
|
|
1970
|
+
case "lt":
|
|
1971
|
+
return [
|
|
1972
|
+
(0, import_drizzle_orm2.lt)(col, val)
|
|
1973
|
+
];
|
|
1974
|
+
case "lte":
|
|
1975
|
+
return [
|
|
1976
|
+
(0, import_drizzle_orm2.lte)(col, val)
|
|
1977
|
+
];
|
|
1978
|
+
default:
|
|
1979
|
+
return [];
|
|
1980
|
+
}
|
|
1981
|
+
});
|
|
1982
|
+
return conditions.length ? (0, import_drizzle_orm2.and)(...conditions) : void 0;
|
|
1983
|
+
}
|
|
1984
|
+
// Builds a search WHERE — OR across all string fields when columnId is 'all', otherwise a single ilike
|
|
1985
|
+
static buildSearch(search, fieldMap) {
|
|
1986
|
+
if (!search?.value) return void 0;
|
|
1987
|
+
if (search.columnId === "all") {
|
|
1988
|
+
const conditions = Object.values(fieldMap).filter((def2) => "column" in def2 && def2.type === "string").map((def2) => (0, import_drizzle_orm2.ilike)(def2.column, `%${search.value}%`));
|
|
1989
|
+
return conditions.length ? (0, import_drizzle_orm2.or)(...conditions) : void 0;
|
|
1990
|
+
}
|
|
1991
|
+
const def = fieldMap[search.columnId];
|
|
1992
|
+
if (!def || !("column" in def)) return void 0;
|
|
1993
|
+
return (0, import_drizzle_orm2.ilike)(def.column, `%${search.value}%`);
|
|
1994
|
+
}
|
|
1995
|
+
// Maps each SortCondition to an asc/desc SQL expression
|
|
1996
|
+
static buildOrderBy(sort = [], fieldMap) {
|
|
1997
|
+
return sort.flatMap((s) => {
|
|
1998
|
+
const def = fieldMap[s.field];
|
|
1999
|
+
if (!def || !("column" in def)) return [];
|
|
2000
|
+
return [
|
|
2001
|
+
s.direction === "asc" ? (0, import_drizzle_orm2.asc)(def.column) : (0, import_drizzle_orm2.desc)(def.column)
|
|
2002
|
+
];
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
// src/database/repositories/primary-base.repository.ts
|
|
2008
|
+
var import_common43 = require("@nestjs/common");
|
|
2009
|
+
var import_drizzle_orm3 = require("drizzle-orm");
|
|
1363
2010
|
function snakeToCamel(str) {
|
|
1364
2011
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1365
2012
|
}
|
|
@@ -1388,9 +2035,9 @@ var PrimaryBaseRepository = class {
|
|
|
1388
2035
|
constructor(database, table) {
|
|
1389
2036
|
this.database = database;
|
|
1390
2037
|
this.table = table;
|
|
1391
|
-
const dbTableName = (0,
|
|
2038
|
+
const dbTableName = (0, import_drizzle_orm3.getTableName)(table);
|
|
1392
2039
|
this.tableName = snakeToCamel(dbTableName);
|
|
1393
|
-
this.logger = new
|
|
2040
|
+
this.logger = new import_common43.Logger(this.constructor.name);
|
|
1394
2041
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1395
2042
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1396
2043
|
}
|
|
@@ -1423,12 +2070,32 @@ var PrimaryBaseRepository = class {
|
|
|
1423
2070
|
this.logger.debug("Finding multiple records");
|
|
1424
2071
|
return this.model.findMany(options);
|
|
1425
2072
|
}
|
|
2073
|
+
// Builds a select query with optional custom fields, join, filter, ordering, and pagination
|
|
2074
|
+
buildSelectQuery(options) {
|
|
2075
|
+
const base = options?.select ? this.db.select(options.select).from(this.table) : this.db.select().from(this.table);
|
|
2076
|
+
const joined = options?.leftJoin ? base.leftJoin(options.leftJoin.table, options.leftJoin.on) : base;
|
|
2077
|
+
const filtered = options?.where ? joined.where(options.where) : joined;
|
|
2078
|
+
const ordered = options?.orderBy?.length ? filtered.orderBy(...options.orderBy) : filtered;
|
|
2079
|
+
const limited = options?.limit ? ordered.limit(options.limit) : ordered;
|
|
2080
|
+
return options?.offset ? limited.offset(options.offset) : limited;
|
|
2081
|
+
}
|
|
2082
|
+
// Returns paginated result and total count, with optional custom select, LEFT JOIN, and ordering
|
|
2083
|
+
async findAllAndCount(options) {
|
|
2084
|
+
const [count, result] = await Promise.all([
|
|
2085
|
+
this.count(options?.where),
|
|
2086
|
+
this.buildSelectQuery(options)
|
|
2087
|
+
]);
|
|
2088
|
+
return {
|
|
2089
|
+
result,
|
|
2090
|
+
count
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
1426
2093
|
// Updates a record by ID and returns the updated record
|
|
1427
2094
|
async update(id, data) {
|
|
1428
2095
|
this.logger.log(`Updating record with ID: ${id}`);
|
|
1429
2096
|
const idColumn = this.table.id;
|
|
1430
2097
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1431
|
-
const results = await this.db.update(this.table).set(data).where((0,
|
|
2098
|
+
const results = await this.db.update(this.table).set(data).where((0, import_drizzle_orm3.eq)(idColumn, id)).returning();
|
|
1432
2099
|
const record = results[0];
|
|
1433
2100
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1434
2101
|
return record;
|
|
@@ -1446,7 +2113,7 @@ var PrimaryBaseRepository = class {
|
|
|
1446
2113
|
this.logger.log(`Deleting record with ID: ${id}`);
|
|
1447
2114
|
const idColumn = this.table.id;
|
|
1448
2115
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1449
|
-
const results = await this.db.delete(this.table).where((0,
|
|
2116
|
+
const results = await this.db.delete(this.table).where((0, import_drizzle_orm3.eq)(idColumn, id)).returning();
|
|
1450
2117
|
const record = results[0];
|
|
1451
2118
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1452
2119
|
return record;
|
|
@@ -1463,7 +2130,7 @@ var PrimaryBaseRepository = class {
|
|
|
1463
2130
|
async count(where) {
|
|
1464
2131
|
this.logger.debug("Counting records");
|
|
1465
2132
|
let query = this.db.select({
|
|
1466
|
-
count:
|
|
2133
|
+
count: import_drizzle_orm3.sql`count(*)::int`
|
|
1467
2134
|
}).from(this.table).$dynamic();
|
|
1468
2135
|
if (where) {
|
|
1469
2136
|
query = query.where(where);
|
|
@@ -1486,20 +2153,44 @@ var PrimaryBaseRepository = class {
|
|
|
1486
2153
|
if (!valueCol) throw new Error(`Column '${config.value}' not found in table '${this.tableName}'`);
|
|
1487
2154
|
const labelCol = tableColumns[config.label];
|
|
1488
2155
|
if (!labelCol) throw new Error(`Column '${config.label}' not found in table '${this.tableName}'`);
|
|
2156
|
+
let descriptionCol = config.description ? tableColumns[config.description] : void 0;
|
|
2157
|
+
if (!descriptionCol && config.description && config.joins) {
|
|
2158
|
+
for (const join of config.joins) {
|
|
2159
|
+
const joinCols = join.table;
|
|
2160
|
+
if (joinCols[config.description]) {
|
|
2161
|
+
descriptionCol = joinCols[config.description];
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
1489
2166
|
if (parsedValues && parsedValues.length > 0) {
|
|
1490
2167
|
const selectCols = {
|
|
1491
2168
|
value: valueCol,
|
|
1492
2169
|
label: labelCol
|
|
1493
2170
|
};
|
|
2171
|
+
if (descriptionCol) selectCols.description = descriptionCol;
|
|
1494
2172
|
if (config.groupId) {
|
|
1495
2173
|
const groupIdCol = tableColumns[config.groupId];
|
|
1496
2174
|
if (groupIdCol) selectCols.groupId = groupIdCol;
|
|
1497
2175
|
}
|
|
1498
|
-
|
|
2176
|
+
let valuesQuery = this.db.select(selectCols).from(this.table).$dynamic();
|
|
2177
|
+
if (config.joins) {
|
|
2178
|
+
for (const join of config.joins) {
|
|
2179
|
+
if (join.type === "inner") {
|
|
2180
|
+
valuesQuery = valuesQuery.innerJoin(join.table, join.on);
|
|
2181
|
+
} else {
|
|
2182
|
+
valuesQuery = valuesQuery.leftJoin(join.table, join.on);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
const rows2 = await valuesQuery.where((0, import_drizzle_orm3.inArray)(valueCol, parsedValues));
|
|
1499
2187
|
return {
|
|
1500
2188
|
options: rows2.map((row) => ({
|
|
1501
2189
|
value: row.value,
|
|
1502
2190
|
label: String(row.label),
|
|
2191
|
+
...descriptionCol && row.description != null ? {
|
|
2192
|
+
description: row.description
|
|
2193
|
+
} : {},
|
|
1503
2194
|
...config.groupId && row.groupId != null ? {
|
|
1504
2195
|
groupId: row.groupId
|
|
1505
2196
|
} : {}
|
|
@@ -1513,47 +2204,63 @@ var PrimaryBaseRepository = class {
|
|
|
1513
2204
|
const selectFields = {
|
|
1514
2205
|
value: valueCol,
|
|
1515
2206
|
label: labelCol,
|
|
1516
|
-
totalCount:
|
|
2207
|
+
totalCount: import_drizzle_orm3.sql`count(*) over()`.mapWith(Number)
|
|
1517
2208
|
};
|
|
2209
|
+
if (descriptionCol) selectFields.description = descriptionCol;
|
|
1518
2210
|
if (config.groupId) {
|
|
1519
2211
|
const groupIdCol = tableColumns[config.groupId];
|
|
1520
2212
|
if (groupIdCol) selectFields.groupId = groupIdCol;
|
|
1521
2213
|
}
|
|
1522
2214
|
const conditions = [];
|
|
1523
2215
|
if (config.search) {
|
|
1524
|
-
conditions.push((0,
|
|
2216
|
+
conditions.push((0, import_drizzle_orm3.ilike)(labelCol, `%${config.search}%`));
|
|
1525
2217
|
}
|
|
1526
2218
|
if (parsedExcludeIds.length > 0) {
|
|
1527
|
-
conditions.push((0,
|
|
2219
|
+
conditions.push((0, import_drizzle_orm3.notInArray)(valueCol, parsedExcludeIds));
|
|
1528
2220
|
}
|
|
1529
2221
|
if (config.where) {
|
|
1530
2222
|
for (const [field, val] of Object.entries(config.where)) {
|
|
1531
2223
|
const column = tableColumns[field];
|
|
1532
2224
|
if (column) {
|
|
1533
|
-
conditions.push((0,
|
|
2225
|
+
conditions.push((0, import_drizzle_orm3.eq)(column, val));
|
|
1534
2226
|
}
|
|
1535
2227
|
}
|
|
1536
2228
|
}
|
|
2229
|
+
if (config.conditions) {
|
|
2230
|
+
conditions.push(...config.conditions);
|
|
2231
|
+
}
|
|
1537
2232
|
const orderByKey = config.orderBy ? Object.keys(config.orderBy)[0] : void 0;
|
|
1538
2233
|
const orderByCol = orderByKey ? tableColumns[orderByKey] ?? labelCol : labelCol;
|
|
1539
2234
|
const limit = Number(config.limit) || 20;
|
|
1540
2235
|
const offset = Number(config.offset) || 0;
|
|
1541
2236
|
let query = this.db.select(selectFields).from(this.table).$dynamic();
|
|
2237
|
+
if (config.joins) {
|
|
2238
|
+
for (const join of config.joins) {
|
|
2239
|
+
if (join.type === "inner") {
|
|
2240
|
+
query = query.innerJoin(join.table, join.on);
|
|
2241
|
+
} else {
|
|
2242
|
+
query = query.leftJoin(join.table, join.on);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
1542
2246
|
if (conditions.length > 0) {
|
|
1543
|
-
query = query.where(conditions.length === 1 ? conditions[0] : (0,
|
|
2247
|
+
query = query.where(conditions.length === 1 ? conditions[0] : (0, import_drizzle_orm3.and)(...conditions));
|
|
1544
2248
|
}
|
|
1545
2249
|
const orderClauses = [];
|
|
1546
2250
|
if (config.groupId) {
|
|
1547
2251
|
const groupIdCol = tableColumns[config.groupId];
|
|
1548
|
-
if (groupIdCol) orderClauses.push((0,
|
|
2252
|
+
if (groupIdCol) orderClauses.push((0, import_drizzle_orm3.asc)(groupIdCol));
|
|
1549
2253
|
}
|
|
1550
|
-
orderClauses.push((0,
|
|
2254
|
+
orderClauses.push((0, import_drizzle_orm3.asc)(orderByCol));
|
|
1551
2255
|
query = query.orderBy(...orderClauses).limit(limit).offset(offset);
|
|
1552
2256
|
const rows = await query;
|
|
1553
2257
|
const totalCount = rows.length > 0 ? rows[0].totalCount : 0;
|
|
1554
2258
|
const options = rows.map((row) => ({
|
|
1555
2259
|
value: row.value,
|
|
1556
2260
|
label: String(row.label),
|
|
2261
|
+
...descriptionCol && row.description != null ? {
|
|
2262
|
+
description: row.description
|
|
2263
|
+
} : {},
|
|
1557
2264
|
...config.groupId && row.groupId != null ? {
|
|
1558
2265
|
groupId: row.groupId
|
|
1559
2266
|
} : {}
|
|
@@ -1570,7 +2277,7 @@ var PrimaryBaseRepository = class {
|
|
|
1570
2277
|
const groupRows = await this.db.select({
|
|
1571
2278
|
id: groupIdCol,
|
|
1572
2279
|
name: groupNameCol
|
|
1573
|
-
}).from(config.groupTable).orderBy((0,
|
|
2280
|
+
}).from(config.groupTable).orderBy((0, import_drizzle_orm3.asc)(groupNameCol));
|
|
1574
2281
|
resolvedGroups = groupRows.map((r) => ({
|
|
1575
2282
|
id: r.id,
|
|
1576
2283
|
name: String(r.name)
|
|
@@ -1588,8 +2295,8 @@ var PrimaryBaseRepository = class {
|
|
|
1588
2295
|
};
|
|
1589
2296
|
|
|
1590
2297
|
// src/database/repositories/tenant-base.repository.ts
|
|
1591
|
-
var
|
|
1592
|
-
var
|
|
2298
|
+
var import_common44 = require("@nestjs/common");
|
|
2299
|
+
var import_drizzle_orm4 = require("drizzle-orm");
|
|
1593
2300
|
var TenantBaseRepository = class {
|
|
1594
2301
|
static {
|
|
1595
2302
|
__name(this, "TenantBaseRepository");
|
|
@@ -1607,8 +2314,8 @@ var TenantBaseRepository = class {
|
|
|
1607
2314
|
constructor(database, table) {
|
|
1608
2315
|
this.database = database;
|
|
1609
2316
|
this.table = table;
|
|
1610
|
-
this.tableName = (0,
|
|
1611
|
-
this.logger = new
|
|
2317
|
+
this.tableName = (0, import_drizzle_orm4.getTableName)(table);
|
|
2318
|
+
this.logger = new import_common44.Logger(this.constructor.name);
|
|
1612
2319
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1613
2320
|
}
|
|
1614
2321
|
// Creates a new record and returns it
|
|
@@ -1624,7 +2331,7 @@ var TenantBaseRepository = class {
|
|
|
1624
2331
|
this.logger.debug(`Finding record by ID: ${id}`);
|
|
1625
2332
|
const idColumn = this.table.id;
|
|
1626
2333
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1627
|
-
const results = await this.db.select().from(this.table).where((0,
|
|
2334
|
+
const results = await this.db.select().from(this.table).where((0, import_drizzle_orm4.eq)(idColumn, id)).limit(1);
|
|
1628
2335
|
return results[0] ?? null;
|
|
1629
2336
|
}
|
|
1630
2337
|
// Finds a single record matching the given SQL condition
|
|
@@ -1656,7 +2363,7 @@ var TenantBaseRepository = class {
|
|
|
1656
2363
|
this.logger.log(`Updating record with ID: ${id}`);
|
|
1657
2364
|
const idColumn = this.table.id;
|
|
1658
2365
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1659
|
-
const results = await this.db.update(this.table).set(data).where((0,
|
|
2366
|
+
const results = await this.db.update(this.table).set(data).where((0, import_drizzle_orm4.eq)(idColumn, id)).returning();
|
|
1660
2367
|
const record = results[0];
|
|
1661
2368
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1662
2369
|
return record;
|
|
@@ -1674,7 +2381,7 @@ var TenantBaseRepository = class {
|
|
|
1674
2381
|
this.logger.log(`Deleting record with ID: ${id}`);
|
|
1675
2382
|
const idColumn = this.table.id;
|
|
1676
2383
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1677
|
-
const results = await this.db.delete(this.table).where((0,
|
|
2384
|
+
const results = await this.db.delete(this.table).where((0, import_drizzle_orm4.eq)(idColumn, id)).returning();
|
|
1678
2385
|
const record = results[0];
|
|
1679
2386
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1680
2387
|
return record;
|
|
@@ -1691,7 +2398,7 @@ var TenantBaseRepository = class {
|
|
|
1691
2398
|
async count(where) {
|
|
1692
2399
|
this.logger.debug("Counting records");
|
|
1693
2400
|
let query = this.db.select({
|
|
1694
|
-
count:
|
|
2401
|
+
count: import_drizzle_orm4.sql`count(*)::int`
|
|
1695
2402
|
}).from(this.table).$dynamic();
|
|
1696
2403
|
if (where) {
|
|
1697
2404
|
query = query.where(where);
|
|
@@ -1723,7 +2430,7 @@ var TenantBaseRepository = class {
|
|
|
1723
2430
|
const groupIdCol = tableColumns[config.groupId];
|
|
1724
2431
|
if (groupIdCol) selectCols.groupId = groupIdCol;
|
|
1725
2432
|
}
|
|
1726
|
-
const rows2 = await this.db.select(selectCols).from(this.table).where((0,
|
|
2433
|
+
const rows2 = await this.db.select(selectCols).from(this.table).where((0, import_drizzle_orm4.inArray)(valueCol, parsedValues));
|
|
1727
2434
|
return {
|
|
1728
2435
|
options: rows2.map((row) => ({
|
|
1729
2436
|
value: row.value,
|
|
@@ -1741,7 +2448,7 @@ var TenantBaseRepository = class {
|
|
|
1741
2448
|
const selectFields = {
|
|
1742
2449
|
value: valueCol,
|
|
1743
2450
|
label: labelCol,
|
|
1744
|
-
totalCount:
|
|
2451
|
+
totalCount: import_drizzle_orm4.sql`count(*) over()`.mapWith(Number)
|
|
1745
2452
|
};
|
|
1746
2453
|
if (config.groupId) {
|
|
1747
2454
|
const groupIdCol = tableColumns[config.groupId];
|
|
@@ -1749,16 +2456,16 @@ var TenantBaseRepository = class {
|
|
|
1749
2456
|
}
|
|
1750
2457
|
const conditions = [];
|
|
1751
2458
|
if (config.search) {
|
|
1752
|
-
conditions.push((0,
|
|
2459
|
+
conditions.push((0, import_drizzle_orm4.ilike)(labelCol, `%${config.search}%`));
|
|
1753
2460
|
}
|
|
1754
2461
|
if (parsedExcludeIds.length > 0) {
|
|
1755
|
-
conditions.push((0,
|
|
2462
|
+
conditions.push((0, import_drizzle_orm4.notInArray)(valueCol, parsedExcludeIds));
|
|
1756
2463
|
}
|
|
1757
2464
|
if (config.where) {
|
|
1758
2465
|
for (const [field, val] of Object.entries(config.where)) {
|
|
1759
2466
|
const column = tableColumns[field];
|
|
1760
2467
|
if (column) {
|
|
1761
|
-
conditions.push((0,
|
|
2468
|
+
conditions.push((0, import_drizzle_orm4.eq)(column, val));
|
|
1762
2469
|
}
|
|
1763
2470
|
}
|
|
1764
2471
|
}
|
|
@@ -1768,14 +2475,14 @@ var TenantBaseRepository = class {
|
|
|
1768
2475
|
const offset = Number(config.offset) || 0;
|
|
1769
2476
|
let query = this.db.select(selectFields).from(this.table).$dynamic();
|
|
1770
2477
|
if (conditions.length > 0) {
|
|
1771
|
-
query = query.where(conditions.length === 1 ? conditions[0] : (0,
|
|
2478
|
+
query = query.where(conditions.length === 1 ? conditions[0] : (0, import_drizzle_orm4.and)(...conditions));
|
|
1772
2479
|
}
|
|
1773
2480
|
const orderClauses = [];
|
|
1774
2481
|
if (config.groupId) {
|
|
1775
2482
|
const groupIdCol = tableColumns[config.groupId];
|
|
1776
|
-
if (groupIdCol) orderClauses.push((0,
|
|
2483
|
+
if (groupIdCol) orderClauses.push((0, import_drizzle_orm4.asc)(groupIdCol));
|
|
1777
2484
|
}
|
|
1778
|
-
orderClauses.push((0,
|
|
2485
|
+
orderClauses.push((0, import_drizzle_orm4.asc)(orderByCol));
|
|
1779
2486
|
query = query.orderBy(...orderClauses).limit(limit).offset(offset);
|
|
1780
2487
|
const rows = await query;
|
|
1781
2488
|
const totalCount = rows.length > 0 ? rows[0].totalCount : 0;
|
|
@@ -1798,7 +2505,7 @@ var TenantBaseRepository = class {
|
|
|
1798
2505
|
const groupRows = await this.db.select({
|
|
1799
2506
|
id: groupIdCol,
|
|
1800
2507
|
name: groupNameCol
|
|
1801
|
-
}).from(config.groupTable).orderBy((0,
|
|
2508
|
+
}).from(config.groupTable).orderBy((0, import_drizzle_orm4.asc)(groupNameCol));
|
|
1802
2509
|
resolvedGroups = groupRows.map((r) => ({
|
|
1803
2510
|
id: r.id,
|
|
1804
2511
|
name: String(r.name)
|
|
@@ -1816,30 +2523,30 @@ var TenantBaseRepository = class {
|
|
|
1816
2523
|
};
|
|
1817
2524
|
|
|
1818
2525
|
// src/email/email.module.ts
|
|
1819
|
-
var
|
|
1820
|
-
var
|
|
2526
|
+
var import_common46 = require("@nestjs/common");
|
|
2527
|
+
var import_config11 = require("@nestjs/config");
|
|
1821
2528
|
|
|
1822
2529
|
// src/email/email.service.ts
|
|
1823
2530
|
var import_brevo = require("@getbrevo/brevo");
|
|
1824
|
-
var
|
|
1825
|
-
var
|
|
1826
|
-
function
|
|
1827
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
1828
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
2531
|
+
var import_common45 = require("@nestjs/common");
|
|
2532
|
+
var import_config10 = require("@nestjs/config");
|
|
2533
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
2534
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2535
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1829
2536
|
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;
|
|
1830
2537
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1831
2538
|
}
|
|
1832
|
-
__name(
|
|
1833
|
-
function
|
|
2539
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2540
|
+
function _ts_metadata11(k, v) {
|
|
1834
2541
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1835
2542
|
}
|
|
1836
|
-
__name(
|
|
2543
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1837
2544
|
var EmailService = class _EmailService {
|
|
1838
2545
|
static {
|
|
1839
2546
|
__name(this, "EmailService");
|
|
1840
2547
|
}
|
|
1841
2548
|
configService;
|
|
1842
|
-
logger = new
|
|
2549
|
+
logger = new import_common45.Logger(_EmailService.name);
|
|
1843
2550
|
brevoClient;
|
|
1844
2551
|
senderEmail;
|
|
1845
2552
|
senderName;
|
|
@@ -2220,388 +2927,169 @@ This is an automated message, please do not reply.
|
|
|
2220
2927
|
<p style="margin: 0; color: #155724; font-size: 18px; font-weight: 600; font-family: monospace;">
|
|
2221
2928
|
${email}
|
|
2222
2929
|
</p>
|
|
2223
|
-
</div>
|
|
2224
|
-
|
|
2225
|
-
<p style="margin: 30px 0 20px; color: #666666; font-size: 14px; line-height: 1.6;">
|
|
2226
|
-
If you did not request this revert, please contact our support team immediately.
|
|
2227
|
-
</p>
|
|
2228
|
-
</td>
|
|
2229
|
-
</tr>
|
|
2230
|
-
|
|
2231
|
-
<!-- Footer -->
|
|
2232
|
-
<tr>
|
|
2233
|
-
<td style="padding: 30px 40px; border-top: 1px solid #e0e0e0; text-align: center;">
|
|
2234
|
-
<p style="margin: 0; color: #999999; font-size: 12px; line-height: 1.5;">
|
|
2235
|
-
Vritti AI Cloud - Cloud Management Platform
|
|
2236
|
-
</p>
|
|
2237
|
-
<p style="margin: 8px 0 0; color: #999999; font-size: 12px; line-height: 1.5;">
|
|
2238
|
-
This is an automated message, please do not reply.
|
|
2239
|
-
</p>
|
|
2240
|
-
</td>
|
|
2241
|
-
</tr>
|
|
2242
|
-
</table>
|
|
2243
|
-
</td>
|
|
2244
|
-
</tr>
|
|
2245
|
-
</table>
|
|
2246
|
-
</body>
|
|
2247
|
-
</html>
|
|
2248
|
-
`;
|
|
2249
|
-
const textContent = `
|
|
2250
|
-
Hello ${name},
|
|
2251
|
-
|
|
2252
|
-
Your recent email address change has been successfully reverted. Your email is now:
|
|
2253
|
-
|
|
2254
|
-
${email}
|
|
2255
|
-
|
|
2256
|
-
If you did not request this revert, please contact our support team immediately.
|
|
2257
|
-
|
|
2258
|
-
---
|
|
2259
|
-
Vritti AI Cloud - Cloud Management Platform
|
|
2260
|
-
This is an automated message, please do not reply.
|
|
2261
|
-
`.trim();
|
|
2262
|
-
await this.sendEmail({
|
|
2263
|
-
to: [
|
|
2264
|
-
{
|
|
2265
|
-
email,
|
|
2266
|
-
name
|
|
2267
|
-
}
|
|
2268
|
-
],
|
|
2269
|
-
subject,
|
|
2270
|
-
htmlContent,
|
|
2271
|
-
textContent
|
|
2272
|
-
});
|
|
2273
|
-
this.logger.log(`Email revert confirmation sent to ${email}`);
|
|
2274
|
-
}
|
|
2275
|
-
// Verifies Brevo API connectivity — a 400 response means the API is reachable
|
|
2276
|
-
async verifyConnection() {
|
|
2277
|
-
try {
|
|
2278
|
-
await this.brevoClient.transactionalEmails.sendTransacEmail({
|
|
2279
|
-
sender: {
|
|
2280
|
-
email: this.senderEmail,
|
|
2281
|
-
name: this.senderName
|
|
2282
|
-
},
|
|
2283
|
-
to: [
|
|
2284
|
-
{
|
|
2285
|
-
email: this.senderEmail
|
|
2286
|
-
}
|
|
2287
|
-
],
|
|
2288
|
-
subject: "Connection Test",
|
|
2289
|
-
htmlContent: "<p>Test</p>"
|
|
2290
|
-
});
|
|
2291
|
-
return true;
|
|
2292
|
-
} catch (err) {
|
|
2293
|
-
if (err instanceof import_brevo.BrevoError && err.statusCode === 400) {
|
|
2294
|
-
return true;
|
|
2295
|
-
}
|
|
2296
|
-
this.logger.error("Brevo connection verification failed:", err);
|
|
2297
|
-
return false;
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
// Sends a transactional email via Brevo — retries handled internally by BrevoClient
|
|
2301
|
-
async sendEmail(emailData) {
|
|
2302
|
-
try {
|
|
2303
|
-
const result = await this.brevoClient.transactionalEmails.sendTransacEmail({
|
|
2304
|
-
sender: {
|
|
2305
|
-
email: this.senderEmail,
|
|
2306
|
-
name: this.senderName
|
|
2307
|
-
},
|
|
2308
|
-
to: emailData.to,
|
|
2309
|
-
subject: emailData.subject,
|
|
2310
|
-
htmlContent: emailData.htmlContent,
|
|
2311
|
-
textContent: emailData.textContent
|
|
2312
|
-
});
|
|
2313
|
-
this.logger.debug(`Email sent successfully. Message ID: ${result.messageId}`);
|
|
2314
|
-
} catch (err) {
|
|
2315
|
-
if (err instanceof import_brevo.BrevoTimeoutError) {
|
|
2316
|
-
this.logger.error("Brevo request timed out after retries.");
|
|
2317
|
-
throw new Error("Email sending failed: timeout");
|
|
2318
|
-
}
|
|
2319
|
-
if (err instanceof import_brevo.BrevoError) {
|
|
2320
|
-
if (err.statusCode === 429) {
|
|
2321
|
-
this.logger.error("Brevo rate limit exceeded after retries.");
|
|
2322
|
-
throw new Error("Email sending failed: rate limit exceeded");
|
|
2323
|
-
}
|
|
2324
|
-
if (err.statusCode === 401) {
|
|
2325
|
-
this.logger.error("Brevo authentication failed. Check your API key.");
|
|
2326
|
-
throw new Error("Email service authentication failed");
|
|
2327
|
-
}
|
|
2328
|
-
if (err.statusCode === 400) {
|
|
2329
|
-
this.logger.error("Bad request to Brevo API:", err.message);
|
|
2330
|
-
throw new Error(`Invalid email parameters: ${err.message}`);
|
|
2331
|
-
}
|
|
2332
|
-
this.logger.error(`Brevo API error ${err.statusCode}:`, err.message);
|
|
2333
|
-
throw new Error(`Email sending failed: ${err.message}`);
|
|
2334
|
-
}
|
|
2335
|
-
throw err;
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
};
|
|
2339
|
-
EmailService = _ts_decorate11([
|
|
2340
|
-
(0, import_common21.Injectable)(),
|
|
2341
|
-
_ts_metadata7("design:type", Function),
|
|
2342
|
-
_ts_metadata7("design:paramtypes", [
|
|
2343
|
-
typeof import_config6.ConfigService === "undefined" ? Object : import_config6.ConfigService
|
|
2344
|
-
])
|
|
2345
|
-
], EmailService);
|
|
2346
|
-
|
|
2347
|
-
// src/email/email.module.ts
|
|
2348
|
-
function _ts_decorate12(decorators, target, key, desc) {
|
|
2349
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2350
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2351
|
-
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;
|
|
2352
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2353
|
-
}
|
|
2354
|
-
__name(_ts_decorate12, "_ts_decorate");
|
|
2355
|
-
var EmailModule = class {
|
|
2356
|
-
static {
|
|
2357
|
-
__name(this, "EmailModule");
|
|
2358
|
-
}
|
|
2359
|
-
};
|
|
2360
|
-
EmailModule = _ts_decorate12([
|
|
2361
|
-
(0, import_common22.Global)(),
|
|
2362
|
-
(0, import_common22.Module)({
|
|
2363
|
-
imports: [
|
|
2364
|
-
import_config7.ConfigModule
|
|
2365
|
-
],
|
|
2366
|
-
providers: [
|
|
2367
|
-
EmailService
|
|
2368
|
-
],
|
|
2369
|
-
exports: [
|
|
2370
|
-
EmailService
|
|
2371
|
-
]
|
|
2372
|
-
})
|
|
2373
|
-
], EmailModule);
|
|
2374
|
-
|
|
2375
|
-
// src/exceptions/bad-gateway.exception.ts
|
|
2376
|
-
var import_common24 = require("@nestjs/common");
|
|
2377
|
-
|
|
2378
|
-
// src/exceptions/base-field.exception.ts
|
|
2379
|
-
var import_common23 = require("@nestjs/common");
|
|
2380
|
-
var HttpProblemException = class extends import_common23.HttpException {
|
|
2381
|
-
static {
|
|
2382
|
-
__name(this, "HttpProblemException");
|
|
2383
|
-
}
|
|
2384
|
-
constructor(detailOrOptions, httpStatus) {
|
|
2385
|
-
const options = typeof detailOrOptions === "string" ? {
|
|
2386
|
-
detail: detailOrOptions
|
|
2387
|
-
} : detailOrOptions;
|
|
2388
|
-
super({
|
|
2389
|
-
type: options.type ?? "about:blank",
|
|
2390
|
-
label: options.label,
|
|
2391
|
-
detail: options.detail,
|
|
2392
|
-
errors: options.errors ?? []
|
|
2393
|
-
}, httpStatus);
|
|
2394
|
-
}
|
|
2395
|
-
};
|
|
2396
|
-
|
|
2397
|
-
// src/exceptions/bad-gateway.exception.ts
|
|
2398
|
-
var BadGatewayException = class extends HttpProblemException {
|
|
2399
|
-
static {
|
|
2400
|
-
__name(this, "BadGatewayException");
|
|
2401
|
-
}
|
|
2402
|
-
constructor(detailOrOptions) {
|
|
2403
|
-
super(detailOrOptions ?? "Bad Gateway", import_common24.HttpStatus.BAD_GATEWAY);
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
|
|
2407
|
-
// src/exceptions/bad-request.exception.ts
|
|
2408
|
-
var import_common25 = require("@nestjs/common");
|
|
2409
|
-
var BadRequestException = class extends HttpProblemException {
|
|
2410
|
-
static {
|
|
2411
|
-
__name(this, "BadRequestException");
|
|
2412
|
-
}
|
|
2413
|
-
constructor(detailOrOptions) {
|
|
2414
|
-
super(detailOrOptions ?? "Bad Request", import_common25.HttpStatus.BAD_REQUEST);
|
|
2415
|
-
}
|
|
2416
|
-
};
|
|
2417
|
-
|
|
2418
|
-
// src/exceptions/conflict.exception.ts
|
|
2419
|
-
var import_common26 = require("@nestjs/common");
|
|
2420
|
-
var ConflictException = class extends HttpProblemException {
|
|
2421
|
-
static {
|
|
2422
|
-
__name(this, "ConflictException");
|
|
2423
|
-
}
|
|
2424
|
-
constructor(detailOrOptions) {
|
|
2425
|
-
super(detailOrOptions ?? "Conflict", import_common26.HttpStatus.CONFLICT);
|
|
2426
|
-
}
|
|
2427
|
-
};
|
|
2428
|
-
|
|
2429
|
-
// src/exceptions/forbidden.exception.ts
|
|
2430
|
-
var import_common27 = require("@nestjs/common");
|
|
2431
|
-
var ForbiddenException2 = class extends HttpProblemException {
|
|
2432
|
-
static {
|
|
2433
|
-
__name(this, "ForbiddenException");
|
|
2434
|
-
}
|
|
2435
|
-
constructor(detailOrOptions) {
|
|
2436
|
-
super(detailOrOptions ?? "Forbidden", import_common27.HttpStatus.FORBIDDEN);
|
|
2437
|
-
}
|
|
2438
|
-
};
|
|
2439
|
-
|
|
2440
|
-
// src/exceptions/gone.exception.ts
|
|
2441
|
-
var import_common28 = require("@nestjs/common");
|
|
2442
|
-
var GoneException = class extends HttpProblemException {
|
|
2443
|
-
static {
|
|
2444
|
-
__name(this, "GoneException");
|
|
2445
|
-
}
|
|
2446
|
-
constructor(detailOrOptions) {
|
|
2447
|
-
super(detailOrOptions ?? "Gone", import_common28.HttpStatus.GONE);
|
|
2448
|
-
}
|
|
2449
|
-
};
|
|
2450
|
-
|
|
2451
|
-
// src/exceptions/internal-server-error.exception.ts
|
|
2452
|
-
var import_common29 = require("@nestjs/common");
|
|
2453
|
-
var InternalServerErrorException3 = class extends HttpProblemException {
|
|
2454
|
-
static {
|
|
2455
|
-
__name(this, "InternalServerErrorException");
|
|
2456
|
-
}
|
|
2457
|
-
constructor(detailOrOptions) {
|
|
2458
|
-
super(detailOrOptions ?? "Internal Server Error", import_common29.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
2459
|
-
}
|
|
2460
|
-
};
|
|
2461
|
-
|
|
2462
|
-
// src/exceptions/method-not-allowed.exception.ts
|
|
2463
|
-
var import_common30 = require("@nestjs/common");
|
|
2464
|
-
var MethodNotAllowedException = class extends HttpProblemException {
|
|
2465
|
-
static {
|
|
2466
|
-
__name(this, "MethodNotAllowedException");
|
|
2467
|
-
}
|
|
2468
|
-
constructor(detailOrOptions) {
|
|
2469
|
-
super(detailOrOptions ?? "Method Not Allowed", import_common30.HttpStatus.METHOD_NOT_ALLOWED);
|
|
2470
|
-
}
|
|
2471
|
-
};
|
|
2472
|
-
|
|
2473
|
-
// src/exceptions/not-acceptable.exception.ts
|
|
2474
|
-
var import_common31 = require("@nestjs/common");
|
|
2475
|
-
var NotAcceptableException = class extends HttpProblemException {
|
|
2476
|
-
static {
|
|
2477
|
-
__name(this, "NotAcceptableException");
|
|
2478
|
-
}
|
|
2479
|
-
constructor(detailOrOptions) {
|
|
2480
|
-
super(detailOrOptions ?? "Not Acceptable", import_common31.HttpStatus.NOT_ACCEPTABLE);
|
|
2481
|
-
}
|
|
2482
|
-
};
|
|
2483
|
-
|
|
2484
|
-
// src/exceptions/not-found.exception.ts
|
|
2485
|
-
var import_common32 = require("@nestjs/common");
|
|
2486
|
-
var NotFoundException = class extends HttpProblemException {
|
|
2487
|
-
static {
|
|
2488
|
-
__name(this, "NotFoundException");
|
|
2489
|
-
}
|
|
2490
|
-
constructor(detailOrOptions) {
|
|
2491
|
-
super(detailOrOptions ?? "Not Found", import_common32.HttpStatus.NOT_FOUND);
|
|
2492
|
-
}
|
|
2493
|
-
};
|
|
2494
|
-
|
|
2495
|
-
// src/exceptions/not-implemented.exception.ts
|
|
2496
|
-
var import_common33 = require("@nestjs/common");
|
|
2497
|
-
var NotImplementedException = class extends HttpProblemException {
|
|
2498
|
-
static {
|
|
2499
|
-
__name(this, "NotImplementedException");
|
|
2500
|
-
}
|
|
2501
|
-
constructor(detailOrOptions) {
|
|
2502
|
-
super(detailOrOptions ?? "Not Implemented", import_common33.HttpStatus.NOT_IMPLEMENTED);
|
|
2503
|
-
}
|
|
2504
|
-
};
|
|
2505
|
-
|
|
2506
|
-
// src/exceptions/payload-too-large.exception.ts
|
|
2507
|
-
var import_common34 = require("@nestjs/common");
|
|
2508
|
-
var PayloadTooLargeException = class extends HttpProblemException {
|
|
2509
|
-
static {
|
|
2510
|
-
__name(this, "PayloadTooLargeException");
|
|
2511
|
-
}
|
|
2512
|
-
constructor(detailOrOptions) {
|
|
2513
|
-
super(detailOrOptions ?? "Payload Too Large", import_common34.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
2514
|
-
}
|
|
2515
|
-
};
|
|
2930
|
+
</div>
|
|
2516
2931
|
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
}
|
|
2523
|
-
constructor(detailOrOptions) {
|
|
2524
|
-
super(detailOrOptions ?? "Request Timeout", import_common35.HttpStatus.REQUEST_TIMEOUT);
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2932
|
+
<p style="margin: 30px 0 20px; color: #666666; font-size: 14px; line-height: 1.6;">
|
|
2933
|
+
If you did not request this revert, please contact our support team immediately.
|
|
2934
|
+
</p>
|
|
2935
|
+
</td>
|
|
2936
|
+
</tr>
|
|
2527
2937
|
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2938
|
+
<!-- Footer -->
|
|
2939
|
+
<tr>
|
|
2940
|
+
<td style="padding: 30px 40px; border-top: 1px solid #e0e0e0; text-align: center;">
|
|
2941
|
+
<p style="margin: 0; color: #999999; font-size: 12px; line-height: 1.5;">
|
|
2942
|
+
Vritti AI Cloud - Cloud Management Platform
|
|
2943
|
+
</p>
|
|
2944
|
+
<p style="margin: 8px 0 0; color: #999999; font-size: 12px; line-height: 1.5;">
|
|
2945
|
+
This is an automated message, please do not reply.
|
|
2946
|
+
</p>
|
|
2947
|
+
</td>
|
|
2948
|
+
</tr>
|
|
2949
|
+
</table>
|
|
2950
|
+
</td>
|
|
2951
|
+
</tr>
|
|
2952
|
+
</table>
|
|
2953
|
+
</body>
|
|
2954
|
+
</html>
|
|
2955
|
+
`;
|
|
2956
|
+
const textContent = `
|
|
2957
|
+
Hello ${name},
|
|
2538
2958
|
|
|
2539
|
-
|
|
2540
|
-
var import_common37 = require("@nestjs/common");
|
|
2541
|
-
var TooManyRequestsException = class extends HttpProblemException {
|
|
2542
|
-
static {
|
|
2543
|
-
__name(this, "TooManyRequestsException");
|
|
2544
|
-
}
|
|
2545
|
-
constructor(detailOrOptions) {
|
|
2546
|
-
super(detailOrOptions ?? "Too Many Requests", import_common37.HttpStatus.TOO_MANY_REQUESTS);
|
|
2547
|
-
}
|
|
2548
|
-
};
|
|
2959
|
+
Your recent email address change has been successfully reverted. Your email is now:
|
|
2549
2960
|
|
|
2550
|
-
|
|
2551
|
-
var import_common38 = require("@nestjs/common");
|
|
2552
|
-
var UnauthorizedException3 = class extends HttpProblemException {
|
|
2553
|
-
static {
|
|
2554
|
-
__name(this, "UnauthorizedException");
|
|
2555
|
-
}
|
|
2556
|
-
constructor(detailOrOptions) {
|
|
2557
|
-
super(detailOrOptions ?? "Unauthorized", import_common38.HttpStatus.UNAUTHORIZED);
|
|
2558
|
-
}
|
|
2559
|
-
};
|
|
2961
|
+
${email}
|
|
2560
2962
|
|
|
2561
|
-
|
|
2562
|
-
var import_common39 = require("@nestjs/common");
|
|
2563
|
-
var UnprocessableEntityException = class extends HttpProblemException {
|
|
2564
|
-
static {
|
|
2565
|
-
__name(this, "UnprocessableEntityException");
|
|
2566
|
-
}
|
|
2567
|
-
constructor(detailOrOptions) {
|
|
2568
|
-
super(detailOrOptions ?? "Unprocessable Entity", import_common39.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
2569
|
-
}
|
|
2570
|
-
};
|
|
2963
|
+
If you did not request this revert, please contact our support team immediately.
|
|
2571
2964
|
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2965
|
+
---
|
|
2966
|
+
Vritti AI Cloud - Cloud Management Platform
|
|
2967
|
+
This is an automated message, please do not reply.
|
|
2968
|
+
`.trim();
|
|
2969
|
+
await this.sendEmail({
|
|
2970
|
+
to: [
|
|
2971
|
+
{
|
|
2972
|
+
email,
|
|
2973
|
+
name
|
|
2974
|
+
}
|
|
2975
|
+
],
|
|
2976
|
+
subject,
|
|
2977
|
+
htmlContent,
|
|
2978
|
+
textContent
|
|
2979
|
+
});
|
|
2980
|
+
this.logger.log(`Email revert confirmation sent to ${email}`);
|
|
2577
2981
|
}
|
|
2578
|
-
|
|
2579
|
-
|
|
2982
|
+
// Verifies Brevo API connectivity — a 400 response means the API is reachable
|
|
2983
|
+
async verifyConnection() {
|
|
2984
|
+
try {
|
|
2985
|
+
await this.brevoClient.transactionalEmails.sendTransacEmail({
|
|
2986
|
+
sender: {
|
|
2987
|
+
email: this.senderEmail,
|
|
2988
|
+
name: this.senderName
|
|
2989
|
+
},
|
|
2990
|
+
to: [
|
|
2991
|
+
{
|
|
2992
|
+
email: this.senderEmail
|
|
2993
|
+
}
|
|
2994
|
+
],
|
|
2995
|
+
subject: "Connection Test",
|
|
2996
|
+
htmlContent: "<p>Test</p>"
|
|
2997
|
+
});
|
|
2998
|
+
return true;
|
|
2999
|
+
} catch (err) {
|
|
3000
|
+
if (err instanceof import_brevo.BrevoError && err.statusCode === 400) {
|
|
3001
|
+
return true;
|
|
3002
|
+
}
|
|
3003
|
+
this.logger.error("Brevo connection verification failed:", err);
|
|
3004
|
+
return false;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
// Sends a transactional email via Brevo — retries handled internally by BrevoClient
|
|
3008
|
+
async sendEmail(emailData) {
|
|
3009
|
+
try {
|
|
3010
|
+
const result = await this.brevoClient.transactionalEmails.sendTransacEmail({
|
|
3011
|
+
sender: {
|
|
3012
|
+
email: this.senderEmail,
|
|
3013
|
+
name: this.senderName
|
|
3014
|
+
},
|
|
3015
|
+
to: emailData.to,
|
|
3016
|
+
subject: emailData.subject,
|
|
3017
|
+
htmlContent: emailData.htmlContent,
|
|
3018
|
+
textContent: emailData.textContent
|
|
3019
|
+
});
|
|
3020
|
+
this.logger.debug(`Email sent successfully. Message ID: ${result.messageId}`);
|
|
3021
|
+
} catch (err) {
|
|
3022
|
+
if (err instanceof import_brevo.BrevoTimeoutError) {
|
|
3023
|
+
this.logger.error("Brevo request timed out after retries.");
|
|
3024
|
+
throw new Error("Email sending failed: timeout");
|
|
3025
|
+
}
|
|
3026
|
+
if (err instanceof import_brevo.BrevoError) {
|
|
3027
|
+
if (err.statusCode === 429) {
|
|
3028
|
+
this.logger.error("Brevo rate limit exceeded after retries.");
|
|
3029
|
+
throw new Error("Email sending failed: rate limit exceeded");
|
|
3030
|
+
}
|
|
3031
|
+
if (err.statusCode === 401) {
|
|
3032
|
+
this.logger.error("Brevo authentication failed. Check your API key.");
|
|
3033
|
+
throw new Error("Email service authentication failed");
|
|
3034
|
+
}
|
|
3035
|
+
if (err.statusCode === 400) {
|
|
3036
|
+
this.logger.error("Bad request to Brevo API:", err.message);
|
|
3037
|
+
throw new Error(`Invalid email parameters: ${err.message}`);
|
|
3038
|
+
}
|
|
3039
|
+
this.logger.error(`Brevo API error ${err.statusCode}:`, err.message);
|
|
3040
|
+
throw new Error(`Email sending failed: ${err.message}`);
|
|
3041
|
+
}
|
|
3042
|
+
throw err;
|
|
3043
|
+
}
|
|
2580
3044
|
}
|
|
2581
3045
|
};
|
|
3046
|
+
EmailService = _ts_decorate16([
|
|
3047
|
+
(0, import_common45.Injectable)(),
|
|
3048
|
+
_ts_metadata11("design:type", Function),
|
|
3049
|
+
_ts_metadata11("design:paramtypes", [
|
|
3050
|
+
typeof import_config10.ConfigService === "undefined" ? Object : import_config10.ConfigService
|
|
3051
|
+
])
|
|
3052
|
+
], EmailService);
|
|
2582
3053
|
|
|
2583
|
-
// src/
|
|
2584
|
-
|
|
2585
|
-
var
|
|
3054
|
+
// src/email/email.module.ts
|
|
3055
|
+
function _ts_decorate17(decorators, target, key, desc2) {
|
|
3056
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3057
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3058
|
+
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;
|
|
3059
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3060
|
+
}
|
|
3061
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3062
|
+
var EmailModule = class {
|
|
2586
3063
|
static {
|
|
2587
|
-
__name(this, "
|
|
2588
|
-
}
|
|
2589
|
-
constructor(detailOrOptions) {
|
|
2590
|
-
super(detailOrOptions ?? "Validation Failed", import_common41.HttpStatus.BAD_REQUEST);
|
|
3064
|
+
__name(this, "EmailModule");
|
|
2591
3065
|
}
|
|
2592
3066
|
};
|
|
3067
|
+
EmailModule = _ts_decorate17([
|
|
3068
|
+
(0, import_common46.Global)(),
|
|
3069
|
+
(0, import_common46.Module)({
|
|
3070
|
+
imports: [
|
|
3071
|
+
import_config11.ConfigModule
|
|
3072
|
+
],
|
|
3073
|
+
providers: [
|
|
3074
|
+
EmailService
|
|
3075
|
+
],
|
|
3076
|
+
exports: [
|
|
3077
|
+
EmailService
|
|
3078
|
+
]
|
|
3079
|
+
})
|
|
3080
|
+
], EmailModule);
|
|
2593
3081
|
|
|
2594
3082
|
// src/filters/http-exception.filter.ts
|
|
2595
|
-
var
|
|
2596
|
-
function
|
|
2597
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2598
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3083
|
+
var import_common47 = require("@nestjs/common");
|
|
3084
|
+
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3085
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3086
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2599
3087
|
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;
|
|
2600
3088
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2601
3089
|
}
|
|
2602
|
-
__name(
|
|
3090
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
2603
3091
|
function getHttpStatusTitle(status) {
|
|
2604
|
-
const enumKey = Object.entries(
|
|
3092
|
+
const enumKey = Object.entries(import_common47.HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2605
3093
|
if (!enumKey) {
|
|
2606
3094
|
return "Error";
|
|
2607
3095
|
}
|
|
@@ -2612,17 +3100,17 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2612
3100
|
static {
|
|
2613
3101
|
__name(this, "HttpExceptionFilter");
|
|
2614
3102
|
}
|
|
2615
|
-
logger = new
|
|
3103
|
+
logger = new import_common47.Logger(_HttpExceptionFilter.name);
|
|
2616
3104
|
catch(exception, host) {
|
|
2617
3105
|
const ctx = host.switchToHttp();
|
|
2618
3106
|
const response = ctx.getResponse();
|
|
2619
3107
|
const request = ctx.getRequest();
|
|
2620
|
-
let status =
|
|
3108
|
+
let status = import_common47.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2621
3109
|
let type = "about:blank";
|
|
2622
3110
|
let label;
|
|
2623
3111
|
let detail = "Internal server error";
|
|
2624
3112
|
let errors = [];
|
|
2625
|
-
if (exception instanceof
|
|
3113
|
+
if (exception instanceof import_common47.HttpException) {
|
|
2626
3114
|
status = exception.getStatus();
|
|
2627
3115
|
const exceptionResponse = exception.getResponse();
|
|
2628
3116
|
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
@@ -2652,10 +3140,14 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2652
3140
|
} else if (typeof exceptionResponse === "string") {
|
|
2653
3141
|
detail = exceptionResponse;
|
|
2654
3142
|
}
|
|
3143
|
+
} else if (this.isAxiosError(exception)) {
|
|
3144
|
+
const axiosStatus = exception.response?.status;
|
|
3145
|
+
const axiosDetail = exception.response?.data?.message || exception.response?.data?.detail || exception.message;
|
|
3146
|
+
const url = exception.config?.url;
|
|
3147
|
+
status = import_common47.HttpStatus.BAD_GATEWAY;
|
|
3148
|
+
detail = `Upstream service error${axiosStatus ? ` (${axiosStatus})` : ""}: ${axiosDetail}`;
|
|
3149
|
+
this.logger.error(`Upstream API error [${axiosStatus}]: ${axiosDetail} \u2014 URL: ${url}`, exception.stack);
|
|
2655
3150
|
} else {
|
|
2656
|
-
const errorMessage = exception instanceof Error ? exception.message : "Unknown error";
|
|
2657
|
-
const stack = exception instanceof Error ? exception.stack : void 0;
|
|
2658
|
-
this.logger.error(`Unexpected error: ${errorMessage}`, stack);
|
|
2659
3151
|
detail = "An unexpected error occurred";
|
|
2660
3152
|
}
|
|
2661
3153
|
const problemDetails = {
|
|
@@ -2671,17 +3163,21 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2671
3163
|
};
|
|
2672
3164
|
response.header("Content-Type", "application/problem+json").status(status).send(problemDetails);
|
|
2673
3165
|
}
|
|
3166
|
+
// Duck-type check for AxiosError without importing axios
|
|
3167
|
+
isAxiosError(error) {
|
|
3168
|
+
return error instanceof Error && error.isAxiosError === true;
|
|
3169
|
+
}
|
|
2674
3170
|
};
|
|
2675
|
-
HttpExceptionFilter =
|
|
2676
|
-
(0,
|
|
3171
|
+
HttpExceptionFilter = _ts_decorate18([
|
|
3172
|
+
(0, import_common47.Catch)()
|
|
2677
3173
|
], HttpExceptionFilter);
|
|
2678
3174
|
|
|
2679
3175
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2680
|
-
var
|
|
3176
|
+
var import_common49 = require("@nestjs/common");
|
|
2681
3177
|
var import_operators = require("rxjs/operators");
|
|
2682
3178
|
|
|
2683
3179
|
// src/logger/services/logger.service.ts
|
|
2684
|
-
var
|
|
3180
|
+
var import_common48 = require("@nestjs/common");
|
|
2685
3181
|
var import_winston = require("winston");
|
|
2686
3182
|
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
2687
3183
|
|
|
@@ -2719,23 +3215,23 @@ function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_C
|
|
|
2719
3215
|
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2720
3216
|
|
|
2721
3217
|
// src/logger/services/logger.service.ts
|
|
2722
|
-
function
|
|
2723
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2724
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3218
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
3219
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3220
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2725
3221
|
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;
|
|
2726
3222
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2727
3223
|
}
|
|
2728
|
-
__name(
|
|
2729
|
-
function
|
|
3224
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3225
|
+
function _ts_metadata12(k, v) {
|
|
2730
3226
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2731
3227
|
}
|
|
2732
|
-
__name(
|
|
2733
|
-
function
|
|
3228
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3229
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2734
3230
|
return function(target, key) {
|
|
2735
3231
|
decorator(target, key, paramIndex);
|
|
2736
3232
|
};
|
|
2737
3233
|
}
|
|
2738
|
-
__name(
|
|
3234
|
+
__name(_ts_param5, "_ts_param");
|
|
2739
3235
|
var LoggerService = class _LoggerService {
|
|
2740
3236
|
static {
|
|
2741
3237
|
__name(this, "LoggerService");
|
|
@@ -2927,35 +3423,35 @@ ${trace}`;
|
|
|
2927
3423
|
return childLogger;
|
|
2928
3424
|
}
|
|
2929
3425
|
};
|
|
2930
|
-
LoggerService =
|
|
2931
|
-
(0,
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3426
|
+
LoggerService = _ts_decorate19([
|
|
3427
|
+
(0, import_common48.Injectable)(),
|
|
3428
|
+
_ts_param5(0, (0, import_common48.Optional)()),
|
|
3429
|
+
_ts_param5(1, (0, import_common48.Optional)()),
|
|
3430
|
+
_ts_metadata12("design:type", Function),
|
|
3431
|
+
_ts_metadata12("design:paramtypes", [
|
|
2936
3432
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2937
3433
|
typeof Logger === "undefined" ? Object : Logger
|
|
2938
3434
|
])
|
|
2939
3435
|
], LoggerService);
|
|
2940
3436
|
|
|
2941
3437
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2942
|
-
function
|
|
2943
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2944
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3438
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
3439
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3440
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2945
3441
|
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;
|
|
2946
3442
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2947
3443
|
}
|
|
2948
|
-
__name(
|
|
2949
|
-
function
|
|
3444
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3445
|
+
function _ts_metadata13(k, v) {
|
|
2950
3446
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2951
3447
|
}
|
|
2952
|
-
__name(
|
|
2953
|
-
function
|
|
3448
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3449
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2954
3450
|
return function(target, key) {
|
|
2955
3451
|
decorator(target, key, paramIndex);
|
|
2956
3452
|
};
|
|
2957
3453
|
}
|
|
2958
|
-
__name(
|
|
3454
|
+
__name(_ts_param6, "_ts_param");
|
|
2959
3455
|
var HttpLoggerInterceptor = class {
|
|
2960
3456
|
static {
|
|
2961
3457
|
__name(this, "HttpLoggerInterceptor");
|
|
@@ -3058,32 +3554,32 @@ var HttpLoggerInterceptor = class {
|
|
|
3058
3554
|
}
|
|
3059
3555
|
}
|
|
3060
3556
|
};
|
|
3061
|
-
HttpLoggerInterceptor =
|
|
3062
|
-
(0,
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3557
|
+
HttpLoggerInterceptor = _ts_decorate20([
|
|
3558
|
+
(0, import_common49.Injectable)(),
|
|
3559
|
+
_ts_param6(1, (0, import_common49.Optional)()),
|
|
3560
|
+
_ts_metadata13("design:type", Function),
|
|
3561
|
+
_ts_metadata13("design:paramtypes", [
|
|
3066
3562
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
3067
3563
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
3068
3564
|
])
|
|
3069
3565
|
], HttpLoggerInterceptor);
|
|
3070
3566
|
|
|
3071
3567
|
// src/logger/logger.module.ts
|
|
3072
|
-
var
|
|
3568
|
+
var import_common51 = require("@nestjs/common");
|
|
3073
3569
|
|
|
3074
3570
|
// src/logger/middleware/correlation-id.middleware.ts
|
|
3075
|
-
var
|
|
3076
|
-
function
|
|
3077
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3078
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3571
|
+
var import_common50 = require("@nestjs/common");
|
|
3572
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
3573
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3574
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3079
3575
|
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;
|
|
3080
3576
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3081
3577
|
}
|
|
3082
|
-
__name(
|
|
3083
|
-
function
|
|
3578
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3579
|
+
function _ts_metadata14(k, v) {
|
|
3084
3580
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3085
3581
|
}
|
|
3086
|
-
__name(
|
|
3582
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3087
3583
|
var CorrelationIdMiddleware = class {
|
|
3088
3584
|
static {
|
|
3089
3585
|
__name(this, "CorrelationIdMiddleware");
|
|
@@ -3120,22 +3616,22 @@ var CorrelationIdMiddleware = class {
|
|
|
3120
3616
|
}
|
|
3121
3617
|
}
|
|
3122
3618
|
};
|
|
3123
|
-
CorrelationIdMiddleware =
|
|
3124
|
-
(0,
|
|
3125
|
-
|
|
3126
|
-
|
|
3619
|
+
CorrelationIdMiddleware = _ts_decorate21([
|
|
3620
|
+
(0, import_common50.Injectable)(),
|
|
3621
|
+
_ts_metadata14("design:type", Function),
|
|
3622
|
+
_ts_metadata14("design:paramtypes", [
|
|
3127
3623
|
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
3128
3624
|
])
|
|
3129
3625
|
], CorrelationIdMiddleware);
|
|
3130
3626
|
|
|
3131
3627
|
// src/logger/logger.module.ts
|
|
3132
|
-
function
|
|
3133
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3134
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3628
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
3629
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3630
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3135
3631
|
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;
|
|
3136
3632
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3137
3633
|
}
|
|
3138
|
-
__name(
|
|
3634
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3139
3635
|
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
3140
3636
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
3141
3637
|
provider: "winston",
|
|
@@ -3212,9 +3708,9 @@ function mergeWithDefaults(options = {}) {
|
|
|
3212
3708
|
__name(mergeWithDefaults, "mergeWithDefaults");
|
|
3213
3709
|
function createDefaultLoggerProvider(options) {
|
|
3214
3710
|
return {
|
|
3215
|
-
provide:
|
|
3711
|
+
provide: import_common51.Logger,
|
|
3216
3712
|
useFactory: /* @__PURE__ */ __name(() => {
|
|
3217
|
-
const logger = new
|
|
3713
|
+
const logger = new import_common51.Logger();
|
|
3218
3714
|
if (options.level) {
|
|
3219
3715
|
const levels = getLevelsUpTo(options.level);
|
|
3220
3716
|
logger.setLogLevels?.(levels);
|
|
@@ -3244,7 +3740,7 @@ function createLoggerProviders(options = {}) {
|
|
|
3244
3740
|
inject: [
|
|
3245
3741
|
LOGGER_MODULE_OPTIONS,
|
|
3246
3742
|
{
|
|
3247
|
-
token:
|
|
3743
|
+
token: import_common51.Logger,
|
|
3248
3744
|
optional: true
|
|
3249
3745
|
}
|
|
3250
3746
|
]
|
|
@@ -3323,10 +3819,10 @@ var LoggerModule = class _LoggerModule {
|
|
|
3323
3819
|
...asyncProviders,
|
|
3324
3820
|
// Default logger provider
|
|
3325
3821
|
{
|
|
3326
|
-
provide:
|
|
3822
|
+
provide: import_common51.Logger,
|
|
3327
3823
|
useFactory: /* @__PURE__ */ __name((opts) => {
|
|
3328
3824
|
if (opts.provider === "default") {
|
|
3329
|
-
const logger = new
|
|
3825
|
+
const logger = new import_common51.Logger();
|
|
3330
3826
|
if (opts.level) {
|
|
3331
3827
|
const levels = getLevelsUpTo(opts.level);
|
|
3332
3828
|
logger.setLogLevels?.(levels);
|
|
@@ -3348,7 +3844,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3348
3844
|
inject: [
|
|
3349
3845
|
LOGGER_MODULE_OPTIONS,
|
|
3350
3846
|
{
|
|
3351
|
-
token:
|
|
3847
|
+
token: import_common51.Logger,
|
|
3352
3848
|
optional: true
|
|
3353
3849
|
}
|
|
3354
3850
|
]
|
|
@@ -3447,25 +3943,25 @@ var LoggerModule = class _LoggerModule {
|
|
|
3447
3943
|
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3448
3944
|
}
|
|
3449
3945
|
};
|
|
3450
|
-
LoggerModule =
|
|
3451
|
-
(0,
|
|
3452
|
-
(0,
|
|
3946
|
+
LoggerModule = _ts_decorate22([
|
|
3947
|
+
(0, import_common51.Global)(),
|
|
3948
|
+
(0, import_common51.Module)({})
|
|
3453
3949
|
], LoggerModule);
|
|
3454
3950
|
|
|
3455
3951
|
// src/root/root.module.ts
|
|
3456
|
-
var
|
|
3952
|
+
var import_common57 = require("@nestjs/common");
|
|
3457
3953
|
|
|
3458
3954
|
// src/root/controllers/app.controller.ts
|
|
3459
|
-
var
|
|
3460
|
-
var
|
|
3955
|
+
var import_common54 = require("@nestjs/common");
|
|
3956
|
+
var import_swagger5 = require("@nestjs/swagger");
|
|
3461
3957
|
|
|
3462
3958
|
// src/root/docs/app.docs.ts
|
|
3463
|
-
var
|
|
3464
|
-
var
|
|
3959
|
+
var import_common52 = require("@nestjs/common");
|
|
3960
|
+
var import_swagger4 = require("@nestjs/swagger");
|
|
3465
3961
|
function ApiHealthCheck() {
|
|
3466
|
-
return (0,
|
|
3962
|
+
return (0, import_common52.applyDecorators)((0, import_swagger4.ApiOperation)({
|
|
3467
3963
|
summary: "Health check endpoint"
|
|
3468
|
-
}), (0,
|
|
3964
|
+
}), (0, import_swagger4.ApiResponse)({
|
|
3469
3965
|
status: 200,
|
|
3470
3966
|
description: "Returns a welcome message indicating the API is running",
|
|
3471
3967
|
type: String
|
|
@@ -3474,14 +3970,14 @@ function ApiHealthCheck() {
|
|
|
3474
3970
|
__name(ApiHealthCheck, "ApiHealthCheck");
|
|
3475
3971
|
|
|
3476
3972
|
// src/root/services/app.service.ts
|
|
3477
|
-
var
|
|
3478
|
-
function
|
|
3479
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3480
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3973
|
+
var import_common53 = require("@nestjs/common");
|
|
3974
|
+
function _ts_decorate23(decorators, target, key, desc2) {
|
|
3975
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3976
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3481
3977
|
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;
|
|
3482
3978
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3483
3979
|
}
|
|
3484
|
-
__name(
|
|
3980
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3485
3981
|
var AppService = class {
|
|
3486
3982
|
static {
|
|
3487
3983
|
__name(this, "AppService");
|
|
@@ -3491,22 +3987,22 @@ var AppService = class {
|
|
|
3491
3987
|
return `Hello World!`;
|
|
3492
3988
|
}
|
|
3493
3989
|
};
|
|
3494
|
-
AppService =
|
|
3495
|
-
(0,
|
|
3990
|
+
AppService = _ts_decorate23([
|
|
3991
|
+
(0, import_common53.Injectable)()
|
|
3496
3992
|
], AppService);
|
|
3497
3993
|
|
|
3498
3994
|
// src/root/controllers/app.controller.ts
|
|
3499
|
-
function
|
|
3500
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3501
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3995
|
+
function _ts_decorate24(decorators, target, key, desc2) {
|
|
3996
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3997
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3502
3998
|
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;
|
|
3503
3999
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3504
4000
|
}
|
|
3505
|
-
__name(
|
|
3506
|
-
function
|
|
4001
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4002
|
+
function _ts_metadata15(k, v) {
|
|
3507
4003
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3508
4004
|
}
|
|
3509
|
-
__name(
|
|
4005
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3510
4006
|
var AppController = class {
|
|
3511
4007
|
static {
|
|
3512
4008
|
__name(this, "AppController");
|
|
@@ -3520,35 +4016,35 @@ var AppController = class {
|
|
|
3520
4016
|
return this.appService.getHello();
|
|
3521
4017
|
}
|
|
3522
4018
|
};
|
|
3523
|
-
|
|
3524
|
-
(0,
|
|
4019
|
+
_ts_decorate24([
|
|
4020
|
+
(0, import_common54.Get)(),
|
|
3525
4021
|
Public(),
|
|
3526
4022
|
ApiHealthCheck(),
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
4023
|
+
_ts_metadata15("design:type", Function),
|
|
4024
|
+
_ts_metadata15("design:paramtypes", []),
|
|
4025
|
+
_ts_metadata15("design:returntype", String)
|
|
3530
4026
|
], AppController.prototype, "getHello", null);
|
|
3531
|
-
AppController =
|
|
3532
|
-
(0,
|
|
3533
|
-
(0,
|
|
3534
|
-
|
|
3535
|
-
|
|
4027
|
+
AppController = _ts_decorate24([
|
|
4028
|
+
(0, import_swagger5.ApiTags)("Health"),
|
|
4029
|
+
(0, import_common54.Controller)(),
|
|
4030
|
+
_ts_metadata15("design:type", Function),
|
|
4031
|
+
_ts_metadata15("design:paramtypes", [
|
|
3536
4032
|
typeof AppService === "undefined" ? Object : AppService
|
|
3537
4033
|
])
|
|
3538
4034
|
], AppController);
|
|
3539
4035
|
|
|
3540
4036
|
// src/root/controllers/csrf.controller.ts
|
|
3541
|
-
var
|
|
3542
|
-
var
|
|
4037
|
+
var import_common56 = require("@nestjs/common");
|
|
4038
|
+
var import_swagger7 = require("@nestjs/swagger");
|
|
3543
4039
|
|
|
3544
4040
|
// src/root/docs/csrf.docs.ts
|
|
3545
|
-
var
|
|
3546
|
-
var
|
|
4041
|
+
var import_common55 = require("@nestjs/common");
|
|
4042
|
+
var import_swagger6 = require("@nestjs/swagger");
|
|
3547
4043
|
function ApiGetCsrfToken() {
|
|
3548
|
-
return (0,
|
|
4044
|
+
return (0, import_common55.applyDecorators)((0, import_swagger6.ApiOperation)({
|
|
3549
4045
|
summary: "Get CSRF token",
|
|
3550
4046
|
description: "Generates and returns a CSRF token that must be included in all state-changing requests (POST, PUT, PATCH, DELETE). The token should be sent in the X-CSRF-Token header."
|
|
3551
|
-
}), (0,
|
|
4047
|
+
}), (0, import_swagger6.ApiResponse)({
|
|
3552
4048
|
status: 200,
|
|
3553
4049
|
description: "CSRF token generated successfully",
|
|
3554
4050
|
schema: {
|
|
@@ -3569,23 +4065,23 @@ function ApiGetCsrfToken() {
|
|
|
3569
4065
|
__name(ApiGetCsrfToken, "ApiGetCsrfToken");
|
|
3570
4066
|
|
|
3571
4067
|
// src/root/controllers/csrf.controller.ts
|
|
3572
|
-
function
|
|
3573
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3574
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4068
|
+
function _ts_decorate25(decorators, target, key, desc2) {
|
|
4069
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4070
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3575
4071
|
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;
|
|
3576
4072
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3577
4073
|
}
|
|
3578
|
-
__name(
|
|
3579
|
-
function
|
|
4074
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4075
|
+
function _ts_metadata16(k, v) {
|
|
3580
4076
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3581
4077
|
}
|
|
3582
|
-
__name(
|
|
3583
|
-
function
|
|
4078
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4079
|
+
function _ts_param7(paramIndex, decorator) {
|
|
3584
4080
|
return function(target, key) {
|
|
3585
4081
|
decorator(target, key, paramIndex);
|
|
3586
4082
|
};
|
|
3587
4083
|
}
|
|
3588
|
-
__name(
|
|
4084
|
+
__name(_ts_param7, "_ts_param");
|
|
3589
4085
|
var CsrfController = class {
|
|
3590
4086
|
static {
|
|
3591
4087
|
__name(this, "CsrfController");
|
|
@@ -3598,40 +4094,40 @@ var CsrfController = class {
|
|
|
3598
4094
|
};
|
|
3599
4095
|
}
|
|
3600
4096
|
};
|
|
3601
|
-
|
|
3602
|
-
(0,
|
|
4097
|
+
_ts_decorate25([
|
|
4098
|
+
(0, import_common56.Get)("token"),
|
|
3603
4099
|
Public(),
|
|
3604
|
-
(0,
|
|
4100
|
+
(0, import_common56.HttpCode)(import_common56.HttpStatus.OK),
|
|
3605
4101
|
ApiGetCsrfToken(),
|
|
3606
|
-
|
|
4102
|
+
_ts_param7(0, (0, import_common56.Res)({
|
|
3607
4103
|
passthrough: true
|
|
3608
4104
|
})),
|
|
3609
|
-
|
|
3610
|
-
|
|
4105
|
+
_ts_metadata16("design:type", Function),
|
|
4106
|
+
_ts_metadata16("design:paramtypes", [
|
|
3611
4107
|
typeof FastifyReply === "undefined" ? Object : FastifyReply
|
|
3612
4108
|
]),
|
|
3613
|
-
|
|
4109
|
+
_ts_metadata16("design:returntype", Object)
|
|
3614
4110
|
], CsrfController.prototype, "getToken", null);
|
|
3615
|
-
CsrfController =
|
|
3616
|
-
(0,
|
|
3617
|
-
(0,
|
|
4111
|
+
CsrfController = _ts_decorate25([
|
|
4112
|
+
(0, import_swagger7.ApiTags)("CSRF"),
|
|
4113
|
+
(0, import_common56.Controller)("csrf")
|
|
3618
4114
|
], CsrfController);
|
|
3619
4115
|
|
|
3620
4116
|
// src/root/root.module.ts
|
|
3621
|
-
function
|
|
3622
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
3623
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
4117
|
+
function _ts_decorate26(decorators, target, key, desc2) {
|
|
4118
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4119
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3624
4120
|
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;
|
|
3625
4121
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3626
4122
|
}
|
|
3627
|
-
__name(
|
|
4123
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
3628
4124
|
var RootModule = class {
|
|
3629
4125
|
static {
|
|
3630
4126
|
__name(this, "RootModule");
|
|
3631
4127
|
}
|
|
3632
4128
|
};
|
|
3633
|
-
RootModule =
|
|
3634
|
-
(0,
|
|
4129
|
+
RootModule = _ts_decorate26([
|
|
4130
|
+
(0, import_common57.Module)({
|
|
3635
4131
|
controllers: [
|
|
3636
4132
|
AppController,
|
|
3637
4133
|
CsrfController
|
|
@@ -3857,12 +4353,17 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3857
4353
|
AuthConfigModule,
|
|
3858
4354
|
BadGatewayException,
|
|
3859
4355
|
BadRequestException,
|
|
4356
|
+
CACHE_PROVIDER,
|
|
4357
|
+
CacheModule,
|
|
4358
|
+
CacheService,
|
|
3860
4359
|
ConflictException,
|
|
4360
|
+
CookieDomain,
|
|
3861
4361
|
CorrelationIdMiddleware,
|
|
3862
4362
|
DEFAULT_CORRELATION_HEADER,
|
|
3863
4363
|
DatabaseModule,
|
|
3864
4364
|
EmailModule,
|
|
3865
4365
|
EmailService,
|
|
4366
|
+
FilterProcessor,
|
|
3866
4367
|
ForbiddenException,
|
|
3867
4368
|
GoneException,
|
|
3868
4369
|
HttpExceptionFilter,
|
|
@@ -3883,6 +4384,8 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3883
4384
|
PrimaryDatabaseService,
|
|
3884
4385
|
Public,
|
|
3885
4386
|
RESET_KEY,
|
|
4387
|
+
RedisCacheProvider,
|
|
4388
|
+
RefreshCookieOptions,
|
|
3886
4389
|
RefreshTokenCookie,
|
|
3887
4390
|
RequestTimeoutException,
|
|
3888
4391
|
Reset,
|
|
@@ -3892,6 +4395,8 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3892
4395
|
ServiceUnavailableException,
|
|
3893
4396
|
SessionData,
|
|
3894
4397
|
SkipCsrf,
|
|
4398
|
+
SuccessResponseDto,
|
|
4399
|
+
TableResponseDto,
|
|
3895
4400
|
Tenant,
|
|
3896
4401
|
TenantBaseRepository,
|
|
3897
4402
|
TenantContextService,
|
|
@@ -3915,6 +4420,7 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3915
4420
|
getHttpStatusTitle,
|
|
3916
4421
|
getJwtExpiry,
|
|
3917
4422
|
getRefreshCookieOptions,
|
|
4423
|
+
getRefreshCookieOptionsForHost,
|
|
3918
4424
|
getTokenExpiry,
|
|
3919
4425
|
hashToken,
|
|
3920
4426
|
jwtConfigFactory,
|