@viardex/viardex-libs 1.0.11 → 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 (176) hide show
  1. package/README.md +12 -235
  2. package/dist/cache/index.cjs +229 -0
  3. package/dist/cache/index.cjs.map +1 -0
  4. package/dist/cache/{cache.service.d.ts → index.d.cts} +14 -4
  5. package/dist/cache/index.d.ts +40 -3
  6. package/dist/cache/index.js +191 -17
  7. package/dist/cache/index.js.map +1 -0
  8. package/dist/common/index.cjs +979 -0
  9. package/dist/common/index.cjs.map +1 -0
  10. package/dist/common/index.d.cts +214 -0
  11. package/dist/common/index.d.ts +214 -10
  12. package/dist/common/index.js +874 -26
  13. package/dist/common/index.js.map +1 -0
  14. package/dist/index.cjs +1661 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +10 -0
  17. package/dist/index.d.ts +10 -9
  18. package/dist/index.js +1527 -25
  19. package/dist/index.js.map +1 -0
  20. package/dist/logger/index.cjs +209 -0
  21. package/dist/logger/index.cjs.map +1 -0
  22. package/dist/logger/index.d.cts +15 -0
  23. package/dist/logger/index.d.ts +14 -2
  24. package/dist/logger/index.js +181 -19
  25. package/dist/logger/index.js.map +1 -0
  26. package/dist/nats/index.cjs +271 -0
  27. package/dist/nats/index.cjs.map +1 -0
  28. package/dist/nats/{constants/nats.constants.d.ts → index.d.cts} +61 -18
  29. package/dist/nats/index.d.ts +200 -5
  30. package/dist/nats/index.js +225 -20
  31. package/dist/nats/index.js.map +1 -0
  32. package/dist/rpc/index.cjs +93 -0
  33. package/dist/rpc/index.cjs.map +1 -0
  34. package/dist/rpc/index.d.cts +22 -0
  35. package/dist/rpc/index.d.ts +7 -3
  36. package/dist/rpc/index.js +69 -63
  37. package/dist/rpc/index.js.map +1 -0
  38. package/package.json +31 -60
  39. package/dist/argon/argon.module.d.ts +0 -2
  40. package/dist/argon/argon.module.js +0 -21
  41. package/dist/argon/argon.service.d.ts +0 -6
  42. package/dist/argon/argon.service.js +0 -74
  43. package/dist/argon/index.d.ts +0 -2
  44. package/dist/argon/index.js +0 -18
  45. package/dist/auth/auth.constants.d.ts +0 -4
  46. package/dist/auth/auth.constants.js +0 -7
  47. package/dist/auth/auth.interfaces.d.ts +0 -19
  48. package/dist/auth/auth.interfaces.js +0 -2
  49. package/dist/auth/auth.module.d.ts +0 -2
  50. package/dist/auth/auth.module.js +0 -31
  51. package/dist/auth/auth.service.d.ts +0 -13
  52. package/dist/auth/auth.service.js +0 -104
  53. package/dist/auth/decorators/auth-token-types.decorator.d.ts +0 -2
  54. package/dist/auth/decorators/auth-token-types.decorator.js +0 -7
  55. package/dist/auth/decorators/current-auth.decorator.d.ts +0 -1
  56. package/dist/auth/decorators/current-auth.decorator.js +0 -10
  57. package/dist/auth/decorators/index.d.ts +0 -5
  58. package/dist/auth/decorators/index.js +0 -21
  59. package/dist/auth/decorators/permissions.decorator.d.ts +0 -1
  60. package/dist/auth/decorators/permissions.decorator.js +0 -7
  61. package/dist/auth/decorators/public.decorator.d.ts +0 -1
  62. package/dist/auth/decorators/public.decorator.js +0 -7
  63. package/dist/auth/decorators/roles.decorator.d.ts +0 -1
  64. package/dist/auth/decorators/roles.decorator.js +0 -7
  65. package/dist/auth/guards/auth.guard.d.ts +0 -10
  66. package/dist/auth/guards/auth.guard.js +0 -65
  67. package/dist/auth/guards/index.d.ts +0 -3
  68. package/dist/auth/guards/index.js +0 -19
  69. package/dist/auth/guards/permissions.guard.d.ts +0 -7
  70. package/dist/auth/guards/permissions.guard.js +0 -52
  71. package/dist/auth/guards/roles.guard.d.ts +0 -7
  72. package/dist/auth/guards/roles.guard.js +0 -53
  73. package/dist/auth/index.d.ts +0 -6
  74. package/dist/auth/index.js +0 -22
  75. package/dist/cache/cache.constants.d.ts +0 -1
  76. package/dist/cache/cache.constants.js +0 -4
  77. package/dist/cache/cache.interface.d.ts +0 -2
  78. package/dist/cache/cache.interface.js +0 -2
  79. package/dist/cache/cache.module.d.ts +0 -5
  80. package/dist/cache/cache.module.js +0 -31
  81. package/dist/cache/cache.service.js +0 -125
  82. package/dist/common/cards/card.utils.d.ts +0 -9
  83. package/dist/common/cards/card.utils.js +0 -48
  84. package/dist/common/cards/index.d.ts +0 -1
  85. package/dist/common/cards/index.js +0 -17
  86. package/dist/common/config/index.d.ts +0 -1
  87. package/dist/common/config/index.js +0 -17
  88. package/dist/common/config/nats.config.d.ts +0 -8
  89. package/dist/common/config/nats.config.js +0 -33
  90. package/dist/common/constants/index.d.ts +0 -2
  91. package/dist/common/constants/index.js +0 -18
  92. package/dist/common/constants/otp.constants.d.ts +0 -15
  93. package/dist/common/constants/otp.constants.js +0 -18
  94. package/dist/common/constants/queues.constants.d.ts +0 -9
  95. package/dist/common/constants/queues.constants.js +0 -12
  96. package/dist/common/crypto/crypto.utils.d.ts +0 -7
  97. package/dist/common/crypto/crypto.utils.js +0 -42
  98. package/dist/common/crypto/index.d.ts +0 -1
  99. package/dist/common/crypto/index.js +0 -17
  100. package/dist/common/dto/index.d.ts +0 -1
  101. package/dist/common/dto/index.js +0 -17
  102. package/dist/common/dto/pagination-query.dto.d.ts +0 -7
  103. package/dist/common/dto/pagination-query.dto.js +0 -51
  104. package/dist/common/enums/index.d.ts +0 -1
  105. package/dist/common/enums/index.js +0 -17
  106. package/dist/common/enums/otp.enum.d.ts +0 -16
  107. package/dist/common/enums/otp.enum.js +0 -20
  108. package/dist/common/interfaces/index.d.ts +0 -1
  109. package/dist/common/interfaces/index.js +0 -17
  110. package/dist/common/interfaces/response.interface.d.ts +0 -27
  111. package/dist/common/interfaces/response.interface.js +0 -2
  112. package/dist/common/pipes/file-validation.pipe.d.ts +0 -22
  113. package/dist/common/pipes/file-validation.pipe.js +0 -78
  114. package/dist/common/pipes/index.d.ts +0 -2
  115. package/dist/common/pipes/index.js +0 -18
  116. package/dist/common/pipes/pagination-query-cleaner.pipe.d.ts +0 -4
  117. package/dist/common/pipes/pagination-query-cleaner.pipe.js +0 -24
  118. package/dist/common/response/http-exception.filter.d.ts +0 -6
  119. package/dist/common/response/http-exception.filter.js +0 -61
  120. package/dist/common/response/http-only-exception.filter.d.ts +0 -5
  121. package/dist/common/response/http-only-exception.filter.js +0 -24
  122. package/dist/common/response/index.d.ts +0 -4
  123. package/dist/common/response/index.js +0 -20
  124. package/dist/common/response/response.interceptor.d.ts +0 -6
  125. package/dist/common/response/response.interceptor.js +0 -57
  126. package/dist/common/response/response.utils.d.ts +0 -6
  127. package/dist/common/response/response.utils.js +0 -34
  128. package/dist/common/utils/country.utils.d.ts +0 -1
  129. package/dist/common/utils/country.utils.js +0 -38
  130. package/dist/common/utils/date.utils.d.ts +0 -6
  131. package/dist/common/utils/date.utils.js +0 -48
  132. package/dist/common/utils/decimal.utils.d.ts +0 -3
  133. package/dist/common/utils/decimal.utils.js +0 -22
  134. package/dist/common/utils/format.utils.d.ts +0 -13
  135. package/dist/common/utils/format.utils.js +0 -127
  136. package/dist/common/utils/index.d.ts +0 -8
  137. package/dist/common/utils/index.js +0 -24
  138. package/dist/common/utils/random.utils.d.ts +0 -10
  139. package/dist/common/utils/random.utils.js +0 -27
  140. package/dist/common/utils/reference.utils.d.ts +0 -1
  141. package/dist/common/utils/reference.utils.js +0 -17
  142. package/dist/common/utils/string.utils.d.ts +0 -10
  143. package/dist/common/utils/string.utils.js +0 -34
  144. package/dist/common/utils/validation.utils.d.ts +0 -8
  145. package/dist/common/utils/validation.utils.js +0 -44
  146. package/dist/health/health.controller.d.ts +0 -19
  147. package/dist/health/health.controller.js +0 -103
  148. package/dist/health/health.module.d.ts +0 -2
  149. package/dist/health/health.module.js +0 -21
  150. package/dist/health/index.d.ts +0 -2
  151. package/dist/health/index.js +0 -18
  152. package/dist/logger/logger.module.d.ts +0 -2
  153. package/dist/logger/logger.module.js +0 -72
  154. package/dist/logger/logging.interceptor.d.ts +0 -8
  155. package/dist/logger/logging.interceptor.js +0 -66
  156. package/dist/nats/constants/nats.constants.js +0 -101
  157. package/dist/nats/decorators/nats-event-pattern.decorator.d.ts +0 -2
  158. package/dist/nats/decorators/nats-event-pattern.decorator.js +0 -11
  159. package/dist/nats/dto/nats-message.dto.d.ts +0 -5
  160. package/dist/nats/dto/nats-message.dto.js +0 -33
  161. package/dist/nats/interceptors/nats-logging.interceptor.d.ts +0 -6
  162. package/dist/nats/interceptors/nats-logging.interceptor.js +0 -33
  163. package/dist/nats/interfaces/nats-options.interface.d.ts +0 -23
  164. package/dist/nats/interfaces/nats-options.interface.js +0 -2
  165. package/dist/storage/index.d.ts +0 -5
  166. package/dist/storage/index.js +0 -21
  167. package/dist/storage/r2.service.d.ts +0 -20
  168. package/dist/storage/r2.service.js +0 -213
  169. package/dist/storage/s3.service.d.ts +0 -20
  170. package/dist/storage/s3.service.js +0 -209
  171. package/dist/storage/storage.interface.d.ts +0 -29
  172. package/dist/storage/storage.interface.js +0 -2
  173. package/dist/storage/storage.module.d.ts +0 -2
  174. package/dist/storage/storage.module.js +0 -24
  175. package/dist/storage/storage.service.d.ts +0 -22
  176. package/dist/storage/storage.service.js +0 -63
