@takentrade/takentrade-libs 1.0.3 → 1.0.5
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.
- package/dist/auth/interfaces/auth.interface.d.ts +7 -4
- package/dist/auth/interfaces/auth.interface.js +10 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/notification/index.d.ts +4 -0
- package/dist/notification/index.js +20 -0
- package/dist/notification/notification.client.d.ts +50 -0
- package/dist/notification/notification.client.js +211 -0
- package/dist/notification/notification.enum.d.ts +36 -0
- package/dist/notification/notification.enum.js +46 -0
- package/dist/notification/notification.interface.d.ts +133 -0
- package/dist/notification/notification.interface.js +2 -0
- package/dist/notification/notification.module.d.ts +2 -0
- package/dist/notification/notification.module.js +20 -0
- package/package.json +1 -1
|
@@ -5,14 +5,17 @@ export interface AuthUser {
|
|
|
5
5
|
isActive: boolean;
|
|
6
6
|
role?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare enum
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export declare enum UserRole {
|
|
9
|
+
ADMIN = "ADMIN",
|
|
10
|
+
USER = "USER",
|
|
11
|
+
STAFF = "STAFF",
|
|
12
|
+
SUPER_ADMIN = "SUPER_ADMIN",
|
|
13
|
+
LOAN_OFFICER = "LOAN_OFFICER",
|
|
14
|
+
ACCOUNTANT = "ACCOUNTANT"
|
|
11
15
|
}
|
|
12
16
|
export interface TokenPayload {
|
|
13
17
|
sub?: string;
|
|
14
18
|
id?: string;
|
|
15
19
|
email?: string;
|
|
16
20
|
role?: string;
|
|
17
|
-
[key: string]: any;
|
|
18
21
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
exports.UserRole = void 0;
|
|
4
|
+
var UserRole;
|
|
5
|
+
(function (UserRole) {
|
|
6
|
+
UserRole["ADMIN"] = "ADMIN";
|
|
7
|
+
UserRole["USER"] = "USER";
|
|
8
|
+
UserRole["STAFF"] = "STAFF";
|
|
9
|
+
UserRole["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
10
|
+
UserRole["LOAN_OFFICER"] = "LOAN_OFFICER";
|
|
11
|
+
UserRole["ACCOUNTANT"] = "ACCOUNTANT";
|
|
12
|
+
})(UserRole || (exports.UserRole = UserRole = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
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("./notification.client"), exports);
|
|
18
|
+
__exportStar(require("./notification.interface"), exports);
|
|
19
|
+
__exportStar(require("./notification.enum"), exports);
|
|
20
|
+
__exportStar(require("./notification.module"), exports);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ClientProxy } from '@nestjs/microservices';
|
|
2
|
+
import { OTPNotificationChannel } from './notification.enum';
|
|
3
|
+
import { AccountFreezeEmailData, AccountStatementEmailData, AccountUnfreezeEmailData, AjoCancellationEmailData, AjoContributionEmailData, AjoInviteEmailData, AjoMembershipUpdateEmailData, ContactMessageEmailData, CreditTransactionMailData, CustomMailSendOptions, DebitTransactionMailData, InvestmentCancellationEmailData, LoanApprovedEmailData, LoanRepaymentConfirmationEmailData, LoanRepaymentFailedEmailData, NewLoanApplicationEmailData, OTPMailData, PasswordResetMailData, ResetTransactionPinEmailData, AjoContributionConfirmationEmailData, InvestmentConfirmationEmailData, SendPushNotificationInput, BaseEmailData } from './notification.interface';
|
|
4
|
+
export declare class NotificationClient {
|
|
5
|
+
private readonly natsClient;
|
|
6
|
+
constructor(natsClient: ClientProxy);
|
|
7
|
+
private validatePhoneNumber;
|
|
8
|
+
private validateEmailAddress;
|
|
9
|
+
sendSms(to: string, message: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* This utility method sends an OTP message via the SMS channel.
|
|
12
|
+
*
|
|
13
|
+
* @param to - The recipient phone number
|
|
14
|
+
* @param message - The OTP message
|
|
15
|
+
* @deprecated
|
|
16
|
+
*/
|
|
17
|
+
sendSmsOTP(to: string, message: string): Promise<void>;
|
|
18
|
+
sendCustomMail(to: string, options: CustomMailSendOptions): Promise<void>;
|
|
19
|
+
sendPasswordResetMail(to: string, data: PasswordResetMailData): Promise<void>;
|
|
20
|
+
sendCreditTransactionMail(to: string, data: CreditTransactionMailData): Promise<void>;
|
|
21
|
+
sendDebitTransactionMail(to: string, data: DebitTransactionMailData): Promise<void>;
|
|
22
|
+
sendAccountFreezeMail(to: string, data: AccountFreezeEmailData): Promise<void>;
|
|
23
|
+
sendAccountStatementMail(to: string, data: AccountStatementEmailData): Promise<void>;
|
|
24
|
+
sendAccountUnfreezeMail(to: string, data: AccountUnfreezeEmailData): Promise<void>;
|
|
25
|
+
sendAdminNewLoanMail(to: string, data: NewLoanApplicationEmailData): Promise<void>;
|
|
26
|
+
sendAjoCancellationMail(to: string, data: AjoCancellationEmailData): Promise<void>;
|
|
27
|
+
sendAjoContributionMail(to: string, data: AjoContributionEmailData): Promise<void>;
|
|
28
|
+
sendAjoInvitationMail(to: string, data: AjoInviteEmailData): Promise<void>;
|
|
29
|
+
sendAjoMembershipMail(to: string, data: AjoMembershipUpdateEmailData): Promise<void>;
|
|
30
|
+
sendContactMail(to: string, data: ContactMessageEmailData): Promise<void>;
|
|
31
|
+
sendForgetPinOTPMail(to: string, data: ResetTransactionPinEmailData): Promise<void>;
|
|
32
|
+
sendInvestmentCancellationMail(to: string, data: InvestmentCancellationEmailData): Promise<void>;
|
|
33
|
+
sendLoanApprovedMail(to: string, data: LoanApprovedEmailData): Promise<void>;
|
|
34
|
+
sendLoanRepaymentFailedMail(to: string, data: LoanRepaymentFailedEmailData): Promise<void>;
|
|
35
|
+
sendLoanRepaymentSuccessMail(to: string, data: LoanRepaymentConfirmationEmailData): Promise<void>;
|
|
36
|
+
sendNewAjoMail(to: string, data: AjoContributionConfirmationEmailData): Promise<void>;
|
|
37
|
+
sendNewInvestmentMail(to: string, data: InvestmentConfirmationEmailData): Promise<void>;
|
|
38
|
+
sendWelcomeMail(to: string, data: BaseEmailData): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Sends generated OTP to a recipient
|
|
41
|
+
* @param to - recipient phone number or email
|
|
42
|
+
* @param data - OTP data
|
|
43
|
+
* @param channel - OTP notification channel. Defaults to sms.
|
|
44
|
+
*/
|
|
45
|
+
sendOTP(to: string, data: OTPMailData, channel?: OTPNotificationChannel): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Sends push notification
|
|
48
|
+
*/
|
|
49
|
+
sendPush(input: SendPushNotificationInput): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NotificationClient = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const notification_enum_1 = require("./notification.enum");
|
|
15
|
+
const nats_1 = require("../nats");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
let NotificationClient = class NotificationClient {
|
|
18
|
+
natsClient;
|
|
19
|
+
constructor(natsClient) {
|
|
20
|
+
this.natsClient = natsClient;
|
|
21
|
+
}
|
|
22
|
+
validatePhoneNumber(phone) {
|
|
23
|
+
if (!(0, class_validator_1.isPhoneNumber)(phone)) {
|
|
24
|
+
throw new common_1.BadRequestException('Invalid phone number');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
validateEmailAddress(email) {
|
|
28
|
+
if (!(0, class_validator_1.isEmail)(email)) {
|
|
29
|
+
throw new common_1.BadRequestException('Invalid email address');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async sendSms(to, message) {
|
|
33
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_TEXT, {
|
|
34
|
+
to: to.slice(1),
|
|
35
|
+
message,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This utility method sends an OTP message via the SMS channel.
|
|
40
|
+
*
|
|
41
|
+
* @param to - The recipient phone number
|
|
42
|
+
* @param message - The OTP message
|
|
43
|
+
* @deprecated
|
|
44
|
+
*/
|
|
45
|
+
async sendSmsOTP(to, message) {
|
|
46
|
+
this.natsClient.emit(`notification.sms.otp`, {
|
|
47
|
+
to: to.slice(1),
|
|
48
|
+
message,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async sendCustomMail(to, options) {
|
|
52
|
+
this.validateEmailAddress(to);
|
|
53
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_MAIL, {
|
|
54
|
+
to,
|
|
55
|
+
...options,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async sendPasswordResetMail(to, data) {
|
|
59
|
+
this.validateEmailAddress(to);
|
|
60
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.PASSWORD_RESET_MAIL, {
|
|
61
|
+
to,
|
|
62
|
+
data,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async sendCreditTransactionMail(to, data) {
|
|
66
|
+
this.validateEmailAddress(to);
|
|
67
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.TRANSANCTION_CREDIT_MAIL, { to, data });
|
|
68
|
+
}
|
|
69
|
+
async sendDebitTransactionMail(to, data) {
|
|
70
|
+
this.validateEmailAddress(to);
|
|
71
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.TRANSANCTION_DEBIT_MAIL, { to, data });
|
|
72
|
+
}
|
|
73
|
+
async sendAccountFreezeMail(to, data) {
|
|
74
|
+
this.validateEmailAddress(to);
|
|
75
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_FREEZE_MAIL, {
|
|
76
|
+
to,
|
|
77
|
+
data,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async sendAccountStatementMail(to, data) {
|
|
81
|
+
this.validateEmailAddress(to);
|
|
82
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_STATEMENT_MAIL, { to, data });
|
|
83
|
+
}
|
|
84
|
+
async sendAccountUnfreezeMail(to, data) {
|
|
85
|
+
this.validateEmailAddress(to);
|
|
86
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ACCOUNT_UNFREEZE_MAIL, { to, data });
|
|
87
|
+
}
|
|
88
|
+
async sendAdminNewLoanMail(to, data) {
|
|
89
|
+
this.validateEmailAddress(to);
|
|
90
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.ADMIN_NEW_LOAN_MAIL, {
|
|
91
|
+
to,
|
|
92
|
+
data,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async sendAjoCancellationMail(to, data) {
|
|
96
|
+
this.validateEmailAddress(to);
|
|
97
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_CANCELLATION_MAIL, { to, data });
|
|
98
|
+
}
|
|
99
|
+
async sendAjoContributionMail(to, data) {
|
|
100
|
+
this.validateEmailAddress(to);
|
|
101
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_CONTRIBUTION_MAIL, { to, data });
|
|
102
|
+
}
|
|
103
|
+
async sendAjoInvitationMail(to, data) {
|
|
104
|
+
this.validateEmailAddress(to);
|
|
105
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_INVITATION_MAIL, {
|
|
106
|
+
to,
|
|
107
|
+
data,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async sendAjoMembershipMail(to, data) {
|
|
111
|
+
this.validateEmailAddress(to);
|
|
112
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.AJO_MEMBERSHIP_MAIL, {
|
|
113
|
+
to,
|
|
114
|
+
data,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async sendContactMail(to, data) {
|
|
118
|
+
this.validateEmailAddress(to);
|
|
119
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.CONTACT_MAIL, {
|
|
120
|
+
to,
|
|
121
|
+
data,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async sendForgetPinOTPMail(to, data) {
|
|
125
|
+
this.validateEmailAddress(to);
|
|
126
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.FORGET_PIN_OTP_MAIL, {
|
|
127
|
+
to,
|
|
128
|
+
data,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async sendInvestmentCancellationMail(to, data) {
|
|
132
|
+
this.validateEmailAddress(to);
|
|
133
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.INVESTMENT_CANCELLATION_MAIL, { to, data });
|
|
134
|
+
}
|
|
135
|
+
async sendLoanApprovedMail(to, data) {
|
|
136
|
+
this.validateEmailAddress(to);
|
|
137
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_APPROVED_MAIL, {
|
|
138
|
+
to,
|
|
139
|
+
data,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async sendLoanRepaymentFailedMail(to, data) {
|
|
143
|
+
this.validateEmailAddress(to);
|
|
144
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_REPAYMENT_FAILED_MAIL, { to, data });
|
|
145
|
+
}
|
|
146
|
+
async sendLoanRepaymentSuccessMail(to, data) {
|
|
147
|
+
this.validateEmailAddress(to);
|
|
148
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.LOAN_REPAYMENT_SUCCESS_MAIL, { to, data });
|
|
149
|
+
}
|
|
150
|
+
async sendNewAjoMail(to, data) {
|
|
151
|
+
this.validateEmailAddress(to);
|
|
152
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_AJO_MAIL, {
|
|
153
|
+
to,
|
|
154
|
+
data,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async sendNewInvestmentMail(to, data) {
|
|
158
|
+
this.validateEmailAddress(to);
|
|
159
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NEW_INVESTMENT_MAIL, {
|
|
160
|
+
to,
|
|
161
|
+
data,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
async sendWelcomeMail(to, data) {
|
|
165
|
+
this.validateEmailAddress(to);
|
|
166
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.WELCOME_MAIL, {
|
|
167
|
+
to,
|
|
168
|
+
data,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Sends generated OTP to a recipient
|
|
173
|
+
* @param to - recipient phone number or email
|
|
174
|
+
* @param data - OTP data
|
|
175
|
+
* @param channel - OTP notification channel. Defaults to sms.
|
|
176
|
+
*/
|
|
177
|
+
async sendOTP(to, data, channel = notification_enum_1.OTPNotificationChannel.sms) {
|
|
178
|
+
if (channel == notification_enum_1.OTPNotificationChannel.mail) {
|
|
179
|
+
this.validateEmailAddress(to);
|
|
180
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.OTP_MAIL, {
|
|
181
|
+
to,
|
|
182
|
+
...data,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else if (channel == notification_enum_1.OTPNotificationChannel.sms) {
|
|
186
|
+
this.validatePhoneNumber(to);
|
|
187
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_OTP_TEXT, { to, ...data });
|
|
188
|
+
}
|
|
189
|
+
else if (channel == notification_enum_1.OTPNotificationChannel.voice) {
|
|
190
|
+
this.validatePhoneNumber(to);
|
|
191
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_OTP_VOICE, { to, ...data });
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
throw new common_1.BadRequestException('Invalid OTP channel');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Sends push notification
|
|
199
|
+
*/
|
|
200
|
+
async sendPush(input) {
|
|
201
|
+
if (!input.tokens?.length && !input.userId) {
|
|
202
|
+
throw new common_1.BadRequestException('You must provide a device tokens array or a userId');
|
|
203
|
+
}
|
|
204
|
+
this.natsClient.emit(notification_enum_1.NotificationSubcribedNATSSubject.NOTIFICATION_PUSH, input);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.NotificationClient = NotificationClient;
|
|
208
|
+
exports.NotificationClient = NotificationClient = __decorate([
|
|
209
|
+
(0, common_1.Injectable)(),
|
|
210
|
+
__param(0, (0, common_1.Inject)(nats_1.NATS_CLIENT))
|
|
211
|
+
], NotificationClient);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare enum NotificationTextChannel {
|
|
2
|
+
sms = "sms"
|
|
3
|
+
}
|
|
4
|
+
export declare enum OTPNotificationChannel {
|
|
5
|
+
sms = "sms",
|
|
6
|
+
voice = "voice",
|
|
7
|
+
mail = "mail"
|
|
8
|
+
}
|
|
9
|
+
export declare enum NotificationSubcribedNATSSubject {
|
|
10
|
+
NOTIFICATION_MAIL = "notification.mail",
|
|
11
|
+
OTP_MAIL = "notification.mail.otp",
|
|
12
|
+
WELCOME_MAIL = "notification.mail.welcome",
|
|
13
|
+
PASSWORD_RESET_MAIL = "notification.mail.passwordreset",
|
|
14
|
+
TRANSANCTION_DEBIT_MAIL = "notification.mail.transaction.debit",
|
|
15
|
+
TRANSANCTION_CREDIT_MAIL = "notification.mail.transaction.credit",
|
|
16
|
+
ACCOUNT_FREEZE_MAIL = "notification.mail.account.freeze",
|
|
17
|
+
ACCOUNT_STATEMENT_MAIL = "notification.mail.account.statement",
|
|
18
|
+
ACCOUNT_UNFREEZE_MAIL = "notification.mail.account.unfreeze",
|
|
19
|
+
ADMIN_NEW_LOAN_MAIL = "notification.mail.admin.loan.new",
|
|
20
|
+
AJO_CANCELLATION_MAIL = "notification.mail.ajo.cancellation",
|
|
21
|
+
AJO_CONTRIBUTION_MAIL = "notification.mail.ajo.contribution",
|
|
22
|
+
AJO_INVITATION_MAIL = "notification.mail.ajo.invitation",
|
|
23
|
+
AJO_MEMBERSHIP_MAIL = "notification.mail.ajo.membership",
|
|
24
|
+
CONTACT_MAIL = "notification.mail.contact",
|
|
25
|
+
FORGET_PIN_OTP_MAIL = "notification.mail.forgetpin.otp",
|
|
26
|
+
INVESTMENT_CANCELLATION_MAIL = "notification.mail.investment.cancellation",
|
|
27
|
+
LOAN_APPROVED_MAIL = "notification.mail.loan.approved",
|
|
28
|
+
LOAN_REPAYMENT_FAILED_MAIL = "notification.mail.loan.repayment.failed",
|
|
29
|
+
LOAN_REPAYMENT_SUCCESS_MAIL = "notification.mail.loan.repayment.success",
|
|
30
|
+
NEW_AJO_MAIL = "notification.mail.ajo.new",
|
|
31
|
+
NEW_INVESTMENT_MAIL = "notification.mail.investment.new",
|
|
32
|
+
NOTIFICATION_TEXT = "notification.text",
|
|
33
|
+
NOTIFICATION_OTP_TEXT = "notification.text.otp",
|
|
34
|
+
NOTIFICATION_OTP_VOICE = "notification.voice.otp",
|
|
35
|
+
NOTIFICATION_PUSH = "notification.push"
|
|
36
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationSubcribedNATSSubject = exports.OTPNotificationChannel = exports.NotificationTextChannel = void 0;
|
|
4
|
+
var NotificationTextChannel;
|
|
5
|
+
(function (NotificationTextChannel) {
|
|
6
|
+
NotificationTextChannel["sms"] = "sms";
|
|
7
|
+
})(NotificationTextChannel || (exports.NotificationTextChannel = NotificationTextChannel = {}));
|
|
8
|
+
var OTPNotificationChannel;
|
|
9
|
+
(function (OTPNotificationChannel) {
|
|
10
|
+
OTPNotificationChannel["sms"] = "sms";
|
|
11
|
+
OTPNotificationChannel["voice"] = "voice";
|
|
12
|
+
OTPNotificationChannel["mail"] = "mail";
|
|
13
|
+
})(OTPNotificationChannel || (exports.OTPNotificationChannel = OTPNotificationChannel = {}));
|
|
14
|
+
var NotificationSubcribedNATSSubject;
|
|
15
|
+
(function (NotificationSubcribedNATSSubject) {
|
|
16
|
+
// MAIL
|
|
17
|
+
NotificationSubcribedNATSSubject["NOTIFICATION_MAIL"] = "notification.mail";
|
|
18
|
+
NotificationSubcribedNATSSubject["OTP_MAIL"] = "notification.mail.otp";
|
|
19
|
+
NotificationSubcribedNATSSubject["WELCOME_MAIL"] = "notification.mail.welcome";
|
|
20
|
+
NotificationSubcribedNATSSubject["PASSWORD_RESET_MAIL"] = "notification.mail.passwordreset";
|
|
21
|
+
NotificationSubcribedNATSSubject["TRANSANCTION_DEBIT_MAIL"] = "notification.mail.transaction.debit";
|
|
22
|
+
NotificationSubcribedNATSSubject["TRANSANCTION_CREDIT_MAIL"] = "notification.mail.transaction.credit";
|
|
23
|
+
NotificationSubcribedNATSSubject["ACCOUNT_FREEZE_MAIL"] = "notification.mail.account.freeze";
|
|
24
|
+
NotificationSubcribedNATSSubject["ACCOUNT_STATEMENT_MAIL"] = "notification.mail.account.statement";
|
|
25
|
+
NotificationSubcribedNATSSubject["ACCOUNT_UNFREEZE_MAIL"] = "notification.mail.account.unfreeze";
|
|
26
|
+
NotificationSubcribedNATSSubject["ADMIN_NEW_LOAN_MAIL"] = "notification.mail.admin.loan.new";
|
|
27
|
+
NotificationSubcribedNATSSubject["AJO_CANCELLATION_MAIL"] = "notification.mail.ajo.cancellation";
|
|
28
|
+
NotificationSubcribedNATSSubject["AJO_CONTRIBUTION_MAIL"] = "notification.mail.ajo.contribution";
|
|
29
|
+
NotificationSubcribedNATSSubject["AJO_INVITATION_MAIL"] = "notification.mail.ajo.invitation";
|
|
30
|
+
NotificationSubcribedNATSSubject["AJO_MEMBERSHIP_MAIL"] = "notification.mail.ajo.membership";
|
|
31
|
+
NotificationSubcribedNATSSubject["CONTACT_MAIL"] = "notification.mail.contact";
|
|
32
|
+
NotificationSubcribedNATSSubject["FORGET_PIN_OTP_MAIL"] = "notification.mail.forgetpin.otp";
|
|
33
|
+
NotificationSubcribedNATSSubject["INVESTMENT_CANCELLATION_MAIL"] = "notification.mail.investment.cancellation";
|
|
34
|
+
NotificationSubcribedNATSSubject["LOAN_APPROVED_MAIL"] = "notification.mail.loan.approved";
|
|
35
|
+
NotificationSubcribedNATSSubject["LOAN_REPAYMENT_FAILED_MAIL"] = "notification.mail.loan.repayment.failed";
|
|
36
|
+
NotificationSubcribedNATSSubject["LOAN_REPAYMENT_SUCCESS_MAIL"] = "notification.mail.loan.repayment.success";
|
|
37
|
+
NotificationSubcribedNATSSubject["NEW_AJO_MAIL"] = "notification.mail.ajo.new";
|
|
38
|
+
NotificationSubcribedNATSSubject["NEW_INVESTMENT_MAIL"] = "notification.mail.investment.new";
|
|
39
|
+
// TEXT
|
|
40
|
+
NotificationSubcribedNATSSubject["NOTIFICATION_TEXT"] = "notification.text";
|
|
41
|
+
NotificationSubcribedNATSSubject["NOTIFICATION_OTP_TEXT"] = "notification.text.otp";
|
|
42
|
+
// VOICE
|
|
43
|
+
NotificationSubcribedNATSSubject["NOTIFICATION_OTP_VOICE"] = "notification.voice.otp";
|
|
44
|
+
// PUSH
|
|
45
|
+
NotificationSubcribedNATSSubject["NOTIFICATION_PUSH"] = "notification.push";
|
|
46
|
+
})(NotificationSubcribedNATSSubject || (exports.NotificationSubcribedNATSSubject = NotificationSubcribedNATSSubject = {}));
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { MulterFile } from '../utils';
|
|
2
|
+
export interface CustomMailSendOptions {
|
|
3
|
+
subject: string;
|
|
4
|
+
from?: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
html?: string;
|
|
7
|
+
template?: string | Buffer;
|
|
8
|
+
attachments?: MulterFile[] | Buffer[];
|
|
9
|
+
data?: object;
|
|
10
|
+
}
|
|
11
|
+
export interface TemplateMailSendOption<D = Record<string, string | number>> {
|
|
12
|
+
to: string[];
|
|
13
|
+
attachments?: MulterFile[] | Buffer[];
|
|
14
|
+
data?: D;
|
|
15
|
+
}
|
|
16
|
+
export interface BaseEmailData {
|
|
17
|
+
firstName: string;
|
|
18
|
+
currentYear: number;
|
|
19
|
+
}
|
|
20
|
+
export interface OTPMailData extends BaseEmailData {
|
|
21
|
+
otp: string;
|
|
22
|
+
expiration: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PasswordResetMailData extends OTPMailData {
|
|
25
|
+
}
|
|
26
|
+
export interface BaseTransactionMailData extends BaseEmailData {
|
|
27
|
+
amount: string;
|
|
28
|
+
currency: string;
|
|
29
|
+
type: string;
|
|
30
|
+
direction: string;
|
|
31
|
+
totalAmount: string;
|
|
32
|
+
paymentReference: string;
|
|
33
|
+
description: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
beneficiaryAccountName?: string;
|
|
36
|
+
beneficiaryAccountNumber?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface CreditTransactionMailData extends BaseTransactionMailData {
|
|
39
|
+
}
|
|
40
|
+
export interface DebitTransactionMailData extends BaseTransactionMailData {
|
|
41
|
+
}
|
|
42
|
+
export interface AccountFreezeEmailData extends BaseEmailData {
|
|
43
|
+
freezeDate: string;
|
|
44
|
+
reason: string;
|
|
45
|
+
}
|
|
46
|
+
export interface AccountStatementEmailData extends BaseEmailData {
|
|
47
|
+
userName: string;
|
|
48
|
+
startDate: string;
|
|
49
|
+
format: 'pdf' | 'csv' | 'xlsx';
|
|
50
|
+
expiryDate: string;
|
|
51
|
+
statementUrl: string;
|
|
52
|
+
isAdmin?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface AccountUnfreezeEmailData extends BaseEmailData {
|
|
55
|
+
unfreezeDate: string;
|
|
56
|
+
reason: string;
|
|
57
|
+
}
|
|
58
|
+
export interface NewLoanApplicationEmailData extends BaseEmailData {
|
|
59
|
+
amount: number;
|
|
60
|
+
repaymentDate: string;
|
|
61
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
62
|
+
}
|
|
63
|
+
export interface AjoCancellationEmailData extends BaseEmailData {
|
|
64
|
+
ajoName: string;
|
|
65
|
+
refundAmount: number;
|
|
66
|
+
}
|
|
67
|
+
export interface AjoContributionEmailData extends BaseEmailData {
|
|
68
|
+
amount: number;
|
|
69
|
+
ajoName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AjoInviteEmailData extends BaseEmailData {
|
|
72
|
+
ajoName: string;
|
|
73
|
+
acceptUrl: string;
|
|
74
|
+
}
|
|
75
|
+
export interface AjoMembershipUpdateEmailData extends BaseEmailData {
|
|
76
|
+
ajoName: string;
|
|
77
|
+
status: 'active' | 'inactive' | 'pending' | 'cancelled';
|
|
78
|
+
}
|
|
79
|
+
export interface ContactMessageEmailData extends BaseEmailData {
|
|
80
|
+
name: string;
|
|
81
|
+
email: string;
|
|
82
|
+
message: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ResetTransactionPinEmailData extends BaseEmailData {
|
|
85
|
+
otpCode: string;
|
|
86
|
+
expiryMinutes: number;
|
|
87
|
+
}
|
|
88
|
+
export interface InvestmentCancellationEmailData extends BaseEmailData {
|
|
89
|
+
amount: number;
|
|
90
|
+
reason: string;
|
|
91
|
+
}
|
|
92
|
+
export interface LoanApprovedEmailData extends BaseEmailData {
|
|
93
|
+
amount: number;
|
|
94
|
+
repaymentDate: string;
|
|
95
|
+
status: 'approved';
|
|
96
|
+
}
|
|
97
|
+
export interface LoanRepaymentFailedEmailData extends BaseEmailData {
|
|
98
|
+
amount: number;
|
|
99
|
+
repaymentDate: string;
|
|
100
|
+
}
|
|
101
|
+
export interface LoanRepaymentConfirmationEmailData extends BaseEmailData {
|
|
102
|
+
amount: number;
|
|
103
|
+
remainingBalance?: number;
|
|
104
|
+
isFullyRepaid: boolean;
|
|
105
|
+
wasDefaulted?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface AjoContributionConfirmationEmailData extends BaseEmailData {
|
|
108
|
+
ajoName: string;
|
|
109
|
+
amount: number;
|
|
110
|
+
frequency: 'daily' | 'weekly' | 'monthly';
|
|
111
|
+
startDate: string;
|
|
112
|
+
duration: number;
|
|
113
|
+
}
|
|
114
|
+
export interface InvestmentConfirmationEmailData extends BaseEmailData {
|
|
115
|
+
type: string;
|
|
116
|
+
amount: number;
|
|
117
|
+
duration: string;
|
|
118
|
+
startDate: string;
|
|
119
|
+
maturityDate: string;
|
|
120
|
+
expectedReturn: number;
|
|
121
|
+
}
|
|
122
|
+
export interface SendPushNotificationInput {
|
|
123
|
+
title: string;
|
|
124
|
+
body: string;
|
|
125
|
+
userId?: string;
|
|
126
|
+
tokens?: string[];
|
|
127
|
+
data?: {
|
|
128
|
+
resourceType: string;
|
|
129
|
+
resourceId: string;
|
|
130
|
+
};
|
|
131
|
+
priority?: boolean;
|
|
132
|
+
topic?: string;
|
|
133
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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.NotificationClientModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const notification_client_1 = require("./notification.client");
|
|
12
|
+
let NotificationClientModule = class NotificationClientModule {
|
|
13
|
+
};
|
|
14
|
+
exports.NotificationClientModule = NotificationClientModule;
|
|
15
|
+
exports.NotificationClientModule = NotificationClientModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [notification_client_1.NotificationClient],
|
|
18
|
+
exports: [notification_client_1.NotificationClient],
|
|
19
|
+
})
|
|
20
|
+
], NotificationClientModule);
|