@viardex/viardex-libs 1.0.8 → 1.0.10

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 (48) hide show
  1. package/README.md +69 -0
  2. package/dist/common/cards/card.utils.d.ts +9 -0
  3. package/dist/common/cards/card.utils.js +48 -0
  4. package/dist/common/cards/index.d.ts +1 -0
  5. package/dist/common/cards/index.js +17 -0
  6. package/dist/common/crypto/crypto.utils.d.ts +7 -0
  7. package/dist/common/crypto/crypto.utils.js +42 -0
  8. package/dist/common/crypto/index.d.ts +1 -0
  9. package/dist/common/crypto/index.js +17 -0
  10. package/dist/common/dto/index.d.ts +1 -0
  11. package/dist/common/dto/index.js +17 -0
  12. package/dist/common/dto/pagination-query.dto.d.ts +7 -0
  13. package/dist/common/dto/pagination-query.dto.js +51 -0
  14. package/dist/common/index.d.ts +6 -0
  15. package/dist/common/index.js +6 -0
  16. package/dist/common/interfaces/index.d.ts +1 -0
  17. package/dist/common/interfaces/index.js +17 -0
  18. package/dist/common/interfaces/response.interface.d.ts +27 -0
  19. package/dist/common/interfaces/response.interface.js +2 -0
  20. package/dist/common/pipes/file-validation.pipe.d.ts +22 -0
  21. package/dist/common/pipes/file-validation.pipe.js +78 -0
  22. package/dist/common/pipes/index.d.ts +2 -0
  23. package/dist/common/pipes/index.js +18 -0
  24. package/dist/common/pipes/pagination-query-cleaner.pipe.d.ts +4 -0
  25. package/dist/common/pipes/pagination-query-cleaner.pipe.js +24 -0
  26. package/dist/common/response/http-exception.filter.d.ts +6 -0
  27. package/dist/common/response/http-exception.filter.js +61 -0
  28. package/dist/common/response/index.d.ts +3 -0
  29. package/dist/common/response/index.js +19 -0
  30. package/dist/common/response/response.interceptor.d.ts +6 -0
  31. package/dist/common/response/response.interceptor.js +57 -0
  32. package/dist/common/response/response.utils.d.ts +6 -0
  33. package/dist/common/response/response.utils.js +34 -0
  34. package/dist/common/utils/country.utils.d.ts +1 -0
  35. package/dist/common/utils/country.utils.js +38 -0
  36. package/dist/common/utils/date.utils.d.ts +6 -0
  37. package/dist/common/utils/date.utils.js +48 -0
  38. package/dist/common/utils/decimal.utils.d.ts +3 -0
  39. package/dist/common/utils/decimal.utils.js +22 -0
  40. package/dist/common/utils/format.utils.d.ts +13 -0
  41. package/dist/common/utils/format.utils.js +127 -0
  42. package/dist/common/utils/index.d.ts +5 -0
  43. package/dist/common/utils/index.js +5 -0
  44. package/dist/common/utils/validation.utils.d.ts +8 -0
  45. package/dist/common/utils/validation.utils.js +44 -0
  46. package/dist/nats/constants/nats.constants.d.ts +148 -2
  47. package/dist/nats/constants/nats.constants.js +90 -4
  48. package/package.json +1 -1
