@vritti/api-sdk 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2171 -590
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +263 -6
- package/dist/index.d.ts +263 -6
- package/dist/index.js +2101 -530
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -10,14 +10,15 @@ 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
|
};
|
|
21
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
23
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
24
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -35,18 +36,29 @@ __export(index_exports, {
|
|
|
35
36
|
AuthConfigModule: () => AuthConfigModule,
|
|
36
37
|
BadGatewayException: () => BadGatewayException,
|
|
37
38
|
BadRequestException: () => BadRequestException,
|
|
39
|
+
CACHE_PROVIDER: () => CACHE_PROVIDER,
|
|
40
|
+
CacheModule: () => CacheModule,
|
|
41
|
+
CacheService: () => CacheService,
|
|
38
42
|
ConflictException: () => ConflictException,
|
|
43
|
+
CookieDomain: () => CookieDomain,
|
|
39
44
|
CorrelationIdMiddleware: () => CorrelationIdMiddleware,
|
|
45
|
+
CreateDataTableViewDto: () => CreateDataTableViewDto,
|
|
46
|
+
DATA_TABLE_VIEWS_TABLE: () => DATA_TABLE_VIEWS_TABLE,
|
|
40
47
|
DEFAULT_CORRELATION_HEADER: () => DEFAULT_CORRELATION_HEADER,
|
|
48
|
+
DataTableModule: () => DataTableModule,
|
|
49
|
+
DataTableStateService: () => DataTableStateService,
|
|
50
|
+
DataTableViewDto: () => DataTableViewDto,
|
|
51
|
+
DataTableViewsService: () => DataTableViewsService,
|
|
41
52
|
DatabaseModule: () => DatabaseModule,
|
|
42
53
|
EmailModule: () => EmailModule,
|
|
43
54
|
EmailService: () => EmailService,
|
|
44
|
-
|
|
55
|
+
FilterProcessor: () => FilterProcessor,
|
|
56
|
+
ForbiddenException: () => ForbiddenException,
|
|
45
57
|
GoneException: () => GoneException,
|
|
46
58
|
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
47
59
|
HttpLoggerInterceptor: () => HttpLoggerInterceptor,
|
|
48
60
|
HttpProblemException: () => HttpProblemException,
|
|
49
|
-
InternalServerErrorException: () =>
|
|
61
|
+
InternalServerErrorException: () => InternalServerErrorException,
|
|
50
62
|
JwtAuthService: () => JwtAuthService,
|
|
51
63
|
LOGGER_MODULE_OPTIONS: () => LOGGER_MODULE_OPTIONS,
|
|
52
64
|
LoggerModule: () => LoggerModule,
|
|
@@ -61,7 +73,10 @@ __export(index_exports, {
|
|
|
61
73
|
PrimaryDatabaseService: () => PrimaryDatabaseService,
|
|
62
74
|
Public: () => Public,
|
|
63
75
|
RESET_KEY: () => RESET_KEY,
|
|
76
|
+
RedisCacheProvider: () => RedisCacheProvider,
|
|
77
|
+
RefreshCookieOptions: () => RefreshCookieOptions,
|
|
64
78
|
RefreshTokenCookie: () => RefreshTokenCookie,
|
|
79
|
+
RenameDataTableViewDto: () => RenameDataTableViewDto,
|
|
65
80
|
RequestTimeoutException: () => RequestTimeoutException,
|
|
66
81
|
Reset: () => Reset,
|
|
67
82
|
RootModule: () => RootModule,
|
|
@@ -70,21 +85,28 @@ __export(index_exports, {
|
|
|
70
85
|
ServiceUnavailableException: () => ServiceUnavailableException,
|
|
71
86
|
SessionData: () => SessionData,
|
|
72
87
|
SkipCsrf: () => SkipCsrf,
|
|
88
|
+
SuccessResponseDto: () => SuccessResponseDto,
|
|
89
|
+
TableResponseDto: () => TableResponseDto,
|
|
73
90
|
Tenant: () => Tenant,
|
|
74
91
|
TenantBaseRepository: () => TenantBaseRepository,
|
|
75
92
|
TenantContextService: () => TenantContextService,
|
|
76
93
|
TenantDatabaseService: () => TenantDatabaseService,
|
|
94
|
+
ToggleShareDataTableViewDto: () => ToggleShareDataTableViewDto,
|
|
77
95
|
TokenType: () => TokenType,
|
|
78
96
|
TooManyRequestsException: () => TooManyRequestsException,
|
|
79
|
-
UnauthorizedException: () =>
|
|
97
|
+
UnauthorizedException: () => UnauthorizedException,
|
|
80
98
|
UnprocessableEntityException: () => UnprocessableEntityException,
|
|
81
99
|
UnsupportedMediaTypeException: () => UnsupportedMediaTypeException,
|
|
100
|
+
UpdateDataTableViewDto: () => UpdateDataTableViewDto,
|
|
101
|
+
UpsertDataTableStateDto: () => UpsertDataTableStateDto,
|
|
82
102
|
UserId: () => UserId,
|
|
83
103
|
ValidationException: () => ValidationException,
|
|
84
104
|
VrittiAuthGuard: () => VrittiAuthGuard,
|
|
85
105
|
addCorrelationIdToResponse: () => addCorrelationIdToResponse,
|
|
86
106
|
configureApiSdk: () => configureApiSdk,
|
|
87
107
|
correlationStorage: () => correlationStorage,
|
|
108
|
+
dataTableViewsColumns: () => dataTableViewsColumns,
|
|
109
|
+
dataTableViewsIndexes: () => dataTableViewsIndexes,
|
|
88
110
|
defineConfig: () => defineConfig,
|
|
89
111
|
extractCountryFromPhone: () => extractCountryFromPhone,
|
|
90
112
|
generateCorrelationId: () => generateCorrelationId,
|
|
@@ -93,6 +115,7 @@ __export(index_exports, {
|
|
|
93
115
|
getHttpStatusTitle: () => getHttpStatusTitle,
|
|
94
116
|
getJwtExpiry: () => getJwtExpiry,
|
|
95
117
|
getRefreshCookieOptions: () => getRefreshCookieOptions,
|
|
118
|
+
getRefreshCookieOptionsForHost: () => getRefreshCookieOptionsForHost,
|
|
96
119
|
getTokenExpiry: () => getTokenExpiry,
|
|
97
120
|
hashToken: () => hashToken,
|
|
98
121
|
jwtConfigFactory: () => jwtConfigFactory,
|
|
@@ -106,18 +129,237 @@ __export(index_exports, {
|
|
|
106
129
|
module.exports = __toCommonJS(index_exports);
|
|
107
130
|
|
|
108
131
|
// src/auth/auth-config.module.ts
|
|
109
|
-
var
|
|
132
|
+
var import_common26 = require("@nestjs/common");
|
|
110
133
|
var import_config4 = require("@nestjs/config");
|
|
111
134
|
var import_core3 = require("@nestjs/core");
|
|
112
135
|
var import_jwt4 = require("@nestjs/jwt");
|
|
113
136
|
|
|
114
137
|
// src/request/request.module.ts
|
|
115
|
-
var
|
|
138
|
+
var import_common21 = require("@nestjs/common");
|
|
116
139
|
|
|
117
140
|
// src/request/services/request.service.ts
|
|
118
|
-
var
|
|
141
|
+
var import_common20 = require("@nestjs/common");
|
|
119
142
|
var import_core = require("@nestjs/core");
|
|
120
143
|
|
|
144
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
145
|
+
var import_common2 = require("@nestjs/common");
|
|
146
|
+
|
|
147
|
+
// src/exceptions/base-field.exception.ts
|
|
148
|
+
var import_common = require("@nestjs/common");
|
|
149
|
+
var HttpProblemException = class extends import_common.HttpException {
|
|
150
|
+
static {
|
|
151
|
+
__name(this, "HttpProblemException");
|
|
152
|
+
}
|
|
153
|
+
constructor(detailOrOptions, httpStatus) {
|
|
154
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
155
|
+
detail: detailOrOptions
|
|
156
|
+
} : detailOrOptions;
|
|
157
|
+
super({
|
|
158
|
+
type: options.type ?? "about:blank",
|
|
159
|
+
label: options.label,
|
|
160
|
+
detail: options.detail,
|
|
161
|
+
errors: options.errors ?? []
|
|
162
|
+
}, httpStatus);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
167
|
+
var BadGatewayException = class extends HttpProblemException {
|
|
168
|
+
static {
|
|
169
|
+
__name(this, "BadGatewayException");
|
|
170
|
+
}
|
|
171
|
+
constructor(detailOrOptions) {
|
|
172
|
+
super(detailOrOptions ?? "Bad Gateway", import_common2.HttpStatus.BAD_GATEWAY);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/exceptions/bad-request.exception.ts
|
|
177
|
+
var import_common3 = require("@nestjs/common");
|
|
178
|
+
var BadRequestException = class extends HttpProblemException {
|
|
179
|
+
static {
|
|
180
|
+
__name(this, "BadRequestException");
|
|
181
|
+
}
|
|
182
|
+
constructor(detailOrOptions) {
|
|
183
|
+
super(detailOrOptions ?? "Bad Request", import_common3.HttpStatus.BAD_REQUEST);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// src/exceptions/conflict.exception.ts
|
|
188
|
+
var import_common4 = require("@nestjs/common");
|
|
189
|
+
var ConflictException = class extends HttpProblemException {
|
|
190
|
+
static {
|
|
191
|
+
__name(this, "ConflictException");
|
|
192
|
+
}
|
|
193
|
+
constructor(detailOrOptions) {
|
|
194
|
+
super(detailOrOptions ?? "Conflict", import_common4.HttpStatus.CONFLICT);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/exceptions/forbidden.exception.ts
|
|
199
|
+
var import_common5 = require("@nestjs/common");
|
|
200
|
+
var ForbiddenException = class extends HttpProblemException {
|
|
201
|
+
static {
|
|
202
|
+
__name(this, "ForbiddenException");
|
|
203
|
+
}
|
|
204
|
+
constructor(detailOrOptions) {
|
|
205
|
+
super(detailOrOptions ?? "Forbidden", import_common5.HttpStatus.FORBIDDEN);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/exceptions/gone.exception.ts
|
|
210
|
+
var import_common6 = require("@nestjs/common");
|
|
211
|
+
var GoneException = class extends HttpProblemException {
|
|
212
|
+
static {
|
|
213
|
+
__name(this, "GoneException");
|
|
214
|
+
}
|
|
215
|
+
constructor(detailOrOptions) {
|
|
216
|
+
super(detailOrOptions ?? "Gone", import_common6.HttpStatus.GONE);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// src/exceptions/internal-server-error.exception.ts
|
|
221
|
+
var import_common7 = require("@nestjs/common");
|
|
222
|
+
var InternalServerErrorException = class extends HttpProblemException {
|
|
223
|
+
static {
|
|
224
|
+
__name(this, "InternalServerErrorException");
|
|
225
|
+
}
|
|
226
|
+
constructor(detailOrOptions) {
|
|
227
|
+
super(detailOrOptions ?? "Internal Server Error", import_common7.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/exceptions/method-not-allowed.exception.ts
|
|
232
|
+
var import_common8 = require("@nestjs/common");
|
|
233
|
+
var MethodNotAllowedException = class extends HttpProblemException {
|
|
234
|
+
static {
|
|
235
|
+
__name(this, "MethodNotAllowedException");
|
|
236
|
+
}
|
|
237
|
+
constructor(detailOrOptions) {
|
|
238
|
+
super(detailOrOptions ?? "Method Not Allowed", import_common8.HttpStatus.METHOD_NOT_ALLOWED);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/exceptions/not-acceptable.exception.ts
|
|
243
|
+
var import_common9 = require("@nestjs/common");
|
|
244
|
+
var NotAcceptableException = class extends HttpProblemException {
|
|
245
|
+
static {
|
|
246
|
+
__name(this, "NotAcceptableException");
|
|
247
|
+
}
|
|
248
|
+
constructor(detailOrOptions) {
|
|
249
|
+
super(detailOrOptions ?? "Not Acceptable", import_common9.HttpStatus.NOT_ACCEPTABLE);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// src/exceptions/not-found.exception.ts
|
|
254
|
+
var import_common10 = require("@nestjs/common");
|
|
255
|
+
var NotFoundException = class extends HttpProblemException {
|
|
256
|
+
static {
|
|
257
|
+
__name(this, "NotFoundException");
|
|
258
|
+
}
|
|
259
|
+
constructor(detailOrOptions) {
|
|
260
|
+
super(detailOrOptions ?? "Not Found", import_common10.HttpStatus.NOT_FOUND);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// src/exceptions/not-implemented.exception.ts
|
|
265
|
+
var import_common11 = require("@nestjs/common");
|
|
266
|
+
var NotImplementedException = class extends HttpProblemException {
|
|
267
|
+
static {
|
|
268
|
+
__name(this, "NotImplementedException");
|
|
269
|
+
}
|
|
270
|
+
constructor(detailOrOptions) {
|
|
271
|
+
super(detailOrOptions ?? "Not Implemented", import_common11.HttpStatus.NOT_IMPLEMENTED);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/exceptions/payload-too-large.exception.ts
|
|
276
|
+
var import_common12 = require("@nestjs/common");
|
|
277
|
+
var PayloadTooLargeException = class extends HttpProblemException {
|
|
278
|
+
static {
|
|
279
|
+
__name(this, "PayloadTooLargeException");
|
|
280
|
+
}
|
|
281
|
+
constructor(detailOrOptions) {
|
|
282
|
+
super(detailOrOptions ?? "Payload Too Large", import_common12.HttpStatus.PAYLOAD_TOO_LARGE);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/exceptions/request-timeout.exception.ts
|
|
287
|
+
var import_common13 = require("@nestjs/common");
|
|
288
|
+
var RequestTimeoutException = class extends HttpProblemException {
|
|
289
|
+
static {
|
|
290
|
+
__name(this, "RequestTimeoutException");
|
|
291
|
+
}
|
|
292
|
+
constructor(detailOrOptions) {
|
|
293
|
+
super(detailOrOptions ?? "Request Timeout", import_common13.HttpStatus.REQUEST_TIMEOUT);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// src/exceptions/service-unavailable.exception.ts
|
|
298
|
+
var import_common14 = require("@nestjs/common");
|
|
299
|
+
var ServiceUnavailableException = class extends HttpProblemException {
|
|
300
|
+
static {
|
|
301
|
+
__name(this, "ServiceUnavailableException");
|
|
302
|
+
}
|
|
303
|
+
constructor(detailOrOptions) {
|
|
304
|
+
super(detailOrOptions ?? "Service Unavailable", import_common14.HttpStatus.SERVICE_UNAVAILABLE);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// src/exceptions/too-many-requests.exception.ts
|
|
309
|
+
var import_common15 = require("@nestjs/common");
|
|
310
|
+
var TooManyRequestsException = class extends HttpProblemException {
|
|
311
|
+
static {
|
|
312
|
+
__name(this, "TooManyRequestsException");
|
|
313
|
+
}
|
|
314
|
+
constructor(detailOrOptions) {
|
|
315
|
+
super(detailOrOptions ?? "Too Many Requests", import_common15.HttpStatus.TOO_MANY_REQUESTS);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// src/exceptions/unauthorized.exception.ts
|
|
320
|
+
var import_common16 = require("@nestjs/common");
|
|
321
|
+
var UnauthorizedException = class extends HttpProblemException {
|
|
322
|
+
static {
|
|
323
|
+
__name(this, "UnauthorizedException");
|
|
324
|
+
}
|
|
325
|
+
constructor(detailOrOptions) {
|
|
326
|
+
super(detailOrOptions ?? "Unauthorized", import_common16.HttpStatus.UNAUTHORIZED);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/exceptions/unprocessable-entity.exception.ts
|
|
331
|
+
var import_common17 = require("@nestjs/common");
|
|
332
|
+
var UnprocessableEntityException = class extends HttpProblemException {
|
|
333
|
+
static {
|
|
334
|
+
__name(this, "UnprocessableEntityException");
|
|
335
|
+
}
|
|
336
|
+
constructor(detailOrOptions) {
|
|
337
|
+
super(detailOrOptions ?? "Unprocessable Entity", import_common17.HttpStatus.UNPROCESSABLE_ENTITY);
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/exceptions/unsupported-media-type.exception.ts
|
|
342
|
+
var import_common18 = require("@nestjs/common");
|
|
343
|
+
var UnsupportedMediaTypeException = class extends HttpProblemException {
|
|
344
|
+
static {
|
|
345
|
+
__name(this, "UnsupportedMediaTypeException");
|
|
346
|
+
}
|
|
347
|
+
constructor(detailOrOptions) {
|
|
348
|
+
super(detailOrOptions ?? "Unsupported Media Type", import_common18.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/exceptions/validation.exception.ts
|
|
353
|
+
var import_common19 = require("@nestjs/common");
|
|
354
|
+
var ValidationException = class extends HttpProblemException {
|
|
355
|
+
static {
|
|
356
|
+
__name(this, "ValidationException");
|
|
357
|
+
}
|
|
358
|
+
constructor(detailOrOptions) {
|
|
359
|
+
super(detailOrOptions ?? "Validation Failed", import_common19.HttpStatus.BAD_REQUEST);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
121
363
|
// src/config/index.ts
|
|
122
364
|
var defaultConfig = {
|
|
123
365
|
cookie: {
|
|
@@ -174,19 +416,36 @@ function resetConfig() {
|
|
|
174
416
|
}
|
|
175
417
|
__name(resetConfig, "resetConfig");
|
|
176
418
|
function getRefreshCookieOptions() {
|
|
177
|
-
|
|
419
|
+
return {
|
|
178
420
|
httpOnly: true,
|
|
179
421
|
secure: currentConfig.cookie.refreshCookieSecure,
|
|
180
422
|
sameSite: currentConfig.cookie.refreshCookieSameSite,
|
|
181
423
|
path: currentConfig.cookie.refreshCookiePath,
|
|
182
|
-
maxAge: currentConfig.cookie.refreshCookieMaxAge
|
|
424
|
+
maxAge: currentConfig.cookie.refreshCookieMaxAge,
|
|
425
|
+
...currentConfig.cookie.refreshCookieDomain && {
|
|
426
|
+
domain: currentConfig.cookie.refreshCookieDomain
|
|
427
|
+
}
|
|
183
428
|
};
|
|
184
|
-
if (currentConfig.cookie.refreshCookieDomain) {
|
|
185
|
-
options.domain = currentConfig.cookie.refreshCookieDomain;
|
|
186
|
-
}
|
|
187
|
-
return options;
|
|
188
429
|
}
|
|
189
430
|
__name(getRefreshCookieOptions, "getRefreshCookieOptions");
|
|
431
|
+
function getRefreshCookieOptionsForHost(hostname) {
|
|
432
|
+
const baseDomain = currentConfig.cookie.refreshCookieDomain;
|
|
433
|
+
if (!baseDomain) {
|
|
434
|
+
throw new Error("refreshCookieDomain must be configured before using getRefreshCookieOptionsForHost");
|
|
435
|
+
}
|
|
436
|
+
if (!hostname.endsWith(`.${baseDomain}`)) {
|
|
437
|
+
throw new UnauthorizedException("Invalid request host.");
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
httpOnly: true,
|
|
441
|
+
secure: currentConfig.cookie.refreshCookieSecure,
|
|
442
|
+
sameSite: currentConfig.cookie.refreshCookieSameSite,
|
|
443
|
+
path: currentConfig.cookie.refreshCookiePath,
|
|
444
|
+
maxAge: currentConfig.cookie.refreshCookieMaxAge,
|
|
445
|
+
domain: hostname
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
__name(getRefreshCookieOptionsForHost, "getRefreshCookieOptionsForHost");
|
|
190
449
|
function getJwtExpiry() {
|
|
191
450
|
return {
|
|
192
451
|
access: currentConfig.jwt.accessTokenExpiry,
|
|
@@ -197,9 +456,9 @@ function getJwtExpiry() {
|
|
|
197
456
|
__name(getJwtExpiry, "getJwtExpiry");
|
|
198
457
|
|
|
199
458
|
// 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,
|
|
459
|
+
function _ts_decorate(decorators, target, key, desc2) {
|
|
460
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
461
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
203
462
|
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
463
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
205
464
|
}
|
|
@@ -265,10 +524,10 @@ var RequestService = class {
|
|
|
265
524
|
}
|
|
266
525
|
};
|
|
267
526
|
RequestService = _ts_decorate([
|
|
268
|
-
(0,
|
|
269
|
-
scope:
|
|
527
|
+
(0, import_common20.Injectable)({
|
|
528
|
+
scope: import_common20.Scope.REQUEST
|
|
270
529
|
}),
|
|
271
|
-
_ts_param(0, (0,
|
|
530
|
+
_ts_param(0, (0, import_common20.Inject)(import_core.REQUEST)),
|
|
272
531
|
_ts_metadata("design:type", Function),
|
|
273
532
|
_ts_metadata("design:paramtypes", [
|
|
274
533
|
typeof FastifyRequest === "undefined" ? Object : FastifyRequest
|
|
@@ -276,9 +535,9 @@ RequestService = _ts_decorate([
|
|
|
276
535
|
], RequestService);
|
|
277
536
|
|
|
278
537
|
// 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,
|
|
538
|
+
function _ts_decorate2(decorators, target, key, desc2) {
|
|
539
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
540
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
282
541
|
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
542
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
284
543
|
}
|
|
@@ -289,8 +548,8 @@ var RequestModule = class {
|
|
|
289
548
|
}
|
|
290
549
|
};
|
|
291
550
|
RequestModule = _ts_decorate2([
|
|
292
|
-
(0,
|
|
293
|
-
(0,
|
|
551
|
+
(0, import_common21.Global)(),
|
|
552
|
+
(0, import_common21.Module)({
|
|
294
553
|
providers: [
|
|
295
554
|
RequestService
|
|
296
555
|
],
|
|
@@ -301,21 +560,21 @@ RequestModule = _ts_decorate2([
|
|
|
301
560
|
], RequestModule);
|
|
302
561
|
|
|
303
562
|
// src/auth/guards/vritti-auth.guard.ts
|
|
304
|
-
var
|
|
563
|
+
var import_common24 = require("@nestjs/common");
|
|
305
564
|
var import_constants = require("@nestjs/common/constants");
|
|
306
565
|
var import_config2 = require("@nestjs/config");
|
|
307
566
|
var import_core2 = require("@nestjs/core");
|
|
308
567
|
var import_jwt = require("@nestjs/jwt");
|
|
309
568
|
|
|
310
569
|
// src/auth/decorators/reset.decorator.ts
|
|
311
|
-
var
|
|
570
|
+
var import_common22 = require("@nestjs/common");
|
|
312
571
|
var RESET_KEY = "isReset";
|
|
313
|
-
var Reset = /* @__PURE__ */ __name(() => (0,
|
|
572
|
+
var Reset = /* @__PURE__ */ __name(() => (0, import_common22.SetMetadata)(RESET_KEY, true), "Reset");
|
|
314
573
|
|
|
315
574
|
// src/auth/decorators/skip-csrf.decorator.ts
|
|
316
|
-
var
|
|
575
|
+
var import_common23 = require("@nestjs/common");
|
|
317
576
|
var SKIP_CSRF_KEY = "skipCsrf";
|
|
318
|
-
var SkipCsrf = /* @__PURE__ */ __name(() => (0,
|
|
577
|
+
var SkipCsrf = /* @__PURE__ */ __name(() => (0, import_common23.SetMetadata)(SKIP_CSRF_KEY, true), "SkipCsrf");
|
|
319
578
|
|
|
320
579
|
// src/auth/utils/token-hash.util.ts
|
|
321
580
|
var crypto = __toESM(require("crypto"), 1);
|
|
@@ -331,9 +590,9 @@ function verifyTokenHash(token, expectedHash) {
|
|
|
331
590
|
__name(verifyTokenHash, "verifyTokenHash");
|
|
332
591
|
|
|
333
592
|
// 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,
|
|
593
|
+
function _ts_decorate3(decorators, target, key, desc2) {
|
|
594
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
595
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
337
596
|
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
597
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
339
598
|
}
|
|
@@ -350,7 +609,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
350
609
|
_configService;
|
|
351
610
|
jwtService;
|
|
352
611
|
requestService;
|
|
353
|
-
logger = new
|
|
612
|
+
logger = new import_common24.Logger(_VrittiAuthGuard.name);
|
|
354
613
|
constructor(reflector, _configService, jwtService, requestService) {
|
|
355
614
|
this.reflector = reflector;
|
|
356
615
|
this._configService = _configService;
|
|
@@ -389,21 +648,21 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
389
648
|
try {
|
|
390
649
|
const accessToken = this.requestService.getAccessToken();
|
|
391
650
|
if (!accessToken) {
|
|
392
|
-
throw new
|
|
651
|
+
throw new import_common24.UnauthorizedException("Access token not found");
|
|
393
652
|
}
|
|
394
653
|
const decodedAccessToken = this.validateAccessToken(accessToken);
|
|
395
654
|
if (decodedAccessToken.tokenType !== "access") {
|
|
396
|
-
throw new
|
|
655
|
+
throw new import_common24.UnauthorizedException("Invalid token type");
|
|
397
656
|
}
|
|
398
657
|
this.validateRefreshTokenBinding(decodedAccessToken);
|
|
399
658
|
if (isOnboarding && decodedAccessToken.sessionType !== "ONBOARDING") {
|
|
400
|
-
throw new
|
|
659
|
+
throw new import_common24.UnauthorizedException("This endpoint requires an onboarding session");
|
|
401
660
|
}
|
|
402
661
|
if (isReset && decodedAccessToken.sessionType !== "RESET") {
|
|
403
|
-
throw new
|
|
662
|
+
throw new import_common24.UnauthorizedException("This endpoint requires a reset session");
|
|
404
663
|
}
|
|
405
664
|
if (!isOnboarding && !isReset && (decodedAccessToken.sessionType === "ONBOARDING" || decodedAccessToken.sessionType === "RESET")) {
|
|
406
|
-
throw new
|
|
665
|
+
throw new import_common24.UnauthorizedException(`${decodedAccessToken.sessionType} sessions cannot access this endpoint`);
|
|
407
666
|
}
|
|
408
667
|
request.sessionInfo = {
|
|
409
668
|
userId: decodedAccessToken.userId,
|
|
@@ -412,11 +671,11 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
412
671
|
};
|
|
413
672
|
return true;
|
|
414
673
|
} catch (error) {
|
|
415
|
-
if (error instanceof
|
|
674
|
+
if (error instanceof import_common24.UnauthorizedException) {
|
|
416
675
|
throw error;
|
|
417
676
|
}
|
|
418
677
|
this.logger.error("Unexpected error in auth guard", error);
|
|
419
|
-
throw new
|
|
678
|
+
throw new import_common24.UnauthorizedException("Authentication failed");
|
|
420
679
|
}
|
|
421
680
|
}
|
|
422
681
|
// Validates JWT signature, expiry, and not-before claims
|
|
@@ -424,50 +683,50 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
424
683
|
try {
|
|
425
684
|
return this.jwtService.verify(token);
|
|
426
685
|
} catch (error) {
|
|
427
|
-
if (error instanceof
|
|
686
|
+
if (error instanceof import_common24.UnauthorizedException) throw error;
|
|
428
687
|
const jwtError = error;
|
|
429
688
|
if (jwtError?.name === "TokenExpiredError") {
|
|
430
|
-
throw new
|
|
689
|
+
throw new import_common24.UnauthorizedException("Access token has expired");
|
|
431
690
|
}
|
|
432
691
|
if (jwtError?.name === "JsonWebTokenError") {
|
|
433
|
-
throw new
|
|
692
|
+
throw new import_common24.UnauthorizedException("Invalid access token");
|
|
434
693
|
}
|
|
435
694
|
if (jwtError?.name === "NotBeforeError") {
|
|
436
|
-
throw new
|
|
695
|
+
throw new import_common24.UnauthorizedException("Access token not yet valid");
|
|
437
696
|
}
|
|
438
|
-
throw new
|
|
697
|
+
throw new import_common24.UnauthorizedException("Access token validation failed");
|
|
439
698
|
}
|
|
440
699
|
}
|
|
441
700
|
// Validates that the access token is bound to the refresh token in the cookie
|
|
442
701
|
validateRefreshTokenBinding(decodedAccessToken) {
|
|
443
702
|
if (!decodedAccessToken.refreshTokenHash) {
|
|
444
|
-
throw new
|
|
703
|
+
throw new import_common24.UnauthorizedException("Token missing refresh token binding");
|
|
445
704
|
}
|
|
446
705
|
const refreshToken = this.requestService.getRefreshToken();
|
|
447
706
|
if (!refreshToken) {
|
|
448
|
-
throw new
|
|
707
|
+
throw new import_common24.UnauthorizedException("Session validation failed");
|
|
449
708
|
}
|
|
450
709
|
if (!verifyTokenHash(refreshToken, decodedAccessToken.refreshTokenHash)) {
|
|
451
|
-
throw new
|
|
710
|
+
throw new import_common24.UnauthorizedException("Session validation failed");
|
|
452
711
|
}
|
|
453
712
|
}
|
|
454
713
|
// Authenticates SSE connections using the refresh token httpOnly cookie
|
|
455
714
|
handleSseAuth(request, isOnboarding) {
|
|
456
715
|
const refreshToken = this.requestService.getRefreshToken();
|
|
457
716
|
if (!refreshToken) {
|
|
458
|
-
throw new
|
|
717
|
+
throw new import_common24.UnauthorizedException("Authentication required");
|
|
459
718
|
}
|
|
460
719
|
let decoded;
|
|
461
720
|
try {
|
|
462
721
|
decoded = this.jwtService.verify(refreshToken);
|
|
463
722
|
} catch {
|
|
464
|
-
throw new
|
|
723
|
+
throw new import_common24.UnauthorizedException("Invalid or expired session");
|
|
465
724
|
}
|
|
466
725
|
if (decoded.tokenType !== "refresh") {
|
|
467
|
-
throw new
|
|
726
|
+
throw new import_common24.UnauthorizedException("Invalid token type");
|
|
468
727
|
}
|
|
469
728
|
if (isOnboarding && decoded.sessionType !== "ONBOARDING") {
|
|
470
|
-
throw new
|
|
729
|
+
throw new import_common24.UnauthorizedException("This endpoint requires an onboarding session");
|
|
471
730
|
}
|
|
472
731
|
request.sessionInfo = {
|
|
473
732
|
userId: decoded.userId,
|
|
@@ -488,7 +747,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
488
747
|
const fastifyInstance = request.server;
|
|
489
748
|
const csrfProtection = fastifyInstance.csrfProtection;
|
|
490
749
|
if (!csrfProtection) {
|
|
491
|
-
throw new
|
|
750
|
+
throw new import_common24.ForbiddenException("CSRF protection not configured");
|
|
492
751
|
}
|
|
493
752
|
await new Promise((resolve, reject) => {
|
|
494
753
|
const originalSend = reply.send.bind(reply);
|
|
@@ -504,7 +763,7 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
504
763
|
});
|
|
505
764
|
});
|
|
506
765
|
} catch (error) {
|
|
507
|
-
throw new
|
|
766
|
+
throw new import_common24.ForbiddenException({
|
|
508
767
|
errors: [
|
|
509
768
|
{
|
|
510
769
|
field: "csrf",
|
|
@@ -517,8 +776,8 @@ var VrittiAuthGuard = class _VrittiAuthGuard {
|
|
|
517
776
|
}
|
|
518
777
|
};
|
|
519
778
|
VrittiAuthGuard = _ts_decorate3([
|
|
520
|
-
(0,
|
|
521
|
-
scope:
|
|
779
|
+
(0, import_common24.Injectable)({
|
|
780
|
+
scope: import_common24.Scope.REQUEST
|
|
522
781
|
}),
|
|
523
782
|
_ts_metadata2("design:type", Function),
|
|
524
783
|
_ts_metadata2("design:paramtypes", [
|
|
@@ -530,7 +789,7 @@ VrittiAuthGuard = _ts_decorate3([
|
|
|
530
789
|
], VrittiAuthGuard);
|
|
531
790
|
|
|
532
791
|
// src/auth/services/jwt-auth.service.ts
|
|
533
|
-
var
|
|
792
|
+
var import_common25 = require("@nestjs/common");
|
|
534
793
|
var import_config3 = require("@nestjs/config");
|
|
535
794
|
var import_jwt2 = require("@nestjs/jwt");
|
|
536
795
|
|
|
@@ -569,9 +828,9 @@ var TokenType = /* @__PURE__ */ (function(TokenType2) {
|
|
|
569
828
|
})({});
|
|
570
829
|
|
|
571
830
|
// 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,
|
|
831
|
+
function _ts_decorate4(decorators, target, key, desc2) {
|
|
832
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
833
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
575
834
|
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
835
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
577
836
|
}
|
|
@@ -586,7 +845,7 @@ var JwtAuthService = class _JwtAuthService {
|
|
|
586
845
|
}
|
|
587
846
|
jwtService;
|
|
588
847
|
configService;
|
|
589
|
-
logger = new
|
|
848
|
+
logger = new import_common25.Logger(_JwtAuthService.name);
|
|
590
849
|
tokenExpiry;
|
|
591
850
|
constructor(jwtService, configService) {
|
|
592
851
|
this.jwtService = jwtService;
|
|
@@ -643,7 +902,7 @@ var JwtAuthService = class _JwtAuthService {
|
|
|
643
902
|
}
|
|
644
903
|
};
|
|
645
904
|
JwtAuthService = _ts_decorate4([
|
|
646
|
-
(0,
|
|
905
|
+
(0, import_common25.Injectable)(),
|
|
647
906
|
_ts_metadata3("design:type", Function),
|
|
648
907
|
_ts_metadata3("design:paramtypes", [
|
|
649
908
|
typeof import_jwt2.JwtService === "undefined" ? Object : import_jwt2.JwtService,
|
|
@@ -652,9 +911,9 @@ JwtAuthService = _ts_decorate4([
|
|
|
652
911
|
], JwtAuthService);
|
|
653
912
|
|
|
654
913
|
// 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,
|
|
914
|
+
function _ts_decorate5(decorators, target, key, desc2) {
|
|
915
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
916
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
658
917
|
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
918
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
660
919
|
}
|
|
@@ -705,29 +964,52 @@ var AuthConfigModule = class _AuthConfigModule {
|
|
|
705
964
|
}
|
|
706
965
|
};
|
|
707
966
|
AuthConfigModule = _ts_decorate5([
|
|
708
|
-
(0,
|
|
709
|
-
(0,
|
|
967
|
+
(0, import_common26.Global)(),
|
|
968
|
+
(0, import_common26.Module)({})
|
|
710
969
|
], AuthConfigModule);
|
|
711
970
|
|
|
712
971
|
// src/auth/decorators/access-token.decorator.ts
|
|
713
|
-
var
|
|
714
|
-
var AccessToken = (0,
|
|
972
|
+
var import_common27 = require("@nestjs/common");
|
|
973
|
+
var AccessToken = (0, import_common27.createParamDecorator)((_data, ctx) => {
|
|
715
974
|
const request = ctx.switchToHttp().getRequest();
|
|
716
975
|
const authHeader = request.headers.authorization;
|
|
717
976
|
return authHeader?.replace("Bearer ", "") || "";
|
|
718
977
|
});
|
|
719
978
|
|
|
979
|
+
// src/auth/decorators/cookie-domain.decorator.ts
|
|
980
|
+
var import_common28 = require("@nestjs/common");
|
|
981
|
+
var CookieDomain = (0, import_common28.createParamDecorator)((_data, ctx) => {
|
|
982
|
+
const request = ctx.switchToHttp().getRequest();
|
|
983
|
+
const forwarded = request.headers["x-forwarded-host"];
|
|
984
|
+
const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
985
|
+
const hostStr = raw ?? request.hostname;
|
|
986
|
+
const domain = hostStr.split(":")[0] ?? hostStr;
|
|
987
|
+
const baseDomain = getConfig().cookie.refreshCookieDomain ?? "";
|
|
988
|
+
return domain.endsWith(`.${baseDomain}`) ? domain : baseDomain;
|
|
989
|
+
});
|
|
990
|
+
|
|
720
991
|
// src/auth/decorators/onboarding.decorator.ts
|
|
721
|
-
var
|
|
722
|
-
var Onboarding = /* @__PURE__ */ __name(() => (0,
|
|
992
|
+
var import_common29 = require("@nestjs/common");
|
|
993
|
+
var Onboarding = /* @__PURE__ */ __name(() => (0, import_common29.SetMetadata)("isOnboarding", true), "Onboarding");
|
|
723
994
|
|
|
724
995
|
// src/auth/decorators/public.decorator.ts
|
|
725
|
-
var
|
|
726
|
-
var Public = /* @__PURE__ */ __name(() => (0,
|
|
996
|
+
var import_common30 = require("@nestjs/common");
|
|
997
|
+
var Public = /* @__PURE__ */ __name(() => (0, import_common30.SetMetadata)("isPublic", true), "Public");
|
|
998
|
+
|
|
999
|
+
// src/auth/decorators/refresh-cookie-options.decorator.ts
|
|
1000
|
+
var import_common31 = require("@nestjs/common");
|
|
1001
|
+
var RefreshCookieOptions = (0, import_common31.createParamDecorator)((_data, ctx) => {
|
|
1002
|
+
const request = ctx.switchToHttp().getRequest();
|
|
1003
|
+
const forwarded = request.headers["x-forwarded-host"];
|
|
1004
|
+
const raw = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
1005
|
+
const hostStr = raw ?? request.hostname;
|
|
1006
|
+
const domain = hostStr.split(":")[0] ?? hostStr;
|
|
1007
|
+
return getRefreshCookieOptionsForHost(domain);
|
|
1008
|
+
});
|
|
727
1009
|
|
|
728
1010
|
// src/auth/decorators/refresh-token-cookie.decorator.ts
|
|
729
|
-
var
|
|
730
|
-
var RefreshTokenCookie = (0,
|
|
1011
|
+
var import_common32 = require("@nestjs/common");
|
|
1012
|
+
var RefreshTokenCookie = (0, import_common32.createParamDecorator)((_data, ctx) => {
|
|
731
1013
|
const request = ctx.switchToHttp().getRequest();
|
|
732
1014
|
const cookies = request.cookies ?? {};
|
|
733
1015
|
const config = getConfig();
|
|
@@ -735,8 +1017,8 @@ var RefreshTokenCookie = (0, import_common11.createParamDecorator)((_data, ctx)
|
|
|
735
1017
|
});
|
|
736
1018
|
|
|
737
1019
|
// src/auth/decorators/session-data.decorator.ts
|
|
738
|
-
var
|
|
739
|
-
var SessionData = (0,
|
|
1020
|
+
var import_common33 = require("@nestjs/common");
|
|
1021
|
+
var SessionData = (0, import_common33.createParamDecorator)((_data, ctx) => {
|
|
740
1022
|
const request = ctx.switchToHttp().getRequest();
|
|
741
1023
|
const sessionInfo = request.sessionInfo;
|
|
742
1024
|
if (!sessionInfo?.sessionId) {
|
|
@@ -750,8 +1032,8 @@ var SessionData = (0, import_common12.createParamDecorator)((_data, ctx) => {
|
|
|
750
1032
|
});
|
|
751
1033
|
|
|
752
1034
|
// src/auth/decorators/user-id.decorator.ts
|
|
753
|
-
var
|
|
754
|
-
var UserId = (0,
|
|
1035
|
+
var import_common34 = require("@nestjs/common");
|
|
1036
|
+
var UserId = (0, import_common34.createParamDecorator)((_data, ctx) => {
|
|
755
1037
|
const request = ctx.switchToHttp().getRequest();
|
|
756
1038
|
const sessionInfo = request.sessionInfo;
|
|
757
1039
|
if (!sessionInfo?.userId) {
|
|
@@ -760,21 +1042,20 @@ var UserId = (0, import_common13.createParamDecorator)((_data, ctx) => {
|
|
|
760
1042
|
return sessionInfo.userId;
|
|
761
1043
|
});
|
|
762
1044
|
|
|
763
|
-
// src/
|
|
764
|
-
var
|
|
765
|
-
var
|
|
1045
|
+
// src/cache/cache.module.ts
|
|
1046
|
+
var import_common37 = require("@nestjs/common");
|
|
1047
|
+
var import_config9 = require("@nestjs/config");
|
|
766
1048
|
|
|
767
|
-
// src/
|
|
768
|
-
var
|
|
1049
|
+
// src/cache/cache.service.ts
|
|
1050
|
+
var import_common35 = require("@nestjs/common");
|
|
769
1051
|
|
|
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);
|
|
1052
|
+
// src/cache/constants.ts
|
|
1053
|
+
var CACHE_PROVIDER = Symbol("CACHE_PROVIDER");
|
|
1054
|
+
|
|
1055
|
+
// src/cache/cache.service.ts
|
|
1056
|
+
function _ts_decorate6(decorators, target, key, desc2) {
|
|
1057
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1058
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
778
1059
|
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
1060
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
780
1061
|
}
|
|
@@ -789,12 +1070,218 @@ function _ts_param2(paramIndex, decorator) {
|
|
|
789
1070
|
};
|
|
790
1071
|
}
|
|
791
1072
|
__name(_ts_param2, "_ts_param");
|
|
1073
|
+
var CacheService = class _CacheService {
|
|
1074
|
+
static {
|
|
1075
|
+
__name(this, "CacheService");
|
|
1076
|
+
}
|
|
1077
|
+
provider;
|
|
1078
|
+
logger = new import_common35.Logger(_CacheService.name);
|
|
1079
|
+
constructor(provider) {
|
|
1080
|
+
this.provider = provider;
|
|
1081
|
+
}
|
|
1082
|
+
// Stores a value with mandatory TTL — errors are logged and swallowed so DB writes still succeed
|
|
1083
|
+
async set(key, value, ttlSeconds) {
|
|
1084
|
+
try {
|
|
1085
|
+
await this.provider.set(key, value, ttlSeconds);
|
|
1086
|
+
} catch (err) {
|
|
1087
|
+
this.logger.error(`Cache set failed for key "${key}"`, err);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
// Returns cached value or null on miss or any Redis error — callers fall back to DB
|
|
1091
|
+
async get(key) {
|
|
1092
|
+
try {
|
|
1093
|
+
return await this.provider.get(key);
|
|
1094
|
+
} catch (err) {
|
|
1095
|
+
this.logger.error(`Cache get failed for key "${key}"`, err);
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
// Deletes one or more keys — errors are logged and swallowed
|
|
1100
|
+
async del(...keys) {
|
|
1101
|
+
try {
|
|
1102
|
+
await this.provider.del(...keys);
|
|
1103
|
+
} catch (err) {
|
|
1104
|
+
this.logger.error(`Cache del failed for keys "${keys.join(", ")}"`, err);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
// Returns all keys matching a glob pattern — returns empty array on error
|
|
1108
|
+
async scanKeys(pattern) {
|
|
1109
|
+
try {
|
|
1110
|
+
return await this.provider.scanKeys(pattern);
|
|
1111
|
+
} catch (err) {
|
|
1112
|
+
this.logger.error(`Cache scanKeys failed for pattern "${pattern}"`, err);
|
|
1113
|
+
return [];
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
// Returns raw memory info from the provider — returns empty string on error
|
|
1117
|
+
async getMemoryInfo() {
|
|
1118
|
+
try {
|
|
1119
|
+
return await this.provider.getMemoryInfo();
|
|
1120
|
+
} catch (err) {
|
|
1121
|
+
this.logger.error("Cache getMemoryInfo failed", err);
|
|
1122
|
+
return "";
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
CacheService = _ts_decorate6([
|
|
1127
|
+
(0, import_common35.Injectable)(),
|
|
1128
|
+
_ts_param2(0, (0, import_common35.Inject)(CACHE_PROVIDER)),
|
|
1129
|
+
_ts_metadata4("design:type", Function),
|
|
1130
|
+
_ts_metadata4("design:paramtypes", [
|
|
1131
|
+
typeof ICacheProvider === "undefined" ? Object : ICacheProvider
|
|
1132
|
+
])
|
|
1133
|
+
], CacheService);
|
|
1134
|
+
|
|
1135
|
+
// src/cache/providers/redis.provider.ts
|
|
1136
|
+
var import_common36 = require("@nestjs/common");
|
|
1137
|
+
var import_config8 = require("@nestjs/config");
|
|
1138
|
+
var import_ioredis = __toESM(require("ioredis"), 1);
|
|
1139
|
+
function _ts_decorate7(decorators, target, key, desc2) {
|
|
1140
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1141
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1142
|
+
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;
|
|
1143
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1144
|
+
}
|
|
1145
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
1146
|
+
function _ts_metadata5(k, v) {
|
|
1147
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1148
|
+
}
|
|
1149
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
1150
|
+
var RedisCacheProvider = class _RedisCacheProvider {
|
|
1151
|
+
static {
|
|
1152
|
+
__name(this, "RedisCacheProvider");
|
|
1153
|
+
}
|
|
1154
|
+
configService;
|
|
1155
|
+
logger = new import_common36.Logger(_RedisCacheProvider.name);
|
|
1156
|
+
client;
|
|
1157
|
+
constructor(configService) {
|
|
1158
|
+
this.configService = configService;
|
|
1159
|
+
}
|
|
1160
|
+
// Creates the ioredis client and attaches connection/error listeners
|
|
1161
|
+
onModuleInit() {
|
|
1162
|
+
const url = this.configService.getOrThrow("REDIS_URL");
|
|
1163
|
+
this.client = new import_ioredis.default(url, {
|
|
1164
|
+
lazyConnect: true,
|
|
1165
|
+
maxRetriesPerRequest: 3
|
|
1166
|
+
});
|
|
1167
|
+
this.client.on("connect", () => this.logger.log("Redis connected"));
|
|
1168
|
+
this.client.on("error", (err) => this.logger.error("Redis error", err));
|
|
1169
|
+
}
|
|
1170
|
+
// Gracefully closes the ioredis connection on app shutdown
|
|
1171
|
+
async onModuleDestroy() {
|
|
1172
|
+
await this.client.quit();
|
|
1173
|
+
this.logger.log("Redis disconnected");
|
|
1174
|
+
}
|
|
1175
|
+
// Serializes value to JSON and stores with a mandatory TTL
|
|
1176
|
+
async set(key, value, ttlSeconds) {
|
|
1177
|
+
const json = JSON.stringify(value);
|
|
1178
|
+
await this.client.setex(key, ttlSeconds, json);
|
|
1179
|
+
}
|
|
1180
|
+
// Reads the stored JSON string and parses back to the original type
|
|
1181
|
+
async get(key) {
|
|
1182
|
+
const json = await this.client.get(key);
|
|
1183
|
+
if (!json) return null;
|
|
1184
|
+
return JSON.parse(json);
|
|
1185
|
+
}
|
|
1186
|
+
// Deletes one or more keys in a single command
|
|
1187
|
+
async del(...keys) {
|
|
1188
|
+
if (keys.length > 0) {
|
|
1189
|
+
await this.client.del(...keys);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
// Cursor-iterates all keys matching a glob pattern — never uses KEYS command
|
|
1193
|
+
async scanKeys(pattern) {
|
|
1194
|
+
const keys = [];
|
|
1195
|
+
let cursor = "0";
|
|
1196
|
+
do {
|
|
1197
|
+
const [nextCursor, batch] = await this.client.scan(cursor, "MATCH", pattern, "COUNT", 100);
|
|
1198
|
+
cursor = nextCursor;
|
|
1199
|
+
keys.push(...batch);
|
|
1200
|
+
} while (cursor !== "0");
|
|
1201
|
+
return keys;
|
|
1202
|
+
}
|
|
1203
|
+
// Returns raw INFO memory output for memory monitoring
|
|
1204
|
+
async getMemoryInfo() {
|
|
1205
|
+
return this.client.info("memory");
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
RedisCacheProvider = _ts_decorate7([
|
|
1209
|
+
(0, import_common36.Injectable)(),
|
|
1210
|
+
_ts_metadata5("design:type", Function),
|
|
1211
|
+
_ts_metadata5("design:paramtypes", [
|
|
1212
|
+
typeof import_config8.ConfigService === "undefined" ? Object : import_config8.ConfigService
|
|
1213
|
+
])
|
|
1214
|
+
], RedisCacheProvider);
|
|
1215
|
+
|
|
1216
|
+
// src/cache/cache.module.ts
|
|
1217
|
+
function _ts_decorate8(decorators, target, key, desc2) {
|
|
1218
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1219
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1220
|
+
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;
|
|
1221
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1222
|
+
}
|
|
1223
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
1224
|
+
var CacheModule = class {
|
|
1225
|
+
static {
|
|
1226
|
+
__name(this, "CacheModule");
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
CacheModule = _ts_decorate8([
|
|
1230
|
+
(0, import_common37.Module)({
|
|
1231
|
+
imports: [
|
|
1232
|
+
import_config9.ConfigModule
|
|
1233
|
+
],
|
|
1234
|
+
providers: [
|
|
1235
|
+
RedisCacheProvider,
|
|
1236
|
+
{
|
|
1237
|
+
provide: CACHE_PROVIDER,
|
|
1238
|
+
useExisting: RedisCacheProvider
|
|
1239
|
+
},
|
|
1240
|
+
CacheService
|
|
1241
|
+
],
|
|
1242
|
+
exports: [
|
|
1243
|
+
RedisCacheProvider,
|
|
1244
|
+
CACHE_PROVIDER,
|
|
1245
|
+
CacheService
|
|
1246
|
+
]
|
|
1247
|
+
})
|
|
1248
|
+
], CacheModule);
|
|
1249
|
+
|
|
1250
|
+
// src/database/database.module.ts
|
|
1251
|
+
var import_common41 = require("@nestjs/common");
|
|
1252
|
+
var import_core4 = require("@nestjs/core");
|
|
1253
|
+
|
|
1254
|
+
// src/database/constants.ts
|
|
1255
|
+
var DATABASE_MODULE_OPTIONS = Symbol("DATABASE_MODULE_OPTIONS");
|
|
1256
|
+
|
|
1257
|
+
// src/database/services/primary-database.service.ts
|
|
1258
|
+
var import_common38 = require("@nestjs/common");
|
|
1259
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
1260
|
+
var import_node_postgres = require("drizzle-orm/node-postgres");
|
|
1261
|
+
var import_pg = require("pg");
|
|
1262
|
+
function _ts_decorate9(decorators, target, key, desc2) {
|
|
1263
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1264
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1265
|
+
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;
|
|
1266
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1267
|
+
}
|
|
1268
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
1269
|
+
function _ts_metadata6(k, v) {
|
|
1270
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1271
|
+
}
|
|
1272
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
1273
|
+
function _ts_param3(paramIndex, decorator) {
|
|
1274
|
+
return function(target, key) {
|
|
1275
|
+
decorator(target, key, paramIndex);
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
__name(_ts_param3, "_ts_param");
|
|
792
1279
|
var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
793
1280
|
static {
|
|
794
1281
|
__name(this, "PrimaryDatabaseService");
|
|
795
1282
|
}
|
|
796
1283
|
options;
|
|
797
|
-
logger = new
|
|
1284
|
+
logger = new import_common38.Logger(_PrimaryDatabaseService.name);
|
|
798
1285
|
pool = null;
|
|
799
1286
|
db = null;
|
|
800
1287
|
tenantConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -811,10 +1298,21 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
811
1298
|
// Initializes connection to primary database using Drizzle
|
|
812
1299
|
async initializeDrizzleClient() {
|
|
813
1300
|
try {
|
|
814
|
-
const
|
|
1301
|
+
const { host, port = 5432, username, password, database, schema, sslMode = "require" } = this.options.primaryDb;
|
|
815
1302
|
this.pool = new import_pg.Pool({
|
|
816
|
-
|
|
817
|
-
|
|
1303
|
+
host,
|
|
1304
|
+
port,
|
|
1305
|
+
user: username,
|
|
1306
|
+
password,
|
|
1307
|
+
database,
|
|
1308
|
+
max: this.options.maxConnections || 10,
|
|
1309
|
+
ssl: sslMode === "disable" ? false : {
|
|
1310
|
+
rejectUnauthorized: sslMode !== "no-verify"
|
|
1311
|
+
},
|
|
1312
|
+
// Pass schema as a PostgreSQL startup option — recognized by node-postgres, unlike the ?schema= URL param
|
|
1313
|
+
...schema && {
|
|
1314
|
+
options: `-csearch_path=${schema}`
|
|
1315
|
+
}
|
|
818
1316
|
});
|
|
819
1317
|
this.logger.debug(`Schema keys passed to drizzle: [${Object.keys(this.options.drizzleSchema || {}).join(", ")}]`);
|
|
820
1318
|
this.logger.debug(`Relations keys passed to drizzle: [${Object.keys(this.options.drizzleRelations || {}).join(", ")}]`);
|
|
@@ -825,34 +1323,11 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
825
1323
|
});
|
|
826
1324
|
this.logger.debug(`Drizzle query keys after init: [${Object.keys(this.db.query || {}).join(", ")}]`);
|
|
827
1325
|
await this.pool.query("SELECT 1");
|
|
828
|
-
this.logger.log(
|
|
1326
|
+
this.logger.log(`Connected to primary database (schema: ${schema ?? "public"})`);
|
|
829
1327
|
} catch (error) {
|
|
830
1328
|
this.logger.error("Failed to connect to primary database", error);
|
|
831
|
-
throw new
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
// Builds the PostgreSQL connection URL from primary database config properties
|
|
835
|
-
buildPrimaryDbUrl() {
|
|
836
|
-
if (!this.options.primaryDb) {
|
|
837
|
-
throw new Error("Primary database configuration not provided");
|
|
838
|
-
}
|
|
839
|
-
const { host, port = 5432, username, password, database, schema = "public", sslMode = "require" } = this.options.primaryDb;
|
|
840
|
-
let url = `postgresql://${username}:${encodeURIComponent(password)}@${host}:${port}/${database}`;
|
|
841
|
-
const params = new URLSearchParams();
|
|
842
|
-
if (schema) {
|
|
843
|
-
params.set("schema", schema);
|
|
1329
|
+
throw new import_common38.InternalServerErrorException("Failed to initialize tenant registry");
|
|
844
1330
|
}
|
|
845
|
-
params.set("sslmode", sslMode);
|
|
846
|
-
const queryString = params.toString();
|
|
847
|
-
if (queryString) {
|
|
848
|
-
url += `?${queryString}`;
|
|
849
|
-
}
|
|
850
|
-
this.logger.debug(`Primary DB connection URL: ${this.maskPassword(url)}`);
|
|
851
|
-
return url;
|
|
852
|
-
}
|
|
853
|
-
// Masks password in connection URL for safe logging
|
|
854
|
-
maskPassword(url) {
|
|
855
|
-
return url.replace(/:([^@]+)@/, ":****@");
|
|
856
1331
|
}
|
|
857
1332
|
// Retrieves tenant configuration by ID or subdomain, with in-memory caching
|
|
858
1333
|
async getTenantInfo(tenantIdentifier) {
|
|
@@ -900,7 +1375,7 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
900
1375
|
return info;
|
|
901
1376
|
} catch (error) {
|
|
902
1377
|
this.logger.error(`Failed to fetch tenant info: ${tenantIdentifier}`, error);
|
|
903
|
-
throw new
|
|
1378
|
+
throw new import_common38.InternalServerErrorException("Failed to resolve tenant");
|
|
904
1379
|
}
|
|
905
1380
|
}
|
|
906
1381
|
// Caches tenant info by both ID and subdomain with TTL expiration
|
|
@@ -950,24 +1425,24 @@ var PrimaryDatabaseService = class _PrimaryDatabaseService {
|
|
|
950
1425
|
}
|
|
951
1426
|
}
|
|
952
1427
|
};
|
|
953
|
-
PrimaryDatabaseService =
|
|
954
|
-
(0,
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1428
|
+
PrimaryDatabaseService = _ts_decorate9([
|
|
1429
|
+
(0, import_common38.Injectable)(),
|
|
1430
|
+
_ts_param3(0, (0, import_common38.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1431
|
+
_ts_metadata6("design:type", Function),
|
|
1432
|
+
_ts_metadata6("design:paramtypes", [
|
|
958
1433
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions
|
|
959
1434
|
])
|
|
960
1435
|
], PrimaryDatabaseService);
|
|
961
1436
|
|
|
962
1437
|
// 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,
|
|
1438
|
+
var import_common39 = require("@nestjs/common");
|
|
1439
|
+
function _ts_decorate10(decorators, target, key, desc2) {
|
|
1440
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1441
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
967
1442
|
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
1443
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
969
1444
|
}
|
|
970
|
-
__name(
|
|
1445
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
971
1446
|
var TenantContextService = class {
|
|
972
1447
|
static {
|
|
973
1448
|
__name(this, "TenantContextService");
|
|
@@ -983,7 +1458,7 @@ var TenantContextService = class {
|
|
|
983
1458
|
// Returns the tenant info for this request, throwing if context is not set
|
|
984
1459
|
getTenant() {
|
|
985
1460
|
if (!this.tenantInfo) {
|
|
986
|
-
throw new
|
|
1461
|
+
throw new import_common39.UnauthorizedException("Tenant context not set");
|
|
987
1462
|
}
|
|
988
1463
|
return this.tenantInfo;
|
|
989
1464
|
}
|
|
@@ -1004,40 +1479,40 @@ var TenantContextService = class {
|
|
|
1004
1479
|
return this.tenantInfo?.subdomain ?? null;
|
|
1005
1480
|
}
|
|
1006
1481
|
};
|
|
1007
|
-
TenantContextService =
|
|
1008
|
-
(0,
|
|
1009
|
-
scope:
|
|
1482
|
+
TenantContextService = _ts_decorate10([
|
|
1483
|
+
(0, import_common39.Injectable)({
|
|
1484
|
+
scope: import_common39.Scope.REQUEST
|
|
1010
1485
|
})
|
|
1011
1486
|
], TenantContextService);
|
|
1012
1487
|
|
|
1013
1488
|
// src/database/services/tenant-database.service.ts
|
|
1014
|
-
var
|
|
1489
|
+
var import_common40 = require("@nestjs/common");
|
|
1015
1490
|
var import_node_postgres2 = require("drizzle-orm/node-postgres");
|
|
1016
1491
|
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,
|
|
1492
|
+
function _ts_decorate11(decorators, target, key, desc2) {
|
|
1493
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1494
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1020
1495
|
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
1496
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1022
1497
|
}
|
|
1023
|
-
__name(
|
|
1024
|
-
function
|
|
1498
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1499
|
+
function _ts_metadata7(k, v) {
|
|
1025
1500
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1026
1501
|
}
|
|
1027
|
-
__name(
|
|
1028
|
-
function
|
|
1502
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1503
|
+
function _ts_param4(paramIndex, decorator) {
|
|
1029
1504
|
return function(target, key) {
|
|
1030
1505
|
decorator(target, key, paramIndex);
|
|
1031
1506
|
};
|
|
1032
1507
|
}
|
|
1033
|
-
__name(
|
|
1508
|
+
__name(_ts_param4, "_ts_param");
|
|
1034
1509
|
var TenantDatabaseService = class _TenantDatabaseService {
|
|
1035
1510
|
static {
|
|
1036
1511
|
__name(this, "TenantDatabaseService");
|
|
1037
1512
|
}
|
|
1038
1513
|
options;
|
|
1039
1514
|
tenantContext;
|
|
1040
|
-
logger = new
|
|
1515
|
+
logger = new import_common40.Logger(_TenantDatabaseService.name);
|
|
1041
1516
|
clients = /* @__PURE__ */ new Map();
|
|
1042
1517
|
clientLastUsed = /* @__PURE__ */ new Map();
|
|
1043
1518
|
cleanupInterval;
|
|
@@ -1089,7 +1564,7 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1089
1564
|
};
|
|
1090
1565
|
} catch (error) {
|
|
1091
1566
|
this.logger.error(`Failed to create database connection for tenant: ${tenant.subdomain}`, error);
|
|
1092
|
-
throw new
|
|
1567
|
+
throw new import_common40.InternalServerErrorException("Failed to connect to tenant database");
|
|
1093
1568
|
}
|
|
1094
1569
|
}
|
|
1095
1570
|
// Builds the PostgreSQL connection URL for a dedicated tenant database
|
|
@@ -1169,24 +1644,24 @@ var TenantDatabaseService = class _TenantDatabaseService {
|
|
|
1169
1644
|
this.logger.log("All database connections closed");
|
|
1170
1645
|
}
|
|
1171
1646
|
};
|
|
1172
|
-
TenantDatabaseService =
|
|
1173
|
-
(0,
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1647
|
+
TenantDatabaseService = _ts_decorate11([
|
|
1648
|
+
(0, import_common40.Injectable)(),
|
|
1649
|
+
_ts_param4(0, (0, import_common40.Inject)(DATABASE_MODULE_OPTIONS)),
|
|
1650
|
+
_ts_metadata7("design:type", Function),
|
|
1651
|
+
_ts_metadata7("design:paramtypes", [
|
|
1177
1652
|
typeof DatabaseModuleOptions === "undefined" ? Object : DatabaseModuleOptions,
|
|
1178
1653
|
typeof TenantContextService === "undefined" ? Object : TenantContextService
|
|
1179
1654
|
])
|
|
1180
1655
|
], TenantDatabaseService);
|
|
1181
1656
|
|
|
1182
1657
|
// 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,
|
|
1658
|
+
function _ts_decorate12(decorators, target, key, desc2) {
|
|
1659
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1660
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1186
1661
|
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
1662
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1188
1663
|
}
|
|
1189
|
-
__name(
|
|
1664
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1190
1665
|
var DatabaseModule = class _DatabaseModule {
|
|
1191
1666
|
static {
|
|
1192
1667
|
__name(this, "DatabaseModule");
|
|
@@ -1232,14 +1707,14 @@ var DatabaseModule = class _DatabaseModule {
|
|
|
1232
1707
|
};
|
|
1233
1708
|
}
|
|
1234
1709
|
};
|
|
1235
|
-
DatabaseModule =
|
|
1236
|
-
(0,
|
|
1237
|
-
(0,
|
|
1710
|
+
DatabaseModule = _ts_decorate12([
|
|
1711
|
+
(0, import_common41.Global)(),
|
|
1712
|
+
(0, import_common41.Module)({})
|
|
1238
1713
|
], DatabaseModule);
|
|
1239
1714
|
|
|
1240
1715
|
// src/database/decorators/tenant.decorator.ts
|
|
1241
|
-
var
|
|
1242
|
-
var Tenant = (0,
|
|
1716
|
+
var import_common42 = require("@nestjs/common");
|
|
1717
|
+
var Tenant = (0, import_common42.createParamDecorator)((_data, ctx) => {
|
|
1243
1718
|
const request = ctx.switchToHttp().getRequest();
|
|
1244
1719
|
const tenantContext = request.app?.get?.(TenantContextService);
|
|
1245
1720
|
if (!tenantContext) {
|
|
@@ -1252,17 +1727,17 @@ var Tenant = (0, import_common18.createParamDecorator)((_data, ctx) => {
|
|
|
1252
1727
|
var import_swagger = require("@nestjs/swagger");
|
|
1253
1728
|
var import_class_transformer = require("class-transformer");
|
|
1254
1729
|
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,
|
|
1730
|
+
function _ts_decorate13(decorators, target, key, desc2) {
|
|
1731
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1732
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1258
1733
|
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
1734
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1260
1735
|
}
|
|
1261
|
-
__name(
|
|
1262
|
-
function
|
|
1736
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1737
|
+
function _ts_metadata8(k, v) {
|
|
1263
1738
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1264
1739
|
}
|
|
1265
|
-
__name(
|
|
1740
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
1266
1741
|
var SelectOptionsQueryDto = class {
|
|
1267
1742
|
static {
|
|
1268
1743
|
__name(this, "SelectOptionsQueryDto");
|
|
@@ -1274,18 +1749,19 @@ var SelectOptionsQueryDto = class {
|
|
|
1274
1749
|
excludeIds;
|
|
1275
1750
|
valueKey;
|
|
1276
1751
|
labelKey;
|
|
1752
|
+
descriptionKey;
|
|
1277
1753
|
groupIdKey;
|
|
1278
1754
|
};
|
|
1279
|
-
|
|
1755
|
+
_ts_decorate13([
|
|
1280
1756
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1281
1757
|
description: "Search term to filter by label",
|
|
1282
1758
|
example: "united"
|
|
1283
1759
|
}),
|
|
1284
1760
|
(0, import_class_validator.IsOptional)(),
|
|
1285
1761
|
(0, import_class_validator.IsString)(),
|
|
1286
|
-
|
|
1762
|
+
_ts_metadata8("design:type", String)
|
|
1287
1763
|
], SelectOptionsQueryDto.prototype, "search", void 0);
|
|
1288
|
-
|
|
1764
|
+
_ts_decorate13([
|
|
1289
1765
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1290
1766
|
description: "Maximum number of results",
|
|
1291
1767
|
example: 20,
|
|
@@ -1295,9 +1771,9 @@ _ts_decorate10([
|
|
|
1295
1771
|
(0, import_class_transformer.Type)(() => Number),
|
|
1296
1772
|
(0, import_class_validator.IsInt)(),
|
|
1297
1773
|
(0, import_class_validator.Min)(1),
|
|
1298
|
-
|
|
1774
|
+
_ts_metadata8("design:type", Number)
|
|
1299
1775
|
], SelectOptionsQueryDto.prototype, "limit", void 0);
|
|
1300
|
-
|
|
1776
|
+
_ts_decorate13([
|
|
1301
1777
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1302
1778
|
description: "Number of results to skip",
|
|
1303
1779
|
example: 0,
|
|
@@ -1307,27 +1783,27 @@ _ts_decorate10([
|
|
|
1307
1783
|
(0, import_class_transformer.Type)(() => Number),
|
|
1308
1784
|
(0, import_class_validator.IsInt)(),
|
|
1309
1785
|
(0, import_class_validator.Min)(0),
|
|
1310
|
-
|
|
1786
|
+
_ts_metadata8("design:type", Number)
|
|
1311
1787
|
], SelectOptionsQueryDto.prototype, "offset", void 0);
|
|
1312
|
-
|
|
1788
|
+
_ts_decorate13([
|
|
1313
1789
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1314
1790
|
description: "Comma-separated values to fetch specific options",
|
|
1315
1791
|
example: "1,2,3"
|
|
1316
1792
|
}),
|
|
1317
1793
|
(0, import_class_validator.IsOptional)(),
|
|
1318
1794
|
(0, import_class_validator.IsString)(),
|
|
1319
|
-
|
|
1795
|
+
_ts_metadata8("design:type", String)
|
|
1320
1796
|
], SelectOptionsQueryDto.prototype, "values", void 0);
|
|
1321
|
-
|
|
1797
|
+
_ts_decorate13([
|
|
1322
1798
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1323
1799
|
description: "Comma-separated IDs to exclude from results (already selected)",
|
|
1324
1800
|
example: "5,10"
|
|
1325
1801
|
}),
|
|
1326
1802
|
(0, import_class_validator.IsOptional)(),
|
|
1327
1803
|
(0, import_class_validator.IsString)(),
|
|
1328
|
-
|
|
1804
|
+
_ts_metadata8("design:type", String)
|
|
1329
1805
|
], SelectOptionsQueryDto.prototype, "excludeIds", void 0);
|
|
1330
|
-
|
|
1806
|
+
_ts_decorate13([
|
|
1331
1807
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1332
1808
|
description: "Column name for option value",
|
|
1333
1809
|
example: "id",
|
|
@@ -1335,9 +1811,9 @@ _ts_decorate10([
|
|
|
1335
1811
|
}),
|
|
1336
1812
|
(0, import_class_validator.IsOptional)(),
|
|
1337
1813
|
(0, import_class_validator.IsString)(),
|
|
1338
|
-
|
|
1814
|
+
_ts_metadata8("design:type", String)
|
|
1339
1815
|
], SelectOptionsQueryDto.prototype, "valueKey", void 0);
|
|
1340
|
-
|
|
1816
|
+
_ts_decorate13([
|
|
1341
1817
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1342
1818
|
description: "Column name for option label",
|
|
1343
1819
|
example: "name",
|
|
@@ -1345,21 +1821,193 @@ _ts_decorate10([
|
|
|
1345
1821
|
}),
|
|
1346
1822
|
(0, import_class_validator.IsOptional)(),
|
|
1347
1823
|
(0, import_class_validator.IsString)(),
|
|
1348
|
-
|
|
1824
|
+
_ts_metadata8("design:type", String)
|
|
1349
1825
|
], SelectOptionsQueryDto.prototype, "labelKey", void 0);
|
|
1350
|
-
|
|
1826
|
+
_ts_decorate13([
|
|
1827
|
+
(0, import_swagger.ApiPropertyOptional)({
|
|
1828
|
+
description: "Column name for option description",
|
|
1829
|
+
example: "description"
|
|
1830
|
+
}),
|
|
1831
|
+
(0, import_class_validator.IsOptional)(),
|
|
1832
|
+
(0, import_class_validator.IsString)(),
|
|
1833
|
+
_ts_metadata8("design:type", String)
|
|
1834
|
+
], SelectOptionsQueryDto.prototype, "descriptionKey", void 0);
|
|
1835
|
+
_ts_decorate13([
|
|
1351
1836
|
(0, import_swagger.ApiPropertyOptional)({
|
|
1352
1837
|
description: "Column name for group ID",
|
|
1353
1838
|
example: "regionId"
|
|
1354
1839
|
}),
|
|
1355
1840
|
(0, import_class_validator.IsOptional)(),
|
|
1356
1841
|
(0, import_class_validator.IsString)(),
|
|
1357
|
-
|
|
1842
|
+
_ts_metadata8("design:type", String)
|
|
1358
1843
|
], SelectOptionsQueryDto.prototype, "groupIdKey", void 0);
|
|
1359
1844
|
|
|
1360
|
-
// src/database/
|
|
1361
|
-
var
|
|
1845
|
+
// src/database/dto/success-response.dto.ts
|
|
1846
|
+
var import_swagger2 = require("@nestjs/swagger");
|
|
1847
|
+
var import_class_validator2 = require("class-validator");
|
|
1848
|
+
function _ts_decorate14(decorators, target, key, desc2) {
|
|
1849
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1850
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1851
|
+
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;
|
|
1852
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1853
|
+
}
|
|
1854
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1855
|
+
function _ts_metadata9(k, v) {
|
|
1856
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1857
|
+
}
|
|
1858
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
1859
|
+
var SuccessResponseDto = class {
|
|
1860
|
+
static {
|
|
1861
|
+
__name(this, "SuccessResponseDto");
|
|
1862
|
+
}
|
|
1863
|
+
success;
|
|
1864
|
+
message;
|
|
1865
|
+
};
|
|
1866
|
+
_ts_decorate14([
|
|
1867
|
+
(0, import_swagger2.ApiProperty)({
|
|
1868
|
+
example: true
|
|
1869
|
+
}),
|
|
1870
|
+
(0, import_class_validator2.IsNotEmpty)(),
|
|
1871
|
+
(0, import_class_validator2.IsBoolean)(),
|
|
1872
|
+
_ts_metadata9("design:type", Boolean)
|
|
1873
|
+
], SuccessResponseDto.prototype, "success", void 0);
|
|
1874
|
+
_ts_decorate14([
|
|
1875
|
+
(0, import_swagger2.ApiProperty)({
|
|
1876
|
+
example: "Operation completed successfully"
|
|
1877
|
+
}),
|
|
1878
|
+
(0, import_class_validator2.IsNotEmpty)(),
|
|
1879
|
+
(0, import_class_validator2.IsString)(),
|
|
1880
|
+
_ts_metadata9("design:type", String)
|
|
1881
|
+
], SuccessResponseDto.prototype, "message", void 0);
|
|
1882
|
+
|
|
1883
|
+
// src/database/dto/table-response.dto.ts
|
|
1884
|
+
var import_swagger3 = require("@nestjs/swagger");
|
|
1885
|
+
function _ts_decorate15(decorators, target, key, desc2) {
|
|
1886
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
1887
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1888
|
+
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;
|
|
1889
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1890
|
+
}
|
|
1891
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1892
|
+
function _ts_metadata10(k, v) {
|
|
1893
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1894
|
+
}
|
|
1895
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1896
|
+
var TableResponseDto = class {
|
|
1897
|
+
static {
|
|
1898
|
+
__name(this, "TableResponseDto");
|
|
1899
|
+
}
|
|
1900
|
+
result;
|
|
1901
|
+
count;
|
|
1902
|
+
state;
|
|
1903
|
+
activeViewId;
|
|
1904
|
+
};
|
|
1905
|
+
_ts_decorate15([
|
|
1906
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1907
|
+
_ts_metadata10("design:type", Array)
|
|
1908
|
+
], TableResponseDto.prototype, "result", void 0);
|
|
1909
|
+
_ts_decorate15([
|
|
1910
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1911
|
+
_ts_metadata10("design:type", Number)
|
|
1912
|
+
], TableResponseDto.prototype, "count", void 0);
|
|
1913
|
+
_ts_decorate15([
|
|
1914
|
+
(0, import_swagger3.ApiProperty)(),
|
|
1915
|
+
_ts_metadata10("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
1916
|
+
], TableResponseDto.prototype, "state", void 0);
|
|
1917
|
+
_ts_decorate15([
|
|
1918
|
+
(0, import_swagger3.ApiPropertyOptional)({
|
|
1919
|
+
nullable: true
|
|
1920
|
+
}),
|
|
1921
|
+
_ts_metadata10("design:type", Object)
|
|
1922
|
+
], TableResponseDto.prototype, "activeViewId", void 0);
|
|
1923
|
+
|
|
1924
|
+
// src/database/filter/filter.processor.ts
|
|
1362
1925
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
1926
|
+
var FilterProcessor = class {
|
|
1927
|
+
static {
|
|
1928
|
+
__name(this, "FilterProcessor");
|
|
1929
|
+
}
|
|
1930
|
+
// Returns undefined if no conditions (Drizzle accepts undefined as "no WHERE")
|
|
1931
|
+
static buildWhere(filters = [], fieldMap) {
|
|
1932
|
+
const conditions = filters.flatMap((f) => {
|
|
1933
|
+
const def = fieldMap[f.field];
|
|
1934
|
+
if (!def) return [];
|
|
1935
|
+
if ("expression" in def) return [
|
|
1936
|
+
def.expression(f.value)
|
|
1937
|
+
];
|
|
1938
|
+
const { column: col } = def;
|
|
1939
|
+
const val = f.value;
|
|
1940
|
+
switch (f.operator) {
|
|
1941
|
+
case "equals":
|
|
1942
|
+
if (def.type === "boolean") return [
|
|
1943
|
+
(0, import_drizzle_orm2.eq)(col, val === "true" || val === 1)
|
|
1944
|
+
];
|
|
1945
|
+
return [
|
|
1946
|
+
(0, import_drizzle_orm2.eq)(col, val)
|
|
1947
|
+
];
|
|
1948
|
+
case "notEquals":
|
|
1949
|
+
if (def.type === "boolean") return [
|
|
1950
|
+
(0, import_drizzle_orm2.ne)(col, val === "true" || val === 1)
|
|
1951
|
+
];
|
|
1952
|
+
return [
|
|
1953
|
+
(0, import_drizzle_orm2.ne)(col, val)
|
|
1954
|
+
];
|
|
1955
|
+
case "contains":
|
|
1956
|
+
return [
|
|
1957
|
+
(0, import_drizzle_orm2.ilike)(col, `%${val}%`)
|
|
1958
|
+
];
|
|
1959
|
+
case "notContains":
|
|
1960
|
+
return [
|
|
1961
|
+
(0, import_drizzle_orm2.notIlike)(col, `%${val}%`)
|
|
1962
|
+
];
|
|
1963
|
+
case "gt":
|
|
1964
|
+
return [
|
|
1965
|
+
(0, import_drizzle_orm2.gt)(col, val)
|
|
1966
|
+
];
|
|
1967
|
+
case "gte":
|
|
1968
|
+
return [
|
|
1969
|
+
(0, import_drizzle_orm2.gte)(col, val)
|
|
1970
|
+
];
|
|
1971
|
+
case "lt":
|
|
1972
|
+
return [
|
|
1973
|
+
(0, import_drizzle_orm2.lt)(col, val)
|
|
1974
|
+
];
|
|
1975
|
+
case "lte":
|
|
1976
|
+
return [
|
|
1977
|
+
(0, import_drizzle_orm2.lte)(col, val)
|
|
1978
|
+
];
|
|
1979
|
+
default:
|
|
1980
|
+
return [];
|
|
1981
|
+
}
|
|
1982
|
+
});
|
|
1983
|
+
return conditions.length ? (0, import_drizzle_orm2.and)(...conditions) : void 0;
|
|
1984
|
+
}
|
|
1985
|
+
// Builds a search WHERE — OR across all string fields when columnId is 'all', otherwise a single ilike
|
|
1986
|
+
static buildSearch(search, fieldMap) {
|
|
1987
|
+
if (!search?.value) return void 0;
|
|
1988
|
+
if (search.columnId === "all") {
|
|
1989
|
+
const conditions = Object.values(fieldMap).filter((def2) => "column" in def2 && def2.type === "string").map((def2) => (0, import_drizzle_orm2.ilike)(def2.column, `%${search.value}%`));
|
|
1990
|
+
return conditions.length ? (0, import_drizzle_orm2.or)(...conditions) : void 0;
|
|
1991
|
+
}
|
|
1992
|
+
const def = fieldMap[search.columnId];
|
|
1993
|
+
if (!def || !("column" in def)) return void 0;
|
|
1994
|
+
return (0, import_drizzle_orm2.ilike)(def.column, `%${search.value}%`);
|
|
1995
|
+
}
|
|
1996
|
+
// Maps each SortCondition to an asc/desc SQL expression
|
|
1997
|
+
static buildOrderBy(sort = [], fieldMap) {
|
|
1998
|
+
return sort.flatMap((s) => {
|
|
1999
|
+
const def = fieldMap[s.field];
|
|
2000
|
+
if (!def || !("column" in def)) return [];
|
|
2001
|
+
return [
|
|
2002
|
+
s.direction === "asc" ? (0, import_drizzle_orm2.asc)(def.column) : (0, import_drizzle_orm2.desc)(def.column)
|
|
2003
|
+
];
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
// src/database/repositories/primary-base.repository.ts
|
|
2009
|
+
var import_common43 = require("@nestjs/common");
|
|
2010
|
+
var import_drizzle_orm3 = require("drizzle-orm");
|
|
1363
2011
|
function snakeToCamel(str) {
|
|
1364
2012
|
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1365
2013
|
}
|
|
@@ -1388,9 +2036,9 @@ var PrimaryBaseRepository = class {
|
|
|
1388
2036
|
constructor(database, table) {
|
|
1389
2037
|
this.database = database;
|
|
1390
2038
|
this.table = table;
|
|
1391
|
-
const dbTableName = (0,
|
|
2039
|
+
const dbTableName = (0, import_drizzle_orm3.getTableName)(table);
|
|
1392
2040
|
this.tableName = snakeToCamel(dbTableName);
|
|
1393
|
-
this.logger = new
|
|
2041
|
+
this.logger = new import_common43.Logger(this.constructor.name);
|
|
1394
2042
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1395
2043
|
this.logger.debug(`Table name: '${dbTableName}' -> query key: '${this.tableName}'`);
|
|
1396
2044
|
}
|
|
@@ -1423,12 +2071,32 @@ var PrimaryBaseRepository = class {
|
|
|
1423
2071
|
this.logger.debug("Finding multiple records");
|
|
1424
2072
|
return this.model.findMany(options);
|
|
1425
2073
|
}
|
|
2074
|
+
// Builds a select query with optional custom fields, join, filter, ordering, and pagination
|
|
2075
|
+
buildSelectQuery(options) {
|
|
2076
|
+
const base = options?.select ? this.db.select(options.select).from(this.table) : this.db.select().from(this.table);
|
|
2077
|
+
const joined = options?.leftJoin ? base.leftJoin(options.leftJoin.table, options.leftJoin.on) : base;
|
|
2078
|
+
const filtered = options?.where ? joined.where(options.where) : joined;
|
|
2079
|
+
const ordered = options?.orderBy?.length ? filtered.orderBy(...options.orderBy) : filtered;
|
|
2080
|
+
const limited = options?.limit ? ordered.limit(options.limit) : ordered;
|
|
2081
|
+
return options?.offset ? limited.offset(options.offset) : limited;
|
|
2082
|
+
}
|
|
2083
|
+
// Returns paginated result and total count, with optional custom select, LEFT JOIN, and ordering
|
|
2084
|
+
async findAllAndCount(options) {
|
|
2085
|
+
const [count, result] = await Promise.all([
|
|
2086
|
+
this.count(options?.where),
|
|
2087
|
+
this.buildSelectQuery(options)
|
|
2088
|
+
]);
|
|
2089
|
+
return {
|
|
2090
|
+
result,
|
|
2091
|
+
count
|
|
2092
|
+
};
|
|
2093
|
+
}
|
|
1426
2094
|
// Updates a record by ID and returns the updated record
|
|
1427
2095
|
async update(id, data) {
|
|
1428
2096
|
this.logger.log(`Updating record with ID: ${id}`);
|
|
1429
2097
|
const idColumn = this.table.id;
|
|
1430
2098
|
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,
|
|
2099
|
+
const results = await this.db.update(this.table).set(data).where((0, import_drizzle_orm3.eq)(idColumn, id)).returning();
|
|
1432
2100
|
const record = results[0];
|
|
1433
2101
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1434
2102
|
return record;
|
|
@@ -1446,7 +2114,7 @@ var PrimaryBaseRepository = class {
|
|
|
1446
2114
|
this.logger.log(`Deleting record with ID: ${id}`);
|
|
1447
2115
|
const idColumn = this.table.id;
|
|
1448
2116
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1449
|
-
const results = await this.db.delete(this.table).where((0,
|
|
2117
|
+
const results = await this.db.delete(this.table).where((0, import_drizzle_orm3.eq)(idColumn, id)).returning();
|
|
1450
2118
|
const record = results[0];
|
|
1451
2119
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1452
2120
|
return record;
|
|
@@ -1463,7 +2131,7 @@ var PrimaryBaseRepository = class {
|
|
|
1463
2131
|
async count(where) {
|
|
1464
2132
|
this.logger.debug("Counting records");
|
|
1465
2133
|
let query = this.db.select({
|
|
1466
|
-
count:
|
|
2134
|
+
count: import_drizzle_orm3.sql`count(*)::int`
|
|
1467
2135
|
}).from(this.table).$dynamic();
|
|
1468
2136
|
if (where) {
|
|
1469
2137
|
query = query.where(where);
|
|
@@ -1486,20 +2154,44 @@ var PrimaryBaseRepository = class {
|
|
|
1486
2154
|
if (!valueCol) throw new Error(`Column '${config.value}' not found in table '${this.tableName}'`);
|
|
1487
2155
|
const labelCol = tableColumns[config.label];
|
|
1488
2156
|
if (!labelCol) throw new Error(`Column '${config.label}' not found in table '${this.tableName}'`);
|
|
2157
|
+
let descriptionCol = config.description ? tableColumns[config.description] : void 0;
|
|
2158
|
+
if (!descriptionCol && config.description && config.joins) {
|
|
2159
|
+
for (const join of config.joins) {
|
|
2160
|
+
const joinCols = join.table;
|
|
2161
|
+
if (joinCols[config.description]) {
|
|
2162
|
+
descriptionCol = joinCols[config.description];
|
|
2163
|
+
break;
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
1489
2167
|
if (parsedValues && parsedValues.length > 0) {
|
|
1490
2168
|
const selectCols = {
|
|
1491
2169
|
value: valueCol,
|
|
1492
2170
|
label: labelCol
|
|
1493
2171
|
};
|
|
2172
|
+
if (descriptionCol) selectCols.description = descriptionCol;
|
|
1494
2173
|
if (config.groupId) {
|
|
1495
2174
|
const groupIdCol = tableColumns[config.groupId];
|
|
1496
2175
|
if (groupIdCol) selectCols.groupId = groupIdCol;
|
|
1497
2176
|
}
|
|
1498
|
-
|
|
2177
|
+
let valuesQuery = this.db.select(selectCols).from(this.table).$dynamic();
|
|
2178
|
+
if (config.joins) {
|
|
2179
|
+
for (const join of config.joins) {
|
|
2180
|
+
if (join.type === "inner") {
|
|
2181
|
+
valuesQuery = valuesQuery.innerJoin(join.table, join.on);
|
|
2182
|
+
} else {
|
|
2183
|
+
valuesQuery = valuesQuery.leftJoin(join.table, join.on);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
const rows2 = await valuesQuery.where((0, import_drizzle_orm3.inArray)(valueCol, parsedValues));
|
|
1499
2188
|
return {
|
|
1500
2189
|
options: rows2.map((row) => ({
|
|
1501
2190
|
value: row.value,
|
|
1502
2191
|
label: String(row.label),
|
|
2192
|
+
...descriptionCol && row.description != null ? {
|
|
2193
|
+
description: row.description
|
|
2194
|
+
} : {},
|
|
1503
2195
|
...config.groupId && row.groupId != null ? {
|
|
1504
2196
|
groupId: row.groupId
|
|
1505
2197
|
} : {}
|
|
@@ -1513,47 +2205,63 @@ var PrimaryBaseRepository = class {
|
|
|
1513
2205
|
const selectFields = {
|
|
1514
2206
|
value: valueCol,
|
|
1515
2207
|
label: labelCol,
|
|
1516
|
-
totalCount:
|
|
2208
|
+
totalCount: import_drizzle_orm3.sql`count(*) over()`.mapWith(Number)
|
|
1517
2209
|
};
|
|
2210
|
+
if (descriptionCol) selectFields.description = descriptionCol;
|
|
1518
2211
|
if (config.groupId) {
|
|
1519
2212
|
const groupIdCol = tableColumns[config.groupId];
|
|
1520
2213
|
if (groupIdCol) selectFields.groupId = groupIdCol;
|
|
1521
2214
|
}
|
|
1522
2215
|
const conditions = [];
|
|
1523
2216
|
if (config.search) {
|
|
1524
|
-
conditions.push((0,
|
|
2217
|
+
conditions.push((0, import_drizzle_orm3.ilike)(labelCol, `%${config.search}%`));
|
|
1525
2218
|
}
|
|
1526
2219
|
if (parsedExcludeIds.length > 0) {
|
|
1527
|
-
conditions.push((0,
|
|
2220
|
+
conditions.push((0, import_drizzle_orm3.notInArray)(valueCol, parsedExcludeIds));
|
|
1528
2221
|
}
|
|
1529
2222
|
if (config.where) {
|
|
1530
2223
|
for (const [field, val] of Object.entries(config.where)) {
|
|
1531
2224
|
const column = tableColumns[field];
|
|
1532
2225
|
if (column) {
|
|
1533
|
-
conditions.push((0,
|
|
2226
|
+
conditions.push((0, import_drizzle_orm3.eq)(column, val));
|
|
1534
2227
|
}
|
|
1535
2228
|
}
|
|
1536
2229
|
}
|
|
2230
|
+
if (config.conditions) {
|
|
2231
|
+
conditions.push(...config.conditions);
|
|
2232
|
+
}
|
|
1537
2233
|
const orderByKey = config.orderBy ? Object.keys(config.orderBy)[0] : void 0;
|
|
1538
2234
|
const orderByCol = orderByKey ? tableColumns[orderByKey] ?? labelCol : labelCol;
|
|
1539
2235
|
const limit = Number(config.limit) || 20;
|
|
1540
2236
|
const offset = Number(config.offset) || 0;
|
|
1541
2237
|
let query = this.db.select(selectFields).from(this.table).$dynamic();
|
|
2238
|
+
if (config.joins) {
|
|
2239
|
+
for (const join of config.joins) {
|
|
2240
|
+
if (join.type === "inner") {
|
|
2241
|
+
query = query.innerJoin(join.table, join.on);
|
|
2242
|
+
} else {
|
|
2243
|
+
query = query.leftJoin(join.table, join.on);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
1542
2247
|
if (conditions.length > 0) {
|
|
1543
|
-
query = query.where(conditions.length === 1 ? conditions[0] : (0,
|
|
2248
|
+
query = query.where(conditions.length === 1 ? conditions[0] : (0, import_drizzle_orm3.and)(...conditions));
|
|
1544
2249
|
}
|
|
1545
2250
|
const orderClauses = [];
|
|
1546
2251
|
if (config.groupId) {
|
|
1547
2252
|
const groupIdCol = tableColumns[config.groupId];
|
|
1548
|
-
if (groupIdCol) orderClauses.push((0,
|
|
2253
|
+
if (groupIdCol) orderClauses.push((0, import_drizzle_orm3.asc)(groupIdCol));
|
|
1549
2254
|
}
|
|
1550
|
-
orderClauses.push((0,
|
|
2255
|
+
orderClauses.push((0, import_drizzle_orm3.asc)(orderByCol));
|
|
1551
2256
|
query = query.orderBy(...orderClauses).limit(limit).offset(offset);
|
|
1552
2257
|
const rows = await query;
|
|
1553
2258
|
const totalCount = rows.length > 0 ? rows[0].totalCount : 0;
|
|
1554
2259
|
const options = rows.map((row) => ({
|
|
1555
2260
|
value: row.value,
|
|
1556
2261
|
label: String(row.label),
|
|
2262
|
+
...descriptionCol && row.description != null ? {
|
|
2263
|
+
description: row.description
|
|
2264
|
+
} : {},
|
|
1557
2265
|
...config.groupId && row.groupId != null ? {
|
|
1558
2266
|
groupId: row.groupId
|
|
1559
2267
|
} : {}
|
|
@@ -1570,7 +2278,7 @@ var PrimaryBaseRepository = class {
|
|
|
1570
2278
|
const groupRows = await this.db.select({
|
|
1571
2279
|
id: groupIdCol,
|
|
1572
2280
|
name: groupNameCol
|
|
1573
|
-
}).from(config.groupTable).orderBy((0,
|
|
2281
|
+
}).from(config.groupTable).orderBy((0, import_drizzle_orm3.asc)(groupNameCol));
|
|
1574
2282
|
resolvedGroups = groupRows.map((r) => ({
|
|
1575
2283
|
id: r.id,
|
|
1576
2284
|
name: String(r.name)
|
|
@@ -1588,8 +2296,8 @@ var PrimaryBaseRepository = class {
|
|
|
1588
2296
|
};
|
|
1589
2297
|
|
|
1590
2298
|
// src/database/repositories/tenant-base.repository.ts
|
|
1591
|
-
var
|
|
1592
|
-
var
|
|
2299
|
+
var import_common44 = require("@nestjs/common");
|
|
2300
|
+
var import_drizzle_orm4 = require("drizzle-orm");
|
|
1593
2301
|
var TenantBaseRepository = class {
|
|
1594
2302
|
static {
|
|
1595
2303
|
__name(this, "TenantBaseRepository");
|
|
@@ -1607,8 +2315,8 @@ var TenantBaseRepository = class {
|
|
|
1607
2315
|
constructor(database, table) {
|
|
1608
2316
|
this.database = database;
|
|
1609
2317
|
this.table = table;
|
|
1610
|
-
this.tableName = (0,
|
|
1611
|
-
this.logger = new
|
|
2318
|
+
this.tableName = (0, import_drizzle_orm4.getTableName)(table);
|
|
2319
|
+
this.logger = new import_common44.Logger(this.constructor.name);
|
|
1612
2320
|
this.logger.debug(`Initialized ${this.constructor.name}`);
|
|
1613
2321
|
}
|
|
1614
2322
|
// Creates a new record and returns it
|
|
@@ -1624,7 +2332,7 @@ var TenantBaseRepository = class {
|
|
|
1624
2332
|
this.logger.debug(`Finding record by ID: ${id}`);
|
|
1625
2333
|
const idColumn = this.table.id;
|
|
1626
2334
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1627
|
-
const results = await this.db.select().from(this.table).where((0,
|
|
2335
|
+
const results = await this.db.select().from(this.table).where((0, import_drizzle_orm4.eq)(idColumn, id)).limit(1);
|
|
1628
2336
|
return results[0] ?? null;
|
|
1629
2337
|
}
|
|
1630
2338
|
// Finds a single record matching the given SQL condition
|
|
@@ -1656,7 +2364,7 @@ var TenantBaseRepository = class {
|
|
|
1656
2364
|
this.logger.log(`Updating record with ID: ${id}`);
|
|
1657
2365
|
const idColumn = this.table.id;
|
|
1658
2366
|
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,
|
|
2367
|
+
const results = await this.db.update(this.table).set(data).where((0, import_drizzle_orm4.eq)(idColumn, id)).returning();
|
|
1660
2368
|
const record = results[0];
|
|
1661
2369
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1662
2370
|
return record;
|
|
@@ -1674,7 +2382,7 @@ var TenantBaseRepository = class {
|
|
|
1674
2382
|
this.logger.log(`Deleting record with ID: ${id}`);
|
|
1675
2383
|
const idColumn = this.table.id;
|
|
1676
2384
|
if (!idColumn) throw new Error(`Table '${this.tableName}' has no 'id' column`);
|
|
1677
|
-
const results = await this.db.delete(this.table).where((0,
|
|
2385
|
+
const results = await this.db.delete(this.table).where((0, import_drizzle_orm4.eq)(idColumn, id)).returning();
|
|
1678
2386
|
const record = results[0];
|
|
1679
2387
|
if (!record) throw new Error(`${this.tableName}: database operation returned no record`);
|
|
1680
2388
|
return record;
|
|
@@ -1691,7 +2399,7 @@ var TenantBaseRepository = class {
|
|
|
1691
2399
|
async count(where) {
|
|
1692
2400
|
this.logger.debug("Counting records");
|
|
1693
2401
|
let query = this.db.select({
|
|
1694
|
-
count:
|
|
2402
|
+
count: import_drizzle_orm4.sql`count(*)::int`
|
|
1695
2403
|
}).from(this.table).$dynamic();
|
|
1696
2404
|
if (where) {
|
|
1697
2405
|
query = query.where(where);
|
|
@@ -1723,7 +2431,7 @@ var TenantBaseRepository = class {
|
|
|
1723
2431
|
const groupIdCol = tableColumns[config.groupId];
|
|
1724
2432
|
if (groupIdCol) selectCols.groupId = groupIdCol;
|
|
1725
2433
|
}
|
|
1726
|
-
const rows2 = await this.db.select(selectCols).from(this.table).where((0,
|
|
2434
|
+
const rows2 = await this.db.select(selectCols).from(this.table).where((0, import_drizzle_orm4.inArray)(valueCol, parsedValues));
|
|
1727
2435
|
return {
|
|
1728
2436
|
options: rows2.map((row) => ({
|
|
1729
2437
|
value: row.value,
|
|
@@ -1741,7 +2449,7 @@ var TenantBaseRepository = class {
|
|
|
1741
2449
|
const selectFields = {
|
|
1742
2450
|
value: valueCol,
|
|
1743
2451
|
label: labelCol,
|
|
1744
|
-
totalCount:
|
|
2452
|
+
totalCount: import_drizzle_orm4.sql`count(*) over()`.mapWith(Number)
|
|
1745
2453
|
};
|
|
1746
2454
|
if (config.groupId) {
|
|
1747
2455
|
const groupIdCol = tableColumns[config.groupId];
|
|
@@ -1749,16 +2457,16 @@ var TenantBaseRepository = class {
|
|
|
1749
2457
|
}
|
|
1750
2458
|
const conditions = [];
|
|
1751
2459
|
if (config.search) {
|
|
1752
|
-
conditions.push((0,
|
|
2460
|
+
conditions.push((0, import_drizzle_orm4.ilike)(labelCol, `%${config.search}%`));
|
|
1753
2461
|
}
|
|
1754
2462
|
if (parsedExcludeIds.length > 0) {
|
|
1755
|
-
conditions.push((0,
|
|
2463
|
+
conditions.push((0, import_drizzle_orm4.notInArray)(valueCol, parsedExcludeIds));
|
|
1756
2464
|
}
|
|
1757
2465
|
if (config.where) {
|
|
1758
2466
|
for (const [field, val] of Object.entries(config.where)) {
|
|
1759
2467
|
const column = tableColumns[field];
|
|
1760
2468
|
if (column) {
|
|
1761
|
-
conditions.push((0,
|
|
2469
|
+
conditions.push((0, import_drizzle_orm4.eq)(column, val));
|
|
1762
2470
|
}
|
|
1763
2471
|
}
|
|
1764
2472
|
}
|
|
@@ -1768,14 +2476,14 @@ var TenantBaseRepository = class {
|
|
|
1768
2476
|
const offset = Number(config.offset) || 0;
|
|
1769
2477
|
let query = this.db.select(selectFields).from(this.table).$dynamic();
|
|
1770
2478
|
if (conditions.length > 0) {
|
|
1771
|
-
query = query.where(conditions.length === 1 ? conditions[0] : (0,
|
|
2479
|
+
query = query.where(conditions.length === 1 ? conditions[0] : (0, import_drizzle_orm4.and)(...conditions));
|
|
1772
2480
|
}
|
|
1773
2481
|
const orderClauses = [];
|
|
1774
2482
|
if (config.groupId) {
|
|
1775
2483
|
const groupIdCol = tableColumns[config.groupId];
|
|
1776
|
-
if (groupIdCol) orderClauses.push((0,
|
|
2484
|
+
if (groupIdCol) orderClauses.push((0, import_drizzle_orm4.asc)(groupIdCol));
|
|
1777
2485
|
}
|
|
1778
|
-
orderClauses.push((0,
|
|
2486
|
+
orderClauses.push((0, import_drizzle_orm4.asc)(orderByCol));
|
|
1779
2487
|
query = query.orderBy(...orderClauses).limit(limit).offset(offset);
|
|
1780
2488
|
const rows = await query;
|
|
1781
2489
|
const totalCount = rows.length > 0 ? rows[0].totalCount : 0;
|
|
@@ -1798,7 +2506,7 @@ var TenantBaseRepository = class {
|
|
|
1798
2506
|
const groupRows = await this.db.select({
|
|
1799
2507
|
id: groupIdCol,
|
|
1800
2508
|
name: groupNameCol
|
|
1801
|
-
}).from(config.groupTable).orderBy((0,
|
|
2509
|
+
}).from(config.groupTable).orderBy((0, import_drizzle_orm4.asc)(groupNameCol));
|
|
1802
2510
|
resolvedGroups = groupRows.map((r) => ({
|
|
1803
2511
|
id: r.id,
|
|
1804
2512
|
name: String(r.name)
|
|
@@ -1816,30 +2524,30 @@ var TenantBaseRepository = class {
|
|
|
1816
2524
|
};
|
|
1817
2525
|
|
|
1818
2526
|
// src/email/email.module.ts
|
|
1819
|
-
var
|
|
1820
|
-
var
|
|
2527
|
+
var import_common46 = require("@nestjs/common");
|
|
2528
|
+
var import_config11 = require("@nestjs/config");
|
|
1821
2529
|
|
|
1822
2530
|
// src/email/email.service.ts
|
|
1823
2531
|
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,
|
|
2532
|
+
var import_common45 = require("@nestjs/common");
|
|
2533
|
+
var import_config10 = require("@nestjs/config");
|
|
2534
|
+
function _ts_decorate16(decorators, target, key, desc2) {
|
|
2535
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
2536
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
1829
2537
|
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
2538
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1831
2539
|
}
|
|
1832
|
-
__name(
|
|
1833
|
-
function
|
|
2540
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2541
|
+
function _ts_metadata11(k, v) {
|
|
1834
2542
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1835
2543
|
}
|
|
1836
|
-
__name(
|
|
2544
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1837
2545
|
var EmailService = class _EmailService {
|
|
1838
2546
|
static {
|
|
1839
2547
|
__name(this, "EmailService");
|
|
1840
2548
|
}
|
|
1841
2549
|
configService;
|
|
1842
|
-
logger = new
|
|
2550
|
+
logger = new import_common45.Logger(_EmailService.name);
|
|
1843
2551
|
brevoClient;
|
|
1844
2552
|
senderEmail;
|
|
1845
2553
|
senderName;
|
|
@@ -2336,32 +3044,32 @@ This is an automated message, please do not reply.
|
|
|
2336
3044
|
}
|
|
2337
3045
|
}
|
|
2338
3046
|
};
|
|
2339
|
-
EmailService =
|
|
2340
|
-
(0,
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
typeof
|
|
3047
|
+
EmailService = _ts_decorate16([
|
|
3048
|
+
(0, import_common45.Injectable)(),
|
|
3049
|
+
_ts_metadata11("design:type", Function),
|
|
3050
|
+
_ts_metadata11("design:paramtypes", [
|
|
3051
|
+
typeof import_config10.ConfigService === "undefined" ? Object : import_config10.ConfigService
|
|
2344
3052
|
])
|
|
2345
3053
|
], EmailService);
|
|
2346
3054
|
|
|
2347
3055
|
// src/email/email.module.ts
|
|
2348
|
-
function
|
|
2349
|
-
var c = arguments.length, r = c < 3 ? target :
|
|
2350
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key,
|
|
3056
|
+
function _ts_decorate17(decorators, target, key, desc2) {
|
|
3057
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3058
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2351
3059
|
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
3060
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2353
3061
|
}
|
|
2354
|
-
__name(
|
|
3062
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2355
3063
|
var EmailModule = class {
|
|
2356
3064
|
static {
|
|
2357
3065
|
__name(this, "EmailModule");
|
|
2358
3066
|
}
|
|
2359
3067
|
};
|
|
2360
|
-
EmailModule =
|
|
2361
|
-
(0,
|
|
2362
|
-
(0,
|
|
3068
|
+
EmailModule = _ts_decorate17([
|
|
3069
|
+
(0, import_common46.Global)(),
|
|
3070
|
+
(0, import_common46.Module)({
|
|
2363
3071
|
imports: [
|
|
2364
|
-
|
|
3072
|
+
import_config11.ConfigModule
|
|
2365
3073
|
],
|
|
2366
3074
|
providers: [
|
|
2367
3075
|
EmailService
|
|
@@ -2372,236 +3080,17 @@ EmailModule = _ts_decorate12([
|
|
|
2372
3080
|
})
|
|
2373
3081
|
], EmailModule);
|
|
2374
3082
|
|
|
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
|
-
};
|
|
2516
|
-
|
|
2517
|
-
// src/exceptions/request-timeout.exception.ts
|
|
2518
|
-
var import_common35 = require("@nestjs/common");
|
|
2519
|
-
var RequestTimeoutException = class extends HttpProblemException {
|
|
2520
|
-
static {
|
|
2521
|
-
__name(this, "RequestTimeoutException");
|
|
2522
|
-
}
|
|
2523
|
-
constructor(detailOrOptions) {
|
|
2524
|
-
super(detailOrOptions ?? "Request Timeout", import_common35.HttpStatus.REQUEST_TIMEOUT);
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
|
|
2528
|
-
// src/exceptions/service-unavailable.exception.ts
|
|
2529
|
-
var import_common36 = require("@nestjs/common");
|
|
2530
|
-
var ServiceUnavailableException = class extends HttpProblemException {
|
|
2531
|
-
static {
|
|
2532
|
-
__name(this, "ServiceUnavailableException");
|
|
2533
|
-
}
|
|
2534
|
-
constructor(detailOrOptions) {
|
|
2535
|
-
super(detailOrOptions ?? "Service Unavailable", import_common36.HttpStatus.SERVICE_UNAVAILABLE);
|
|
2536
|
-
}
|
|
2537
|
-
};
|
|
2538
|
-
|
|
2539
|
-
// src/exceptions/too-many-requests.exception.ts
|
|
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
|
-
};
|
|
2549
|
-
|
|
2550
|
-
// src/exceptions/unauthorized.exception.ts
|
|
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
|
-
};
|
|
2560
|
-
|
|
2561
|
-
// src/exceptions/unprocessable-entity.exception.ts
|
|
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
|
-
};
|
|
2571
|
-
|
|
2572
|
-
// src/exceptions/unsupported-media-type.exception.ts
|
|
2573
|
-
var import_common40 = require("@nestjs/common");
|
|
2574
|
-
var UnsupportedMediaTypeException = class extends HttpProblemException {
|
|
2575
|
-
static {
|
|
2576
|
-
__name(this, "UnsupportedMediaTypeException");
|
|
2577
|
-
}
|
|
2578
|
-
constructor(detailOrOptions) {
|
|
2579
|
-
super(detailOrOptions ?? "Unsupported Media Type", import_common40.HttpStatus.UNSUPPORTED_MEDIA_TYPE);
|
|
2580
|
-
}
|
|
2581
|
-
};
|
|
2582
|
-
|
|
2583
|
-
// src/exceptions/validation.exception.ts
|
|
2584
|
-
var import_common41 = require("@nestjs/common");
|
|
2585
|
-
var ValidationException = class extends HttpProblemException {
|
|
2586
|
-
static {
|
|
2587
|
-
__name(this, "ValidationException");
|
|
2588
|
-
}
|
|
2589
|
-
constructor(detailOrOptions) {
|
|
2590
|
-
super(detailOrOptions ?? "Validation Failed", import_common41.HttpStatus.BAD_REQUEST);
|
|
2591
|
-
}
|
|
2592
|
-
};
|
|
2593
|
-
|
|
2594
3083
|
// 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,
|
|
3084
|
+
var import_common47 = require("@nestjs/common");
|
|
3085
|
+
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3086
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3087
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2599
3088
|
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
3089
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2601
3090
|
}
|
|
2602
|
-
__name(
|
|
3091
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
2603
3092
|
function getHttpStatusTitle(status) {
|
|
2604
|
-
const enumKey = Object.entries(
|
|
3093
|
+
const enumKey = Object.entries(import_common47.HttpStatus).find(([key, value]) => value === status && Number.isNaN(Number(key)))?.[0];
|
|
2605
3094
|
if (!enumKey) {
|
|
2606
3095
|
return "Error";
|
|
2607
3096
|
}
|
|
@@ -2612,17 +3101,17 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2612
3101
|
static {
|
|
2613
3102
|
__name(this, "HttpExceptionFilter");
|
|
2614
3103
|
}
|
|
2615
|
-
logger = new
|
|
3104
|
+
logger = new import_common47.Logger(_HttpExceptionFilter.name);
|
|
2616
3105
|
catch(exception, host) {
|
|
2617
3106
|
const ctx = host.switchToHttp();
|
|
2618
3107
|
const response = ctx.getResponse();
|
|
2619
3108
|
const request = ctx.getRequest();
|
|
2620
|
-
let status =
|
|
3109
|
+
let status = import_common47.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2621
3110
|
let type = "about:blank";
|
|
2622
3111
|
let label;
|
|
2623
3112
|
let detail = "Internal server error";
|
|
2624
3113
|
let errors = [];
|
|
2625
|
-
if (exception
|
|
3114
|
+
if (this.isHttpException(exception)) {
|
|
2626
3115
|
status = exception.getStatus();
|
|
2627
3116
|
const exceptionResponse = exception.getResponse();
|
|
2628
3117
|
if (typeof exceptionResponse === "object" && exceptionResponse !== null) {
|
|
@@ -2652,10 +3141,14 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2652
3141
|
} else if (typeof exceptionResponse === "string") {
|
|
2653
3142
|
detail = exceptionResponse;
|
|
2654
3143
|
}
|
|
3144
|
+
} else if (this.isAxiosError(exception)) {
|
|
3145
|
+
const axiosStatus = exception.response?.status;
|
|
3146
|
+
const axiosDetail = exception.response?.data?.message || exception.response?.data?.detail || exception.message;
|
|
3147
|
+
const url = exception.config?.url;
|
|
3148
|
+
status = import_common47.HttpStatus.BAD_GATEWAY;
|
|
3149
|
+
detail = `Upstream service error${axiosStatus ? ` (${axiosStatus})` : ""}: ${axiosDetail}`;
|
|
3150
|
+
this.logger.error(`Upstream API error [${axiosStatus}]: ${axiosDetail} \u2014 URL: ${url}`, exception.stack);
|
|
2655
3151
|
} 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
3152
|
detail = "An unexpected error occurred";
|
|
2660
3153
|
}
|
|
2661
3154
|
const problemDetails = {
|
|
@@ -2671,17 +3164,25 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
2671
3164
|
};
|
|
2672
3165
|
response.header("Content-Type", "application/problem+json").status(status).send(problemDetails);
|
|
2673
3166
|
}
|
|
3167
|
+
// Duck-type check for HttpException — avoids instanceof failing across pnpm package instances
|
|
3168
|
+
isHttpException(error) {
|
|
3169
|
+
return error instanceof Error && typeof error.getStatus === "function" && typeof error.getResponse === "function";
|
|
3170
|
+
}
|
|
3171
|
+
// Duck-type check for AxiosError without importing axios
|
|
3172
|
+
isAxiosError(error) {
|
|
3173
|
+
return error instanceof Error && error.isAxiosError === true;
|
|
3174
|
+
}
|
|
2674
3175
|
};
|
|
2675
|
-
HttpExceptionFilter =
|
|
2676
|
-
(0,
|
|
3176
|
+
HttpExceptionFilter = _ts_decorate18([
|
|
3177
|
+
(0, import_common47.Catch)()
|
|
2677
3178
|
], HttpExceptionFilter);
|
|
2678
3179
|
|
|
2679
3180
|
// src/logger/interceptors/http-logger.interceptor.ts
|
|
2680
|
-
var
|
|
3181
|
+
var import_common49 = require("@nestjs/common");
|
|
2681
3182
|
var import_operators = require("rxjs/operators");
|
|
2682
3183
|
|
|
2683
3184
|
// src/logger/services/logger.service.ts
|
|
2684
|
-
var
|
|
3185
|
+
var import_common48 = require("@nestjs/common");
|
|
2685
3186
|
var import_winston = require("winston");
|
|
2686
3187
|
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
2687
3188
|
|
|
@@ -2719,23 +3220,23 @@ function addCorrelationIdToResponse(reply, correlationId, headerName = DEFAULT_C
|
|
|
2719
3220
|
__name(addCorrelationIdToResponse, "addCorrelationIdToResponse");
|
|
2720
3221
|
|
|
2721
3222
|
// 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,
|
|
3223
|
+
function _ts_decorate19(decorators, target, key, desc2) {
|
|
3224
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3225
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2725
3226
|
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
3227
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2727
3228
|
}
|
|
2728
|
-
__name(
|
|
2729
|
-
function
|
|
3229
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3230
|
+
function _ts_metadata12(k, v) {
|
|
2730
3231
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2731
3232
|
}
|
|
2732
|
-
__name(
|
|
2733
|
-
function
|
|
3233
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3234
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2734
3235
|
return function(target, key) {
|
|
2735
3236
|
decorator(target, key, paramIndex);
|
|
2736
3237
|
};
|
|
2737
3238
|
}
|
|
2738
|
-
__name(
|
|
3239
|
+
__name(_ts_param5, "_ts_param");
|
|
2739
3240
|
var LoggerService = class _LoggerService {
|
|
2740
3241
|
static {
|
|
2741
3242
|
__name(this, "LoggerService");
|
|
@@ -2775,9 +3276,9 @@ var LoggerService = class _LoggerService {
|
|
|
2775
3276
|
}) : new import_winston.transports.Console({
|
|
2776
3277
|
level,
|
|
2777
3278
|
format: import_winston.format.combine(...baseFormatters, import_winston.format.printf((info) => {
|
|
2778
|
-
const { timestamp, level: level2, message, context, correlationId, trace } = info;
|
|
3279
|
+
const { timestamp: timestamp2, level: level2, message, context, correlationId, trace } = info;
|
|
2779
3280
|
const parts = [
|
|
2780
|
-
|
|
3281
|
+
timestamp2,
|
|
2781
3282
|
level2.toUpperCase().padEnd(7),
|
|
2782
3283
|
correlationId ? `[${correlationId.toString().slice(-6)}]` : "",
|
|
2783
3284
|
context ? `[${context}]` : "",
|
|
@@ -2927,35 +3428,35 @@ ${trace}`;
|
|
|
2927
3428
|
return childLogger;
|
|
2928
3429
|
}
|
|
2929
3430
|
};
|
|
2930
|
-
LoggerService =
|
|
2931
|
-
(0,
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3431
|
+
LoggerService = _ts_decorate19([
|
|
3432
|
+
(0, import_common48.Injectable)(),
|
|
3433
|
+
_ts_param5(0, (0, import_common48.Optional)()),
|
|
3434
|
+
_ts_param5(1, (0, import_common48.Optional)()),
|
|
3435
|
+
_ts_metadata12("design:type", Function),
|
|
3436
|
+
_ts_metadata12("design:paramtypes", [
|
|
2936
3437
|
typeof LoggerModuleOptions === "undefined" ? Object : LoggerModuleOptions,
|
|
2937
3438
|
typeof Logger === "undefined" ? Object : Logger
|
|
2938
3439
|
])
|
|
2939
3440
|
], LoggerService);
|
|
2940
3441
|
|
|
2941
3442
|
// 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,
|
|
3443
|
+
function _ts_decorate20(decorators, target, key, desc2) {
|
|
3444
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3445
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
2945
3446
|
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
3447
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2947
3448
|
}
|
|
2948
|
-
__name(
|
|
2949
|
-
function
|
|
3449
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3450
|
+
function _ts_metadata13(k, v) {
|
|
2950
3451
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2951
3452
|
}
|
|
2952
|
-
__name(
|
|
2953
|
-
function
|
|
3453
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3454
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2954
3455
|
return function(target, key) {
|
|
2955
3456
|
decorator(target, key, paramIndex);
|
|
2956
3457
|
};
|
|
2957
3458
|
}
|
|
2958
|
-
__name(
|
|
3459
|
+
__name(_ts_param6, "_ts_param");
|
|
2959
3460
|
var HttpLoggerInterceptor = class {
|
|
2960
3461
|
static {
|
|
2961
3462
|
__name(this, "HttpLoggerInterceptor");
|
|
@@ -3058,32 +3559,32 @@ var HttpLoggerInterceptor = class {
|
|
|
3058
3559
|
}
|
|
3059
3560
|
}
|
|
3060
3561
|
};
|
|
3061
|
-
HttpLoggerInterceptor =
|
|
3062
|
-
(0,
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3562
|
+
HttpLoggerInterceptor = _ts_decorate20([
|
|
3563
|
+
(0, import_common49.Injectable)(),
|
|
3564
|
+
_ts_param6(1, (0, import_common49.Optional)()),
|
|
3565
|
+
_ts_metadata13("design:type", Function),
|
|
3566
|
+
_ts_metadata13("design:paramtypes", [
|
|
3066
3567
|
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
3067
3568
|
typeof HttpLoggerOptions === "undefined" ? Object : HttpLoggerOptions
|
|
3068
3569
|
])
|
|
3069
3570
|
], HttpLoggerInterceptor);
|
|
3070
3571
|
|
|
3071
3572
|
// src/logger/logger.module.ts
|
|
3072
|
-
var
|
|
3573
|
+
var import_common51 = require("@nestjs/common");
|
|
3073
3574
|
|
|
3074
3575
|
// 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,
|
|
3576
|
+
var import_common50 = require("@nestjs/common");
|
|
3577
|
+
function _ts_decorate21(decorators, target, key, desc2) {
|
|
3578
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3579
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3079
3580
|
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
3581
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3081
3582
|
}
|
|
3082
|
-
__name(
|
|
3083
|
-
function
|
|
3583
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3584
|
+
function _ts_metadata14(k, v) {
|
|
3084
3585
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3085
3586
|
}
|
|
3086
|
-
__name(
|
|
3587
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3087
3588
|
var CorrelationIdMiddleware = class {
|
|
3088
3589
|
static {
|
|
3089
3590
|
__name(this, "CorrelationIdMiddleware");
|
|
@@ -3120,22 +3621,22 @@ var CorrelationIdMiddleware = class {
|
|
|
3120
3621
|
}
|
|
3121
3622
|
}
|
|
3122
3623
|
};
|
|
3123
|
-
CorrelationIdMiddleware =
|
|
3124
|
-
(0,
|
|
3125
|
-
|
|
3126
|
-
|
|
3624
|
+
CorrelationIdMiddleware = _ts_decorate21([
|
|
3625
|
+
(0, import_common50.Injectable)(),
|
|
3626
|
+
_ts_metadata14("design:type", Function),
|
|
3627
|
+
_ts_metadata14("design:paramtypes", [
|
|
3127
3628
|
typeof CorrelationIdMiddlewareOptions === "undefined" ? Object : CorrelationIdMiddlewareOptions
|
|
3128
3629
|
])
|
|
3129
3630
|
], CorrelationIdMiddleware);
|
|
3130
3631
|
|
|
3131
3632
|
// 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,
|
|
3633
|
+
function _ts_decorate22(decorators, target, key, desc2) {
|
|
3634
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3635
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3135
3636
|
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
3637
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3137
3638
|
}
|
|
3138
|
-
__name(
|
|
3639
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3139
3640
|
var LOGGER_MODULE_OPTIONS = Symbol("LOGGER_MODULE_OPTIONS");
|
|
3140
3641
|
var DEFAULT_LOGGER_OPTIONS = {
|
|
3141
3642
|
provider: "winston",
|
|
@@ -3212,9 +3713,9 @@ function mergeWithDefaults(options = {}) {
|
|
|
3212
3713
|
__name(mergeWithDefaults, "mergeWithDefaults");
|
|
3213
3714
|
function createDefaultLoggerProvider(options) {
|
|
3214
3715
|
return {
|
|
3215
|
-
provide:
|
|
3716
|
+
provide: import_common51.Logger,
|
|
3216
3717
|
useFactory: /* @__PURE__ */ __name(() => {
|
|
3217
|
-
const logger = new
|
|
3718
|
+
const logger = new import_common51.Logger();
|
|
3218
3719
|
if (options.level) {
|
|
3219
3720
|
const levels = getLevelsUpTo(options.level);
|
|
3220
3721
|
logger.setLogLevels?.(levels);
|
|
@@ -3244,7 +3745,7 @@ function createLoggerProviders(options = {}) {
|
|
|
3244
3745
|
inject: [
|
|
3245
3746
|
LOGGER_MODULE_OPTIONS,
|
|
3246
3747
|
{
|
|
3247
|
-
token:
|
|
3748
|
+
token: import_common51.Logger,
|
|
3248
3749
|
optional: true
|
|
3249
3750
|
}
|
|
3250
3751
|
]
|
|
@@ -3323,10 +3824,10 @@ var LoggerModule = class _LoggerModule {
|
|
|
3323
3824
|
...asyncProviders,
|
|
3324
3825
|
// Default logger provider
|
|
3325
3826
|
{
|
|
3326
|
-
provide:
|
|
3827
|
+
provide: import_common51.Logger,
|
|
3327
3828
|
useFactory: /* @__PURE__ */ __name((opts) => {
|
|
3328
3829
|
if (opts.provider === "default") {
|
|
3329
|
-
const logger = new
|
|
3830
|
+
const logger = new import_common51.Logger();
|
|
3330
3831
|
if (opts.level) {
|
|
3331
3832
|
const levels = getLevelsUpTo(opts.level);
|
|
3332
3833
|
logger.setLogLevels?.(levels);
|
|
@@ -3348,7 +3849,7 @@ var LoggerModule = class _LoggerModule {
|
|
|
3348
3849
|
inject: [
|
|
3349
3850
|
LOGGER_MODULE_OPTIONS,
|
|
3350
3851
|
{
|
|
3351
|
-
token:
|
|
3852
|
+
token: import_common51.Logger,
|
|
3352
3853
|
optional: true
|
|
3353
3854
|
}
|
|
3354
3855
|
]
|
|
@@ -3447,25 +3948,25 @@ var LoggerModule = class _LoggerModule {
|
|
|
3447
3948
|
throw new Error("LoggerModule.forRootAsync() requires one of: useFactory, useClass, or useExisting");
|
|
3448
3949
|
}
|
|
3449
3950
|
};
|
|
3450
|
-
LoggerModule =
|
|
3451
|
-
(0,
|
|
3452
|
-
(0,
|
|
3951
|
+
LoggerModule = _ts_decorate22([
|
|
3952
|
+
(0, import_common51.Global)(),
|
|
3953
|
+
(0, import_common51.Module)({})
|
|
3453
3954
|
], LoggerModule);
|
|
3454
3955
|
|
|
3455
3956
|
// src/root/root.module.ts
|
|
3456
|
-
var
|
|
3957
|
+
var import_common57 = require("@nestjs/common");
|
|
3457
3958
|
|
|
3458
3959
|
// src/root/controllers/app.controller.ts
|
|
3459
|
-
var
|
|
3460
|
-
var
|
|
3960
|
+
var import_common54 = require("@nestjs/common");
|
|
3961
|
+
var import_swagger5 = require("@nestjs/swagger");
|
|
3461
3962
|
|
|
3462
3963
|
// src/root/docs/app.docs.ts
|
|
3463
|
-
var
|
|
3464
|
-
var
|
|
3964
|
+
var import_common52 = require("@nestjs/common");
|
|
3965
|
+
var import_swagger4 = require("@nestjs/swagger");
|
|
3465
3966
|
function ApiHealthCheck() {
|
|
3466
|
-
return (0,
|
|
3967
|
+
return (0, import_common52.applyDecorators)((0, import_swagger4.ApiOperation)({
|
|
3467
3968
|
summary: "Health check endpoint"
|
|
3468
|
-
}), (0,
|
|
3969
|
+
}), (0, import_swagger4.ApiResponse)({
|
|
3469
3970
|
status: 200,
|
|
3470
3971
|
description: "Returns a welcome message indicating the API is running",
|
|
3471
3972
|
type: String
|
|
@@ -3474,14 +3975,14 @@ function ApiHealthCheck() {
|
|
|
3474
3975
|
__name(ApiHealthCheck, "ApiHealthCheck");
|
|
3475
3976
|
|
|
3476
3977
|
// 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,
|
|
3978
|
+
var import_common53 = require("@nestjs/common");
|
|
3979
|
+
function _ts_decorate23(decorators, target, key, desc2) {
|
|
3980
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3981
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3481
3982
|
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
3983
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3483
3984
|
}
|
|
3484
|
-
__name(
|
|
3985
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3485
3986
|
var AppService = class {
|
|
3486
3987
|
static {
|
|
3487
3988
|
__name(this, "AppService");
|
|
@@ -3491,22 +3992,22 @@ var AppService = class {
|
|
|
3491
3992
|
return `Hello World!`;
|
|
3492
3993
|
}
|
|
3493
3994
|
};
|
|
3494
|
-
AppService =
|
|
3495
|
-
(0,
|
|
3995
|
+
AppService = _ts_decorate23([
|
|
3996
|
+
(0, import_common53.Injectable)()
|
|
3496
3997
|
], AppService);
|
|
3497
3998
|
|
|
3498
3999
|
// 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,
|
|
4000
|
+
function _ts_decorate24(decorators, target, key, desc2) {
|
|
4001
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4002
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3502
4003
|
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
4004
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3504
4005
|
}
|
|
3505
|
-
__name(
|
|
3506
|
-
function
|
|
4006
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4007
|
+
function _ts_metadata15(k, v) {
|
|
3507
4008
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3508
4009
|
}
|
|
3509
|
-
__name(
|
|
4010
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3510
4011
|
var AppController = class {
|
|
3511
4012
|
static {
|
|
3512
4013
|
__name(this, "AppController");
|
|
@@ -3520,35 +4021,35 @@ var AppController = class {
|
|
|
3520
4021
|
return this.appService.getHello();
|
|
3521
4022
|
}
|
|
3522
4023
|
};
|
|
3523
|
-
|
|
3524
|
-
(0,
|
|
4024
|
+
_ts_decorate24([
|
|
4025
|
+
(0, import_common54.Get)(),
|
|
3525
4026
|
Public(),
|
|
3526
4027
|
ApiHealthCheck(),
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
4028
|
+
_ts_metadata15("design:type", Function),
|
|
4029
|
+
_ts_metadata15("design:paramtypes", []),
|
|
4030
|
+
_ts_metadata15("design:returntype", String)
|
|
3530
4031
|
], AppController.prototype, "getHello", null);
|
|
3531
|
-
AppController =
|
|
3532
|
-
(0,
|
|
3533
|
-
(0,
|
|
3534
|
-
|
|
3535
|
-
|
|
4032
|
+
AppController = _ts_decorate24([
|
|
4033
|
+
(0, import_swagger5.ApiTags)("Health"),
|
|
4034
|
+
(0, import_common54.Controller)(),
|
|
4035
|
+
_ts_metadata15("design:type", Function),
|
|
4036
|
+
_ts_metadata15("design:paramtypes", [
|
|
3536
4037
|
typeof AppService === "undefined" ? Object : AppService
|
|
3537
4038
|
])
|
|
3538
4039
|
], AppController);
|
|
3539
4040
|
|
|
3540
4041
|
// src/root/controllers/csrf.controller.ts
|
|
3541
|
-
var
|
|
3542
|
-
var
|
|
4042
|
+
var import_common56 = require("@nestjs/common");
|
|
4043
|
+
var import_swagger7 = require("@nestjs/swagger");
|
|
3543
4044
|
|
|
3544
4045
|
// src/root/docs/csrf.docs.ts
|
|
3545
|
-
var
|
|
3546
|
-
var
|
|
4046
|
+
var import_common55 = require("@nestjs/common");
|
|
4047
|
+
var import_swagger6 = require("@nestjs/swagger");
|
|
3547
4048
|
function ApiGetCsrfToken() {
|
|
3548
|
-
return (0,
|
|
4049
|
+
return (0, import_common55.applyDecorators)((0, import_swagger6.ApiOperation)({
|
|
3549
4050
|
summary: "Get CSRF token",
|
|
3550
4051
|
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,
|
|
4052
|
+
}), (0, import_swagger6.ApiResponse)({
|
|
3552
4053
|
status: 200,
|
|
3553
4054
|
description: "CSRF token generated successfully",
|
|
3554
4055
|
schema: {
|
|
@@ -3569,23 +4070,23 @@ function ApiGetCsrfToken() {
|
|
|
3569
4070
|
__name(ApiGetCsrfToken, "ApiGetCsrfToken");
|
|
3570
4071
|
|
|
3571
4072
|
// 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,
|
|
4073
|
+
function _ts_decorate25(decorators, target, key, desc2) {
|
|
4074
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4075
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3575
4076
|
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
4077
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3577
4078
|
}
|
|
3578
|
-
__name(
|
|
3579
|
-
function
|
|
4079
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4080
|
+
function _ts_metadata16(k, v) {
|
|
3580
4081
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
3581
4082
|
}
|
|
3582
|
-
__name(
|
|
3583
|
-
function
|
|
4083
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
4084
|
+
function _ts_param7(paramIndex, decorator) {
|
|
3584
4085
|
return function(target, key) {
|
|
3585
4086
|
decorator(target, key, paramIndex);
|
|
3586
4087
|
};
|
|
3587
4088
|
}
|
|
3588
|
-
__name(
|
|
4089
|
+
__name(_ts_param7, "_ts_param");
|
|
3589
4090
|
var CsrfController = class {
|
|
3590
4091
|
static {
|
|
3591
4092
|
__name(this, "CsrfController");
|
|
@@ -3598,40 +4099,40 @@ var CsrfController = class {
|
|
|
3598
4099
|
};
|
|
3599
4100
|
}
|
|
3600
4101
|
};
|
|
3601
|
-
|
|
3602
|
-
(0,
|
|
4102
|
+
_ts_decorate25([
|
|
4103
|
+
(0, import_common56.Get)("token"),
|
|
3603
4104
|
Public(),
|
|
3604
|
-
(0,
|
|
4105
|
+
(0, import_common56.HttpCode)(import_common56.HttpStatus.OK),
|
|
3605
4106
|
ApiGetCsrfToken(),
|
|
3606
|
-
|
|
4107
|
+
_ts_param7(0, (0, import_common56.Res)({
|
|
3607
4108
|
passthrough: true
|
|
3608
4109
|
})),
|
|
3609
|
-
|
|
3610
|
-
|
|
4110
|
+
_ts_metadata16("design:type", Function),
|
|
4111
|
+
_ts_metadata16("design:paramtypes", [
|
|
3611
4112
|
typeof FastifyReply === "undefined" ? Object : FastifyReply
|
|
3612
4113
|
]),
|
|
3613
|
-
|
|
4114
|
+
_ts_metadata16("design:returntype", Object)
|
|
3614
4115
|
], CsrfController.prototype, "getToken", null);
|
|
3615
|
-
CsrfController =
|
|
3616
|
-
(0,
|
|
3617
|
-
(0,
|
|
4116
|
+
CsrfController = _ts_decorate25([
|
|
4117
|
+
(0, import_swagger7.ApiTags)("CSRF"),
|
|
4118
|
+
(0, import_common56.Controller)("csrf")
|
|
3618
4119
|
], CsrfController);
|
|
3619
4120
|
|
|
3620
4121
|
// 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,
|
|
4122
|
+
function _ts_decorate26(decorators, target, key, desc2) {
|
|
4123
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4124
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
3624
4125
|
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
4126
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3626
4127
|
}
|
|
3627
|
-
__name(
|
|
4128
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
3628
4129
|
var RootModule = class {
|
|
3629
4130
|
static {
|
|
3630
4131
|
__name(this, "RootModule");
|
|
3631
4132
|
}
|
|
3632
4133
|
};
|
|
3633
|
-
RootModule =
|
|
3634
|
-
(0,
|
|
4134
|
+
RootModule = _ts_decorate26([
|
|
4135
|
+
(0, import_common57.Module)({
|
|
3635
4136
|
controllers: [
|
|
3636
4137
|
AppController,
|
|
3637
4138
|
CsrfController
|
|
@@ -3851,18 +4352,1087 @@ function normalizePhoneNumber(phone) {
|
|
|
3851
4352
|
return phone.startsWith("+") ? phone : `+${phone}`;
|
|
3852
4353
|
}
|
|
3853
4354
|
__name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
4355
|
+
|
|
4356
|
+
// src/data-table/data-table.module.ts
|
|
4357
|
+
var import_common65 = require("@nestjs/common");
|
|
4358
|
+
var import_config14 = require("@nestjs/config");
|
|
4359
|
+
|
|
4360
|
+
// src/data-table/data-table.constants.ts
|
|
4361
|
+
var DATA_TABLE_VIEWS_TABLE = Symbol("DATA_TABLE_VIEWS_TABLE");
|
|
4362
|
+
|
|
4363
|
+
// src/data-table/state/controllers/data-table-state.controller.ts
|
|
4364
|
+
var import_common60 = require("@nestjs/common");
|
|
4365
|
+
var import_swagger10 = require("@nestjs/swagger");
|
|
4366
|
+
|
|
4367
|
+
// src/data-table/state/docs/data-table-state.docs.ts
|
|
4368
|
+
var import_common58 = require("@nestjs/common");
|
|
4369
|
+
var import_swagger9 = require("@nestjs/swagger");
|
|
4370
|
+
|
|
4371
|
+
// src/data-table/state/dto/request/upsert-data-table-state.dto.ts
|
|
4372
|
+
var import_swagger8 = require("@nestjs/swagger");
|
|
4373
|
+
var import_class_validator3 = require("class-validator");
|
|
4374
|
+
function _ts_decorate27(decorators, target, key, desc2) {
|
|
4375
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4376
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4377
|
+
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;
|
|
4378
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4379
|
+
}
|
|
4380
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
4381
|
+
function _ts_metadata17(k, v) {
|
|
4382
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4383
|
+
}
|
|
4384
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4385
|
+
var UpsertDataTableStateDto = class {
|
|
4386
|
+
static {
|
|
4387
|
+
__name(this, "UpsertDataTableStateDto");
|
|
4388
|
+
}
|
|
4389
|
+
tableSlug;
|
|
4390
|
+
state;
|
|
4391
|
+
activeViewId;
|
|
4392
|
+
};
|
|
4393
|
+
_ts_decorate27([
|
|
4394
|
+
(0, import_swagger8.ApiProperty)({
|
|
4395
|
+
description: "Unique slug identifying the table",
|
|
4396
|
+
example: "cloud-providers"
|
|
4397
|
+
}),
|
|
4398
|
+
(0, import_class_validator3.IsString)(),
|
|
4399
|
+
(0, import_class_validator3.MaxLength)(100),
|
|
4400
|
+
_ts_metadata17("design:type", String)
|
|
4401
|
+
], UpsertDataTableStateDto.prototype, "tableSlug", void 0);
|
|
4402
|
+
_ts_decorate27([
|
|
4403
|
+
(0, import_swagger8.ApiProperty)({
|
|
4404
|
+
description: "Full table view state including filters, sort, and column visibility"
|
|
4405
|
+
}),
|
|
4406
|
+
(0, import_class_validator3.IsObject)(),
|
|
4407
|
+
_ts_metadata17("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
4408
|
+
], UpsertDataTableStateDto.prototype, "state", void 0);
|
|
4409
|
+
_ts_decorate27([
|
|
4410
|
+
(0, import_swagger8.ApiPropertyOptional)(),
|
|
4411
|
+
(0, import_class_validator3.IsOptional)(),
|
|
4412
|
+
(0, import_class_validator3.IsUUID)(),
|
|
4413
|
+
_ts_metadata17("design:type", Object)
|
|
4414
|
+
], UpsertDataTableStateDto.prototype, "activeViewId", void 0);
|
|
4415
|
+
|
|
4416
|
+
// src/data-table/state/docs/data-table-state.docs.ts
|
|
4417
|
+
function ApiUpsertDataTableState() {
|
|
4418
|
+
return (0, import_common58.applyDecorators)((0, import_swagger9.ApiOperation)({
|
|
4419
|
+
summary: "Save live table state",
|
|
4420
|
+
description: "Stores the current filter, sort, and column visibility state in Redis cache. Called on filter Apply and sort column click. State expires after TABLE_STATE_CACHE_TTL seconds."
|
|
4421
|
+
}), (0, import_swagger9.ApiBody)({
|
|
4422
|
+
type: UpsertDataTableStateDto
|
|
4423
|
+
}), (0, import_swagger9.ApiResponse)({
|
|
4424
|
+
status: 200,
|
|
4425
|
+
description: "Live state cached."
|
|
4426
|
+
}), (0, import_swagger9.ApiResponse)({
|
|
4427
|
+
status: 400,
|
|
4428
|
+
description: "Invalid request body."
|
|
4429
|
+
}), (0, import_swagger9.ApiResponse)({
|
|
4430
|
+
status: 401,
|
|
4431
|
+
description: "Unauthorized."
|
|
4432
|
+
}));
|
|
4433
|
+
}
|
|
4434
|
+
__name(ApiUpsertDataTableState, "ApiUpsertDataTableState");
|
|
4435
|
+
|
|
4436
|
+
// src/data-table/state/services/data-table-state.service.ts
|
|
4437
|
+
var import_common59 = require("@nestjs/common");
|
|
4438
|
+
var import_config12 = require("@nestjs/config");
|
|
4439
|
+
function _ts_decorate28(decorators, target, key, desc2) {
|
|
4440
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4441
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4442
|
+
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;
|
|
4443
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4444
|
+
}
|
|
4445
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4446
|
+
function _ts_metadata18(k, v) {
|
|
4447
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4448
|
+
}
|
|
4449
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4450
|
+
var EMPTY_TABLE_STATE = {
|
|
4451
|
+
filters: [],
|
|
4452
|
+
sort: [],
|
|
4453
|
+
columnVisibility: {},
|
|
4454
|
+
columnOrder: [],
|
|
4455
|
+
columnSizing: {},
|
|
4456
|
+
columnPinning: {
|
|
4457
|
+
left: [],
|
|
4458
|
+
right: []
|
|
4459
|
+
},
|
|
4460
|
+
lockedColumnSizing: false,
|
|
4461
|
+
density: "normal",
|
|
4462
|
+
filterOrder: [],
|
|
4463
|
+
filterVisibility: {},
|
|
4464
|
+
pagination: {
|
|
4465
|
+
limit: 20,
|
|
4466
|
+
offset: 0
|
|
4467
|
+
}
|
|
4468
|
+
};
|
|
4469
|
+
var DataTableStateService = class _DataTableStateService {
|
|
4470
|
+
static {
|
|
4471
|
+
__name(this, "DataTableStateService");
|
|
4472
|
+
}
|
|
4473
|
+
cacheService;
|
|
4474
|
+
configService;
|
|
4475
|
+
logger = new import_common59.Logger(_DataTableStateService.name);
|
|
4476
|
+
constructor(cacheService, configService) {
|
|
4477
|
+
this.cacheService = cacheService;
|
|
4478
|
+
this.configService = configService;
|
|
4479
|
+
}
|
|
4480
|
+
// Returns configured TTL for live table state in seconds, defaulting to 3600 (1h)
|
|
4481
|
+
get stateTtl() {
|
|
4482
|
+
return this.configService.get("TABLE_STATE_CACHE_TTL") ?? 3600;
|
|
4483
|
+
}
|
|
4484
|
+
// Saves live table state and active view ID to Redis; DB is not written
|
|
4485
|
+
async upsertCurrentState(userId, dto) {
|
|
4486
|
+
const key = `dt:${userId}:${dto.tableSlug}`;
|
|
4487
|
+
await this.cacheService.set(key, {
|
|
4488
|
+
state: dto.state,
|
|
4489
|
+
activeViewId: dto.activeViewId ?? null
|
|
4490
|
+
}, this.stateTtl);
|
|
4491
|
+
this.logger.log(`Cached live state for user: ${userId}, table: ${dto.tableSlug}`);
|
|
4492
|
+
}
|
|
4493
|
+
// Returns live table state and active view ID from Redis; returns empty state on miss — no DB query
|
|
4494
|
+
async getCurrentState(userId, tableSlug) {
|
|
4495
|
+
const key = `dt:${userId}:${tableSlug}`;
|
|
4496
|
+
const cached = await this.cacheService.get(key);
|
|
4497
|
+
return cached ?? {
|
|
4498
|
+
state: EMPTY_TABLE_STATE,
|
|
4499
|
+
activeViewId: null
|
|
4500
|
+
};
|
|
4501
|
+
}
|
|
4502
|
+
};
|
|
4503
|
+
DataTableStateService = _ts_decorate28([
|
|
4504
|
+
(0, import_common59.Injectable)(),
|
|
4505
|
+
_ts_metadata18("design:type", Function),
|
|
4506
|
+
_ts_metadata18("design:paramtypes", [
|
|
4507
|
+
typeof CacheService === "undefined" ? Object : CacheService,
|
|
4508
|
+
typeof import_config12.ConfigService === "undefined" ? Object : import_config12.ConfigService
|
|
4509
|
+
])
|
|
4510
|
+
], DataTableStateService);
|
|
4511
|
+
|
|
4512
|
+
// src/data-table/state/controllers/data-table-state.controller.ts
|
|
4513
|
+
function _ts_decorate29(decorators, target, key, desc2) {
|
|
4514
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4515
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4516
|
+
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;
|
|
4517
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4518
|
+
}
|
|
4519
|
+
__name(_ts_decorate29, "_ts_decorate");
|
|
4520
|
+
function _ts_metadata19(k, v) {
|
|
4521
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4522
|
+
}
|
|
4523
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
4524
|
+
function _ts_param8(paramIndex, decorator) {
|
|
4525
|
+
return function(target, key) {
|
|
4526
|
+
decorator(target, key, paramIndex);
|
|
4527
|
+
};
|
|
4528
|
+
}
|
|
4529
|
+
__name(_ts_param8, "_ts_param");
|
|
4530
|
+
var DataTableStateController = class _DataTableStateController {
|
|
4531
|
+
static {
|
|
4532
|
+
__name(this, "DataTableStateController");
|
|
4533
|
+
}
|
|
4534
|
+
dataTableStateService;
|
|
4535
|
+
logger = new import_common60.Logger(_DataTableStateController.name);
|
|
4536
|
+
constructor(dataTableStateService) {
|
|
4537
|
+
this.dataTableStateService = dataTableStateService;
|
|
4538
|
+
}
|
|
4539
|
+
// Saves live table state to Redis cache for the authenticated user's table
|
|
4540
|
+
upsertCurrentState(userId, dto) {
|
|
4541
|
+
this.logger.log(`POST /table-states - User: ${userId}, table: ${dto.tableSlug}`);
|
|
4542
|
+
return this.dataTableStateService.upsertCurrentState(userId, dto);
|
|
4543
|
+
}
|
|
4544
|
+
};
|
|
4545
|
+
_ts_decorate29([
|
|
4546
|
+
(0, import_common60.Post)(),
|
|
4547
|
+
(0, import_common60.HttpCode)(import_common60.HttpStatus.OK),
|
|
4548
|
+
ApiUpsertDataTableState(),
|
|
4549
|
+
_ts_param8(0, UserId()),
|
|
4550
|
+
_ts_param8(1, (0, import_common60.Body)()),
|
|
4551
|
+
_ts_metadata19("design:type", Function),
|
|
4552
|
+
_ts_metadata19("design:paramtypes", [
|
|
4553
|
+
String,
|
|
4554
|
+
typeof UpsertDataTableStateDto === "undefined" ? Object : UpsertDataTableStateDto
|
|
4555
|
+
]),
|
|
4556
|
+
_ts_metadata19("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
4557
|
+
], DataTableStateController.prototype, "upsertCurrentState", null);
|
|
4558
|
+
DataTableStateController = _ts_decorate29([
|
|
4559
|
+
(0, import_swagger10.ApiTags)("Table States"),
|
|
4560
|
+
(0, import_swagger10.ApiBearerAuth)(),
|
|
4561
|
+
(0, import_common60.Controller)("table-states"),
|
|
4562
|
+
_ts_metadata19("design:type", Function),
|
|
4563
|
+
_ts_metadata19("design:paramtypes", [
|
|
4564
|
+
typeof DataTableStateService === "undefined" ? Object : DataTableStateService
|
|
4565
|
+
])
|
|
4566
|
+
], DataTableStateController);
|
|
4567
|
+
|
|
4568
|
+
// src/data-table/views/controllers/data-table-views.controller.ts
|
|
4569
|
+
var import_common64 = require("@nestjs/common");
|
|
4570
|
+
var import_swagger17 = require("@nestjs/swagger");
|
|
4571
|
+
|
|
4572
|
+
// src/data-table/views/docs/data-table-views.docs.ts
|
|
4573
|
+
var import_common61 = require("@nestjs/common");
|
|
4574
|
+
var import_swagger16 = require("@nestjs/swagger");
|
|
4575
|
+
|
|
4576
|
+
// src/data-table/views/dto/entity/data-table-view.dto.ts
|
|
4577
|
+
var import_swagger11 = require("@nestjs/swagger");
|
|
4578
|
+
function _ts_decorate30(decorators, target, key, desc2) {
|
|
4579
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4580
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4581
|
+
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;
|
|
4582
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4583
|
+
}
|
|
4584
|
+
__name(_ts_decorate30, "_ts_decorate");
|
|
4585
|
+
function _ts_metadata20(k, v) {
|
|
4586
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4587
|
+
}
|
|
4588
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
4589
|
+
var DataTableViewDto = class _DataTableViewDto {
|
|
4590
|
+
static {
|
|
4591
|
+
__name(this, "DataTableViewDto");
|
|
4592
|
+
}
|
|
4593
|
+
id;
|
|
4594
|
+
name;
|
|
4595
|
+
tableSlug;
|
|
4596
|
+
state;
|
|
4597
|
+
isShared;
|
|
4598
|
+
isOwn;
|
|
4599
|
+
createdAt;
|
|
4600
|
+
updatedAt;
|
|
4601
|
+
// Creates a response DTO from a DataTableView entity, computing isOwn by comparing userId
|
|
4602
|
+
static from(view, userId) {
|
|
4603
|
+
const dto = new _DataTableViewDto();
|
|
4604
|
+
dto.id = view.id;
|
|
4605
|
+
dto.name = view.name ?? null;
|
|
4606
|
+
dto.tableSlug = view.tableSlug;
|
|
4607
|
+
dto.state = view.state;
|
|
4608
|
+
dto.isShared = view.isShared;
|
|
4609
|
+
dto.isOwn = view.userId === userId;
|
|
4610
|
+
dto.createdAt = view.createdAt;
|
|
4611
|
+
dto.updatedAt = view.updatedAt ?? null;
|
|
4612
|
+
return dto;
|
|
4613
|
+
}
|
|
4614
|
+
};
|
|
4615
|
+
_ts_decorate30([
|
|
4616
|
+
(0, import_swagger11.ApiProperty)({
|
|
4617
|
+
description: "View unique identifier"
|
|
4618
|
+
}),
|
|
4619
|
+
_ts_metadata20("design:type", String)
|
|
4620
|
+
], DataTableViewDto.prototype, "id", void 0);
|
|
4621
|
+
_ts_decorate30([
|
|
4622
|
+
(0, import_swagger11.ApiPropertyOptional)({
|
|
4623
|
+
description: "Display name of the view",
|
|
4624
|
+
nullable: true
|
|
4625
|
+
}),
|
|
4626
|
+
_ts_metadata20("design:type", Object)
|
|
4627
|
+
], DataTableViewDto.prototype, "name", void 0);
|
|
4628
|
+
_ts_decorate30([
|
|
4629
|
+
(0, import_swagger11.ApiProperty)({
|
|
4630
|
+
description: "Slug of the table this view belongs to",
|
|
4631
|
+
example: "cloud-providers"
|
|
4632
|
+
}),
|
|
4633
|
+
_ts_metadata20("design:type", String)
|
|
4634
|
+
], DataTableViewDto.prototype, "tableSlug", void 0);
|
|
4635
|
+
_ts_decorate30([
|
|
4636
|
+
(0, import_swagger11.ApiProperty)({
|
|
4637
|
+
description: "Stored filter, sort, and column visibility state"
|
|
4638
|
+
}),
|
|
4639
|
+
_ts_metadata20("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
4640
|
+
], DataTableViewDto.prototype, "state", void 0);
|
|
4641
|
+
_ts_decorate30([
|
|
4642
|
+
(0, import_swagger11.ApiProperty)({
|
|
4643
|
+
description: "Whether the view is visible to all users",
|
|
4644
|
+
example: false
|
|
4645
|
+
}),
|
|
4646
|
+
_ts_metadata20("design:type", Boolean)
|
|
4647
|
+
], DataTableViewDto.prototype, "isShared", void 0);
|
|
4648
|
+
_ts_decorate30([
|
|
4649
|
+
(0, import_swagger11.ApiProperty)({
|
|
4650
|
+
description: "Whether the requesting user owns this view",
|
|
4651
|
+
example: true
|
|
4652
|
+
}),
|
|
4653
|
+
_ts_metadata20("design:type", Boolean)
|
|
4654
|
+
], DataTableViewDto.prototype, "isOwn", void 0);
|
|
4655
|
+
_ts_decorate30([
|
|
4656
|
+
(0, import_swagger11.ApiProperty)({
|
|
4657
|
+
description: "Creation timestamp"
|
|
4658
|
+
}),
|
|
4659
|
+
_ts_metadata20("design:type", typeof Date === "undefined" ? Object : Date)
|
|
4660
|
+
], DataTableViewDto.prototype, "createdAt", void 0);
|
|
4661
|
+
_ts_decorate30([
|
|
4662
|
+
(0, import_swagger11.ApiPropertyOptional)({
|
|
4663
|
+
description: "Last updated timestamp",
|
|
4664
|
+
nullable: true
|
|
4665
|
+
}),
|
|
4666
|
+
_ts_metadata20("design:type", Object)
|
|
4667
|
+
], DataTableViewDto.prototype, "updatedAt", void 0);
|
|
4668
|
+
|
|
4669
|
+
// src/data-table/views/dto/request/create-data-table-view.dto.ts
|
|
4670
|
+
var import_swagger12 = require("@nestjs/swagger");
|
|
4671
|
+
var import_class_validator4 = require("class-validator");
|
|
4672
|
+
function _ts_decorate31(decorators, target, key, desc2) {
|
|
4673
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4674
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4675
|
+
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;
|
|
4676
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4677
|
+
}
|
|
4678
|
+
__name(_ts_decorate31, "_ts_decorate");
|
|
4679
|
+
function _ts_metadata21(k, v) {
|
|
4680
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4681
|
+
}
|
|
4682
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4683
|
+
var CreateDataTableViewDto = class {
|
|
4684
|
+
static {
|
|
4685
|
+
__name(this, "CreateDataTableViewDto");
|
|
4686
|
+
}
|
|
4687
|
+
name;
|
|
4688
|
+
tableSlug;
|
|
4689
|
+
state;
|
|
4690
|
+
isShared;
|
|
4691
|
+
};
|
|
4692
|
+
_ts_decorate31([
|
|
4693
|
+
(0, import_swagger12.ApiProperty)({
|
|
4694
|
+
description: "Display name for the saved view",
|
|
4695
|
+
example: "AWS Only"
|
|
4696
|
+
}),
|
|
4697
|
+
(0, import_class_validator4.IsString)(),
|
|
4698
|
+
(0, import_class_validator4.MaxLength)(100),
|
|
4699
|
+
_ts_metadata21("design:type", String)
|
|
4700
|
+
], CreateDataTableViewDto.prototype, "name", void 0);
|
|
4701
|
+
_ts_decorate31([
|
|
4702
|
+
(0, import_swagger12.ApiProperty)({
|
|
4703
|
+
description: "Unique slug identifying the table",
|
|
4704
|
+
example: "cloud-providers"
|
|
4705
|
+
}),
|
|
4706
|
+
(0, import_class_validator4.IsString)(),
|
|
4707
|
+
(0, import_class_validator4.MaxLength)(100),
|
|
4708
|
+
_ts_metadata21("design:type", String)
|
|
4709
|
+
], CreateDataTableViewDto.prototype, "tableSlug", void 0);
|
|
4710
|
+
_ts_decorate31([
|
|
4711
|
+
(0, import_swagger12.ApiProperty)({
|
|
4712
|
+
description: "Full table view state including filters, sort, and column visibility"
|
|
4713
|
+
}),
|
|
4714
|
+
(0, import_class_validator4.IsObject)(),
|
|
4715
|
+
_ts_metadata21("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
4716
|
+
], CreateDataTableViewDto.prototype, "state", void 0);
|
|
4717
|
+
_ts_decorate31([
|
|
4718
|
+
(0, import_swagger12.ApiPropertyOptional)({
|
|
4719
|
+
description: "Whether this view is visible to all users",
|
|
4720
|
+
example: false
|
|
4721
|
+
}),
|
|
4722
|
+
(0, import_class_validator4.IsBoolean)(),
|
|
4723
|
+
(0, import_class_validator4.IsOptional)(),
|
|
4724
|
+
_ts_metadata21("design:type", Boolean)
|
|
4725
|
+
], CreateDataTableViewDto.prototype, "isShared", void 0);
|
|
4726
|
+
|
|
4727
|
+
// src/data-table/views/dto/request/rename-data-table-view.dto.ts
|
|
4728
|
+
var import_swagger13 = require("@nestjs/swagger");
|
|
4729
|
+
var import_class_validator5 = require("class-validator");
|
|
4730
|
+
function _ts_decorate32(decorators, target, key, desc2) {
|
|
4731
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4732
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4733
|
+
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;
|
|
4734
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4735
|
+
}
|
|
4736
|
+
__name(_ts_decorate32, "_ts_decorate");
|
|
4737
|
+
function _ts_metadata22(k, v) {
|
|
4738
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4739
|
+
}
|
|
4740
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
4741
|
+
var RenameDataTableViewDto = class {
|
|
4742
|
+
static {
|
|
4743
|
+
__name(this, "RenameDataTableViewDto");
|
|
4744
|
+
}
|
|
4745
|
+
name;
|
|
4746
|
+
};
|
|
4747
|
+
_ts_decorate32([
|
|
4748
|
+
(0, import_swagger13.ApiProperty)({
|
|
4749
|
+
description: "New display name for the view",
|
|
4750
|
+
example: "AWS Only"
|
|
4751
|
+
}),
|
|
4752
|
+
(0, import_class_validator5.IsString)(),
|
|
4753
|
+
(0, import_class_validator5.MinLength)(1),
|
|
4754
|
+
(0, import_class_validator5.MaxLength)(100),
|
|
4755
|
+
_ts_metadata22("design:type", String)
|
|
4756
|
+
], RenameDataTableViewDto.prototype, "name", void 0);
|
|
4757
|
+
|
|
4758
|
+
// src/data-table/views/dto/request/toggle-share-data-table-view.dto.ts
|
|
4759
|
+
var import_swagger14 = require("@nestjs/swagger");
|
|
4760
|
+
var import_class_validator6 = require("class-validator");
|
|
4761
|
+
function _ts_decorate33(decorators, target, key, desc2) {
|
|
4762
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4763
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4764
|
+
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;
|
|
4765
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4766
|
+
}
|
|
4767
|
+
__name(_ts_decorate33, "_ts_decorate");
|
|
4768
|
+
function _ts_metadata23(k, v) {
|
|
4769
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4770
|
+
}
|
|
4771
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4772
|
+
var ToggleShareDataTableViewDto = class {
|
|
4773
|
+
static {
|
|
4774
|
+
__name(this, "ToggleShareDataTableViewDto");
|
|
4775
|
+
}
|
|
4776
|
+
isShared;
|
|
4777
|
+
};
|
|
4778
|
+
_ts_decorate33([
|
|
4779
|
+
(0, import_swagger14.ApiProperty)({
|
|
4780
|
+
description: "Whether the view should be visible to all users",
|
|
4781
|
+
example: true
|
|
4782
|
+
}),
|
|
4783
|
+
(0, import_class_validator6.IsBoolean)(),
|
|
4784
|
+
_ts_metadata23("design:type", Boolean)
|
|
4785
|
+
], ToggleShareDataTableViewDto.prototype, "isShared", void 0);
|
|
4786
|
+
|
|
4787
|
+
// src/data-table/views/dto/request/update-data-table-view.dto.ts
|
|
4788
|
+
var import_swagger15 = require("@nestjs/swagger");
|
|
4789
|
+
var import_class_validator7 = require("class-validator");
|
|
4790
|
+
function _ts_decorate34(decorators, target, key, desc2) {
|
|
4791
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4792
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4793
|
+
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;
|
|
4794
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4795
|
+
}
|
|
4796
|
+
__name(_ts_decorate34, "_ts_decorate");
|
|
4797
|
+
function _ts_metadata24(k, v) {
|
|
4798
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4799
|
+
}
|
|
4800
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4801
|
+
var UpdateDataTableViewDto = class {
|
|
4802
|
+
static {
|
|
4803
|
+
__name(this, "UpdateDataTableViewDto");
|
|
4804
|
+
}
|
|
4805
|
+
state;
|
|
4806
|
+
};
|
|
4807
|
+
_ts_decorate34([
|
|
4808
|
+
(0, import_swagger15.ApiProperty)({
|
|
4809
|
+
description: "Updated filter, sort, and column visibility state"
|
|
4810
|
+
}),
|
|
4811
|
+
(0, import_class_validator7.IsObject)(),
|
|
4812
|
+
_ts_metadata24("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
4813
|
+
], UpdateDataTableViewDto.prototype, "state", void 0);
|
|
4814
|
+
|
|
4815
|
+
// src/data-table/views/docs/data-table-views.docs.ts
|
|
4816
|
+
function ApiListDataTableViews() {
|
|
4817
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4818
|
+
summary: "List named table views",
|
|
4819
|
+
description: "Returns the authenticated user's own named views plus all shared views for the given table slug."
|
|
4820
|
+
}), (0, import_swagger16.ApiQuery)({
|
|
4821
|
+
name: "tableSlug",
|
|
4822
|
+
description: "Slug of the table to fetch views for",
|
|
4823
|
+
example: "cloud-providers",
|
|
4824
|
+
required: true
|
|
4825
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4826
|
+
status: 200,
|
|
4827
|
+
description: "Named views retrieved.",
|
|
4828
|
+
type: [
|
|
4829
|
+
DataTableViewDto
|
|
4830
|
+
]
|
|
4831
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4832
|
+
status: 401,
|
|
4833
|
+
description: "Unauthorized."
|
|
4834
|
+
}));
|
|
4835
|
+
}
|
|
4836
|
+
__name(ApiListDataTableViews, "ApiListDataTableViews");
|
|
4837
|
+
function ApiCreateDataTableView() {
|
|
4838
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4839
|
+
summary: "Create named table view",
|
|
4840
|
+
description: "Saves the current table state as a named view snapshot. The name must be unique per user+table."
|
|
4841
|
+
}), (0, import_swagger16.ApiBody)({
|
|
4842
|
+
type: CreateDataTableViewDto
|
|
4843
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4844
|
+
status: 201,
|
|
4845
|
+
description: "Named view created.",
|
|
4846
|
+
type: DataTableViewDto
|
|
4847
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4848
|
+
status: 400,
|
|
4849
|
+
description: "Invalid request body."
|
|
4850
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4851
|
+
status: 401,
|
|
4852
|
+
description: "Unauthorized."
|
|
4853
|
+
}));
|
|
4854
|
+
}
|
|
4855
|
+
__name(ApiCreateDataTableView, "ApiCreateDataTableView");
|
|
4856
|
+
function ApiUpdateDataTableView() {
|
|
4857
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4858
|
+
summary: "Update named table view",
|
|
4859
|
+
description: "Updates the state of an existing named view. Only the owner can update."
|
|
4860
|
+
}), (0, import_swagger16.ApiParam)({
|
|
4861
|
+
name: "id",
|
|
4862
|
+
description: "UUID of the table view to update"
|
|
4863
|
+
}), (0, import_swagger16.ApiBody)({
|
|
4864
|
+
type: UpdateDataTableViewDto
|
|
4865
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4866
|
+
status: 200,
|
|
4867
|
+
description: "View updated.",
|
|
4868
|
+
type: DataTableViewDto
|
|
4869
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4870
|
+
status: 400,
|
|
4871
|
+
description: "Validation failed or not owned by caller."
|
|
4872
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4873
|
+
status: 401,
|
|
4874
|
+
description: "Unauthorized."
|
|
4875
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4876
|
+
status: 404,
|
|
4877
|
+
description: "View not found."
|
|
4878
|
+
}));
|
|
4879
|
+
}
|
|
4880
|
+
__name(ApiUpdateDataTableView, "ApiUpdateDataTableView");
|
|
4881
|
+
function ApiRenameDataTableView() {
|
|
4882
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4883
|
+
summary: "Rename a named table view",
|
|
4884
|
+
description: "Updates the display name of an existing view. The new name must be unique per user+table. Only the owner can rename."
|
|
4885
|
+
}), (0, import_swagger16.ApiParam)({
|
|
4886
|
+
name: "id",
|
|
4887
|
+
description: "UUID of the table view to rename"
|
|
4888
|
+
}), (0, import_swagger16.ApiBody)({
|
|
4889
|
+
type: RenameDataTableViewDto
|
|
4890
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4891
|
+
status: 200,
|
|
4892
|
+
description: "View renamed.",
|
|
4893
|
+
type: DataTableViewDto
|
|
4894
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4895
|
+
status: 400,
|
|
4896
|
+
description: "Not owned by caller."
|
|
4897
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4898
|
+
status: 401,
|
|
4899
|
+
description: "Unauthorized."
|
|
4900
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4901
|
+
status: 404,
|
|
4902
|
+
description: "View not found."
|
|
4903
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4904
|
+
status: 409,
|
|
4905
|
+
description: "A view with this name already exists."
|
|
4906
|
+
}));
|
|
4907
|
+
}
|
|
4908
|
+
__name(ApiRenameDataTableView, "ApiRenameDataTableView");
|
|
4909
|
+
function ApiToggleShareDataTableView() {
|
|
4910
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4911
|
+
summary: "Toggle view sharing",
|
|
4912
|
+
description: "Makes a view visible to all users (shared) or restricts it to the owner only (private). Only the owner can toggle sharing."
|
|
4913
|
+
}), (0, import_swagger16.ApiParam)({
|
|
4914
|
+
name: "id",
|
|
4915
|
+
description: "UUID of the table view"
|
|
4916
|
+
}), (0, import_swagger16.ApiBody)({
|
|
4917
|
+
type: ToggleShareDataTableViewDto
|
|
4918
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4919
|
+
status: 200,
|
|
4920
|
+
description: "Sharing status updated.",
|
|
4921
|
+
type: DataTableViewDto
|
|
4922
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4923
|
+
status: 400,
|
|
4924
|
+
description: "Not owned by caller."
|
|
4925
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4926
|
+
status: 401,
|
|
4927
|
+
description: "Unauthorized."
|
|
4928
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4929
|
+
status: 404,
|
|
4930
|
+
description: "View not found."
|
|
4931
|
+
}));
|
|
4932
|
+
}
|
|
4933
|
+
__name(ApiToggleShareDataTableView, "ApiToggleShareDataTableView");
|
|
4934
|
+
function ApiDeleteDataTableView() {
|
|
4935
|
+
return (0, import_common61.applyDecorators)((0, import_swagger16.ApiOperation)({
|
|
4936
|
+
summary: "Delete named table view",
|
|
4937
|
+
description: "Permanently deletes a named view. Only the owner can delete their own views."
|
|
4938
|
+
}), (0, import_swagger16.ApiParam)({
|
|
4939
|
+
name: "id",
|
|
4940
|
+
description: "UUID of the table view to delete"
|
|
4941
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4942
|
+
status: 200,
|
|
4943
|
+
description: "View deleted.",
|
|
4944
|
+
type: DataTableViewDto
|
|
4945
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4946
|
+
status: 400,
|
|
4947
|
+
description: "Not owned by caller."
|
|
4948
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4949
|
+
status: 401,
|
|
4950
|
+
description: "Unauthorized."
|
|
4951
|
+
}), (0, import_swagger16.ApiResponse)({
|
|
4952
|
+
status: 404,
|
|
4953
|
+
description: "View not found."
|
|
4954
|
+
}));
|
|
4955
|
+
}
|
|
4956
|
+
__name(ApiDeleteDataTableView, "ApiDeleteDataTableView");
|
|
4957
|
+
|
|
4958
|
+
// src/data-table/views/services/data-table-views.service.ts
|
|
4959
|
+
var import_node_crypto2 = require("crypto");
|
|
4960
|
+
var import_common63 = require("@nestjs/common");
|
|
4961
|
+
var import_config13 = require("@nestjs/config");
|
|
4962
|
+
|
|
4963
|
+
// src/data-table/views/repositories/data-table-views.repository.ts
|
|
4964
|
+
var import_common62 = require("@nestjs/common");
|
|
4965
|
+
var import_drizzle_orm5 = require("drizzle-orm");
|
|
4966
|
+
function _ts_decorate35(decorators, target, key, desc2) {
|
|
4967
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
4968
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
4969
|
+
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;
|
|
4970
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4971
|
+
}
|
|
4972
|
+
__name(_ts_decorate35, "_ts_decorate");
|
|
4973
|
+
function _ts_metadata25(k, v) {
|
|
4974
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4975
|
+
}
|
|
4976
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4977
|
+
function _ts_param9(paramIndex, decorator) {
|
|
4978
|
+
return function(target, key) {
|
|
4979
|
+
decorator(target, key, paramIndex);
|
|
4980
|
+
};
|
|
4981
|
+
}
|
|
4982
|
+
__name(_ts_param9, "_ts_param");
|
|
4983
|
+
var NAMED_VIEWS_LIMIT = 100;
|
|
4984
|
+
var DataTableViewsRepository = class extends PrimaryBaseRepository {
|
|
4985
|
+
static {
|
|
4986
|
+
__name(this, "DataTableViewsRepository");
|
|
4987
|
+
}
|
|
4988
|
+
constructor(database, table) {
|
|
4989
|
+
super(database, table);
|
|
4990
|
+
}
|
|
4991
|
+
// Returns personal (non-shared) named views owned by the user for a given table
|
|
4992
|
+
async findPersonalViewsBySlug(userId, tableSlug) {
|
|
4993
|
+
const t = this.table;
|
|
4994
|
+
return this.db.select().from(this.table).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(t.tableSlug, tableSlug), (0, import_drizzle_orm5.eq)(t.userId, userId), (0, import_drizzle_orm5.eq)(t.isShared, false))).orderBy(t.createdAt).limit(NAMED_VIEWS_LIMIT);
|
|
4995
|
+
}
|
|
4996
|
+
// Returns all shared named views for a given table — visible to all users
|
|
4997
|
+
async findSharedViewsBySlug(tableSlug) {
|
|
4998
|
+
const t = this.table;
|
|
4999
|
+
return this.db.select().from(this.table).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(t.tableSlug, tableSlug), (0, import_drizzle_orm5.eq)(t.isShared, true))).orderBy(t.createdAt).limit(NAMED_VIEWS_LIMIT);
|
|
5000
|
+
}
|
|
5001
|
+
};
|
|
5002
|
+
DataTableViewsRepository = _ts_decorate35([
|
|
5003
|
+
(0, import_common62.Injectable)(),
|
|
5004
|
+
_ts_param9(1, (0, import_common62.Inject)(DATA_TABLE_VIEWS_TABLE)),
|
|
5005
|
+
_ts_metadata25("design:type", Function),
|
|
5006
|
+
_ts_metadata25("design:paramtypes", [
|
|
5007
|
+
typeof PrimaryDatabaseService === "undefined" ? Object : PrimaryDatabaseService,
|
|
5008
|
+
typeof PgTable === "undefined" ? Object : PgTable
|
|
5009
|
+
])
|
|
5010
|
+
], DataTableViewsRepository);
|
|
5011
|
+
|
|
5012
|
+
// src/data-table/views/services/data-table-views.service.ts
|
|
5013
|
+
function _ts_decorate36(decorators, target, key, desc2) {
|
|
5014
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5015
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5016
|
+
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;
|
|
5017
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5018
|
+
}
|
|
5019
|
+
__name(_ts_decorate36, "_ts_decorate");
|
|
5020
|
+
function _ts_metadata26(k, v) {
|
|
5021
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5022
|
+
}
|
|
5023
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
5024
|
+
function computeChecksum(value) {
|
|
5025
|
+
return (0, import_node_crypto2.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
5026
|
+
}
|
|
5027
|
+
__name(computeChecksum, "computeChecksum");
|
|
5028
|
+
var DataTableViewsService = class _DataTableViewsService {
|
|
5029
|
+
static {
|
|
5030
|
+
__name(this, "DataTableViewsService");
|
|
5031
|
+
}
|
|
5032
|
+
dataTableViewsRepository;
|
|
5033
|
+
cacheService;
|
|
5034
|
+
configService;
|
|
5035
|
+
logger = new import_common63.Logger(_DataTableViewsService.name);
|
|
5036
|
+
constructor(dataTableViewsRepository, cacheService, configService) {
|
|
5037
|
+
this.dataTableViewsRepository = dataTableViewsRepository;
|
|
5038
|
+
this.cacheService = cacheService;
|
|
5039
|
+
this.configService = configService;
|
|
5040
|
+
}
|
|
5041
|
+
// Builds the Redis key for a user's personal (non-shared) views for a given table
|
|
5042
|
+
personalViewsKey(userId, tableSlug) {
|
|
5043
|
+
return `views:personal:${userId}:${tableSlug}`;
|
|
5044
|
+
}
|
|
5045
|
+
// Builds the Redis key for all shared views for a given table — same key for all users
|
|
5046
|
+
sharedViewsKey(tableSlug) {
|
|
5047
|
+
return `views:shared:${tableSlug}`;
|
|
5048
|
+
}
|
|
5049
|
+
// Returns configured TTL for named views in seconds, defaulting to 86400 (24h)
|
|
5050
|
+
get viewsTtl() {
|
|
5051
|
+
return this.configService.get("TABLE_VIEWS_CACHE_TTL") ?? 86400;
|
|
5052
|
+
}
|
|
5053
|
+
// Fetches personal views from cache; falls back to DB and warms cache on miss
|
|
5054
|
+
async getOrCachePersonalViews(userId, tableSlug) {
|
|
5055
|
+
const key = this.personalViewsKey(userId, tableSlug);
|
|
5056
|
+
const cached = await this.cacheService.get(key);
|
|
5057
|
+
if (cached) {
|
|
5058
|
+
this.logger.debug(`Cache hit for personal views: user=${userId}, table=${tableSlug}`);
|
|
5059
|
+
return cached;
|
|
5060
|
+
}
|
|
5061
|
+
const rows = await this.dataTableViewsRepository.findPersonalViewsBySlug(userId, tableSlug);
|
|
5062
|
+
await this.cacheService.set(key, rows, this.viewsTtl);
|
|
5063
|
+
return rows;
|
|
5064
|
+
}
|
|
5065
|
+
// Fetches shared views from cache; falls back to DB and warms cache on miss
|
|
5066
|
+
async getOrCacheSharedViews(tableSlug) {
|
|
5067
|
+
const key = this.sharedViewsKey(tableSlug);
|
|
5068
|
+
const cached = await this.cacheService.get(key);
|
|
5069
|
+
if (cached) {
|
|
5070
|
+
this.logger.debug(`Cache hit for shared views: table=${tableSlug}`);
|
|
5071
|
+
return cached;
|
|
5072
|
+
}
|
|
5073
|
+
const rows = await this.dataTableViewsRepository.findSharedViewsBySlug(tableSlug);
|
|
5074
|
+
await this.cacheService.set(key, rows, this.viewsTtl);
|
|
5075
|
+
return rows;
|
|
5076
|
+
}
|
|
5077
|
+
// Deletes personal and/or shared cache keys based on which pools the mutation affects
|
|
5078
|
+
async invalidateViewsCache(userId, tableSlug, affectsPersonal, affectsShared) {
|
|
5079
|
+
const toDelete = [];
|
|
5080
|
+
if (affectsPersonal) toDelete.push(this.personalViewsKey(userId, tableSlug));
|
|
5081
|
+
if (affectsShared) toDelete.push(this.sharedViewsKey(tableSlug));
|
|
5082
|
+
if (toDelete.length > 0) await this.cacheService.del(...toDelete);
|
|
5083
|
+
}
|
|
5084
|
+
// Returns personal + shared named views — each pool fetched from cache or DB in parallel
|
|
5085
|
+
async findViews(userId, tableSlug) {
|
|
5086
|
+
const [personalRows, sharedRows] = await Promise.all([
|
|
5087
|
+
this.getOrCachePersonalViews(userId, tableSlug),
|
|
5088
|
+
this.getOrCacheSharedViews(tableSlug)
|
|
5089
|
+
]);
|
|
5090
|
+
return [
|
|
5091
|
+
...personalRows,
|
|
5092
|
+
...sharedRows
|
|
5093
|
+
].map((row) => DataTableViewDto.from(row, userId));
|
|
5094
|
+
}
|
|
5095
|
+
// Creates a named snapshot and invalidates the relevant cache pool
|
|
5096
|
+
async createView(userId, dto) {
|
|
5097
|
+
const view = await this.dataTableViewsRepository.create({
|
|
5098
|
+
userId,
|
|
5099
|
+
tableSlug: dto.tableSlug,
|
|
5100
|
+
name: dto.name,
|
|
5101
|
+
state: dto.state,
|
|
5102
|
+
isShared: dto.isShared ?? false
|
|
5103
|
+
});
|
|
5104
|
+
this.logger.log(`Created view "${dto.name}" for user: ${userId}, table: ${dto.tableSlug}`);
|
|
5105
|
+
const isShared = dto.isShared ?? false;
|
|
5106
|
+
await this.invalidateViewsCache(userId, dto.tableSlug, !isShared, isShared);
|
|
5107
|
+
return DataTableViewDto.from(view, userId);
|
|
5108
|
+
}
|
|
5109
|
+
// Updates the state of a named view — skips DB write if state is unchanged
|
|
5110
|
+
async updateView(userId, id, dto) {
|
|
5111
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
5112
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
5113
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to update this view.");
|
|
5114
|
+
if (computeChecksum(dto.state) === computeChecksum(view.state)) {
|
|
5115
|
+
this.logger.log(`State unchanged for view ${id} \u2014 skipping DB write`);
|
|
5116
|
+
return DataTableViewDto.from(view, userId);
|
|
5117
|
+
}
|
|
5118
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
5119
|
+
state: dto.state
|
|
5120
|
+
});
|
|
5121
|
+
this.logger.log(`Updated state for view ${id}, user: ${userId}`);
|
|
5122
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
5123
|
+
return DataTableViewDto.from(updated, userId);
|
|
5124
|
+
}
|
|
5125
|
+
// Toggles the sharing status of a named view — updates both personal and shared cache
|
|
5126
|
+
async toggleShareView(userId, id, isShared) {
|
|
5127
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
5128
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
5129
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to share this view.");
|
|
5130
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
5131
|
+
isShared
|
|
5132
|
+
});
|
|
5133
|
+
this.logger.log(`Set isShared=${isShared} for view ${id}, user: ${userId}`);
|
|
5134
|
+
await this.invalidateViewsCache(userId, view.tableSlug, true, true);
|
|
5135
|
+
return DataTableViewDto.from(updated, userId);
|
|
5136
|
+
}
|
|
5137
|
+
// Renames a named view — enforces unique name per user+table, invalidates personal cache
|
|
5138
|
+
async renameView(userId, id, name) {
|
|
5139
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
5140
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
5141
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to rename this view.");
|
|
5142
|
+
const existing = await this.dataTableViewsRepository.findOne({
|
|
5143
|
+
userId,
|
|
5144
|
+
tableSlug: view.tableSlug,
|
|
5145
|
+
name,
|
|
5146
|
+
isShared: false
|
|
5147
|
+
});
|
|
5148
|
+
if (existing && existing.id !== id) {
|
|
5149
|
+
throw new ConflictException({
|
|
5150
|
+
label: "Name Already Taken",
|
|
5151
|
+
detail: "A view with this name already exists for this table.",
|
|
5152
|
+
errors: [
|
|
5153
|
+
{
|
|
5154
|
+
field: "name",
|
|
5155
|
+
message: "Name already taken"
|
|
5156
|
+
}
|
|
5157
|
+
]
|
|
5158
|
+
});
|
|
5159
|
+
}
|
|
5160
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
5161
|
+
name
|
|
5162
|
+
});
|
|
5163
|
+
this.logger.log(`Renamed view ${id} to "${name}" for user: ${userId}`);
|
|
5164
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
5165
|
+
return DataTableViewDto.from(updated, userId);
|
|
5166
|
+
}
|
|
5167
|
+
// Deletes a named view and invalidates the relevant cache pool
|
|
5168
|
+
async deleteView(userId, id) {
|
|
5169
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
5170
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
5171
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to delete this view.");
|
|
5172
|
+
await this.dataTableViewsRepository.delete(id);
|
|
5173
|
+
this.logger.log(`Deleted view ${id} for user: ${userId}`);
|
|
5174
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
5175
|
+
return DataTableViewDto.from(view, userId);
|
|
5176
|
+
}
|
|
5177
|
+
};
|
|
5178
|
+
DataTableViewsService = _ts_decorate36([
|
|
5179
|
+
(0, import_common63.Injectable)(),
|
|
5180
|
+
_ts_metadata26("design:type", Function),
|
|
5181
|
+
_ts_metadata26("design:paramtypes", [
|
|
5182
|
+
typeof DataTableViewsRepository === "undefined" ? Object : DataTableViewsRepository,
|
|
5183
|
+
typeof CacheService === "undefined" ? Object : CacheService,
|
|
5184
|
+
typeof import_config13.ConfigService === "undefined" ? Object : import_config13.ConfigService
|
|
5185
|
+
])
|
|
5186
|
+
], DataTableViewsService);
|
|
5187
|
+
|
|
5188
|
+
// src/data-table/views/controllers/data-table-views.controller.ts
|
|
5189
|
+
function _ts_decorate37(decorators, target, key, desc2) {
|
|
5190
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5191
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5192
|
+
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;
|
|
5193
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5194
|
+
}
|
|
5195
|
+
__name(_ts_decorate37, "_ts_decorate");
|
|
5196
|
+
function _ts_metadata27(k, v) {
|
|
5197
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
5198
|
+
}
|
|
5199
|
+
__name(_ts_metadata27, "_ts_metadata");
|
|
5200
|
+
function _ts_param10(paramIndex, decorator) {
|
|
5201
|
+
return function(target, key) {
|
|
5202
|
+
decorator(target, key, paramIndex);
|
|
5203
|
+
};
|
|
5204
|
+
}
|
|
5205
|
+
__name(_ts_param10, "_ts_param");
|
|
5206
|
+
var DataTableViewsController = class _DataTableViewsController {
|
|
5207
|
+
static {
|
|
5208
|
+
__name(this, "DataTableViewsController");
|
|
5209
|
+
}
|
|
5210
|
+
dataTableViewsService;
|
|
5211
|
+
logger = new import_common64.Logger(_DataTableViewsController.name);
|
|
5212
|
+
constructor(dataTableViewsService) {
|
|
5213
|
+
this.dataTableViewsService = dataTableViewsService;
|
|
5214
|
+
}
|
|
5215
|
+
// Returns all named views for the given table — own plus shared
|
|
5216
|
+
findViews(userId, tableSlug) {
|
|
5217
|
+
this.logger.log(`GET /table-views?tableSlug=${tableSlug} - User: ${userId}`);
|
|
5218
|
+
return this.dataTableViewsService.findViews(userId, tableSlug);
|
|
5219
|
+
}
|
|
5220
|
+
// Creates a named snapshot of the current table state
|
|
5221
|
+
createView(userId, dto) {
|
|
5222
|
+
this.logger.log(`POST /table-views - User: ${userId}, table: ${dto.tableSlug}`);
|
|
5223
|
+
return this.dataTableViewsService.createView(userId, dto);
|
|
5224
|
+
}
|
|
5225
|
+
// Updates state of an existing named view
|
|
5226
|
+
updateView(userId, id, dto) {
|
|
5227
|
+
this.logger.log(`PATCH /table-views/${id} - User: ${userId}`);
|
|
5228
|
+
return this.dataTableViewsService.updateView(userId, id, dto);
|
|
5229
|
+
}
|
|
5230
|
+
// Renames an existing named view — enforces unique name per user+table
|
|
5231
|
+
renameView(userId, id, dto) {
|
|
5232
|
+
this.logger.log(`PATCH /table-views/${id}/rename - User: ${userId}`);
|
|
5233
|
+
return this.dataTableViewsService.renameView(userId, id, dto.name);
|
|
5234
|
+
}
|
|
5235
|
+
// Toggles sharing visibility of a named view
|
|
5236
|
+
toggleShareView(userId, id, dto) {
|
|
5237
|
+
this.logger.log(`PATCH /table-views/${id}/share - User: ${userId}`);
|
|
5238
|
+
return this.dataTableViewsService.toggleShareView(userId, id, dto.isShared);
|
|
5239
|
+
}
|
|
5240
|
+
// Deletes a named view owned by the authenticated user
|
|
5241
|
+
deleteView(userId, id) {
|
|
5242
|
+
this.logger.log(`DELETE /table-views/${id} - User: ${userId}`);
|
|
5243
|
+
return this.dataTableViewsService.deleteView(userId, id);
|
|
5244
|
+
}
|
|
5245
|
+
};
|
|
5246
|
+
_ts_decorate37([
|
|
5247
|
+
(0, import_common64.Get)(),
|
|
5248
|
+
ApiListDataTableViews(),
|
|
5249
|
+
_ts_param10(0, UserId()),
|
|
5250
|
+
_ts_param10(1, (0, import_common64.Query)("tableSlug")),
|
|
5251
|
+
_ts_metadata27("design:type", Function),
|
|
5252
|
+
_ts_metadata27("design:paramtypes", [
|
|
5253
|
+
String,
|
|
5254
|
+
String
|
|
5255
|
+
]),
|
|
5256
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5257
|
+
], DataTableViewsController.prototype, "findViews", null);
|
|
5258
|
+
_ts_decorate37([
|
|
5259
|
+
(0, import_common64.Post)(),
|
|
5260
|
+
(0, import_common64.HttpCode)(import_common64.HttpStatus.CREATED),
|
|
5261
|
+
ApiCreateDataTableView(),
|
|
5262
|
+
_ts_param10(0, UserId()),
|
|
5263
|
+
_ts_param10(1, (0, import_common64.Body)()),
|
|
5264
|
+
_ts_metadata27("design:type", Function),
|
|
5265
|
+
_ts_metadata27("design:paramtypes", [
|
|
5266
|
+
String,
|
|
5267
|
+
typeof CreateDataTableViewDto === "undefined" ? Object : CreateDataTableViewDto
|
|
5268
|
+
]),
|
|
5269
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5270
|
+
], DataTableViewsController.prototype, "createView", null);
|
|
5271
|
+
_ts_decorate37([
|
|
5272
|
+
(0, import_common64.Patch)(":id"),
|
|
5273
|
+
ApiUpdateDataTableView(),
|
|
5274
|
+
_ts_param10(0, UserId()),
|
|
5275
|
+
_ts_param10(1, (0, import_common64.Param)("id")),
|
|
5276
|
+
_ts_param10(2, (0, import_common64.Body)()),
|
|
5277
|
+
_ts_metadata27("design:type", Function),
|
|
5278
|
+
_ts_metadata27("design:paramtypes", [
|
|
5279
|
+
String,
|
|
5280
|
+
String,
|
|
5281
|
+
typeof UpdateDataTableViewDto === "undefined" ? Object : UpdateDataTableViewDto
|
|
5282
|
+
]),
|
|
5283
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5284
|
+
], DataTableViewsController.prototype, "updateView", null);
|
|
5285
|
+
_ts_decorate37([
|
|
5286
|
+
(0, import_common64.Patch)(":id/rename"),
|
|
5287
|
+
ApiRenameDataTableView(),
|
|
5288
|
+
_ts_param10(0, UserId()),
|
|
5289
|
+
_ts_param10(1, (0, import_common64.Param)("id")),
|
|
5290
|
+
_ts_param10(2, (0, import_common64.Body)()),
|
|
5291
|
+
_ts_metadata27("design:type", Function),
|
|
5292
|
+
_ts_metadata27("design:paramtypes", [
|
|
5293
|
+
String,
|
|
5294
|
+
String,
|
|
5295
|
+
typeof RenameDataTableViewDto === "undefined" ? Object : RenameDataTableViewDto
|
|
5296
|
+
]),
|
|
5297
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5298
|
+
], DataTableViewsController.prototype, "renameView", null);
|
|
5299
|
+
_ts_decorate37([
|
|
5300
|
+
(0, import_common64.Patch)(":id/share"),
|
|
5301
|
+
ApiToggleShareDataTableView(),
|
|
5302
|
+
_ts_param10(0, UserId()),
|
|
5303
|
+
_ts_param10(1, (0, import_common64.Param)("id")),
|
|
5304
|
+
_ts_param10(2, (0, import_common64.Body)()),
|
|
5305
|
+
_ts_metadata27("design:type", Function),
|
|
5306
|
+
_ts_metadata27("design:paramtypes", [
|
|
5307
|
+
String,
|
|
5308
|
+
String,
|
|
5309
|
+
typeof ToggleShareDataTableViewDto === "undefined" ? Object : ToggleShareDataTableViewDto
|
|
5310
|
+
]),
|
|
5311
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5312
|
+
], DataTableViewsController.prototype, "toggleShareView", null);
|
|
5313
|
+
_ts_decorate37([
|
|
5314
|
+
(0, import_common64.Delete)(":id"),
|
|
5315
|
+
ApiDeleteDataTableView(),
|
|
5316
|
+
_ts_param10(0, UserId()),
|
|
5317
|
+
_ts_param10(1, (0, import_common64.Param)("id")),
|
|
5318
|
+
_ts_metadata27("design:type", Function),
|
|
5319
|
+
_ts_metadata27("design:paramtypes", [
|
|
5320
|
+
String,
|
|
5321
|
+
String
|
|
5322
|
+
]),
|
|
5323
|
+
_ts_metadata27("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5324
|
+
], DataTableViewsController.prototype, "deleteView", null);
|
|
5325
|
+
DataTableViewsController = _ts_decorate37([
|
|
5326
|
+
(0, import_swagger17.ApiTags)("Table Views"),
|
|
5327
|
+
(0, import_swagger17.ApiBearerAuth)(),
|
|
5328
|
+
(0, import_common64.Controller)("table-views"),
|
|
5329
|
+
_ts_metadata27("design:type", Function),
|
|
5330
|
+
_ts_metadata27("design:paramtypes", [
|
|
5331
|
+
typeof DataTableViewsService === "undefined" ? Object : DataTableViewsService
|
|
5332
|
+
])
|
|
5333
|
+
], DataTableViewsController);
|
|
5334
|
+
|
|
5335
|
+
// src/data-table/data-table.module.ts
|
|
5336
|
+
function _ts_decorate38(decorators, target, key, desc2) {
|
|
5337
|
+
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
5338
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
5339
|
+
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;
|
|
5340
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5341
|
+
}
|
|
5342
|
+
__name(_ts_decorate38, "_ts_decorate");
|
|
5343
|
+
var DataTableModule = class _DataTableModule {
|
|
5344
|
+
static {
|
|
5345
|
+
__name(this, "DataTableModule");
|
|
5346
|
+
}
|
|
5347
|
+
static forRoot(options) {
|
|
5348
|
+
return {
|
|
5349
|
+
global: true,
|
|
5350
|
+
module: _DataTableModule,
|
|
5351
|
+
imports: [
|
|
5352
|
+
import_config14.ConfigModule,
|
|
5353
|
+
CacheModule
|
|
5354
|
+
],
|
|
5355
|
+
controllers: [
|
|
5356
|
+
DataTableStateController,
|
|
5357
|
+
DataTableViewsController
|
|
5358
|
+
],
|
|
5359
|
+
providers: [
|
|
5360
|
+
{
|
|
5361
|
+
provide: DATA_TABLE_VIEWS_TABLE,
|
|
5362
|
+
useValue: options.tableViews
|
|
5363
|
+
},
|
|
5364
|
+
DataTableViewsService,
|
|
5365
|
+
DataTableViewsRepository,
|
|
5366
|
+
DataTableStateService
|
|
5367
|
+
],
|
|
5368
|
+
exports: [
|
|
5369
|
+
DataTableViewsService,
|
|
5370
|
+
DataTableStateService
|
|
5371
|
+
]
|
|
5372
|
+
};
|
|
5373
|
+
}
|
|
5374
|
+
};
|
|
5375
|
+
DataTableModule = _ts_decorate38([
|
|
5376
|
+
(0, import_common65.Module)({})
|
|
5377
|
+
], DataTableModule);
|
|
5378
|
+
|
|
5379
|
+
// src/drizzle-pg-core.ts
|
|
5380
|
+
var drizzle_pg_core_exports = {};
|
|
5381
|
+
__reExport(drizzle_pg_core_exports, require("drizzle-orm/pg-core"));
|
|
5382
|
+
|
|
5383
|
+
// src/data-table/schema/data-table-views.table.ts
|
|
5384
|
+
function dataTableViewsColumns() {
|
|
5385
|
+
return {
|
|
5386
|
+
id: (0, drizzle_pg_core_exports.uuid)("id").primaryKey().defaultRandom(),
|
|
5387
|
+
userId: (0, drizzle_pg_core_exports.uuid)("user_id").notNull(),
|
|
5388
|
+
tableSlug: (0, drizzle_pg_core_exports.varchar)("table_slug", {
|
|
5389
|
+
length: 100
|
|
5390
|
+
}).notNull(),
|
|
5391
|
+
name: (0, drizzle_pg_core_exports.varchar)("name", {
|
|
5392
|
+
length: 100
|
|
5393
|
+
}).notNull(),
|
|
5394
|
+
state: (0, drizzle_pg_core_exports.jsonb)("state").notNull().$type(),
|
|
5395
|
+
isShared: (0, drizzle_pg_core_exports.boolean)("is_shared").notNull().default(false),
|
|
5396
|
+
createdAt: (0, drizzle_pg_core_exports.timestamp)("created_at", {
|
|
5397
|
+
withTimezone: true
|
|
5398
|
+
}).notNull().defaultNow(),
|
|
5399
|
+
updatedAt: (0, drizzle_pg_core_exports.timestamp)("updated_at", {
|
|
5400
|
+
withTimezone: true
|
|
5401
|
+
}).$onUpdate(() => /* @__PURE__ */ new Date())
|
|
5402
|
+
};
|
|
5403
|
+
}
|
|
5404
|
+
__name(dataTableViewsColumns, "dataTableViewsColumns");
|
|
5405
|
+
function dataTableViewsIndexes(table) {
|
|
5406
|
+
return [
|
|
5407
|
+
(0, drizzle_pg_core_exports.index)("table_views_user_table_idx").on(table.userId, table.tableSlug),
|
|
5408
|
+
(0, drizzle_pg_core_exports.index)("table_views_shared_slug_idx").on(table.tableSlug, table.isShared),
|
|
5409
|
+
(0, drizzle_pg_core_exports.uniqueIndex)("table_views_user_table_name_shared_unique").on(table.userId, table.tableSlug, table.name, table.isShared)
|
|
5410
|
+
];
|
|
5411
|
+
}
|
|
5412
|
+
__name(dataTableViewsIndexes, "dataTableViewsIndexes");
|
|
3854
5413
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3855
5414
|
0 && (module.exports = {
|
|
3856
5415
|
AccessToken,
|
|
3857
5416
|
AuthConfigModule,
|
|
3858
5417
|
BadGatewayException,
|
|
3859
5418
|
BadRequestException,
|
|
5419
|
+
CACHE_PROVIDER,
|
|
5420
|
+
CacheModule,
|
|
5421
|
+
CacheService,
|
|
3860
5422
|
ConflictException,
|
|
5423
|
+
CookieDomain,
|
|
3861
5424
|
CorrelationIdMiddleware,
|
|
5425
|
+
CreateDataTableViewDto,
|
|
5426
|
+
DATA_TABLE_VIEWS_TABLE,
|
|
3862
5427
|
DEFAULT_CORRELATION_HEADER,
|
|
5428
|
+
DataTableModule,
|
|
5429
|
+
DataTableStateService,
|
|
5430
|
+
DataTableViewDto,
|
|
5431
|
+
DataTableViewsService,
|
|
3863
5432
|
DatabaseModule,
|
|
3864
5433
|
EmailModule,
|
|
3865
5434
|
EmailService,
|
|
5435
|
+
FilterProcessor,
|
|
3866
5436
|
ForbiddenException,
|
|
3867
5437
|
GoneException,
|
|
3868
5438
|
HttpExceptionFilter,
|
|
@@ -3883,7 +5453,10 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3883
5453
|
PrimaryDatabaseService,
|
|
3884
5454
|
Public,
|
|
3885
5455
|
RESET_KEY,
|
|
5456
|
+
RedisCacheProvider,
|
|
5457
|
+
RefreshCookieOptions,
|
|
3886
5458
|
RefreshTokenCookie,
|
|
5459
|
+
RenameDataTableViewDto,
|
|
3887
5460
|
RequestTimeoutException,
|
|
3888
5461
|
Reset,
|
|
3889
5462
|
RootModule,
|
|
@@ -3892,21 +5465,28 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3892
5465
|
ServiceUnavailableException,
|
|
3893
5466
|
SessionData,
|
|
3894
5467
|
SkipCsrf,
|
|
5468
|
+
SuccessResponseDto,
|
|
5469
|
+
TableResponseDto,
|
|
3895
5470
|
Tenant,
|
|
3896
5471
|
TenantBaseRepository,
|
|
3897
5472
|
TenantContextService,
|
|
3898
5473
|
TenantDatabaseService,
|
|
5474
|
+
ToggleShareDataTableViewDto,
|
|
3899
5475
|
TokenType,
|
|
3900
5476
|
TooManyRequestsException,
|
|
3901
5477
|
UnauthorizedException,
|
|
3902
5478
|
UnprocessableEntityException,
|
|
3903
5479
|
UnsupportedMediaTypeException,
|
|
5480
|
+
UpdateDataTableViewDto,
|
|
5481
|
+
UpsertDataTableStateDto,
|
|
3904
5482
|
UserId,
|
|
3905
5483
|
ValidationException,
|
|
3906
5484
|
VrittiAuthGuard,
|
|
3907
5485
|
addCorrelationIdToResponse,
|
|
3908
5486
|
configureApiSdk,
|
|
3909
5487
|
correlationStorage,
|
|
5488
|
+
dataTableViewsColumns,
|
|
5489
|
+
dataTableViewsIndexes,
|
|
3910
5490
|
defineConfig,
|
|
3911
5491
|
extractCountryFromPhone,
|
|
3912
5492
|
generateCorrelationId,
|
|
@@ -3915,6 +5495,7 @@ __name(normalizePhoneNumber, "normalizePhoneNumber");
|
|
|
3915
5495
|
getHttpStatusTitle,
|
|
3916
5496
|
getJwtExpiry,
|
|
3917
5497
|
getRefreshCookieOptions,
|
|
5498
|
+
getRefreshCookieOptionsForHost,
|
|
3918
5499
|
getTokenExpiry,
|
|
3919
5500
|
hashToken,
|
|
3920
5501
|
jwtConfigFactory,
|