@viardex/viardex-libs 1.0.10 → 1.0.12

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