@@ -0,0 +1,57 @@
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);
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,34 @@
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;
@@ -0,0 +1 @@
1
+ export declare const countryDialCodes: string[];
@@ -0,0 +1,38 @@
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}`);
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,48 @@
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;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,127 @@
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,3 +1,8 @@
1
+ export * from './country.utils';
2
+ export * from './date.utils';
3
+ export * from './decimal.utils';
4
+ export * from './format.utils';
1
5
  export * from './string.utils';
2
6
  export * from './random.utils';
3
7
  export * from './reference.utils';
8
+ export * from './validation.utils';
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
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);
17
21
  __exportStar(require("./string.utils"), exports);
18
22
  __exportStar(require("./random.utils"), exports);
19
23
  __exportStar(require("./reference.utils"), exports);
24
+ __exportStar(require("./validation.utils"), exports);
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,44 @@
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;
@@ -7,5 +7,151 @@ export declare const DEFAULT_NATS_CONFIG: {
7
7
  reconnectTimeWait: number;
8
8
  maxReconnectAttempts: number;
9
9
  };
10
- export declare enum NatsSubjects {
11
- }
10
+ export declare const NotificationSubjects: {
11
+ readonly CREATE_IN_APP_NOTIFICATION: "notification.create-in-app";
12
+ readonly SEND_TEMPLATE_EMAIL: "notification.email.send-template";
13
+ readonly SEND_TEXT_MESSAGE: "notification.text.send";
14
+ readonly SEND_WHATSAPP_MESSAGE: "notification.whatsapp.send";
15
+ readonly SEND_VOICE_MESSAGE: "notification.voice.send";
16
+ readonly SEND_PUSH_NOTIFICATION: "notification.push.send";
17
+ };
18
+ export declare const UserServiceSubjects: {
19
+ readonly RESOLVE_MARKETING_USERS: "user.marketing.users.resolve";
20
+ };
21
+ export declare const SignupSubjects: {
22
+ readonly SIGNUP_INITIATED: "signup.initiated";
23
+ readonly SIGNUP_COMPLETED: "signup.completed";
24
+ readonly SIGNUP_VERIFICATION_REQUESTED: "signup.verification.requested";
25
+ };
26
+ export declare const SigninSubjects: {
27
+ readonly SIGNIN_INITIATED: "signin.initiated";
28
+ readonly SIGNIN_COMPLETED: "signin.completed";
29
+ readonly DEVICE_VERIFICATION_REQUESTED: "signin.device-verification.requested";
30
+ readonly SIGNIN_FAILED: "signin.failed";
31
+ };
32
+ export declare const PasswordSubjects: {
33
+ readonly PASSWORD_RESET_REQUESTED: "password.reset.requested";
34
+ readonly PASSWORD_RESET_COMPLETED: "password.reset.completed";
35
+ readonly PASSWORD_CHANGED: "password.changed";
36
+ };
37
+ export declare const PinSubjects: {
38
+ readonly PIN_RESET_REQUESTED: "pin.reset.requested";
39
+ readonly PIN_RESET_COMPLETED: "pin.reset.completed";
40
+ readonly PIN_CHANGED: "pin.changed";
41
+ readonly PIN_LOCKED: "pin.locked";
42
+ };
43
+ export declare const PreferencesSubjects: {
44
+ readonly USER_PREFERENCES_PROVISION_REQUESTED: "preferences.user.provision.requested";
45
+ readonly USER_PREFERENCES_UPDATED: "preferences.user.updated";
46
+ readonly STAFF_PREFERENCES_PROVISION_REQUESTED: "preferences.staff.provision.requested";
47
+ readonly STAFF_PREFERENCES_UPDATED: "preferences.staff.updated";
48
+ };
49
+ export declare const ReferralSubjects: {
50
+ readonly REFERRAL_CODE_PROVISION_REQUESTED: "referral.code.provision.requested";
51
+ readonly REFERRAL_LINKED: "referral.linked";
52
+ readonly REFERRAL_COMPLETED: "referral.completed";
53
+ readonly REFERRAL_REWARD_PROCESSING_REQUESTED: "referral.reward.processing.requested";
54
+ };
55
+ export declare const TicketSubjects: {
56
+ readonly TICKET_CREATED: "ticket.created";
57
+ readonly TICKET_UPDATED: "ticket.updated";
58
+ readonly TICKET_RESOLVED: "ticket.resolved";
59
+ };
60
+ export declare const DeviceSubjects: {
61
+ readonly DEVICE_TRUSTED: "device.trusted";
62
+ readonly DEVICE_REVOKED: "device.revoked";
63
+ readonly DEVICE_DEACTIVATED: "device.deactivated";
64
+ readonly DEVICE_ACTIVATED: "device.activated";
65
+ };
66
+ export declare const CountrySubjects: {
67
+ readonly COUNTRIES_SYNC_REQUESTED: "country.sync.requested";
68
+ };
69
+ export declare const StaffSubjects: {
70
+ readonly STAFF_CREATED: "staff.created";
71
+ readonly STAFF_UPDATED: "staff.updated";
72
+ readonly STAFF_PASSWORD_CHANGED: "staff.password.changed";
73
+ readonly STAFF_SIGNIN_COMPLETED: "staff.signin.completed";
74
+ };
75
+ export declare const RoleSubjects: {
76
+ readonly ROLE_CREATED: "role.created";
77
+ readonly ROLE_UPDATED: "role.updated";
78
+ readonly ROLE_PERMISSIONS_UPDATED: "role.permissions.updated";
79
+ };
80
+ export declare const AuditSubjects: {
81
+ readonly AUDIT_LOG_RECORDED: "audit.log.recorded";
82
+ };
83
+ export declare const NatsSubjects: {
84
+ readonly notification: {
85
+ readonly CREATE_IN_APP_NOTIFICATION: "notification.create-in-app";
86
+ readonly SEND_TEMPLATE_EMAIL: "notification.email.send-template";
87
+ readonly SEND_TEXT_MESSAGE: "notification.text.send";
88
+ readonly SEND_WHATSAPP_MESSAGE: "notification.whatsapp.send";
89
+ readonly SEND_VOICE_MESSAGE: "notification.voice.send";
90
+ readonly SEND_PUSH_NOTIFICATION: "notification.push.send";
91
+ };
92
+ readonly userService: {
93
+ readonly RESOLVE_MARKETING_USERS: "user.marketing.users.resolve";
94
+ };
95
+ readonly signup: {
96
+ readonly SIGNUP_INITIATED: "signup.initiated";
97
+ readonly SIGNUP_COMPLETED: "signup.completed";
98
+ readonly SIGNUP_VERIFICATION_REQUESTED: "signup.verification.requested";
99
+ };
100
+ readonly signin: {
101
+ readonly SIGNIN_INITIATED: "signin.initiated";
102
+ readonly SIGNIN_COMPLETED: "signin.completed";
103
+ readonly DEVICE_VERIFICATION_REQUESTED: "signin.device-verification.requested";
104
+ readonly SIGNIN_FAILED: "signin.failed";
105
+ };
106
+ readonly password: {
107
+ readonly PASSWORD_RESET_REQUESTED: "password.reset.requested";
108
+ readonly PASSWORD_RESET_COMPLETED: "password.reset.completed";
109
+ readonly PASSWORD_CHANGED: "password.changed";
110
+ };
111
+ readonly pin: {
112
+ readonly PIN_RESET_REQUESTED: "pin.reset.requested";
113
+ readonly PIN_RESET_COMPLETED: "pin.reset.completed";
114
+ readonly PIN_CHANGED: "pin.changed";
115
+ readonly PIN_LOCKED: "pin.locked";
116
+ };
117
+ readonly preferences: {
118
+ readonly USER_PREFERENCES_PROVISION_REQUESTED: "preferences.user.provision.requested";
119
+ readonly USER_PREFERENCES_UPDATED: "preferences.user.updated";
120
+ readonly STAFF_PREFERENCES_PROVISION_REQUESTED: "preferences.staff.provision.requested";
121
+ readonly STAFF_PREFERENCES_UPDATED: "preferences.staff.updated";
122
+ };
123
+ readonly referrals: {
124
+ readonly REFERRAL_CODE_PROVISION_REQUESTED: "referral.code.provision.requested";
125
+ readonly REFERRAL_LINKED: "referral.linked";
126
+ readonly REFERRAL_COMPLETED: "referral.completed";
127
+ readonly REFERRAL_REWARD_PROCESSING_REQUESTED: "referral.reward.processing.requested";
128
+ };
129
+ readonly tickets: {
130
+ readonly TICKET_CREATED: "ticket.created";
131
+ readonly TICKET_UPDATED: "ticket.updated";
132
+ readonly TICKET_RESOLVED: "ticket.resolved";
133
+ };
134
+ readonly devices: {
135
+ readonly DEVICE_TRUSTED: "device.trusted";
136
+ readonly DEVICE_REVOKED: "device.revoked";
137
+ readonly DEVICE_DEACTIVATED: "device.deactivated";
138
+ readonly DEVICE_ACTIVATED: "device.activated";
139
+ };
140
+ readonly countries: {
141
+ readonly COUNTRIES_SYNC_REQUESTED: "country.sync.requested";
142
+ };
143
+ readonly staff: {
144
+ readonly STAFF_CREATED: "staff.created";
145
+ readonly STAFF_UPDATED: "staff.updated";
146
+ readonly STAFF_PASSWORD_CHANGED: "staff.password.changed";
147
+ readonly STAFF_SIGNIN_COMPLETED: "staff.signin.completed";
148
+ };
149
+ readonly roles: {
150
+ readonly ROLE_CREATED: "role.created";
151
+ readonly ROLE_UPDATED: "role.updated";
152
+ readonly ROLE_PERMISSIONS_UPDATED: "role.permissions.updated";
153
+ };
154
+ readonly audit: {
155
+ readonly AUDIT_LOG_RECORDED: "audit.log.recorded";
156
+ };
157
+ };