@takentrade/takentrade-libs 1.0.2 → 1.0.4

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 (35) hide show
  1. package/dist/auth/auth.module.d.ts +2 -0
  2. package/dist/auth/auth.module.js +21 -0
  3. package/dist/auth/decorators/index.d.ts +3 -0
  4. package/dist/auth/decorators/index.js +19 -0
  5. package/dist/auth/decorators/public.decorator.d.ts +2 -0
  6. package/dist/auth/decorators/public.decorator.js +7 -0
  7. package/dist/auth/decorators/roles.decorator.d.ts +10 -0
  8. package/dist/auth/decorators/roles.decorator.js +15 -0
  9. package/dist/auth/decorators/users.decorator.d.ts +8 -0
  10. package/dist/auth/decorators/users.decorator.js +48 -0
  11. package/dist/auth/guards/auth.guard.d.ts +19 -0
  12. package/dist/auth/guards/auth.guard.js +66 -0
  13. package/dist/auth/guards/index.d.ts +2 -0
  14. package/dist/auth/guards/index.js +18 -0
  15. package/dist/auth/guards/roles.guard.d.ts +15 -0
  16. package/dist/auth/guards/roles.guard.js +41 -0
  17. package/dist/auth/index.d.ts +4 -0
  18. package/dist/auth/index.js +20 -0
  19. package/dist/auth/interfaces/auth.interface.d.ts +18 -0
  20. package/dist/auth/interfaces/auth.interface.js +8 -0
  21. package/dist/auth/interfaces/index.d.ts +1 -0
  22. package/dist/auth/interfaces/index.js +17 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +2 -0
  25. package/dist/notification/index.d.ts +4 -0
  26. package/dist/notification/index.js +20 -0
  27. package/dist/notification/notification.client.d.ts +50 -0
  28. package/dist/notification/notification.client.js +211 -0
  29. package/dist/notification/notification.enum.d.ts +36 -0
  30. package/dist/notification/notification.enum.js +46 -0
  31. package/dist/notification/notification.interface.d.ts +133 -0
  32. package/dist/notification/notification.interface.js +2 -0
  33. package/dist/notification/notification.module.d.ts +2 -0
  34. package/dist/notification/notification.module.js +20 -0
  35. package/package.json +3 -1