package/dist/index.js CHANGED
@@ -1,25 +1,1527 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./nats"), exports);
18
- __exportStar(require("./common"), exports);
19
- __exportStar(require("./cache"), exports);
20
- __exportStar(require("./rpc"), exports);
21
- __exportStar(require("./logger"), exports);
22
- __exportStar(require("./health"), exports);
23
- __exportStar(require("./auth"), exports);
24
- __exportStar(require("./storage"), exports);
25
- __exportStar(require("./argon"), exports);
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/nats/constants/nats.constants.ts
5
+ var NATS_OPTIONS = "NATS_OPTIONS";
6
+ var NATS_CLIENT = "NATS_CLIENT";
7
+ var DEFAULT_NATS_CONFIG = {
8
+ url: "nats://localhost:4222",
9
+ timeout: 5e3,
10
+ reconnect: true,
11
+ reconnectTimeWait: 2e3,
12
+ maxReconnectAttempts: 10
13
+ };
14
+ var NotificationSubjects = {
15
+ CREATE_IN_APP_NOTIFICATION: "notification.create-in-app",
16
+ SEND_TEMPLATE_EMAIL: "notification.email.send-template",
17
+ SEND_TEXT_MESSAGE: "notification.text.send",
18
+ SEND_WHATSAPP_MESSAGE: "notification.whatsapp.send",
19
+ SEND_VOICE_MESSAGE: "notification.voice.send",
20
+ SEND_PUSH_NOTIFICATION: "notification.push.send"
21
+ };
22
+ var UserServiceSubjects = {
23
+ RESOLVE_MARKETING_USERS: "user.marketing.users.resolve"
24
+ };
25
+ var SignupSubjects = {
26
+ SIGNUP_INITIATED: "signup.initiated",
27
+ SIGNUP_COMPLETED: "signup.completed",
28
+ SIGNUP_VERIFICATION_REQUESTED: "signup.verification.requested"
29
+ };
30
+ var SigninSubjects = {
31
+ SIGNIN_INITIATED: "signin.initiated",
32
+ SIGNIN_COMPLETED: "signin.completed",
33
+ DEVICE_VERIFICATION_REQUESTED: "signin.device-verification.requested",
34
+ SIGNIN_FAILED: "signin.failed"
35
+ };
36
+ var PasswordSubjects = {
37
+ PASSWORD_RESET_REQUESTED: "password.reset.requested",
38
+ PASSWORD_RESET_COMPLETED: "password.reset.completed",
39
+ PASSWORD_CHANGED: "password.changed"
40
+ };
41
+ var PinSubjects = {
42
+ PIN_RESET_REQUESTED: "pin.reset.requested",
43
+ PIN_RESET_COMPLETED: "pin.reset.completed",
44
+ PIN_CHANGED: "pin.changed",
45
+ PIN_LOCKED: "pin.locked"
46
+ };
47
+ var PreferencesSubjects = {
48
+ USER_PREFERENCES_PROVISION_REQUESTED: "preferences.user.provision.requested",
49
+ USER_PREFERENCES_UPDATED: "preferences.user.updated",
50
+ STAFF_PREFERENCES_PROVISION_REQUESTED: "preferences.staff.provision.requested",
51
+ STAFF_PREFERENCES_UPDATED: "preferences.staff.updated"
52
+ };
53
+ var ReferralSubjects = {
54
+ REFERRAL_CODE_PROVISION_REQUESTED: "referral.code.provision.requested",
55
+ REFERRAL_LINKED: "referral.linked",
56
+ REFERRAL_COMPLETED: "referral.completed",
57
+ REFERRAL_REWARD_PROCESSING_REQUESTED: "referral.reward.processing.requested"
58
+ };
59
+ var TicketSubjects = {
60
+ TICKET_CREATED: "ticket.created",
61
+ TICKET_UPDATED: "ticket.updated",
62
+ TICKET_RESOLVED: "ticket.resolved"
63
+ };
64
+ var DeviceSubjects = {
65
+ DEVICE_TRUSTED: "device.trusted",
66
+ DEVICE_REVOKED: "device.revoked",
67
+ DEVICE_DEACTIVATED: "device.deactivated",
68
+ DEVICE_ACTIVATED: "device.activated"
69
+ };
70
+ var CountrySubjects = {
71
+ COUNTRIES_SYNC_REQUESTED: "country.sync.requested"
72
+ };
73
+ var StaffSubjects = {
74
+ STAFF_CREATED: "staff.created",
75
+ STAFF_UPDATED: "staff.updated",
76
+ STAFF_PASSWORD_CHANGED: "staff.password.changed",
77
+ STAFF_SIGNIN_COMPLETED: "staff.signin.completed"
78
+ };
79
+ var RoleSubjects = {
80
+ ROLE_CREATED: "role.created",
81
+ ROLE_UPDATED: "role.updated",
82
+ ROLE_PERMISSIONS_UPDATED: "role.permissions.updated"
83
+ };
84
+ var AuditSubjects = {
85
+ AUDIT_LOG_RECORDED: "audit.log.recorded"
86
+ };
87
+ var NatsSubjects = {
88
+ notification: NotificationSubjects,
89
+ userService: UserServiceSubjects,
90
+ signup: SignupSubjects,
91
+ signin: SigninSubjects,
92
+ password: PasswordSubjects,
93
+ pin: PinSubjects,
94
+ preferences: PreferencesSubjects,
95
+ referrals: ReferralSubjects,
96
+ tickets: TicketSubjects,
97
+ devices: DeviceSubjects,
98
+ countries: CountrySubjects,
99
+ staff: StaffSubjects,
100
+ roles: RoleSubjects,
101
+ audit: AuditSubjects
102
+ };
103
+
104
+ // src/nats/dto/nats-message.dto.ts
105
+ import { IsNotEmpty, IsOptional, IsString } from "class-validator";
106
+ function _ts_decorate(decorators, target, key, desc) {
107
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
108
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
109
+ r = Reflect.decorate(decorators, target, key, desc);
110
+ } else {
111
+ for (var i = decorators.length - 1; i >= 0; i--) {
112
+ if (d = decorators[i]) {
113
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
114
+ }
115
+ }
116
+ }
117
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
118
+ }
119
+ __name(_ts_decorate, "_ts_decorate");
120
+ function _ts_metadata(metadataKey, metadataValue) {
121
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
122
+ return Reflect.metadata(metadataKey, metadataValue);
123
+ }
124
+ }
125
+ __name(_ts_metadata, "_ts_metadata");
126
+ var NatsMessageDto = class {
127
+ static {
128
+ __name(this, "NatsMessageDto");
129
+ }
130
+ pattern;
131
+ data;
132
+ replyTo;
133
+ };
134
+ _ts_decorate([
135
+ IsString(),
136
+ IsNotEmpty(),
137
+ _ts_metadata("design:type", String)
138
+ ], NatsMessageDto.prototype, "pattern", void 0);
139
+ _ts_decorate([
140
+ IsNotEmpty(),
141
+ _ts_metadata("design:type", Object)
142
+ ], NatsMessageDto.prototype, "data", void 0);
143
+ _ts_decorate([
144
+ IsString(),
145
+ IsOptional(),
146
+ _ts_metadata("design:type", String)
147
+ ], NatsMessageDto.prototype, "replyTo", void 0);
148
+
149
+ // src/nats/decorators/nats-event-pattern.decorator.ts
150
+ import { applyDecorators, SetMetadata, UseInterceptors } from "@nestjs/common";
151
+ import { EventPattern } from "@nestjs/microservices";
152
+
153
+ // src/nats/interceptors/nats-logging.interceptor.ts
154
+ import { Injectable, Logger } from "@nestjs/common";
155
+ import { tap } from "rxjs";
156
+ function _ts_decorate2(decorators, target, key, desc) {
157
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
158
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
159
+ r = Reflect.decorate(decorators, target, key, desc);
160
+ } else {
161
+ for (var i = decorators.length - 1; i >= 0; i--) {
162
+ if (d = decorators[i]) {
163
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
164
+ }
165
+ }
166
+ }
167
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
168
+ }
169
+ __name(_ts_decorate2, "_ts_decorate");
170
+ var NatsLoggingInterceptor = class _NatsLoggingInterceptor {
171
+ static {
172
+ __name(this, "NatsLoggingInterceptor");
173
+ }
174
+ logger = new Logger(_NatsLoggingInterceptor.name);
175
+ intercept(context, next) {
176
+ const now = Date.now();
177
+ const rpcContext = context.switchToRpc();
178
+ const natsContext = rpcContext.getContext();
179
+ const pattern = natsContext.getSubject();
180
+ return next.handle().pipe(tap({
181
+ next: /* @__PURE__ */ __name((data) => {
182
+ this.logger.log(`Pattern: ${pattern} | Response time: ${Date.now() - now}ms | Response: ${JSON.stringify(data)}`);
183
+ }, "next"),
184
+ error: /* @__PURE__ */ __name((error) => {
185
+ this.logger.error(`Pattern: ${pattern} | Error: ${error.message}`, error.stack);
186
+ }, "error")
187
+ }));
188
+ }
189
+ };
190
+ NatsLoggingInterceptor = _ts_decorate2([
191
+ Injectable()
192
+ ], NatsLoggingInterceptor);
193
+
194
+ // src/nats/decorators/nats-event-pattern.decorator.ts
195
+ var NATS_EVENT_METADATA = "nats_event_metadata";
196
+ function NatsEventPattern(pattern) {
197
+ return applyDecorators(SetMetadata(NATS_EVENT_METADATA, {
198
+ pattern
199
+ }), EventPattern(pattern), UseInterceptors(NatsLoggingInterceptor));
200
+ }
201
+ __name(NatsEventPattern, "NatsEventPattern");
202
+
203
+ // src/common/constants/queues.constants.ts
204
+ var USER_QUEUE = "user_queue";
205
+ var KYC_QUEUE = "kyc_queue";
206
+ var LEDGER_QUEUE = "ledger_queue";
207
+ var BANKING_QUEUE = "banking_queue";
208
+ var CARD_QUEUE = "card_queue";
209
+ var CRYPTO_QUEUE = "crypto_queue";
210
+ var VAS_QUEUE = "vas_queue";
211
+ var OPS_QUEUE = "ops_queue";
212
+ var NOTIFICATION_QUEUE = "notification_queue";
213
+
214
+ // src/common/constants/otp.constants.ts
215
+ var DEFAULT_OTP_LENGTH = 6;
216
+ var DEFAULT_OTP_EXPIRY = 10;
217
+ var MAX_OTP_ATTEMPTS = 3;
218
+ var OTP_BLOCK_DURATION = 30;
219
+ var DEFAULT_OTP_OPTIONS = {
220
+ length: DEFAULT_OTP_LENGTH,
221
+ expiry: DEFAULT_OTP_EXPIRY,
222
+ caseSensitive: false,
223
+ digits: true,
224
+ lowerCaseAlphabets: false,
225
+ upperCaseAlphabets: false,
226
+ specialChars: false
227
+ };
228
+ var OTP_CACHE_PREFIX = "otp:";
229
+ var OTP_ATTEMPTS_CACHE_PREFIX = "otp:attempts:";
230
+
231
+ // src/common/cards/card.utils.ts
232
+ var maskPan = /* @__PURE__ */ __name((pan, visiblePrefix = 0, visibleSuffix = 4) => {
233
+ const digits = pan.replace(/\s+/g, "");
234
+ if (digits.length <= visibleSuffix) {
235
+ return digits;
236
+ }
237
+ const prefix = digits.slice(0, visiblePrefix);
238
+ const suffix = digits.slice(-visibleSuffix);
239
+ const maskedLength = Math.max(0, digits.length - visiblePrefix - visibleSuffix);
240
+ return `${prefix}${"*".repeat(maskedLength)}${suffix}`;
241
+ }, "maskPan");
242
+ var extractLast4 = /* @__PURE__ */ __name((pan) => {
243
+ const digits = pan.replace(/\s+/g, "");
244
+ return digits.slice(-4);
245
+ }, "extractLast4");
246
+ var extractBin = /* @__PURE__ */ __name((pan, length = 6) => {
247
+ const digits = pan.replace(/\s+/g, "");
248
+ return digits.slice(0, length);
249
+ }, "extractBin");
250
+ var formatCardExpiry = /* @__PURE__ */ __name((month, year) => {
251
+ const normalizedMonth = String(month).padStart(2, "0");
252
+ const normalizedYear = String(year).slice(-2);
253
+ return `${normalizedMonth}/${normalizedYear}`;
254
+ }, "formatCardExpiry");
255
+ var normalizeCardExpiry = /* @__PURE__ */ __name((expiry) => {
256
+ const normalized = expiry.trim();
257
+ const match = normalized.match(/^(\d{1,2})\s*\/\s*(\d{2,4})$/);
258
+ if (!match) {
259
+ return null;
260
+ }
261
+ const month = match[1].padStart(2, "0");
262
+ const year = match[2].length === 2 ? `20${match[2]}` : match[2];
263
+ if (Number(month) < 1 || Number(month) > 12) {
264
+ return null;
265
+ }
266
+ return {
267
+ month,
268
+ year
269
+ };
270
+ }, "normalizeCardExpiry");
271
+ var formatCardLabel = /* @__PURE__ */ __name((brand, last4) => {
272
+ return `${brand?.trim() || "Card"} \u2022\u2022\u2022\u2022 ${last4}`;
273
+ }, "formatCardLabel");
274
+
275
+ // src/common/crypto/crypto.utils.ts
276
+ import Decimal from "decimal.js";
277
+ var DECIMAL_ZERO = new Decimal(0);
278
+ var toAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
279
+ return new Decimal(value).mul(new Decimal(10).pow(decimals)).toDecimalPlaces(0, Decimal.ROUND_DOWN).toFixed(0);
280
+ }, "toAtomicUnits");
281
+ var fromAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
282
+ return new Decimal(value).div(new Decimal(10).pow(decimals)).toFixed();
283
+ }, "fromAtomicUnits");
284
+ var formatCryptoAmount = /* @__PURE__ */ __name((value, decimals = 8) => {
285
+ return new Decimal(value).toDecimalPlaces(decimals).toString();
286
+ }, "formatCryptoAmount");
287
+ var normalizeTxHash = /* @__PURE__ */ __name((hash) => {
288
+ return hash.trim().toLowerCase();
289
+ }, "normalizeTxHash");
290
+ var isHexTxHash = /* @__PURE__ */ __name((hash, expectedLength) => {
291
+ const normalized = hash.trim().toLowerCase();
292
+ if (!/^0x[a-f0-9]+$/.test(normalized)) {
293
+ return false;
294
+ }
295
+ if (expectedLength && normalized.length !== expectedLength) {
296
+ return false;
297
+ }
298
+ return true;
299
+ }, "isHexTxHash");
300
+ var isPositiveAmount = /* @__PURE__ */ __name((value) => {
301
+ return new Decimal(value).greaterThan(DECIMAL_ZERO);
302
+ }, "isPositiveAmount");
303
+
304
+ // src/common/enums/otp.enum.ts
305
+ var OtpPurpose = /* @__PURE__ */ (function(OtpPurpose2) {
306
+ OtpPurpose2["PHONE_VERIFICATION"] = "phone_verification";
307
+ OtpPurpose2["PASSWORD_RESET"] = "password_reset";
308
+ OtpPurpose2["TRANSACTION_AUTHORIZATION"] = "transaction_authorization";
309
+ OtpPurpose2["PROFILE_UPDATE"] = "profile_update";
310
+ OtpPurpose2["KYC_VERIFICATION"] = "kyc_verification";
311
+ OtpPurpose2["LOGIN_VERIFICATION"] = "login_verification";
312
+ OtpPurpose2["EMAIL_VERIFICATION"] = "email_verification";
313
+ OtpPurpose2["STAFF_PASSWORD_RESET"] = "staff_password_reset";
314
+ OtpPurpose2["FORGET_PIN"] = "forget_pin";
315
+ OtpPurpose2["CHANGE_PASSWORD"] = "change_password";
316
+ OtpPurpose2["DEVICE_VERIFICATION"] = "device_verification";
317
+ OtpPurpose2["CHANGE_EMAIL"] = "change_email";
318
+ OtpPurpose2["CHANGE_PHONE"] = "change_phone";
319
+ OtpPurpose2["CHANGE_DATE_OF_BIRTH"] = "change_date_of_birth";
320
+ return OtpPurpose2;
321
+ })({});
322
+
323
+ // 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";
326
+ function _ts_decorate3(decorators, target, key, desc) {
327
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
328
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
329
+ r = Reflect.decorate(decorators, target, key, desc);
330
+ } else {
331
+ for (var i = decorators.length - 1; i >= 0; i--) {
332
+ if (d = decorators[i]) {
333
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
334
+ }
335
+ }
336
+ }
337
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
338
+ }
339
+ __name(_ts_decorate3, "_ts_decorate");
340
+ function _ts_metadata2(metadataKey, metadataValue) {
341
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
342
+ return Reflect.metadata(metadataKey, metadataValue);
343
+ }
344
+ }
345
+ __name(_ts_metadata2, "_ts_metadata");
346
+ var PaginationQueryDto = class {
347
+ static {
348
+ __name(this, "PaginationQueryDto");
349
+ }
350
+ page;
351
+ limit;
352
+ search;
353
+ sortBy;
354
+ sortOrder;
355
+ };
356
+ _ts_decorate3([
357
+ Type(() => Number),
358
+ IsInt(),
359
+ Min(1),
360
+ IsOptional2(),
361
+ _ts_metadata2("design:type", Number)
362
+ ], PaginationQueryDto.prototype, "page", void 0);
363
+ _ts_decorate3([
364
+ Type(() => Number),
365
+ IsInt(),
366
+ Min(1),
367
+ IsOptional2(),
368
+ _ts_metadata2("design:type", Number)
369
+ ], PaginationQueryDto.prototype, "limit", void 0);
370
+ _ts_decorate3([
371
+ IsString2(),
372
+ IsOptional2(),
373
+ _ts_metadata2("design:type", String)
374
+ ], PaginationQueryDto.prototype, "search", void 0);
375
+ _ts_decorate3([
376
+ IsString2(),
377
+ IsOptional2(),
378
+ _ts_metadata2("design:type", String)
379
+ ], PaginationQueryDto.prototype, "sortBy", void 0);
380
+ _ts_decorate3([
381
+ IsIn([
382
+ "asc",
383
+ "desc"
384
+ ]),
385
+ IsOptional2(),
386
+ _ts_metadata2("design:type", String)
387
+ ], PaginationQueryDto.prototype, "sortOrder", void 0);
388
+
389
+ // src/common/pipes/file-validation.pipe.ts
390
+ import { BadRequestException, Injectable as Injectable2 } from "@nestjs/common";
391
+ function _ts_decorate4(decorators, target, key, desc) {
392
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
393
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
394
+ r = Reflect.decorate(decorators, target, key, desc);
395
+ } else {
396
+ for (var i = decorators.length - 1; i >= 0; i--) {
397
+ if (d = decorators[i]) {
398
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
399
+ }
400
+ }
401
+ }
402
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
403
+ }
404
+ __name(_ts_decorate4, "_ts_decorate");
405
+ function _ts_metadata3(metadataKey, metadataValue) {
406
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
407
+ return Reflect.metadata(metadataKey, metadataValue);
408
+ }
409
+ }
410
+ __name(_ts_metadata3, "_ts_metadata");
411
+ var DEFAULT_ALLOWED_MIME_TYPES = [
412
+ "image/jpeg",
413
+ "image/jpg",
414
+ "image/png"
415
+ ];
416
+ var DEFAULT_MAX_SIZE_BYTES = 5 * 1024 * 1024;
417
+ var FileValidationPipe = class {
418
+ static {
419
+ __name(this, "FileValidationPipe");
420
+ }
421
+ options;
422
+ constructor(options = {}) {
423
+ this.options = options;
424
+ }
425
+ transform(value) {
426
+ const files = this.normalizeFiles(value);
427
+ if (files.length === 0) {
428
+ throw new BadRequestException("No files uploaded");
429
+ }
430
+ this.validateRequiredFields(value);
431
+ const allowedMimeTypes = this.options.allowedMimeTypes ?? DEFAULT_ALLOWED_MIME_TYPES;
432
+ const maxSizeBytes = this.options.maxSizeBytes ?? DEFAULT_MAX_SIZE_BYTES;
433
+ for (const file of files) {
434
+ const label = file.fieldname || file.originalname || "file";
435
+ if (file.mimetype && !allowedMimeTypes.includes(file.mimetype)) {
436
+ throw new BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
437
+ }
438
+ if (typeof file.size === "number" && file.size > maxSizeBytes) {
439
+ throw new BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
440
+ }
441
+ }
442
+ return value;
443
+ }
444
+ validateRequiredFields(value) {
445
+ const requiredFields = this.options.requiredFields ?? [];
446
+ if (requiredFields.length === 0 || !value || Array.isArray(value) || typeof value !== "object") {
447
+ return;
448
+ }
449
+ for (const field of requiredFields) {
450
+ const files = value[field];
451
+ if (!files || files.length === 0) {
452
+ throw new BadRequestException(`${field} file is required`);
453
+ }
454
+ }
455
+ }
456
+ normalizeFiles(value) {
457
+ if (!value) {
458
+ return [];
459
+ }
460
+ if (Array.isArray(value)) {
461
+ return value;
462
+ }
463
+ return Object.values(value).flatMap((files) => files ?? []);
464
+ }
465
+ formatFileSize(bytes) {
466
+ if (bytes < 1024) {
467
+ return `${bytes} Bytes`;
468
+ }
469
+ if (bytes < 1024 * 1024) {
470
+ return `${(bytes / 1024).toFixed(1)} KB`;
471
+ }
472
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
473
+ }
474
+ };
475
+ FileValidationPipe = _ts_decorate4([
476
+ Injectable2(),
477
+ _ts_metadata3("design:type", Function),
478
+ _ts_metadata3("design:paramtypes", [
479
+ typeof FileValidationOptions === "undefined" ? Object : FileValidationOptions
480
+ ])
481
+ ], FileValidationPipe);
482
+
483
+ // src/common/pipes/pagination-query-cleaner.pipe.ts
484
+ import { Injectable as Injectable3 } from "@nestjs/common";
485
+ function _ts_decorate5(decorators, target, key, desc) {
486
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
487
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
488
+ r = Reflect.decorate(decorators, target, key, desc);
489
+ } else {
490
+ for (var i = decorators.length - 1; i >= 0; i--) {
491
+ if (d = decorators[i]) {
492
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
493
+ }
494
+ }
495
+ }
496
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
497
+ }
498
+ __name(_ts_decorate5, "_ts_decorate");
499
+ var PaginationQueryCleanerPipe = class {
500
+ static {
501
+ __name(this, "PaginationQueryCleanerPipe");
502
+ }
503
+ transform(value, _metadata) {
504
+ if (!value || typeof value !== "object") {
505
+ return value;
506
+ }
507
+ delete value.page;
508
+ delete value.limit;
509
+ return value;
510
+ }
511
+ };
512
+ PaginationQueryCleanerPipe = _ts_decorate5([
513
+ Injectable3()
514
+ ], PaginationQueryCleanerPipe);
515
+
516
+ // src/common/response/http-exception.filter.ts
517
+ import { BadRequestException as BadRequestException2, Catch, HttpException, HttpStatus, Logger as Logger2 } from "@nestjs/common";
518
+
519
+ // src/common/response/response.utils.ts
520
+ var AppResponse = class {
521
+ static {
522
+ __name(this, "AppResponse");
523
+ }
524
+ static success(message, data, meta) {
525
+ return {
526
+ success: true,
527
+ message,
528
+ data,
529
+ ...meta ? {
530
+ meta
531
+ } : {}
532
+ };
533
+ }
534
+ static paginated(message, items, pagination, meta) {
535
+ return {
536
+ success: true,
537
+ message,
538
+ data: items,
539
+ meta: {
540
+ ...meta,
541
+ pagination
542
+ }
543
+ };
544
+ }
545
+ static error(message, errors, meta, data = null) {
546
+ return {
547
+ success: false,
548
+ message,
549
+ data,
550
+ ...meta ? {
551
+ meta
552
+ } : {},
553
+ ...errors?.length ? {
554
+ errors
555
+ } : {}
556
+ };
557
+ }
558
+ };
559
+
560
+ // src/common/response/http-exception.filter.ts
561
+ function _ts_decorate6(decorators, target, key, desc) {
562
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
563
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
564
+ r = Reflect.decorate(decorators, target, key, desc);
565
+ } else {
566
+ for (var i = decorators.length - 1; i >= 0; i--) {
567
+ if (d = decorators[i]) {
568
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
569
+ }
570
+ }
571
+ }
572
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
573
+ }
574
+ __name(_ts_decorate6, "_ts_decorate");
575
+ var HttpExceptionFilter = class _HttpExceptionFilter {
576
+ static {
577
+ __name(this, "HttpExceptionFilter");
578
+ }
579
+ logger = new Logger2(_HttpExceptionFilter.name);
580
+ catch(exception, host) {
581
+ const ctx = host.switchToHttp();
582
+ const response = ctx.getResponse();
583
+ 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";
586
+ const errors = this.getValidationErrors(exception);
587
+ this.logger.error({
588
+ method: request.method,
589
+ url: request.url,
590
+ statusCode: status,
591
+ error: message,
592
+ stack: exception instanceof Error ? exception.stack : void 0
593
+ }, "HTTP request failed");
594
+ const body = AppResponse.error(message, errors, {
595
+ path: request.url ? `${request.method ?? "GET"} ${request.url}` : void 0,
596
+ requestId: request.requestId ?? request.id,
597
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
598
+ });
599
+ response.status(status).send(body);
600
+ }
601
+ getValidationErrors(exception) {
602
+ if (!(exception instanceof BadRequestException2)) {
603
+ return void 0;
604
+ }
605
+ const payload = exception.getResponse();
606
+ if (typeof payload === "object" && payload !== null) {
607
+ const errors = payload.errors;
608
+ if (Array.isArray(errors)) {
609
+ return errors;
610
+ }
611
+ const message = payload.message;
612
+ if (Array.isArray(message)) {
613
+ return message.map((item) => ({
614
+ message: String(item)
615
+ }));
616
+ }
617
+ }
618
+ return void 0;
619
+ }
620
+ };
621
+ HttpExceptionFilter = _ts_decorate6([
622
+ Catch()
623
+ ], HttpExceptionFilter);
624
+
625
+ // src/common/response/http-only-exception.filter.ts
626
+ import { Catch as Catch2 } from "@nestjs/common";
627
+ function _ts_decorate7(decorators, target, key, desc) {
628
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
629
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
630
+ r = Reflect.decorate(decorators, target, key, desc);
631
+ } else {
632
+ for (var i = decorators.length - 1; i >= 0; i--) {
633
+ if (d = decorators[i]) {
634
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
635
+ }
636
+ }
637
+ }
638
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
639
+ }
640
+ __name(_ts_decorate7, "_ts_decorate");
641
+ var HttpOnlyExceptionFilter = class {
642
+ static {
643
+ __name(this, "HttpOnlyExceptionFilter");
644
+ }
645
+ httpExceptionFilter = new HttpExceptionFilter();
646
+ catch(exception, host) {
647
+ if (host.getType() !== "http") {
648
+ throw exception;
649
+ }
650
+ this.httpExceptionFilter.catch(exception, host);
651
+ }
652
+ };
653
+ HttpOnlyExceptionFilter = _ts_decorate7([
654
+ Catch2()
655
+ ], HttpOnlyExceptionFilter);
656
+
657
+ // src/common/response/response.interceptor.ts
658
+ import { Injectable as Injectable4 } from "@nestjs/common";
659
+ import { map } from "rxjs/operators";
660
+ function _ts_decorate8(decorators, target, key, desc) {
661
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
662
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
663
+ r = Reflect.decorate(decorators, target, key, desc);
664
+ } else {
665
+ for (var i = decorators.length - 1; i >= 0; i--) {
666
+ if (d = decorators[i]) {
667
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
668
+ }
669
+ }
670
+ }
671
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
672
+ }
673
+ __name(_ts_decorate8, "_ts_decorate");
674
+ function isApiResponse(value) {
675
+ return typeof value === "object" && value !== null && "success" in value && "message" in value && "data" in value;
676
+ }
677
+ __name(isApiResponse, "isApiResponse");
678
+ function isPaginatedPayload(value) {
679
+ return typeof value === "object" && value !== null && "items" in value && Array.isArray(value.items) && "pagination" in value;
680
+ }
681
+ __name(isPaginatedPayload, "isPaginatedPayload");
682
+ var ResponseInterceptor = class {
683
+ static {
684
+ __name(this, "ResponseInterceptor");
685
+ }
686
+ intercept(context, next) {
687
+ if (context.getType() !== "http") {
688
+ return next.handle();
689
+ }
690
+ const request = context.switchToHttp().getRequest();
691
+ return next.handle().pipe(map((data) => {
692
+ if (isApiResponse(data)) {
693
+ return data;
694
+ }
695
+ const meta = {
696
+ path: request.url ? `${request.method ?? "GET"} ${request.url}` : void 0,
697
+ requestId: request.requestId ?? request.id,
698
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
699
+ };
700
+ if (isPaginatedPayload(data)) {
701
+ return AppResponse.paginated(data.message ?? "Request successful", data.items, data.pagination, {
702
+ ...meta,
703
+ ...data.meta
704
+ });
705
+ }
706
+ return AppResponse.success("Request successful", data, meta);
707
+ }));
708
+ }
709
+ };
710
+ ResponseInterceptor = _ts_decorate8([
711
+ Injectable4()
712
+ ], ResponseInterceptor);
713
+
714
+ // src/common/utils/country.utils.ts
715
+ import * as CountryCodeList from "country-codes-list";
716
+ var countryDialCodes = Object.keys(CountryCodeList.customList("countryCallingCode")).map((code) => `+${code}`);
717
+
718
+ // src/common/utils/date.utils.ts
719
+ var calculateNextDate = /* @__PURE__ */ __name((frequency, lastDate) => {
720
+ const nextDate = new Date(lastDate);
721
+ switch (frequency) {
722
+ case "DAILY":
723
+ nextDate.setDate(nextDate.getDate() + 1);
724
+ return nextDate;
725
+ case "WEEKLY":
726
+ nextDate.setDate(nextDate.getDate() + 7);
727
+ return nextDate;
728
+ case "MONTHLY":
729
+ nextDate.setMonth(nextDate.getMonth() + 1);
730
+ return nextDate;
731
+ }
732
+ }, "calculateNextDate");
733
+ var isToday = /* @__PURE__ */ __name((date) => {
734
+ const currentDate = new Date(date);
735
+ const today = /* @__PURE__ */ new Date();
736
+ return currentDate.getDate() === today.getDate() && currentDate.getMonth() === today.getMonth() && currentDate.getFullYear() === today.getFullYear();
737
+ }, "isToday");
738
+ var isNotPastDate = /* @__PURE__ */ __name((date) => {
739
+ return new Date(date).getTime() >= Date.now();
740
+ }, "isNotPastDate");
741
+ var isDateInRange = /* @__PURE__ */ __name((date, minDate, maxDate) => {
742
+ const timestamp = new Date(date).getTime();
743
+ return timestamp >= new Date(minDate).getTime() && timestamp <= new Date(maxDate).getTime();
744
+ }, "isDateInRange");
745
+ var isValidAge = /* @__PURE__ */ __name((dateOfBirth, minAge = 18) => {
746
+ const today = /* @__PURE__ */ new Date();
747
+ const birthDate = new Date(dateOfBirth);
748
+ let age = today.getFullYear() - birthDate.getFullYear();
749
+ const monthDiff = today.getMonth() - birthDate.getMonth();
750
+ if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
751
+ age--;
752
+ }
753
+ return age >= minAge;
754
+ }, "isValidAge");
755
+
756
+ // src/common/utils/decimal.utils.ts
757
+ import Decimal2 from "decimal.js";
758
+ var DEFAULT_DECIMAL_PLACES = 4;
759
+ Decimal2.set({
760
+ precision: 20,
761
+ rounding: Decimal2.ROUND_HALF_UP
762
+ });
763
+ var toDecimal = /* @__PURE__ */ __name((value) => {
764
+ try {
765
+ return new Decimal2(value);
766
+ } catch {
767
+ throw new Error(`Invalid decimal value: ${value}`);
768
+ }
769
+ }, "toDecimal");
770
+ var toRoundedNumber = /* @__PURE__ */ __name((value, decimalPlaces = DEFAULT_DECIMAL_PLACES) => {
771
+ return toDecimal(value).toDecimalPlaces(decimalPlaces).toNumber();
772
+ }, "toRoundedNumber");
773
+
774
+ // src/common/utils/format.utils.ts
775
+ var formatCurrency = /* @__PURE__ */ __name((amount, currencySymbol = "\u20A6", decimals = 2) => {
776
+ const formatted = amount.toLocaleString("en-NG", {
777
+ minimumFractionDigits: decimals,
778
+ maximumFractionDigits: decimals
779
+ });
780
+ return `${currencySymbol}${formatted}`;
781
+ }, "formatCurrency");
782
+ var formatAmount = /* @__PURE__ */ __name((amount, decimals = 2, locale = "en-NG") => {
783
+ return amount.toLocaleString(locale, {
784
+ minimumFractionDigits: decimals,
785
+ maximumFractionDigits: decimals
786
+ });
787
+ }, "formatAmount");
788
+ var formatAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
789
+ if (accountNumber.length !== 10) {
790
+ return accountNumber;
791
+ }
792
+ return `${accountNumber.slice(0, 4)} ${accountNumber.slice(4, 8)} ${accountNumber.slice(8)}`;
793
+ }, "formatAccountNumber");
794
+ var maskAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
795
+ if (accountNumber.length < 4) {
796
+ return accountNumber;
797
+ }
798
+ return "*".repeat(accountNumber.length - 4) + accountNumber.slice(-4);
799
+ }, "maskAccountNumber");
800
+ var maskEmail = /* @__PURE__ */ __name((email) => {
801
+ const [username, domain] = email.split("@");
802
+ if (!username || !domain) {
803
+ return email;
804
+ }
805
+ return `${username[0]}${"*".repeat(Math.max(0, username.length - 1))}@${domain}`;
806
+ }, "maskEmail");
807
+ var formatDate = /* @__PURE__ */ __name((date) => {
808
+ const currentDate = new Date(date);
809
+ const day = String(currentDate.getDate()).padStart(2, "0");
810
+ const month = String(currentDate.getMonth() + 1).padStart(2, "0");
811
+ const year = currentDate.getFullYear();
812
+ return `${day}/${month}/${year}`;
813
+ }, "formatDate");
814
+ var formatDateTime = /* @__PURE__ */ __name((date) => {
815
+ const currentDate = new Date(date);
816
+ const hours = String(currentDate.getHours()).padStart(2, "0");
817
+ const minutes = String(currentDate.getMinutes()).padStart(2, "0");
818
+ return `${formatDate(currentDate)} ${hours}:${minutes}`;
819
+ }, "formatDateTime");
820
+ var formatRelativeTime = /* @__PURE__ */ __name((date) => {
821
+ const currentDate = new Date(date);
822
+ const diffMs = Date.now() - currentDate.getTime();
823
+ const diffSeconds = Math.floor(diffMs / 1e3);
824
+ const diffMinutes = Math.floor(diffSeconds / 60);
825
+ const diffHours = Math.floor(diffMinutes / 60);
826
+ const diffDays = Math.floor(diffHours / 24);
827
+ if (diffSeconds < 60) {
828
+ return "Just now";
829
+ }
830
+ if (diffMinutes < 60) {
831
+ return `${diffMinutes} minute${diffMinutes > 1 ? "s" : ""} ago`;
832
+ }
833
+ if (diffHours < 24) {
834
+ return `${diffHours} hour${diffHours > 1 ? "s" : ""} ago`;
835
+ }
836
+ if (diffDays < 7) {
837
+ return `${diffDays} day${diffDays > 1 ? "s" : ""} ago`;
838
+ }
839
+ return formatDate(currentDate);
840
+ }, "formatRelativeTime");
841
+ var formatPercentage = /* @__PURE__ */ __name((value, decimals = 1) => {
842
+ return `${(value * 100).toFixed(decimals)}%`;
843
+ }, "formatPercentage");
844
+ var formatFileSize = /* @__PURE__ */ __name((bytes) => {
845
+ if (bytes === 0) {
846
+ return "0 Bytes";
847
+ }
848
+ const unit = 1024;
849
+ const sizes = [
850
+ "Bytes",
851
+ "KB",
852
+ "MB",
853
+ "GB",
854
+ "TB"
855
+ ];
856
+ const sizeIndex = Math.floor(Math.log(bytes) / Math.log(unit));
857
+ return `${Number((bytes / unit ** sizeIndex).toFixed(2))} ${sizes[sizeIndex]}`;
858
+ }, "formatFileSize");
859
+ var truncateText = /* @__PURE__ */ __name((text, maxLength) => {
860
+ if (text.length <= maxLength) {
861
+ return text;
862
+ }
863
+ return `${text.slice(0, maxLength - 3)}...`;
864
+ }, "truncateText");
865
+ var toTitleCase = /* @__PURE__ */ __name((text) => {
866
+ return text.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
867
+ }, "toTitleCase");
868
+ var normalizeNigerianPhone = /* @__PURE__ */ __name((phone, withPlus = false) => {
869
+ const digits = `${phone}`.replace(/\D/g, "").trim();
870
+ if (digits === "") {
871
+ return "";
872
+ }
873
+ let normalized = digits;
874
+ if (digits.startsWith("234") && digits.length === 13) {
875
+ normalized = digits;
876
+ } else if (digits.startsWith("0") && digits.length === 11) {
877
+ normalized = `234${digits.slice(1)}`;
878
+ } else if (digits.length === 10 && /^[789]/.test(digits)) {
879
+ normalized = `234${digits}`;
880
+ } else if (!digits.startsWith("234") && digits.length === 10) {
881
+ normalized = `234${digits}`;
882
+ }
883
+ return withPlus ? `+${normalized}` : normalized;
884
+ }, "normalizeNigerianPhone");
885
+
886
+ // src/common/utils/string.utils.ts
887
+ var formatPhoneNumber = /* @__PURE__ */ __name((phone) => {
888
+ const cleaned = phone.replace(/[\s\-\(\)]/g, "");
889
+ let formatted = cleaned;
890
+ if (formatted.startsWith("0")) {
891
+ formatted = "234" + formatted.substring(1);
892
+ }
893
+ if (formatted.startsWith("234")) {
894
+ return `+234 ${formatted.substring(3, 6)} ${formatted.substring(6, 9)} ${formatted.substring(9)}`;
895
+ }
896
+ return phone;
897
+ }, "formatPhoneNumber");
898
+ var maskPhoneNumber = /* @__PURE__ */ __name((phone) => {
899
+ const cleaned = phone.replace(/[\s\-\(\)]/g, "");
900
+ if (cleaned.length < 8) return phone;
901
+ const prefix = cleaned.substring(0, 4);
902
+ const suffix = cleaned.slice(-4);
903
+ return `${prefix}****${suffix}`;
904
+ }, "maskPhoneNumber");
905
+
906
+ // src/common/utils/random.utils.ts
907
+ var DIGITS = "0123456789";
908
+ var LOWERCASE_CHARS = "abcdefghijklmnopqrstuvwxyz";
909
+ var UPPERCASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
910
+ var SPECIAL_CHARS = "!@#$%^&*()_+-=[]{}|;:,.<>?";
911
+ function generateRandomString(options = {}) {
912
+ const { length = 6, digits = true, lowerCaseAlphabets = false, upperCaseAlphabets = false, specialChars = false } = options;
913
+ let chars = "";
914
+ if (digits) chars += DIGITS;
915
+ if (lowerCaseAlphabets) chars += LOWERCASE_CHARS;
916
+ if (upperCaseAlphabets) chars += UPPERCASE_CHARS;
917
+ if (specialChars) chars += SPECIAL_CHARS;
918
+ if (!chars) chars = DIGITS;
919
+ let result = "";
920
+ const charactersLength = chars.length;
921
+ for (let i = 0; i < length; i++) {
922
+ result += chars.charAt(Math.floor(Math.random() * charactersLength));
923
+ }
924
+ return result;
925
+ }
926
+ __name(generateRandomString, "generateRandomString");
927
+
928
+ // src/common/utils/reference.utils.ts
929
+ var generateRandomString2 = /* @__PURE__ */ __name((length) => {
930
+ const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
931
+ const charactersLength = characters.length;
932
+ let result = "";
933
+ for (let i = 0; i < length; i++) {
934
+ const randomIndex = Math.floor(Math.random() * charactersLength);
935
+ result += characters[randomIndex];
936
+ }
937
+ return result;
938
+ }, "generateRandomString");
939
+ var generateReference = /* @__PURE__ */ __name((prefix = "TRX") => {
940
+ return `${prefix}_${generateRandomString2(12)}`;
941
+ }, "generateReference");
942
+
943
+ // src/common/utils/validation.utils.ts
944
+ var isValidNigerianPhone = /* @__PURE__ */ __name((phone) => {
945
+ const cleaned = phone.replace(/[\s\-()]/g, "");
946
+ const patterns = [
947
+ /^0[7-9][0-1]\d{8}$/,
948
+ /^\+234[7-9][0-1]\d{8}$/,
949
+ /^234[7-9][0-1]\d{8}$/
950
+ ];
951
+ return patterns.some((pattern) => pattern.test(cleaned));
952
+ }, "isValidNigerianPhone");
953
+ var isValidEmail = /* @__PURE__ */ __name((email) => {
954
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
955
+ }, "isValidEmail");
956
+ var isValidBVN = /* @__PURE__ */ __name((bvn) => {
957
+ return /^\d{11}$/.test(bvn);
958
+ }, "isValidBVN");
959
+ var isValidNIN = /* @__PURE__ */ __name((nin) => {
960
+ return /^\d{11}$/.test(nin);
961
+ }, "isValidNIN");
962
+ var isValidAccountNumber = /* @__PURE__ */ __name((accountNumber) => {
963
+ return /^\d{10}$/.test(accountNumber);
964
+ }, "isValidAccountNumber");
965
+ var isValidAmount = /* @__PURE__ */ __name((amount) => {
966
+ return typeof amount === "number" && Number.isFinite(amount) && amount > 0;
967
+ }, "isValidAmount");
968
+ var isStrongPassword = /* @__PURE__ */ __name((password) => {
969
+ return password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /\d/.test(password);
970
+ }, "isStrongPassword");
971
+ var isValidTransactionReference = /* @__PURE__ */ __name((reference) => {
972
+ return /^[A-Z0-9_-]{10,50}$/.test(reference);
973
+ }, "isValidTransactionReference");
974
+
975
+ // src/common/config/nats.config.ts
976
+ import { Transport } from "@nestjs/microservices";
977
+ var getNatsServers = /* @__PURE__ */ __name((configService) => {
978
+ const rawServers = configService.get("NATS_URL") ?? "nats://localhost:4222";
979
+ return rawServers.split(",").map((server) => server.trim()).filter(Boolean);
980
+ }, "getNatsServers");
981
+ var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
982
+ transport: Transport.NATS,
983
+ options: {
984
+ servers: getNatsServers(configService)
985
+ }
986
+ }), "getNatsMicroserviceConfig");
987
+ var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
988
+ const queue = queueName && configService.get(`NATS_${queueName.toUpperCase()}_QUEUE`);
989
+ return {
990
+ transport: Transport.NATS,
991
+ options: {
992
+ servers: getNatsServers(configService),
993
+ ...queue ? {
994
+ queue
995
+ } : {}
996
+ }
997
+ };
998
+ }, "getNatsConfig");
999
+
1000
+ // src/cache/cache.constants.ts
1001
+ var CACHE_MODULE_OPTIONS = /* @__PURE__ */ Symbol("CACHE_MODULE_OPTIONS");
1002
+
1003
+ // src/cache/cache.module.ts
1004
+ import { Module } from "@nestjs/common";
1005
+ import { ConfigModule } from "@nestjs/config";
1006
+
1007
+ // src/cache/cache.service.ts
1008
+ import { Inject, Injectable as Injectable5 } from "@nestjs/common";
1009
+ import Redis from "ioredis";
1010
+ function _ts_decorate9(decorators, target, key, desc) {
1011
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1012
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1013
+ r = Reflect.decorate(decorators, target, key, desc);
1014
+ } else {
1015
+ for (var i = decorators.length - 1; i >= 0; i--) {
1016
+ if (d = decorators[i]) {
1017
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1018
+ }
1019
+ }
1020
+ }
1021
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1022
+ }
1023
+ __name(_ts_decorate9, "_ts_decorate");
1024
+ function _ts_metadata4(metadataKey, metadataValue) {
1025
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1026
+ return Reflect.metadata(metadataKey, metadataValue);
1027
+ }
1028
+ }
1029
+ __name(_ts_metadata4, "_ts_metadata");
1030
+ function _ts_param(paramIndex, decorator) {
1031
+ return function(target, key) {
1032
+ decorator(target, key, paramIndex);
1033
+ };
1034
+ }
1035
+ __name(_ts_param, "_ts_param");
1036
+ var CacheService = class {
1037
+ static {
1038
+ __name(this, "CacheService");
1039
+ }
1040
+ options;
1041
+ redisClient;
1042
+ constructor(options) {
1043
+ this.options = options;
1044
+ }
1045
+ async onModuleInit() {
1046
+ const options = this.options || {};
1047
+ this.redisClient = new Redis({
1048
+ ...options,
1049
+ host: options.host || process.env.REDIS_HOST || "localhost",
1050
+ port: options.port || +(process.env?.REDIS_PORT || 6379),
1051
+ username: options.username || process.env?.REDIS_USERNAME,
1052
+ password: options.password || process.env?.REDIS_PASSWORD,
1053
+ keyPrefix: options.keyPrefix || "viardex:"
1054
+ });
1055
+ }
1056
+ async onModuleDestroy() {
1057
+ await this.redisClient.quit();
1058
+ }
1059
+ getClient() {
1060
+ return this.redisClient;
1061
+ }
1062
+ async ping() {
1063
+ return this.redisClient.ping();
1064
+ }
1065
+ async set(key, value, ttlSeconds) {
1066
+ if (ttlSeconds) {
1067
+ await this.redisClient.setex(key, ttlSeconds, value);
1068
+ } else {
1069
+ await this.redisClient.set(key, value);
1070
+ }
1071
+ }
1072
+ async setIfNotExists(key, value, ttlSeconds) {
1073
+ const result = ttlSeconds ? await this.redisClient.set(key, value, "EX", ttlSeconds, "NX") : await this.redisClient.set(key, value, "NX");
1074
+ return result === "OK";
1075
+ }
1076
+ async get(key) {
1077
+ return this.redisClient.get(key);
1078
+ }
1079
+ async setJson(key, value, ttlSeconds) {
1080
+ await this.set(key, JSON.stringify(value), ttlSeconds);
1081
+ }
1082
+ async getJson(key) {
1083
+ const value = await this.get(key);
1084
+ return value ? JSON.parse(value) : null;
1085
+ }
1086
+ async del(key) {
1087
+ await this.redisClient.del(key);
1088
+ }
1089
+ async exists(key) {
1090
+ const result = await this.redisClient.exists(key);
1091
+ return result === 1;
1092
+ }
1093
+ async ttl(key) {
1094
+ return this.redisClient.ttl(key);
1095
+ }
1096
+ async keys(pattern) {
1097
+ return this.redisClient.keys(pattern);
1098
+ }
1099
+ async scan(pattern, count = 100) {
1100
+ const keys = [];
1101
+ let cursor = "0";
1102
+ do {
1103
+ const [nextCursor, batch] = await this.redisClient.scan(cursor, "MATCH", pattern, "COUNT", count);
1104
+ cursor = nextCursor;
1105
+ keys.push(...batch);
1106
+ } while (cursor !== "0");
1107
+ return keys;
1108
+ }
1109
+ async flushAll() {
1110
+ await this.redisClient.flushall();
1111
+ }
1112
+ async incr(key) {
1113
+ return this.redisClient.incr(key);
1114
+ }
1115
+ async decr(key) {
1116
+ return this.redisClient.decr(key);
1117
+ }
1118
+ async hset(key, field, value) {
1119
+ await this.redisClient.hset(key, field, value);
1120
+ }
1121
+ async hget(key, field) {
1122
+ return this.redisClient.hget(key, field);
1123
+ }
1124
+ async hgetall(key) {
1125
+ return this.redisClient.hgetall(key);
1126
+ }
1127
+ async hdel(key, field) {
1128
+ await this.redisClient.hdel(key, field);
1129
+ }
1130
+ async expire(key, ttlSeconds) {
1131
+ await this.redisClient.expire(key, ttlSeconds);
1132
+ }
1133
+ };
1134
+ CacheService = _ts_decorate9([
1135
+ Injectable5(),
1136
+ _ts_param(0, Inject(CACHE_MODULE_OPTIONS)),
1137
+ _ts_metadata4("design:type", Function),
1138
+ _ts_metadata4("design:paramtypes", [
1139
+ typeof CacheOptions === "undefined" ? Object : CacheOptions
1140
+ ])
1141
+ ], CacheService);
1142
+
1143
+ // src/cache/cache.module.ts
1144
+ function _ts_decorate10(decorators, target, key, desc) {
1145
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1146
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1147
+ r = Reflect.decorate(decorators, target, key, desc);
1148
+ } else {
1149
+ for (var i = decorators.length - 1; i >= 0; i--) {
1150
+ if (d = decorators[i]) {
1151
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1152
+ }
1153
+ }
1154
+ }
1155
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1156
+ }
1157
+ __name(_ts_decorate10, "_ts_decorate");
1158
+ var CacheModule = class _CacheModule {
1159
+ static {
1160
+ __name(this, "CacheModule");
1161
+ }
1162
+ static register(options = {}) {
1163
+ return {
1164
+ module: _CacheModule,
1165
+ imports: [
1166
+ ConfigModule
1167
+ ],
1168
+ providers: [
1169
+ CacheService,
1170
+ {
1171
+ provide: CACHE_MODULE_OPTIONS,
1172
+ useValue: options
1173
+ }
1174
+ ],
1175
+ exports: [
1176
+ CacheService
1177
+ ]
1178
+ };
1179
+ }
1180
+ };
1181
+ CacheModule = _ts_decorate10([
1182
+ Module({})
1183
+ ], CacheModule);
1184
+
1185
+ // src/rpc/index.ts
1186
+ import { BadRequestException as BadRequestException3, HttpException as HttpException2, Logger as Logger3 } from "@nestjs/common";
1187
+ import { RpcException } from "@nestjs/microservices";
1188
+ var ViardexRpcUtils = class ViardexRpcUtils2 {
1189
+ static {
1190
+ __name(this, "ViardexRpcUtils");
1191
+ }
1192
+ static getValidationErrors(err) {
1193
+ if (err instanceof BadRequestException3) {
1194
+ const response = err.getResponse();
1195
+ if (typeof response === "object" && response !== null && "errors" in response) {
1196
+ return Array.isArray(response.errors) ? response.errors : [];
1197
+ }
1198
+ }
1199
+ return [];
1200
+ }
1201
+ static isErrorResponse(result) {
1202
+ return typeof result === "object" && result !== null && "error" in result;
1203
+ }
1204
+ static formatSuccessResponse(data) {
1205
+ return {
1206
+ data
1207
+ };
1208
+ }
1209
+ };
1210
+ var ViardexRpc = class {
1211
+ static {
1212
+ __name(this, "ViardexRpc");
1213
+ }
1214
+ static async handleRequest(promise, ctx) {
1215
+ return promise.then((value) => ViardexRpcUtils.formatSuccessResponse(value)).catch((err) => this.catch(err, ctx));
1216
+ }
1217
+ static handleRequestError(err, ctx) {
1218
+ return this.catch(err, ctx);
1219
+ }
1220
+ static catch(err, ctx) {
1221
+ const subject = ctx ? ctx.getArgs()[0] : null;
1222
+ const error = err instanceof Error ? err : new Error(String(err));
1223
+ const statusCode = err instanceof HttpException2 ? err.getStatus() : 500;
1224
+ const errorDetails = {
1225
+ success: false,
1226
+ subject,
1227
+ message: error.message,
1228
+ statusCode,
1229
+ errors: ViardexRpcUtils.getValidationErrors(err)
1230
+ };
1231
+ return new RpcException(errorDetails);
1232
+ }
1233
+ static async withReply(obs) {
1234
+ const result = await new Promise((resolve, reject) => {
1235
+ obs.subscribe({
1236
+ next: /* @__PURE__ */ __name((value) => resolve(value), "next"),
1237
+ error: /* @__PURE__ */ __name((err) => reject(err instanceof Error ? err : new Error(String(err))), "error")
1238
+ });
1239
+ });
1240
+ if (ViardexRpcUtils.isErrorResponse(result)) {
1241
+ Logger3.error(result.error);
1242
+ throw new HttpException2(result.error, result.error.statusCode, {
1243
+ cause: result.error.errors
1244
+ });
1245
+ }
1246
+ return ViardexRpcUtils.formatSuccessResponse(result);
1247
+ }
1248
+ };
1249
+
1250
+ // 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";
1255
+
1256
+ // 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";
1260
+ function _ts_decorate11(decorators, target, key, desc) {
1261
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1262
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1263
+ r = Reflect.decorate(decorators, target, key, desc);
1264
+ } else {
1265
+ for (var i = decorators.length - 1; i >= 0; i--) {
1266
+ if (d = decorators[i]) {
1267
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1268
+ }
1269
+ }
1270
+ }
1271
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1272
+ }
1273
+ __name(_ts_decorate11, "_ts_decorate");
1274
+ function _ts_metadata5(metadataKey, metadataValue) {
1275
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1276
+ return Reflect.metadata(metadataKey, metadataValue);
1277
+ }
1278
+ }
1279
+ __name(_ts_metadata5, "_ts_metadata");
1280
+ function _ts_param2(paramIndex, decorator) {
1281
+ return function(target, key) {
1282
+ decorator(target, key, paramIndex);
1283
+ };
1284
+ }
1285
+ __name(_ts_param2, "_ts_param");
1286
+ var LoggingInterceptor = class {
1287
+ static {
1288
+ __name(this, "LoggingInterceptor");
1289
+ }
1290
+ logger;
1291
+ constructor(logger) {
1292
+ this.logger = logger;
1293
+ }
1294
+ intercept(context, next) {
1295
+ if (context.getType() !== "http") {
1296
+ return next.handle();
1297
+ }
1298
+ const request = context.switchToHttp().getRequest();
1299
+ const response = context.switchToHttp().getResponse();
1300
+ const requestId = request.requestId ?? request.id;
1301
+ const startTime = Date.now();
1302
+ this.logger.debug({
1303
+ requestId,
1304
+ method: request.method,
1305
+ url: request.url
1306
+ }, "Incoming request");
1307
+ return next.handle().pipe(tap2({
1308
+ next: /* @__PURE__ */ __name(() => {
1309
+ this.logger.info({
1310
+ requestId,
1311
+ method: request.method,
1312
+ url: request.url,
1313
+ statusCode: response.statusCode,
1314
+ duration: Date.now() - startTime
1315
+ }, "Request completed");
1316
+ }, "next"),
1317
+ error: /* @__PURE__ */ __name((error) => {
1318
+ this.logger.error({
1319
+ requestId,
1320
+ method: request.method,
1321
+ url: request.url,
1322
+ statusCode: error.status ?? 500,
1323
+ duration: Date.now() - startTime,
1324
+ error: error.message,
1325
+ stack: error.stack
1326
+ }, "Request failed");
1327
+ }, "error")
1328
+ }));
1329
+ }
1330
+ };
1331
+ LoggingInterceptor = _ts_decorate11([
1332
+ Injectable6(),
1333
+ _ts_param2(0, Inject2(PinoLogger)),
1334
+ _ts_metadata5("design:type", Function),
1335
+ _ts_metadata5("design:paramtypes", [
1336
+ typeof PinoLogger === "undefined" ? Object : PinoLogger
1337
+ ])
1338
+ ], LoggingInterceptor);
1339
+
1340
+ // src/logger/logger.module.ts
1341
+ function _ts_decorate12(decorators, target, key, desc) {
1342
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1343
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1344
+ r = Reflect.decorate(decorators, target, key, desc);
1345
+ } else {
1346
+ for (var i = decorators.length - 1; i >= 0; i--) {
1347
+ if (d = decorators[i]) {
1348
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1349
+ }
1350
+ }
1351
+ }
1352
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1353
+ }
1354
+ __name(_ts_decorate12, "_ts_decorate");
1355
+ var LoggerModule = class {
1356
+ static {
1357
+ __name(this, "LoggerModule");
1358
+ }
1359
+ };
1360
+ LoggerModule = _ts_decorate12([
1361
+ Global(),
1362
+ Module2({
1363
+ imports: [
1364
+ PinoLoggerModule.forRootAsync({
1365
+ imports: [
1366
+ ConfigModule2
1367
+ ],
1368
+ inject: [
1369
+ ConfigService
1370
+ ],
1371
+ useFactory: /* @__PURE__ */ __name((configService) => {
1372
+ const env = configService.get("NODE_ENV", "development");
1373
+ const isDevelopment = env === "development";
1374
+ return {
1375
+ pinoHttp: {
1376
+ autoLogging: false,
1377
+ level: configService.get("LOG_LEVEL", isDevelopment ? "debug" : "info"),
1378
+ transport: isDevelopment ? {
1379
+ target: "pino-pretty",
1380
+ options: {
1381
+ colorize: true,
1382
+ singleLine: false,
1383
+ translateTime: "SYS:standard",
1384
+ ignore: "pid,hostname"
1385
+ }
1386
+ } : void 0,
1387
+ serializers: {
1388
+ req: /* @__PURE__ */ __name((req) => ({
1389
+ id: req.id,
1390
+ method: req.method,
1391
+ url: req.url,
1392
+ remoteAddress: req.ip
1393
+ }), "req"),
1394
+ res: /* @__PURE__ */ __name((res) => ({
1395
+ statusCode: res.statusCode
1396
+ }), "res")
1397
+ }
1398
+ }
1399
+ };
1400
+ }, "useFactory")
1401
+ })
1402
+ ],
1403
+ providers: [
1404
+ LoggingInterceptor,
1405
+ {
1406
+ provide: APP_INTERCEPTOR,
1407
+ useExisting: LoggingInterceptor
1408
+ },
1409
+ {
1410
+ provide: Logger4,
1411
+ useExisting: PinoLogger2
1412
+ }
1413
+ ],
1414
+ exports: [
1415
+ PinoLoggerModule,
1416
+ LoggingInterceptor,
1417
+ Logger4
1418
+ ]
1419
+ })
1420
+ ], LoggerModule);
1421
+
1422
+ // src/logger/index.ts
1423
+ import { PinoLogger as PinoLogger3 } from "nestjs-pino";
1424
+ export {
1425
+ AppResponse,
1426
+ AuditSubjects,
1427
+ BANKING_QUEUE,
1428
+ CACHE_MODULE_OPTIONS,
1429
+ CARD_QUEUE,
1430
+ CRYPTO_QUEUE,
1431
+ CacheModule,
1432
+ CacheService,
1433
+ CountrySubjects,
1434
+ DEFAULT_NATS_CONFIG,
1435
+ DEFAULT_OTP_EXPIRY,
1436
+ DEFAULT_OTP_LENGTH,
1437
+ DEFAULT_OTP_OPTIONS,
1438
+ DeviceSubjects,
1439
+ FileValidationPipe,
1440
+ HttpExceptionFilter,
1441
+ HttpOnlyExceptionFilter,
1442
+ KYC_QUEUE,
1443
+ LEDGER_QUEUE,
1444
+ LoggerModule,
1445
+ LoggingInterceptor,
1446
+ MAX_OTP_ATTEMPTS,
1447
+ NATS_CLIENT,
1448
+ NATS_EVENT_METADATA,
1449
+ NATS_OPTIONS,
1450
+ NOTIFICATION_QUEUE,
1451
+ NatsEventPattern,
1452
+ NatsLoggingInterceptor,
1453
+ NatsMessageDto,
1454
+ NatsSubjects,
1455
+ NotificationSubjects,
1456
+ OPS_QUEUE,
1457
+ OTP_ATTEMPTS_CACHE_PREFIX,
1458
+ OTP_BLOCK_DURATION,
1459
+ OTP_CACHE_PREFIX,
1460
+ OtpPurpose,
1461
+ PaginationQueryCleanerPipe,
1462
+ PaginationQueryDto,
1463
+ PasswordSubjects,
1464
+ PinSubjects,
1465
+ PinoLogger3 as PinoLogger,
1466
+ PreferencesSubjects,
1467
+ ReferralSubjects,
1468
+ ResponseInterceptor,
1469
+ RoleSubjects,
1470
+ SigninSubjects,
1471
+ SignupSubjects,
1472
+ StaffSubjects,
1473
+ TicketSubjects,
1474
+ USER_QUEUE,
1475
+ UserServiceSubjects,
1476
+ VAS_QUEUE,
1477
+ ViardexRpc,
1478
+ calculateNextDate,
1479
+ countryDialCodes,
1480
+ extractBin,
1481
+ extractLast4,
1482
+ formatAccountNumber,
1483
+ formatAmount,
1484
+ formatCardExpiry,
1485
+ formatCardLabel,
1486
+ formatCryptoAmount,
1487
+ formatCurrency,
1488
+ formatDate,
1489
+ formatDateTime,
1490
+ formatFileSize,
1491
+ formatPercentage,
1492
+ formatPhoneNumber,
1493
+ formatRelativeTime,
1494
+ fromAtomicUnits,
1495
+ generateRandomString,
1496
+ generateReference,
1497
+ getNatsConfig,
1498
+ getNatsMicroserviceConfig,
1499
+ getNatsServers,
1500
+ isDateInRange,
1501
+ isHexTxHash,
1502
+ isNotPastDate,
1503
+ isPositiveAmount,
1504
+ isStrongPassword,
1505
+ isToday,
1506
+ isValidAccountNumber,
1507
+ isValidAge,
1508
+ isValidAmount,
1509
+ isValidBVN,
1510
+ isValidEmail,
1511
+ isValidNIN,
1512
+ isValidNigerianPhone,
1513
+ isValidTransactionReference,
1514
+ maskAccountNumber,
1515
+ maskEmail,
1516
+ maskPan,
1517
+ maskPhoneNumber,
1518
+ normalizeCardExpiry,
1519
+ normalizeNigerianPhone,
1520
+ normalizeTxHash,
1521
+ toAtomicUnits,
1522
+ toDecimal,
1523
+ toRoundedNumber,
1524
+ toTitleCase,
1525
+ truncateText
1526
+ };
1527
+ //# sourceMappingURL=index.js.map