@viardex/viardex-libs 1.0.12 → 1.0.13

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.
Files changed (40) hide show
  1. package/README.md +12 -235
  2. package/dist/cache/{index.mjs → index.cjs} +48 -12
  3. package/dist/cache/index.cjs.map +1 -0
  4. package/dist/cache/{index.d.mts → index.d.cts} +1 -1
  5. package/dist/cache/index.d.ts +1 -1
  6. package/dist/cache/index.js +11 -47
  7. package/dist/cache/index.js.map +1 -1
  8. package/dist/common/{index.mjs → index.cjs} +159 -54
  9. package/dist/common/index.cjs.map +1 -0
  10. package/dist/common/{index.d.mts → index.d.cts} +0 -1
  11. package/dist/common/index.d.ts +0 -1
  12. package/dist/common/index.js +53 -158
  13. package/dist/common/index.js.map +1 -1
  14. package/dist/{index.mjs → index.cjs} +242 -108
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/{index.d.mts → index.d.cts} +5 -6
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.js +107 -241
  19. package/dist/index.js.map +1 -1
  20. package/dist/logger/{index.mjs → index.cjs} +52 -26
  21. package/dist/logger/index.cjs.map +1 -0
  22. package/dist/logger/index.js +25 -51
  23. package/dist/logger/index.js.map +1 -1
  24. package/dist/nats/{index.mjs → index.cjs} +63 -18
  25. package/dist/nats/index.cjs.map +1 -0
  26. package/dist/nats/index.js +17 -62
  27. package/dist/nats/index.js.map +1 -1
  28. package/dist/rpc/{index.mjs → index.cjs} +32 -10
  29. package/dist/rpc/{index.mjs.map → index.cjs.map} +1 -1
  30. package/dist/rpc/index.js +9 -31
  31. package/dist/rpc/index.js.map +1 -1
  32. package/package.json +14 -13
  33. package/dist/cache/index.mjs.map +0 -1
  34. package/dist/common/index.mjs.map +0 -1
  35. package/dist/index.mjs.map +0 -1
  36. package/dist/logger/index.mjs.map +0 -1
  37. package/dist/nats/index.mjs.map +0 -1
  38. /package/dist/logger/{index.d.mts → index.d.cts} +0 -0
  39. /package/dist/nats/{index.d.mts → index.d.cts} +0 -0
  40. /package/dist/rpc/{index.d.mts → index.d.cts} +0 -0