@@ -0,0 +1,2 @@
1
+ export declare class TNTAuthModule {
2
+ }
@@ -0,0 +1,21 @@
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.TNTAuthModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const auth_guard_1 = require("./guards/auth.guard");
12
+ const roles_guard_1 = require("./guards/roles.guard");
13
+ let TNTAuthModule = class TNTAuthModule {
14
+ };
15
+ exports.TNTAuthModule = TNTAuthModule;
16
+ exports.TNTAuthModule = TNTAuthModule = __decorate([
17
+ (0, common_1.Module)({
18
+ providers: [auth_guard_1.TNTAuthGuard, roles_guard_1.RolesGuard],
19
+ exports: [auth_guard_1.TNTAuthGuard, roles_guard_1.RolesGuard],
20
+ })
21
+ ], TNTAuthModule);
@@ -0,0 +1,3 @@
1
+ export * from './public.decorator';
2
+ export * from './users.decorator';
3
+ export * from './roles.decorator';
@@ -0,0 +1,19 @@
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("./public.decorator"), exports);
18
+ __exportStar(require("./users.decorator"), exports);
19
+ __exportStar(require("./roles.decorator"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const IS_PUBLIC_KEY = "isPublic";
2
+ export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Public = exports.IS_PUBLIC_KEY = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.IS_PUBLIC_KEY = 'isPublic';
6
+ const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
7
+ exports.Public = Public;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Metadata key for storing roles in the decorator.
3
+ */
4
+ export declare const ROLES_KEY = "roles";
5
+ /**
6
+ * Decorator to set required roles for a route or controller.
7
+ * @param roles List of role names required to access the resource.
8
+ * @returns Custom metadata decorator for role-based access control.
9
+ */
10
+ export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Roles = exports.ROLES_KEY = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * Metadata key for storing roles in the decorator.
7
+ */
8
+ exports.ROLES_KEY = 'roles';
9
+ /**
10
+ * Decorator to set required roles for a route or controller.
11
+ * @param roles List of role names required to access the resource.
12
+ * @returns Custom metadata decorator for role-based access control.
13
+ */
14
+ const Roles = (...roles) => (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
15
+ exports.Roles = Roles;
@@ -0,0 +1,8 @@
1
+ import { TokenPayload } from '../interfaces';
2
+ /**
3
+ * Custom decorator to extract user data from the request.
4
+ * @param data Optional key of the TokenPayload to extract a specific property.
5
+ * @param ctx Execution context to access the request.
6
+ * @returns The user object or the specified property value.
7
+ */
8
+ export declare const GetUser: (...dataOrPipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | keyof TokenPayload | undefined)[]) => ParameterDecorator;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetUser = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * Extracts the user object or a specific property from the request's user payload.
7
+ * @param data Optional key of the TokenPayload to extract a specific property.
8
+ * @param ctx Execution context to access the request.
9
+ * @returns The entire user object or the specified property value.
10
+ * @throws UnauthorizedException if user or requested property is not found.
11
+ */
12
+ const getUserHelpers = {
13
+ getUserFromRequest(request) {
14
+ const user = request.user;
15
+ if (!user) {
16
+ throw new common_1.UnauthorizedException('User not found in request');
17
+ }
18
+ return user;
19
+ },
20
+ getUserProperty(user, data) {
21
+ if (!data) {
22
+ return user;
23
+ }
24
+ if (data === 'sub') {
25
+ const value = user.id || user.sub;
26
+ if (!value) {
27
+ throw new common_1.UnauthorizedException('User ID not found');
28
+ }
29
+ return value;
30
+ }
31
+ const value = user[data];
32
+ if (value === undefined) {
33
+ throw new common_1.UnauthorizedException(`User ${data} not found`);
34
+ }
35
+ return value;
36
+ },
37
+ };
38
+ /**
39
+ * Custom decorator to extract user data from the request.
40
+ * @param data Optional key of the TokenPayload to extract a specific property.
41
+ * @param ctx Execution context to access the request.
42
+ * @returns The user object or the specified property value.
43
+ */
44
+ exports.GetUser = (0, common_1.createParamDecorator)((data, ctx) => {
45
+ const request = ctx.switchToHttp().getRequest();
46
+ const user = getUserHelpers.getUserFromRequest(request);
47
+ return getUserHelpers.getUserProperty(user, data);
48
+ });
@@ -0,0 +1,19 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ declare const TNTAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
4
+ /**
5
+ * Custom guard to validate JWT tokens and authorize requests using Passport JWT strategy.
6
+ * Allows public routes to bypass authentication if decorated with @Public().
7
+ */
8
+ export declare class TNTAuthGuard extends TNTAuthGuard_base implements CanActivate {
9
+ private readonly reflector;
10
+ constructor(reflector: Reflector);
11
+ /**
12
+ * Determines if the request is authorized based on JWT validation.
13
+ * @param context Execution context containing the request.
14
+ * @returns True if the request is authorized or public, false otherwise.
15
+ * @throws UnauthorizedException if token validation fails.
16
+ */
17
+ canActivate(context: ExecutionContext): Promise<boolean>;
18
+ }
19
+ export {};
@@ -0,0 +1,66 @@
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.TNTAuthGuard = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const passport_1 = require("@nestjs/passport");
12
+ const public_decorator_1 = require("../decorators/public.decorator");
13
+ /**
14
+ * Validates if the decoded JWT payload contains required AuthUser properties.
15
+ * @param payload The decoded JWT payload.
16
+ * @returns The validated AuthUser object with id, email, phone, isActive, and optional role.
17
+ * @throws UnauthorizedException if required properties are missing.
18
+ */
19
+ function validateAuthUser(payload) {
20
+ if (!payload || typeof payload !== 'object') {
21
+ throw new common_1.UnauthorizedException('Invalid token payload');
22
+ }
23
+ const { id, email, phone, isActive, role } = payload;
24
+ if (!id || !email || !phone || isActive === undefined) {
25
+ throw new common_1.UnauthorizedException('Token payload missing required properties');
26
+ }
27
+ return { id, email, phone, isActive, role };
28
+ }
29
+ /**
30
+ * Custom guard to validate JWT tokens and authorize requests using Passport JWT strategy.
31
+ * Allows public routes to bypass authentication if decorated with @Public().
32
+ */
33
+ let TNTAuthGuard = class TNTAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
34
+ reflector;
35
+ constructor(reflector) {
36
+ super();
37
+ this.reflector = reflector;
38
+ }
39
+ /**
40
+ * Determines if the request is authorized based on JWT validation.
41
+ * @param context Execution context containing the request.
42
+ * @returns True if the request is authorized or public, false otherwise.
43
+ * @throws UnauthorizedException if token validation fails.
44
+ */
45
+ async canActivate(context) {
46
+ const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
47
+ context.getHandler(),
48
+ context.getClass(),
49
+ ]);
50
+ if (isPublic) {
51
+ return true;
52
+ }
53
+ const canActivate = await super.canActivate(context);
54
+ if (!canActivate) {
55
+ throw new common_1.UnauthorizedException('Invalid or expired token');
56
+ }
57
+ const request = context.switchToHttp().getRequest();
58
+ const user = request.user;
59
+ request.user = validateAuthUser(user);
60
+ return true;
61
+ }
62
+ };
63
+ exports.TNTAuthGuard = TNTAuthGuard;
64
+ exports.TNTAuthGuard = TNTAuthGuard = __decorate([
65
+ (0, common_1.Injectable)()
66
+ ], TNTAuthGuard);
@@ -0,0 +1,2 @@
1
+ export * from './auth.guard';
2
+ export * from './roles.guard';
@@ -0,0 +1,18 @@
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("./auth.guard"), exports);
18
+ __exportStar(require("./roles.guard"), exports);
@@ -0,0 +1,15 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ /**
4
+ * Guard to enforce role-based access control using the Roles decorator.
5
+ */
6
+ export declare class RolesGuard implements CanActivate {
7
+ private reflector;
8
+ constructor(reflector: Reflector);
9
+ /**
10
+ * Checks if the user has one of the required roles to access the route.
11
+ * @param context Execution context containing the request.
12
+ * @returns True if the user has a required role or no roles are specified, false otherwise.
13
+ */
14
+ canActivate(context: ExecutionContext): boolean;
15
+ }
@@ -0,0 +1,41 @@
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.RolesGuard = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const roles_decorator_1 = require("../decorators/roles.decorator");
12
+ /**
13
+ * Guard to enforce role-based access control using the Roles decorator.
14
+ */
15
+ let RolesGuard = class RolesGuard {
16
+ reflector;
17
+ constructor(reflector) {
18
+ this.reflector = reflector;
19
+ }
20
+ /**
21
+ * Checks if the user has one of the required roles to access the route.
22
+ * @param context Execution context containing the request.
23
+ * @returns True if the user has a required role or no roles are specified, false otherwise.
24
+ */
25
+ canActivate(context) {
26
+ const requiredRoles = this.reflector.getAllAndOverride(roles_decorator_1.ROLES_KEY, [context.getHandler(), context.getClass()]);
27
+ if (!requiredRoles || requiredRoles.length === 0) {
28
+ return true;
29
+ }
30
+ const request = context.switchToHttp().getRequest();
31
+ const user = request.user;
32
+ if (!user || !user.role) {
33
+ return false;
34
+ }
35
+ return requiredRoles.includes(user.role);
36
+ }
37
+ };
38
+ exports.RolesGuard = RolesGuard;
39
+ exports.RolesGuard = RolesGuard = __decorate([
40
+ (0, common_1.Injectable)()
41
+ ], RolesGuard);
@@ -0,0 +1,4 @@
1
+ export * from './guards';
2
+ export * from './decorators';
3
+ export * from './auth.module';
4
+ export * from './interfaces';
@@ -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("./guards"), exports);
18
+ __exportStar(require("./decorators"), exports);
19
+ __exportStar(require("./auth.module"), exports);
20
+ __exportStar(require("./interfaces"), exports);
@@ -0,0 +1,18 @@
1
+ export interface AuthUser {
2
+ id: string;
3
+ email: string;
4
+ phone: string;
5
+ isActive: boolean;
6
+ role?: string;
7
+ }
8
+ export declare enum UserType {
9
+ CUSTOMER = "CUSTOMER",
10
+ STAFF = "STAFF"
11
+ }
12
+ export interface TokenPayload {
13
+ sub?: string;
14
+ id?: string;
15
+ email?: string;
16
+ role?: string;
17
+ [key: string]: any;
18
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserType = void 0;
4
+ var UserType;
5
+ (function (UserType) {
6
+ UserType["CUSTOMER"] = "CUSTOMER";
7
+ UserType["STAFF"] = "STAFF";
8
+ })(UserType || (exports.UserType = UserType = {}));
@@ -0,0 +1 @@
1
+ export * from './auth.interface';
@@ -0,0 +1,17 @@
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("./auth.interface"), exports);
package/dist/index.d.ts CHANGED
@@ -5,3 +5,5 @@ export * from './cache';
5
5
  export * from './utils';
