@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
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ResponseInterceptor = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const operators_1 = require("rxjs/operators");
12
- const response_utils_1 = require("./response.utils");
13
- function isApiResponse(value) {
14
- return (typeof value === 'object' &&
15
- value !== null &&
16
- 'success' in value &&
17
- 'message' in value &&
18
- 'data' in value);
19
- }
20
- function isPaginatedPayload(value) {
21
- return (typeof value === 'object' &&
22
- value !== null &&
23
- 'items' in value &&
24
- Array.isArray(value.items) &&
25
- 'pagination' in value);
26
- }
27
- let ResponseInterceptor = class ResponseInterceptor {
28
- intercept(context, next) {
29
- if (context.getType() !== 'http') {
30
- return next.handle();
31
- }
32
- const request = context.switchToHttp().getRequest();
33
- return next.handle().pipe((0, operators_1.map)((data) => {
34
- if (isApiResponse(data)) {
35
- return data;
36
- }
37
- const meta = {
38
- path: request.url
39
- ? `${request.method ?? 'GET'} ${request.url}`
40
- : undefined,
41
- requestId: request.requestId ?? request.id,
42
- timestamp: new Date().toISOString(),
43
- };
44
- if (isPaginatedPayload(data)) {
45
- return response_utils_1.AppResponse.paginated(data.message ?? 'Request successful', data.items, data.pagination, {
46
- ...meta,
47
- ...data.meta,
48
- });
49
- }
50
- return response_utils_1.AppResponse.success('Request successful', data, meta);
51
- }));
52
- }
53
- };
54
- exports.ResponseInterceptor = ResponseInterceptor;
55
- exports.ResponseInterceptor = ResponseInterceptor = __decorate([
56
- (0, common_1.Injectable)()
57
- ], ResponseInterceptor);
@@ -1,6 +0,0 @@
1
- import type { ApiResponse, ErrorDetail, PaginationMeta, ResponseMeta } from '../interfaces';
2
- export declare class AppResponse {
3
- static success<T>(message: string, data: T, meta?: ResponseMeta): ApiResponse<T>;
4
- static paginated<T>(message: string, items: T[], pagination: PaginationMeta, meta?: Omit<ResponseMeta, 'pagination'>): ApiResponse<T[]>;
5
- static error(message: string, errors?: ErrorDetail[], meta?: ResponseMeta, data?: null): ApiResponse<null>;
6
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppResponse = void 0;
4
- class AppResponse {
5
- static success(message, data, meta) {
6
- return {
7
- success: true,
8
- message,
9
- data,
10
- ...(meta ? { meta } : {}),
11
- };
12
- }
13
- static paginated(message, items, pagination, meta) {
14
- return {
15
- success: true,
16
- message,
17
- data: items,
18
- meta: {
19
- ...meta,
20
- pagination,
21
- },
22
- };
23
- }
24
- static error(message, errors, meta, data = null) {
25
- return {
26
- success: false,
27
- message,
28
- data,
29
- ...(meta ? { meta } : {}),
30
- ...(errors?.length ? { errors } : {}),
31
- };
32
- }
33
- }
34
- exports.AppResponse = AppResponse;
@@ -1 +0,0 @@
1
- export declare const countryDialCodes: string[];
@@ -1,38 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.countryDialCodes = void 0;
37
- const CountryCodeList = __importStar(require("country-codes-list"));
38
- exports.countryDialCodes = Object.keys(CountryCodeList.customList('countryCallingCode')).map((code) => `+${code}`);
@@ -1,6 +0,0 @@
1
- export type RecurrenceFrequency = 'DAILY' | 'WEEKLY' | 'MONTHLY';
2
- export declare const calculateNextDate: (frequency: RecurrenceFrequency, lastDate: Date) => Date;
3
- export declare const isToday: (date: Date | string) => boolean;
4
- export declare const isNotPastDate: (date: Date | string) => boolean;
5
- export declare const isDateInRange: (date: Date | string, minDate: Date | string, maxDate: Date | string) => boolean;
6
- export declare const isValidAge: (dateOfBirth: Date | string, minAge?: number) => boolean;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidAge = exports.isDateInRange = exports.isNotPastDate = exports.isToday = exports.calculateNextDate = void 0;
4
- const calculateNextDate = (frequency, lastDate) => {
5
- const nextDate = new Date(lastDate);
6
- switch (frequency) {
7
- case 'DAILY':
8
- nextDate.setDate(nextDate.getDate() + 1);
9
- return nextDate;
10
- case 'WEEKLY':
11
- nextDate.setDate(nextDate.getDate() + 7);
12
- return nextDate;
13
- case 'MONTHLY':
14
- nextDate.setMonth(nextDate.getMonth() + 1);
15
- return nextDate;
16
- }
17
- };
18
- exports.calculateNextDate = calculateNextDate;
19
- const isToday = (date) => {
20
- const currentDate = new Date(date);
21
- const today = new Date();
22
- return (currentDate.getDate() === today.getDate() &&
23
- currentDate.getMonth() === today.getMonth() &&
24
- currentDate.getFullYear() === today.getFullYear());
25
- };
26
- exports.isToday = isToday;
27
- const isNotPastDate = (date) => {
28
- return new Date(date).getTime() >= Date.now();
29
- };
30
- exports.isNotPastDate = isNotPastDate;
31
- const isDateInRange = (date, minDate, maxDate) => {
32
- const timestamp = new Date(date).getTime();
33
- return (timestamp >= new Date(minDate).getTime() &&
34
- timestamp <= new Date(maxDate).getTime());
35
- };
36
- exports.isDateInRange = isDateInRange;
37
- const isValidAge = (dateOfBirth, minAge = 18) => {
38
- const today = new Date();
39
- const birthDate = new Date(dateOfBirth);
40
- let age = today.getFullYear() - birthDate.getFullYear();
41
- const monthDiff = today.getMonth() - birthDate.getMonth();
42
- if (monthDiff < 0 ||
43
- (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
44
- age--;
45
- }
46
- return age >= minAge;
47
- };
48
- exports.isValidAge = isValidAge;
@@ -1,3 +0,0 @@
1
- import Decimal from 'decimal.js';
2
- export declare const toDecimal: (value: number | string | Decimal) => Decimal;
3
- export declare const toRoundedNumber: (value: number | string | Decimal, decimalPlaces?: number) => number;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toRoundedNumber = exports.toDecimal = void 0;
7
- const decimal_js_1 = __importDefault(require("decimal.js"));
8
- const DEFAULT_DECIMAL_PLACES = 4;
9
- decimal_js_1.default.set({ precision: 20, rounding: decimal_js_1.default.ROUND_HALF_UP });
10
- const toDecimal = (value) => {
11
- try {
12
- return new decimal_js_1.default(value);
13
- }
14
- catch {
15
- throw new Error(`Invalid decimal value: ${value}`);
16
- }
17
- };
18
- exports.toDecimal = toDecimal;
19
- const toRoundedNumber = (value, decimalPlaces = DEFAULT_DECIMAL_PLACES) => {
20
- return (0, exports.toDecimal)(value).toDecimalPlaces(decimalPlaces).toNumber();
21
- };
22
- exports.toRoundedNumber = toRoundedNumber;
@@ -1,13 +0,0 @@
1
- export declare const formatCurrency: (amount: number, currencySymbol?: string, decimals?: number) => string;
2
- export declare const formatAmount: (amount: number, decimals?: number, locale?: string) => string;
3
- export declare const formatAccountNumber: (accountNumber: string) => string;
4
- export declare const maskAccountNumber: (accountNumber: string) => string;
5
- export declare const maskEmail: (email: string) => string;
6
- export declare const formatDate: (date: Date | string) => string;
7
- export declare const formatDateTime: (date: Date | string) => string;
8
- export declare const formatRelativeTime: (date: Date | string) => string;
9
- export declare const formatPercentage: (value: number, decimals?: number) => string;
10
- export declare const formatFileSize: (bytes: number) => string;
11
- export declare const truncateText: (text: string, maxLength: number) => string;
12
- export declare const toTitleCase: (text: string) => string;
13
- export declare const normalizeNigerianPhone: (phone: string | number, withPlus?: boolean) => string;
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeNigerianPhone = exports.toTitleCase = exports.truncateText = exports.formatFileSize = exports.formatPercentage = exports.formatRelativeTime = exports.formatDateTime = exports.formatDate = exports.maskEmail = exports.maskAccountNumber = exports.formatAccountNumber = exports.formatAmount = exports.formatCurrency = void 0;
4
- const formatCurrency = (amount, currencySymbol = '₦', decimals = 2) => {
5
- const formatted = amount.toLocaleString('en-NG', {
6
- minimumFractionDigits: decimals,
7
- maximumFractionDigits: decimals,
8
- });
9
- return `${currencySymbol}${formatted}`;
10
- };
11
- exports.formatCurrency = formatCurrency;
12
- const formatAmount = (amount, decimals = 2, locale = 'en-NG') => {
13
- return amount.toLocaleString(locale, {
14
- minimumFractionDigits: decimals,
15
- maximumFractionDigits: decimals,
16
- });
17
- };
18
- exports.formatAmount = formatAmount;
19
- const formatAccountNumber = (accountNumber) => {
20
- if (accountNumber.length !== 10) {
21
- return accountNumber;
22
- }
23
- return `${accountNumber.slice(0, 4)} ${accountNumber.slice(4, 8)} ${accountNumber.slice(8)}`;
24
- };
25
- exports.formatAccountNumber = formatAccountNumber;
26
- const maskAccountNumber = (accountNumber) => {
27
- if (accountNumber.length < 4) {
28
- return accountNumber;
29
- }
30
- return '*'.repeat(accountNumber.length - 4) + accountNumber.slice(-4);
31
- };
32
- exports.maskAccountNumber = maskAccountNumber;
33
- const maskEmail = (email) => {
34
- const [username, domain] = email.split('@');
35
- if (!username || !domain) {
36
- return email;
37
- }
38
- return `${username[0]}${'*'.repeat(Math.max(0, username.length - 1))}@${domain}`;
39
- };
40
- exports.maskEmail = maskEmail;
41
- const formatDate = (date) => {
42
- const currentDate = new Date(date);
43
- const day = String(currentDate.getDate()).padStart(2, '0');
44
- const month = String(currentDate.getMonth() + 1).padStart(2, '0');
45
- const year = currentDate.getFullYear();
46
- return `${day}/${month}/${year}`;
47
- };
48
- exports.formatDate = formatDate;
49
- const formatDateTime = (date) => {
50
- const currentDate = new Date(date);
51
- const hours = String(currentDate.getHours()).padStart(2, '0');
52
- const minutes = String(currentDate.getMinutes()).padStart(2, '0');
53
- return `${(0, exports.formatDate)(currentDate)} ${hours}:${minutes}`;
54
- };
55
- exports.formatDateTime = formatDateTime;
56
- const formatRelativeTime = (date) => {
57
- const currentDate = new Date(date);
58
- const diffMs = Date.now() - currentDate.getTime();
59
- const diffSeconds = Math.floor(diffMs / 1000);
60
- const diffMinutes = Math.floor(diffSeconds / 60);
61
- const diffHours = Math.floor(diffMinutes / 60);
62
- const diffDays = Math.floor(diffHours / 24);
63
- if (diffSeconds < 60) {
64
- return 'Just now';
65
- }
66
- if (diffMinutes < 60) {
67
- return `${diffMinutes} minute${diffMinutes > 1 ? 's' : ''} ago`;
68
- }
69
- if (diffHours < 24) {
70
- return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
71
- }
72
- if (diffDays < 7) {
73
- return `${diffDays} day${diffDays > 1 ? 's' : ''} ago`;
74
- }
75
- return (0, exports.formatDate)(currentDate);
76
- };
77
- exports.formatRelativeTime = formatRelativeTime;
78
- const formatPercentage = (value, decimals = 1) => {
79
- return `${(value * 100).toFixed(decimals)}%`;
80
- };
81
- exports.formatPercentage = formatPercentage;
82
- const formatFileSize = (bytes) => {
83
- if (bytes === 0) {
84
- return '0 Bytes';
85
- }
86
- const unit = 1024;
87
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
88
- const sizeIndex = Math.floor(Math.log(bytes) / Math.log(unit));
89
- return `${Number((bytes / unit ** sizeIndex).toFixed(2))} ${sizes[sizeIndex]}`;
90
- };
91
- exports.formatFileSize = formatFileSize;
92
- const truncateText = (text, maxLength) => {
93
- if (text.length <= maxLength) {
94
- return text;
95
- }
96
- return `${text.slice(0, maxLength - 3)}...`;
97
- };
98
- exports.truncateText = truncateText;
99
- const toTitleCase = (text) => {
100
- return text
101
- .toLowerCase()
102
- .split(' ')
103
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
104
- .join(' ');
105
- };
106
- exports.toTitleCase = toTitleCase;
107
- const normalizeNigerianPhone = (phone, withPlus = false) => {
108
- const digits = `${phone}`.replace(/\D/g, '').trim();
109
- if (digits === '') {
110
- return '';
111
- }
112
- let normalized = digits;
113
- if (digits.startsWith('234') && digits.length === 13) {
114
- normalized = digits;
115
- }
116
- else if (digits.startsWith('0') && digits.length === 11) {
117
- normalized = `234${digits.slice(1)}`;
118
- }
119
- else if (digits.length === 10 && /^[789]/.test(digits)) {
120
- normalized = `234${digits}`;
121
- }
122
- else if (!digits.startsWith('234') && digits.length === 10) {
123
- normalized = `234${digits}`;
124
- }
125
- return withPlus ? `+${normalized}` : normalized;
126
- };
127
- exports.normalizeNigerianPhone = normalizeNigerianPhone;
@@ -1,8 +0,0 @@
1
- export * from './country.utils';
2
- export * from './date.utils';
3
- export * from './decimal.utils';
4
- export * from './format.utils';
5
- export * from './string.utils';
6
- export * from './random.utils';
7
- export * from './reference.utils';
8
- export * from './validation.utils';
@@ -1,24 +0,0 @@
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("./country.utils"), exports);
18
- __exportStar(require("./date.utils"), exports);
19
- __exportStar(require("./decimal.utils"), exports);
20
- __exportStar(require("./format.utils"), exports);
21
- __exportStar(require("./string.utils"), exports);
22
- __exportStar(require("./random.utils"), exports);
23
- __exportStar(require("./reference.utils"), exports);
24
- __exportStar(require("./validation.utils"), exports);
@@ -1,10 +0,0 @@
1
- export interface RandomStringOptions {
2
- length?: number;
3
- expiry?: number;
4
- caseSensitive?: boolean;
5
- digits?: boolean;
6
- lowerCaseAlphabets?: boolean;
7
- upperCaseAlphabets?: boolean;
8
- specialChars?: boolean;
9
- }
10
- export declare function generateRandomString(options?: RandomStringOptions): string;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRandomString = generateRandomString;
4
- const DIGITS = '0123456789';
5
- const LOWERCASE_CHARS = 'abcdefghijklmnopqrstuvwxyz';
6
- const UPPERCASE_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
7
- const SPECIAL_CHARS = '!@#$%^&*()_+-=[]{}|;:,.<>?';
8
- function generateRandomString(options = {}) {
9
- const { length = 6, digits = true, lowerCaseAlphabets = false, upperCaseAlphabets = false, specialChars = false, } = options;
10
- let chars = '';
11
- if (digits)
12
- chars += DIGITS;
13
- if (lowerCaseAlphabets)
14
- chars += LOWERCASE_CHARS;
15
- if (upperCaseAlphabets)
16
- chars += UPPERCASE_CHARS;
17
- if (specialChars)
18
- chars += SPECIAL_CHARS;
19
- if (!chars)
20
- chars = DIGITS; // Default to digits if no character set is selected
21
- let result = '';
22
- const charactersLength = chars.length;
23
- for (let i = 0; i < length; i++) {
24
- result += chars.charAt(Math.floor(Math.random() * charactersLength));
25
- }
26
- return result;
27
- }
@@ -1 +0,0 @@
1
- export declare const generateReference: (prefix?: string) => string;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateReference = void 0;
4
- const generateRandomString = (length) => {
5
- const characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
6
- const charactersLength = characters.length;
7
- let result = '';
8
- for (let i = 0; i < length; i++) {
9
- const randomIndex = Math.floor(Math.random() * charactersLength);
10
- result += characters[randomIndex];
11
- }
12
- return result;
13
- };
14
- const generateReference = (prefix = 'TRX') => {
15
- return `${prefix}_${generateRandomString(12)}`;
16
- };
17
- exports.generateReference = generateReference;
@@ -1,10 +0,0 @@
1
- /**
2
- * Formats phone number for display
3
- * 2348012345678 → +234 801 234 5678
4
- */
5
- export declare const formatPhoneNumber: (phone: string) => string;
6
- /**
7
- * Masks phone number for security
8
- * +2348012345678 → +234****5678
9
- */
10
- export declare const maskPhoneNumber: (phone: string) => string;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.maskPhoneNumber = exports.formatPhoneNumber = void 0;
4
- /**
5
- * Formats phone number for display
6
- * 2348012345678 → +234 801 234 5678
7
- */
8
- const formatPhoneNumber = (phone) => {
9
- const cleaned = phone.replace(/[\s\-\(\)]/g, '');
10
- // Ensure it starts with 234
11
- let formatted = cleaned;
12
- if (formatted.startsWith('0')) {
13
- formatted = '234' + formatted.substring(1);
14
- }
15
- // Format as +234 801 234 5678
16
- if (formatted.startsWith('234')) {
17
- return `+234 ${formatted.substring(3, 6)} ${formatted.substring(6, 9)} ${formatted.substring(9)}`;
18
- }
19
- return phone;
20
- };
21
- exports.formatPhoneNumber = formatPhoneNumber;
22
- /**
23
- * Masks phone number for security
24
- * +2348012345678 → +234****5678
25
- */
26
- const maskPhoneNumber = (phone) => {
27
- const cleaned = phone.replace(/[\s\-\(\)]/g, '');
28
- if (cleaned.length < 8)
29
- return phone;
30
- const prefix = cleaned.substring(0, 4);
31
- const suffix = cleaned.slice(-4);
32
- return `${prefix}****${suffix}`;
33
- };
34
- exports.maskPhoneNumber = maskPhoneNumber;
@@ -1,8 +0,0 @@
1
- export declare const isValidNigerianPhone: (phone: string) => boolean;
2
- export declare const isValidEmail: (email: string) => boolean;
3
- export declare const isValidBVN: (bvn: string) => boolean;
4
- export declare const isValidNIN: (nin: string) => boolean;
5
- export declare const isValidAccountNumber: (accountNumber: string) => boolean;
6
- export declare const isValidAmount: (amount: number) => boolean;
7
- export declare const isStrongPassword: (password: string) => boolean;
8
- export declare const isValidTransactionReference: (reference: string) => boolean;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidTransactionReference = exports.isStrongPassword = exports.isValidAmount = exports.isValidAccountNumber = exports.isValidNIN = exports.isValidBVN = exports.isValidEmail = exports.isValidNigerianPhone = void 0;
4
- const isValidNigerianPhone = (phone) => {
5
- const cleaned = phone.replace(/[\s\-()]/g, '');
6
- const patterns = [
7
- /^0[7-9][0-1]\d{8}$/,
8
- /^\+234[7-9][0-1]\d{8}$/,
9
- /^234[7-9][0-1]\d{8}$/,
10
- ];
11
- return patterns.some((pattern) => pattern.test(cleaned));
12
- };
13
- exports.isValidNigerianPhone = isValidNigerianPhone;
14
- const isValidEmail = (email) => {
15
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
16
- };
17
- exports.isValidEmail = isValidEmail;
18
- const isValidBVN = (bvn) => {
19
- return /^\d{11}$/.test(bvn);
20
- };
21
- exports.isValidBVN = isValidBVN;
22
- const isValidNIN = (nin) => {
23
- return /^\d{11}$/.test(nin);
24
- };
25
- exports.isValidNIN = isValidNIN;
26
- const isValidAccountNumber = (accountNumber) => {
27
- return /^\d{10}$/.test(accountNumber);
28
- };
29
- exports.isValidAccountNumber = isValidAccountNumber;
30
- const isValidAmount = (amount) => {
31
- return typeof amount === 'number' && Number.isFinite(amount) && amount > 0;
32
- };
33
- exports.isValidAmount = isValidAmount;
34
- const isStrongPassword = (password) => {
35
- return (password.length >= 8 &&
36
- /[A-Z]/.test(password) &&
37
- /[a-z]/.test(password) &&
38
- /\d/.test(password));
39
- };
40
- exports.isStrongPassword = isStrongPassword;
41
- const isValidTransactionReference = (reference) => {
42
- return /^[A-Z0-9_-]{10,50}$/.test(reference);
43
- };
44
- exports.isValidTransactionReference = isValidTransactionReference;
@@ -1,19 +0,0 @@
1
- import { ConfigService } from '@nestjs/config';
2
- import { DiskHealthIndicator, HealthCheckService, MemoryHealthIndicator, MicroserviceHealthIndicator } from '@nestjs/terminus';
3
- export declare class HealthController {
4
- private readonly health;
5
- private readonly configService;
6
- private readonly disk;
7
- private readonly memory;
8
- private readonly microservice;
9
- constructor(health: HealthCheckService, configService: ConfigService, disk: DiskHealthIndicator, memory: MemoryHealthIndicator, microservice: MicroserviceHealthIndicator);
10
- check(): Promise<import("@nestjs/terminus").HealthCheckResult<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap">, Partial<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap">> | undefined, Partial<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap">> | undefined>>;
11
- ready(): Promise<import("@nestjs/terminus").HealthCheckResult<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"nats"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_rss"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap"> & import("@nestjs/terminus").HealthIndicatorResult<"storage">, Partial<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"nats"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_rss"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap"> & import("@nestjs/terminus").HealthIndicatorResult<"storage">> | undefined, Partial<import("@nestjs/terminus").HealthIndicatorResult<string, import("@nestjs/terminus").HealthIndicatorStatus, Record<string, any>> & import("@nestjs/terminus").HealthIndicatorResult<"nats"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_rss"> & import("@nestjs/terminus").HealthIndicatorResult<"memory_heap"> & import("@nestjs/terminus").HealthIndicatorResult<"storage">> | undefined>>;
12
- private checkStorage;
13
- private checkMemoryHeap;
14
- private checkMemoryRSS;
15
- private checkNats;
16
- private getMemoryHeapThreshold;
17
- private getMemoryRSSThreshold;
18
- private getDiskThresholdPercent;
19
- }