@@ -1,5 +1,138 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ AppResponse: () => AppResponse,
34
+ AuditSubjects: () => AuditSubjects,
35
+ BANKING_QUEUE: () => BANKING_QUEUE,
36
+ CACHE_MODULE_OPTIONS: () => CACHE_MODULE_OPTIONS,
37
+ CARD_QUEUE: () => CARD_QUEUE,
38
+ CRYPTO_QUEUE: () => CRYPTO_QUEUE,
39
+ CacheModule: () => CacheModule,
40
+ CacheService: () => CacheService,
41
+ CountrySubjects: () => CountrySubjects,
42
+ DEFAULT_NATS_CONFIG: () => DEFAULT_NATS_CONFIG,
43
+ DEFAULT_OTP_EXPIRY: () => DEFAULT_OTP_EXPIRY,
44
+ DEFAULT_OTP_LENGTH: () => DEFAULT_OTP_LENGTH,
45
+ DEFAULT_OTP_OPTIONS: () => DEFAULT_OTP_OPTIONS,
46
+ DeviceSubjects: () => DeviceSubjects,
47
+ FileValidationPipe: () => FileValidationPipe,
48
+ HttpExceptionFilter: () => HttpExceptionFilter,
49
+ HttpOnlyExceptionFilter: () => HttpOnlyExceptionFilter,
50
+ KYC_QUEUE: () => KYC_QUEUE,
51
+ LEDGER_QUEUE: () => LEDGER_QUEUE,
52
+ LoggerModule: () => LoggerModule,
53
+ LoggingInterceptor: () => LoggingInterceptor,
54
+ MAX_OTP_ATTEMPTS: () => MAX_OTP_ATTEMPTS,
55
+ NATS_CLIENT: () => NATS_CLIENT,
56
+ NATS_EVENT_METADATA: () => NATS_EVENT_METADATA,
57
+ NATS_OPTIONS: () => NATS_OPTIONS,
58
+ NOTIFICATION_QUEUE: () => NOTIFICATION_QUEUE,
59
+ NatsEventPattern: () => NatsEventPattern,
60
+ NatsLoggingInterceptor: () => NatsLoggingInterceptor,
61
+ NatsMessageDto: () => NatsMessageDto,
62
+ NatsSubjects: () => NatsSubjects,
63
+ NotificationSubjects: () => NotificationSubjects,
64
+ OPS_QUEUE: () => OPS_QUEUE,
65
+ OTP_ATTEMPTS_CACHE_PREFIX: () => OTP_ATTEMPTS_CACHE_PREFIX,
66
+ OTP_BLOCK_DURATION: () => OTP_BLOCK_DURATION,
67
+ OTP_CACHE_PREFIX: () => OTP_CACHE_PREFIX,
68
+ OtpPurpose: () => OtpPurpose,
69
+ PaginationQueryCleanerPipe: () => PaginationQueryCleanerPipe,
70
+ PaginationQueryDto: () => PaginationQueryDto,
71
+ PasswordSubjects: () => PasswordSubjects,
72
+ PinSubjects: () => PinSubjects,
73
+ PinoLogger: () => import_nestjs_pino3.PinoLogger,
74
+ PreferencesSubjects: () => PreferencesSubjects,
75
+ ReferralSubjects: () => ReferralSubjects,
76
+ ResponseInterceptor: () => ResponseInterceptor,
77
+ RoleSubjects: () => RoleSubjects,
78
+ SigninSubjects: () => SigninSubjects,
79
+ SignupSubjects: () => SignupSubjects,
80
+ StaffSubjects: () => StaffSubjects,
81
+ TicketSubjects: () => TicketSubjects,
82
+ USER_QUEUE: () => USER_QUEUE,
83
+ UserServiceSubjects: () => UserServiceSubjects,
84
+ VAS_QUEUE: () => VAS_QUEUE,
85
+ ViardexRpc: () => ViardexRpc,
86
+ calculateNextDate: () => calculateNextDate,
87
+ countryDialCodes: () => countryDialCodes,
88
+ extractBin: () => extractBin,
89
+ extractLast4: () => extractLast4,
90
+ formatAccountNumber: () => formatAccountNumber,
91
+ formatAmount: () => formatAmount,
92
+ formatCardExpiry: () => formatCardExpiry,
93
+ formatCardLabel: () => formatCardLabel,
94
+ formatCryptoAmount: () => formatCryptoAmount,
95
+ formatCurrency: () => formatCurrency,
96
+ formatDate: () => formatDate,
97
+ formatDateTime: () => formatDateTime,
98
+ formatFileSize: () => formatFileSize,
99
+ formatPercentage: () => formatPercentage,
100
+ formatPhoneNumber: () => formatPhoneNumber,
101
+ formatRelativeTime: () => formatRelativeTime,
102
+ fromAtomicUnits: () => fromAtomicUnits,
103
+ generateRandomString: () => generateRandomString,
104
+ generateReference: () => generateReference,
105
+ getNatsConfig: () => getNatsConfig,
106
+ getNatsMicroserviceConfig: () => getNatsMicroserviceConfig,
107
+ getNatsServers: () => getNatsServers,
108
+ isDateInRange: () => isDateInRange,
109
+ isHexTxHash: () => isHexTxHash,
110
+ isNotPastDate: () => isNotPastDate,
111
+ isPositiveAmount: () => isPositiveAmount,
112
+ isStrongPassword: () => isStrongPassword,
113
+ isToday: () => isToday,
114
+ isValidAccountNumber: () => isValidAccountNumber,
115
+ isValidAge: () => isValidAge,
116
+ isValidAmount: () => isValidAmount,
117
+ isValidBVN: () => isValidBVN,
118
+ isValidEmail: () => isValidEmail,
119
+ isValidNIN: () => isValidNIN,
120
+ isValidNigerianPhone: () => isValidNigerianPhone,
121
+ isValidTransactionReference: () => isValidTransactionReference,
122
+ maskAccountNumber: () => maskAccountNumber,
123
+ maskEmail: () => maskEmail,
124
+ maskPan: () => maskPan,
125
+ maskPhoneNumber: () => maskPhoneNumber,
126
+ normalizeCardExpiry: () => normalizeCardExpiry,
127
+ normalizeNigerianPhone: () => normalizeNigerianPhone,
128
+ normalizeTxHash: () => normalizeTxHash,
129
+ toAtomicUnits: () => toAtomicUnits,
130
+ toDecimal: () => toDecimal,
131
+ toRoundedNumber: () => toRoundedNumber,
132
+ toTitleCase: () => toTitleCase,
133
+ truncateText: () => truncateText
134
+ });
135
+ module.exports = __toCommonJS(src_exports);
3
136
 
4
137
  // src/nats/constants/nats.constants.ts
5
138
  var NATS_OPTIONS = "NATS_OPTIONS";
@@ -102,7 +235,7 @@ var NatsSubjects = {
102
235
  };
103
236
 
104
237
  // src/nats/dto/nats-message.dto.ts