6
6
  export * from './rpc';
7
7
  export * from './prisma';
8
+ export * from './auth';
9
+ export * from './notification';
package/dist/index.js CHANGED
@@ -21,3 +21,5 @@ __exportStar(require("./cache"), exports);
21
21
  __exportStar(require("./utils"), exports);
22
22
  __exportStar(require("./rpc"), exports);
23
23
  __exportStar(require("./prisma"), exports);
24
+ __exportStar(require("./auth"), exports);
25
+ __exportStar(require("./notification"), exports);
@@ -0,0 +1,4 @@
1
+ export * from './notification.client';
2
+ export * from './notification.interface';
3
+ export * from './notification.enum';
4
+ export * from './notification.module';
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare class NotificationClientModule {
2
+ }
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takentrade/takentrade-libs",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "TakeNTrade shared libraries",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -32,6 +32,7 @@
32
32
  "@nestjs/config": "^4.0.2",
33
33
  "@nestjs/jwt": "^11.0.0",
34
34
  "@nestjs/microservices": "^11.1.5",
35
+ "@nestjs/passport": "^11.0.5",
35
36
  "@nestjs/swagger": "^11.2.0",
36
37
  "@nestjs/terminus": "^11.0.0",
37
38
  "@prisma/client": "^6.12.0",
@@ -50,6 +51,7 @@
50
51
  "devDependencies": {
51
52
  "@types/node": "^24.1.0",
52
53
  "@types/object-hash": "^3.0.6",
54
+ "@types/passport": "^1.0.17",
53
55
  "prettier": "^3.6.2"
54
56
  },
55
57
  "exports": {