105
- import { IsNotEmpty, IsOptional, IsString } from "class-validator";
238
+ var import_class_validator = require("class-validator");
106
239
  function _ts_decorate(decorators, target, key, desc) {
107
240
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
108
241
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -132,27 +265,27 @@ var NatsMessageDto = class {
132
265
  replyTo;
133
266
  };
134
267
  _ts_decorate([
135
- IsString(),
136
- IsNotEmpty(),
268
+ (0, import_class_validator.IsString)(),
269
+ (0, import_class_validator.IsNotEmpty)(),
137
270
  _ts_metadata("design:type", String)
138
271
  ], NatsMessageDto.prototype, "pattern", void 0);
139
272
  _ts_decorate([
140
- IsNotEmpty(),
273
+ (0, import_class_validator.IsNotEmpty)(),
141
274
  _ts_metadata("design:type", Object)
142
275
  ], NatsMessageDto.prototype, "data", void 0);
143
276
  _ts_decorate([
144
- IsString(),
145
- IsOptional(),
277
+ (0, import_class_validator.IsString)(),
278
+ (0, import_class_validator.IsOptional)(),
146
279
  _ts_metadata("design:type", String)
147
280
  ], NatsMessageDto.prototype, "replyTo", void 0);
148
281
 
149
282
  // src/nats/decorators/nats-event-pattern.decorator.ts
150
- import { applyDecorators, SetMetadata, UseInterceptors } from "@nestjs/common";
151
- import { EventPattern } from "@nestjs/microservices";
283
+ var import_common2 = require("@nestjs/common");
284
+ var import_microservices = require("@nestjs/microservices");
152
285
 
153
286
  // src/nats/interceptors/nats-logging.interceptor.ts
154
- import { Injectable, Logger } from "@nestjs/common";
155
- import { tap } from "rxjs";
287
+ var import_common = require("@nestjs/common");
288
+ var import_rxjs = require("rxjs");
156
289
  function _ts_decorate2(decorators, target, key, desc) {
157
290
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
158
291
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -171,13 +304,13 @@ var NatsLoggingInterceptor = class _NatsLoggingInterceptor {
171
304
  static {
172
305
  __name(this, "NatsLoggingInterceptor");
173
306
  }
174
- logger = new Logger(_NatsLoggingInterceptor.name);
307
+ logger = new import_common.Logger(_NatsLoggingInterceptor.name);
175
308
  intercept(context, next) {
176
309
  const now = Date.now();
177
310
  const rpcContext = context.switchToRpc();
178
311
  const natsContext = rpcContext.getContext();
179
312
  const pattern = natsContext.getSubject();
180
- return next.handle().pipe(tap({
313
+ return next.handle().pipe((0, import_rxjs.tap)({
181
314
  next: /* @__PURE__ */ __name((data) => {
182
315
  this.logger.log(`Pattern: ${pattern} | Response time: ${Date.now() - now}ms | Response: ${JSON.stringify(data)}`);
183
316
  }, "next"),
@@ -188,15 +321,15 @@ var NatsLoggingInterceptor = class _NatsLoggingInterceptor {
188
321
  }
189
322
  };
190
323
  NatsLoggingInterceptor = _ts_decorate2([
191
- Injectable()
324
+ (0, import_common.Injectable)()
192
325
  ], NatsLoggingInterceptor);
193
326
 
194
327
  // src/nats/decorators/nats-event-pattern.decorator.ts
195
328
  var NATS_EVENT_METADATA = "nats_event_metadata";
196
329
  function NatsEventPattern(pattern) {
197
- return applyDecorators(SetMetadata(NATS_EVENT_METADATA, {
330
+ return (0, import_common2.applyDecorators)((0, import_common2.SetMetadata)(NATS_EVENT_METADATA, {
198
331
  pattern
199
- }), EventPattern(pattern), UseInterceptors(NatsLoggingInterceptor));
332
+ }), (0, import_microservices.EventPattern)(pattern), (0, import_common2.UseInterceptors)(NatsLoggingInterceptor));
200
333
  }
201
334
  __name(NatsEventPattern, "NatsEventPattern");
202
335
 
@@ -273,16 +406,16 @@ var formatCardLabel = /* @__PURE__ */ __name((brand, last4) => {
273
406
  }, "formatCardLabel");
274
407
 
275
408
  // src/common/crypto/crypto.utils.ts
276
- import Decimal from "decimal.js";
277
- var DECIMAL_ZERO = new Decimal(0);
409
+ var import_decimal = __toESM(require("decimal.js"), 1);
410
+ var DECIMAL_ZERO = new import_decimal.default(0);
278
411
  var toAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
279
- return new Decimal(value).mul(new Decimal(10).pow(decimals)).toDecimalPlaces(0, Decimal.ROUND_DOWN).toFixed(0);
412
+ return new import_decimal.default(value).mul(new import_decimal.default(10).pow(decimals)).toDecimalPlaces(0, import_decimal.default.ROUND_DOWN).toFixed(0);
280
413
  }, "toAtomicUnits");
281
414
  var fromAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
282
- return new Decimal(value).div(new Decimal(10).pow(decimals)).toFixed();
415
+ return new import_decimal.default(value).div(new import_decimal.default(10).pow(decimals)).toFixed();
283
416
  }, "fromAtomicUnits");
284
417
  var formatCryptoAmount = /* @__PURE__ */ __name((value, decimals = 8) => {
285
- return new Decimal(value).toDecimalPlaces(decimals).toString();
418
+ return new import_decimal.default(value).toDecimalPlaces(decimals).toString();
286
419
  }, "formatCryptoAmount");
287
420
  var normalizeTxHash = /* @__PURE__ */ __name((hash) => {
288
421
  return hash.trim().toLowerCase();
@@ -298,7 +431,7 @@ var isHexTxHash = /* @__PURE__ */ __name((hash, expectedLength) => {
298
431
  return true;
299
432
  }, "isHexTxHash");
300
433
  var isPositiveAmount = /* @__PURE__ */ __name((value) => {
301
- return new Decimal(value).greaterThan(DECIMAL_ZERO);
434
+ return new import_decimal.default(value).greaterThan(DECIMAL_ZERO);
302
435
  }, "isPositiveAmount");
303
436
 
304
437
  // src/common/enums/otp.enum.ts
@@ -321,8 +454,8 @@ var OtpPurpose = /* @__PURE__ */ (function(OtpPurpose2) {
321
454
  })({});
322
455
 
323
456
  // src/common/dto/pagination-query.dto.ts
324
- import { Type } from "class-transformer";
325
- import { IsIn, IsInt, IsOptional as IsOptional2, IsString as IsString2, Min } from "class-validator";
457
+ var import_class_transformer = require("class-transformer");
458
+ var import_class_validator2 = require("class-validator");
326
459
  function _ts_decorate3(decorators, target, key, desc) {
327
460
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
328
461
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -354,40 +487,40 @@ var PaginationQueryDto = class {
354
487
  sortOrder;
355
488
  };
356
489
  _ts_decorate3([
357
- Type(() => Number),
358
- IsInt(),
359
- Min(1),
360
- IsOptional2(),
490
+ (0, import_class_transformer.Type)(() => Number),
491
+ (0, import_class_validator2.IsInt)(),
492
+ (0, import_class_validator2.Min)(1),
493
+ (0, import_class_validator2.IsOptional)(),
361
494
  _ts_metadata2("design:type", Number)
362
495
  ], PaginationQueryDto.prototype, "page", void 0);
363
496
  _ts_decorate3([
364
- Type(() => Number),
365
- IsInt(),
366
- Min(1),
367
- IsOptional2(),
497
+ (0, import_class_transformer.Type)(() => Number),
498
+ (0, import_class_validator2.IsInt)(),
499
+ (0, import_class_validator2.Min)(1),
500
+ (0, import_class_validator2.IsOptional)(),
368
501
  _ts_metadata2("design:type", Number)
369
502
  ], PaginationQueryDto.prototype, "limit", void 0);
370
503
  _ts_decorate3([
371
- IsString2(),
372
- IsOptional2(),
504
+ (0, import_class_validator2.IsString)(),
505
+ (0, import_class_validator2.IsOptional)(),
373
506
  _ts_metadata2("design:type", String)
374
507
  ], PaginationQueryDto.prototype, "search", void 0);
375
508
  _ts_decorate3([
376
- IsString2(),
377
- IsOptional2(),
509
+ (0, import_class_validator2.IsString)(),
510
+ (0, import_class_validator2.IsOptional)(),
378
511
  _ts_metadata2("design:type", String)
379
512
  ], PaginationQueryDto.prototype, "sortBy", void 0);
380
513
  _ts_decorate3([
381
- IsIn([
514
+ (0, import_class_validator2.IsIn)([
382
515
  "asc",
383
516
  "desc"
384
517
  ]),
385
- IsOptional2(),
518
+ (0, import_class_validator2.IsOptional)(),
386
519
  _ts_metadata2("design:type", String)
387
520
  ], PaginationQueryDto.prototype, "sortOrder", void 0);
388
521
 
389
522
  // src/common/pipes/file-validation.pipe.ts
390
- import { BadRequestException, Injectable as Injectable2 } from "@nestjs/common";
523
+ var import_common3 = require("@nestjs/common");
391
524
  function _ts_decorate4(decorators, target, key, desc) {
392
525
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
393
526
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -425,7 +558,7 @@ var FileValidationPipe = class {
425
558
  transform(value) {
426
559
  const files = this.normalizeFiles(value);
427
560
  if (files.length === 0) {
428
- throw new BadRequestException("No files uploaded");
561
+ throw new import_common3.BadRequestException("No files uploaded");
429
562
  }
430
563
  this.validateRequiredFields(value);
431
564
  const allowedMimeTypes = this.options.allowedMimeTypes ?? DEFAULT_ALLOWED_MIME_TYPES;
@@ -433,10 +566,10 @@ var FileValidationPipe = class {
433
566
  for (const file of files) {
434
567
  const label = file.fieldname || file.originalname || "file";
435
568
  if (file.mimetype && !allowedMimeTypes.includes(file.mimetype)) {
436
- throw new BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
569
+ throw new import_common3.BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
437
570
  }
438
571
  if (typeof file.size === "number" && file.size > maxSizeBytes) {
439
- throw new BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
572
+ throw new import_common3.BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
440
573
  }
441
574
  }
442
575
  return value;
@@ -449,7 +582,7 @@ var FileValidationPipe = class {
449
582
  for (const field of requiredFields) {
450
583
  const files = value[field];
451
584
  if (!files || files.length === 0) {
452
- throw new BadRequestException(`${field} file is required`);
585
+ throw new import_common3.BadRequestException(`${field} file is required`);
453
586
  }
454
587
  }
455
588
  }
@@ -473,7 +606,7 @@ var FileValidationPipe = class {
473
606
  }
474
607
  };
475
608
  FileValidationPipe = _ts_decorate4([
476
- Injectable2(),
609
+ (0, import_common3.Injectable)(),
477
610
  _ts_metadata3("design:type", Function),
478
611
  _ts_metadata3("design:paramtypes", [
479
612
  typeof FileValidationOptions === "undefined" ? Object : FileValidationOptions
@@ -481,7 +614,7 @@ FileValidationPipe = _ts_decorate4([
481
614
  ], FileValidationPipe);
482
615
 
483
616
  // src/common/pipes/pagination-query-cleaner.pipe.ts
484
- import { Injectable as Injectable3 } from "@nestjs/common";
617
+ var import_common4 = require("@nestjs/common");
485
618
  function _ts_decorate5(decorators, target, key, desc) {
486
619
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
487
620
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -510,11 +643,11 @@ var PaginationQueryCleanerPipe = class {
510
643
  }
511
644
  };
512
645
  PaginationQueryCleanerPipe = _ts_decorate5([
513
- Injectable3()
646
+ (0, import_common4.Injectable)()
514
647
  ], PaginationQueryCleanerPipe);
515
648
 
516
649
  // src/common/response/http-exception.filter.ts
517
- import { BadRequestException as BadRequestException2, Catch, HttpException, HttpStatus, Logger as Logger2 } from "@nestjs/common";
650
+ var import_common5 = require("@nestjs/common");
518
651
 
519
652
  // src/common/response/response.utils.ts
520
653
  var AppResponse = class {
@@ -576,13 +709,13 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
576
709
  static {
577
710
  __name(this, "HttpExceptionFilter");
578
711
  }
579
- logger = new Logger2(_HttpExceptionFilter.name);
712
+ logger = new import_common5.Logger(_HttpExceptionFilter.name);
580
713
  catch(exception, host) {
581
714
  const ctx = host.switchToHttp();
582
715
  const response = ctx.getResponse();
583
716
  const request = ctx.getRequest();
584
- const status = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
585
- const message = exception instanceof HttpException ? exception.message : "An unexpected error occurred";
717
+ const status = exception instanceof import_common5.HttpException ? exception.getStatus() : import_common5.HttpStatus.INTERNAL_SERVER_ERROR;
718
+ const message = exception instanceof import_common5.HttpException ? exception.message : "An unexpected error occurred";
586
719
  const errors = this.getValidationErrors(exception);
587
720
  this.logger.error({
588
721
  method: request.method,
@@ -599,7 +732,7 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
599
732
  response.status(status).send(body);
600
733
  }
601
734
  getValidationErrors(exception) {
602
- if (!(exception instanceof BadRequestException2)) {
735
+ if (!(exception instanceof import_common5.BadRequestException)) {
603
736
  return void 0;
604
737
  }
605
738
  const payload = exception.getResponse();
@@ -619,11 +752,11 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
619
752
  }
620
753
  };
621
754
  HttpExceptionFilter = _ts_decorate6([
622
- Catch()
755
+ (0, import_common5.Catch)()
623
756
  ], HttpExceptionFilter);
624
757
 
625
758
  // src/common/response/http-only-exception.filter.ts
626
- import { Catch as Catch2 } from "@nestjs/common";
759
+ var import_common6 = require("@nestjs/common");
627
760
  function _ts_decorate7(decorators, target, key, desc) {
628
761
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
629
762
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -651,12 +784,12 @@ var HttpOnlyExceptionFilter = class {
651
784
  }
652
785
  };
653
786
  HttpOnlyExceptionFilter = _ts_decorate7([
654
- Catch2()
787
+ (0, import_common6.Catch)()
655
788
  ], HttpOnlyExceptionFilter);
656
789
 
657
790
  // src/common/response/response.interceptor.ts
658
- import { Injectable as Injectable4 } from "@nestjs/common";
659
- import { map } from "rxjs/operators";
791
+ var import_common7 = require("@nestjs/common");
792
+ var import_operators = require("rxjs/operators");
660
793
  function _ts_decorate8(decorators, target, key, desc) {
661
794
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
662
795
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -688,7 +821,7 @@ var ResponseInterceptor = class {
688
821
  return next.handle();
689
822
  }
690
823
  const request = context.switchToHttp().getRequest();
691
- return next.handle().pipe(map((data) => {
824
+ return next.handle().pipe((0, import_operators.map)((data) => {
692
825
  if (isApiResponse(data)) {
693
826
  return data;
694
827
  }
@@ -708,11 +841,11 @@ var ResponseInterceptor = class {
708
841
  }
709
842
  };
710
843
  ResponseInterceptor = _ts_decorate8([
711
- Injectable4()
844
+ (0, import_common7.Injectable)()
712
845
  ], ResponseInterceptor);
713
846
 
714
847
  // src/common/utils/country.utils.ts
715
- import * as CountryCodeList from "country-codes-list";
848
+ var CountryCodeList = __toESM(require("country-codes-list"), 1);
716
849
  var countryDialCodes = Object.keys(CountryCodeList.customList("countryCallingCode")).map((code) => `+${code}`);
717
850
 
718
851
  // src/common/utils/date.utils.ts
@@ -754,15 +887,15 @@ var isValidAge = /* @__PURE__ */ __name((dateOfBirth, minAge = 18) => {
754
887
  }, "isValidAge");
755
888
 
756
889
  // src/common/utils/decimal.utils.ts
757
- import Decimal2 from "decimal.js";
890
+ var import_decimal2 = __toESM(require("decimal.js"), 1);
758
891
  var DEFAULT_DECIMAL_PLACES = 4;
759
- Decimal2.set({
892
+ import_decimal2.default.set({
760
893
  precision: 20,
761
- rounding: Decimal2.ROUND_HALF_UP
894
+ rounding: import_decimal2.default.ROUND_HALF_UP
762
895
  });
763
896
  var toDecimal = /* @__PURE__ */ __name((value) => {
764
897
  try {
765
- return new Decimal2(value);
898
+ return new import_decimal2.default(value);
766
899
  } catch {
767
900
  throw new Error(`Invalid decimal value: ${value}`);
768
901
  }
@@ -973,13 +1106,13 @@ var isValidTransactionReference = /* @__PURE__ */ __name((reference) => {
973
1106
  }, "isValidTransactionReference");
974
1107
 
975
1108
  // src/common/config/nats.config.ts
976
- import { Transport } from "@nestjs/microservices";
1109
+ var import_microservices2 = require("@nestjs/microservices");
977
1110
  var getNatsServers = /* @__PURE__ */ __name((configService) => {
978
- const rawServers = configService.get("NATS_SERVERS") ?? configService.get("NATS_URL") ?? "nats://localhost:4222";
1111
+ const rawServers = configService.get("NATS_URL") ?? "nats://localhost:4222";
979
1112
  return rawServers.split(",").map((server) => server.trim()).filter(Boolean);
980
1113
  }, "getNatsServers");
981
1114
  var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
982
- transport: Transport.NATS,
1115
+ transport: import_microservices2.Transport.NATS,
983
1116
  options: {
984
1117
  servers: getNatsServers(configService)
985
1118
  }
@@ -987,7 +1120,7 @@ var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
987
1120
  var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
988
1121
  const queue = queueName && configService.get(`NATS_${queueName.toUpperCase()}_QUEUE`);
989
1122
  return {
990
- transport: Transport.NATS,
1123
+ transport: import_microservices2.Transport.NATS,
991
1124
  options: {
992
1125
  servers: getNatsServers(configService),
993
1126
  ...queue ? {
@@ -1001,12 +1134,12 @@ var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
1001
1134
  var CACHE_MODULE_OPTIONS = /* @__PURE__ */ Symbol("CACHE_MODULE_OPTIONS");
1002
1135
 
1003
1136
  // src/cache/cache.module.ts
1004
- import { Module } from "@nestjs/common";
1005
- import { ConfigModule } from "@nestjs/config";
1137
+ var import_common9 = require("@nestjs/common");
1138
+ var import_config = require("@nestjs/config");
1006
1139
 
1007
1140
  // src/cache/cache.service.ts
1008
- import { Inject, Injectable as Injectable5 } from "@nestjs/common";
1009
- import Redis from "ioredis";
1141
+ var import_common8 = require("@nestjs/common");
1142
+ var import_ioredis = __toESM(require("ioredis"), 1);
1010
1143
  function _ts_decorate9(decorators, target, key, desc) {
1011
1144
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1012
1145
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1044,7 +1177,7 @@ var CacheService = class {
1044
1177
  }
1045
1178
  async onModuleInit() {
1046
1179
  const options = this.options || {};
1047
- this.redisClient = new Redis({
1180
+ this.redisClient = new import_ioredis.default({
1048
1181
  ...options,
1049
1182
  host: options.host || process.env.REDIS_HOST || "localhost",
1050
1183
  port: options.port || +(process.env?.REDIS_PORT || 6379),
@@ -1132,8 +1265,8 @@ var CacheService = class {
1132
1265
  }
1133
1266
  };
1134
1267
  CacheService = _ts_decorate9([
1135
- Injectable5(),
1136
- _ts_param(0, Inject(CACHE_MODULE_OPTIONS)),
1268
+ (0, import_common8.Injectable)(),
1269
+ _ts_param(0, (0, import_common8.Inject)(CACHE_MODULE_OPTIONS)),
1137
1270
  _ts_metadata4("design:type", Function),
1138
1271
  _ts_metadata4("design:paramtypes", [
1139
1272
  typeof CacheOptions === "undefined" ? Object : CacheOptions
@@ -1163,7 +1296,7 @@ var CacheModule = class _CacheModule {
1163
1296
  return {
1164
1297
  module: _CacheModule,
1165
1298
  imports: [
1166
- ConfigModule
1299
+ import_config.ConfigModule
1167
1300
  ],
1168
1301
  providers: [
1169
1302
  CacheService,
@@ -1179,18 +1312,18 @@ var CacheModule = class _CacheModule {
1179
1312
  }
1180
1313
  };
1181
1314
  CacheModule = _ts_decorate10([
1182
- Module({})
1315
+ (0, import_common9.Module)({})
1183
1316
  ], CacheModule);
1184
1317
 
1185
1318
  // src/rpc/index.ts
1186
- import { BadRequestException as BadRequestException3, HttpException as HttpException2, Logger as Logger3 } from "@nestjs/common";
1187
- import { RpcException } from "@nestjs/microservices";
1319
+ var import_common10 = require("@nestjs/common");
1320
+ var import_microservices3 = require("@nestjs/microservices");
1188
1321
  var ViardexRpcUtils = class ViardexRpcUtils2 {
1189
1322
  static {
1190
1323
  __name(this, "ViardexRpcUtils");
1191
1324
  }
1192
1325
  static getValidationErrors(err) {
1193
- if (err instanceof BadRequestException3) {
1326
+ if (err instanceof import_common10.BadRequestException) {
1194
1327
  const response = err.getResponse();
1195
1328
  if (typeof response === "object" && response !== null && "errors" in response) {
1196
1329
  return Array.isArray(response.errors) ? response.errors : [];
@@ -1220,7 +1353,7 @@ var ViardexRpc = class {
1220
1353
  static catch(err, ctx) {
1221
1354
  const subject = ctx ? ctx.getArgs()[0] : null;
1222
1355
  const error = err instanceof Error ? err : new Error(String(err));
1223
- const statusCode = err instanceof HttpException2 ? err.getStatus() : 500;
1356
+ const statusCode = err instanceof import_common10.HttpException ? err.getStatus() : 500;
1224
1357
  const errorDetails = {
1225
1358
  success: false,
1226
1359
  subject,
@@ -1228,7 +1361,7 @@ var ViardexRpc = class {
1228
1361
  statusCode,
1229
1362
  errors: ViardexRpcUtils.getValidationErrors(err)
1230
1363
  };
1231
- return new RpcException(errorDetails);
1364
+ return new import_microservices3.RpcException(errorDetails);
1232
1365
  }
1233
1366
  static async withReply(obs) {
1234
1367
  const result = await new Promise((resolve, reject) => {
@@ -1238,8 +1371,8 @@ var ViardexRpc = class {
1238
1371
  });
1239
1372
  });
1240
1373
  if (ViardexRpcUtils.isErrorResponse(result)) {
1241
- Logger3.error(result.error);
1242
- throw new HttpException2(result.error, result.error.statusCode, {
1374
+ import_common10.Logger.error(result.error);
1375
+ throw new import_common10.HttpException(result.error, result.error.statusCode, {
1243
1376
  cause: result.error.errors
1244
1377
  });
1245
1378
  }
@@ -1248,15 +1381,15 @@ var ViardexRpc = class {
1248
1381
  };
1249
1382
 
1250
1383
  // src/logger/logger.module.ts
1251
- import { Global, Logger as Logger4, Module as Module2 } from "@nestjs/common";
1252
- import { ConfigModule as ConfigModule2, ConfigService } from "@nestjs/config";
1253
- import { APP_INTERCEPTOR } from "@nestjs/core";
1254
- import { LoggerModule as PinoLoggerModule, PinoLogger as PinoLogger2 } from "nestjs-pino";
1384
+ var import_common12 = require("@nestjs/common");
1385
+ var import_config2 = require("@nestjs/config");
1386
+ var import_core = require("@nestjs/core");
1387
+ var import_nestjs_pino2 = require("nestjs-pino");
1255
1388
 
1256
1389
  // src/logger/logging.interceptor.ts
1257
- import { Inject as Inject2, Injectable as Injectable6 } from "@nestjs/common";
1258
- import { tap as tap2 } from "rxjs";
1259
- import { PinoLogger } from "nestjs-pino";
1390
+ var import_common11 = require("@nestjs/common");
1391
+ var import_rxjs2 = require("rxjs");
1392
+ var import_nestjs_pino = require("nestjs-pino");
1260
1393
  function _ts_decorate11(decorators, target, key, desc) {
1261
1394
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1262
1395
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1304,7 +1437,7 @@ var LoggingInterceptor = class {
1304
1437
  method: request.method,
1305
1438
  url: request.url
1306
1439
  }, "Incoming request");
1307
- return next.handle().pipe(tap2({
1440
+ return next.handle().pipe((0, import_rxjs2.tap)({
1308
1441
  next: /* @__PURE__ */ __name(() => {
1309
1442
  this.logger.info({
1310
1443
  requestId,
@@ -1329,11 +1462,11 @@ var LoggingInterceptor = class {
1329
1462
  }
1330
1463
  };
1331
1464
  LoggingInterceptor = _ts_decorate11([
1332
- Injectable6(),
1333
- _ts_param2(0, Inject2(PinoLogger)),
1465
+ (0, import_common11.Injectable)(),
1466
+ _ts_param2(0, (0, import_common11.Inject)(import_nestjs_pino.PinoLogger)),
1334
1467
  _ts_metadata5("design:type", Function),
1335
1468
  _ts_metadata5("design:paramtypes", [
1336
- typeof PinoLogger === "undefined" ? Object : PinoLogger
1469
+ typeof import_nestjs_pino.PinoLogger === "undefined" ? Object : import_nestjs_pino.PinoLogger
1337
1470
  ])
1338
1471
  ], LoggingInterceptor);
1339
1472
 
@@ -1358,15 +1491,15 @@ var LoggerModule = class {
1358
1491
  }
1359
1492
  };
1360
1493
  LoggerModule = _ts_decorate12([
1361
- Global(),
1362
- Module2({
1494
+ (0, import_common12.Global)(),
1495
+ (0, import_common12.Module)({
1363
1496
  imports: [
1364
- PinoLoggerModule.forRootAsync({
1497
+ import_nestjs_pino2.LoggerModule.forRootAsync({
1365
1498
  imports: [
1366
- ConfigModule2
1499
+ import_config2.ConfigModule
1367
1500
  ],
1368
1501
  inject: [
1369
- ConfigService
1502
+ import_config2.ConfigService
1370
1503
  ],
1371
1504
  useFactory: /* @__PURE__ */ __name((configService) => {
1372
1505
  const env = configService.get("NODE_ENV", "development");
@@ -1403,25 +1536,26 @@ LoggerModule = _ts_decorate12([
1403
1536
  providers: [
1404
1537
  LoggingInterceptor,
1405
1538
  {
1406
- provide: APP_INTERCEPTOR,
1539
+ provide: import_core.APP_INTERCEPTOR,
1407
1540
  useExisting: LoggingInterceptor
1408
1541
  },
1409
1542
  {
1410
- provide: Logger4,
1411
- useExisting: PinoLogger2
1543
+ provide: import_common12.Logger,
1544
+ useExisting: import_nestjs_pino2.PinoLogger
1412
1545
  }
1413
1546
  ],
1414
1547
  exports: [
1415
- PinoLoggerModule,
1548
+ import_nestjs_pino2.LoggerModule,
1416
1549
  LoggingInterceptor,
1417
- Logger4
1550
+ import_common12.Logger
1418
1551
  ]
1419
1552
  })
1420
1553
  ], LoggerModule);
1421
1554
 
1422
1555
  // src/logger/index.ts
1423
- import { PinoLogger as PinoLogger3 } from "nestjs-pino";
1424
- export {
1556
+ var import_nestjs_pino3 = require("nestjs-pino");
1557
+ // Annotate the CommonJS export names for ESM import in node:
1558
+ 0 && (module.exports = {
1425
1559
  AppResponse,
1426
1560
  AuditSubjects,
1427
1561
  BANKING_QUEUE,
@@ -1462,7 +1596,7 @@ export {
1462
1596
  PaginationQueryDto,
1463
1597
  PasswordSubjects,
1464
1598
  PinSubjects,
1465
- PinoLogger3 as PinoLogger,
1599
+ PinoLogger,
1466
1600
  PreferencesSubjects,
1467
1601
  ReferralSubjects,
1468
1602
  ResponseInterceptor,
@@ -1523,5 +1657,5 @@ export {
1523
1657
  toRoundedNumber,
1524
1658
  toTitleCase,
1525
1659
  truncateText
1526
- };
1527
- //# sourceMappingURL=index.mjs.map
1660
+ });
1661
+ //# sourceMappingURL=index.cjs.map