@takentrade/takentrade-libs 3.3.3 → 4.0.0
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/decorators/get-user.decorator.d.ts +1 -1
- package/dist/auth/guards/index.d.ts +1 -0
- package/dist/auth/guards/index.js +17 -0
- package/dist/auth/guards/roles.guard.d.ts +20 -0
- package/dist/auth/guards/roles.guard.js +47 -0
- package/dist/auth/index.d.ts +3 -1
- package/dist/auth/index.js +3 -1
- package/dist/auth/interfaces/auth.interface.d.ts +21 -0
- package/dist/auth/interfaces/index.d.ts +1 -0
- package/dist/auth/interfaces/index.js +17 -0
- package/dist/auth/strategies/index.d.ts +1 -0
- package/dist/auth/strategies/index.js +17 -0
- package/dist/auth/strategies/tnt-jwt.strategy.d.ts +23 -0
- package/dist/auth/strategies/tnt-jwt.strategy.js +37 -0
- package/dist/common/dto/account.dto.d.ts +18 -0
- package/dist/common/dto/account.dto.js +68 -0
- package/dist/common/dto/index.d.ts +2 -0
- package/dist/common/dto/index.js +18 -0
- package/dist/common/dto/user.dto.d.ts +34 -0
- package/dist/common/dto/user.dto.js +132 -0
- package/dist/common/enums/index.d.ts +2 -1
- package/dist/common/enums/index.js +2 -1
- package/dist/common/enums/transaction.enum.d.ts +85 -0
- package/dist/common/enums/transaction.enum.js +97 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/logging/index.d.ts +3 -0
- package/dist/logging/index.js +18 -0
- package/dist/logging/logger.module.d.ts +6 -0
- package/dist/logging/logger.module.js +25 -0
- package/dist/logging/logger.service.d.ts +48 -0
- package/dist/logging/logger.service.js +107 -0
- package/dist/nats/constants/nats.constants.d.ts +11 -24
- package/dist/nats/constants/nats.constants.js +16 -28
- package/dist/nats/events/index.d.ts +174 -0
- package/dist/nats/events/index.js +2 -0
- package/dist/nats/index.d.ts +1 -0
- package/dist/nats/index.js +1 -0
- package/dist/rpc/filters/index.d.ts +1 -0
- package/dist/rpc/filters/index.js +17 -0
- package/dist/rpc/filters/rpc-exception.filter.d.ts +10 -0
- package/dist/rpc/filters/rpc-exception.filter.js +38 -0
- package/dist/rpc/index.d.ts +4 -54
- package/dist/rpc/index.js +18 -133
- package/dist/rpc/rpc-error.d.ts +10 -0
- package/dist/rpc/rpc-error.js +2 -0
- package/dist/rpc/rpc-response.d.ts +6 -0
- package/dist/rpc/rpc-response.js +2 -0
- package/dist/rpc/rpc.client.d.ts +46 -0
- package/dist/rpc/rpc.client.js +135 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -3
- package/dist/auth/auth.interface.d.ts +0 -8
- /package/dist/auth/{auth.interface.js → interfaces/auth.interface.js} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Frequency = exports.AjoType = exports.AjoMembershipStatus = exports.AjoStatus = exports.SavingsStatus = exports.LoanStatus = exports.TransactionStatus = exports.TransactionCategory = exports.TransactionType = void 0;
|
|
4
|
+
var TransactionType;
|
|
5
|
+
(function (TransactionType) {
|
|
6
|
+
TransactionType["CREDIT"] = "CREDIT";
|
|
7
|
+
TransactionType["DEBIT"] = "DEBIT";
|
|
8
|
+
TransactionType["DEPOSIT"] = "DEPOSIT";
|
|
9
|
+
TransactionType["TOP_UP"] = "TOP_UP";
|
|
10
|
+
TransactionType["WITHDRAWAL"] = "WITHDRAWAL";
|
|
11
|
+
TransactionType["INTEREST_ACCRUAL"] = "INTEREST_ACCRUAL";
|
|
12
|
+
TransactionType["TAX_DEDUCTION"] = "TAX_DEDUCTION";
|
|
13
|
+
TransactionType["PAUSE"] = "PAUSE";
|
|
14
|
+
TransactionType["CONTRIBUTION"] = "CONTRIBUTION";
|
|
15
|
+
TransactionType["PAYOUT"] = "PAYOUT";
|
|
16
|
+
TransactionType["FEE_DEDUCTION"] = "FEE_DEDUCTION";
|
|
17
|
+
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
|
18
|
+
var TransactionCategory;
|
|
19
|
+
(function (TransactionCategory) {
|
|
20
|
+
TransactionCategory["DEPOSIT"] = "DEPOSIT";
|
|
21
|
+
TransactionCategory["WITHDRAWAL"] = "WITHDRAWAL";
|
|
22
|
+
TransactionCategory["LOAN_DISBURSEMENT"] = "LOAN_DISBURSEMENT";
|
|
23
|
+
TransactionCategory["LOAN_REPAYMENT"] = "LOAN_REPAYMENT";
|
|
24
|
+
TransactionCategory["AJO_CONTRIBUTION"] = "AJO_CONTRIBUTION";
|
|
25
|
+
TransactionCategory["AJO_TOPUP"] = "AJO_TOPUP";
|
|
26
|
+
TransactionCategory["AJO_COMPLETION"] = "AJO_COMPLETION";
|
|
27
|
+
TransactionCategory["AIRTIME"] = "AIRTIME";
|
|
28
|
+
TransactionCategory["DATA"] = "DATA";
|
|
29
|
+
TransactionCategory["ELECTRICITY"] = "ELECTRICITY";
|
|
30
|
+
TransactionCategory["CABLETV"] = "CABLETV";
|
|
31
|
+
TransactionCategory["BETTING"] = "BETTING";
|
|
32
|
+
TransactionCategory["INTERNET"] = "INTERNET";
|
|
33
|
+
TransactionCategory["EDUCATION"] = "EDUCATION";
|
|
34
|
+
TransactionCategory["TRANSPORT"] = "TRANSPORT";
|
|
35
|
+
TransactionCategory["DONATION"] = "DONATION";
|
|
36
|
+
TransactionCategory["INSURANCE"] = "INSURANCE";
|
|
37
|
+
TransactionCategory["TAX"] = "TAX";
|
|
38
|
+
TransactionCategory["RELIGION"] = "RELIGION";
|
|
39
|
+
TransactionCategory["TRANSFER"] = "TRANSFER";
|
|
40
|
+
TransactionCategory["REFERRAL_BONUS"] = "REFERRAL_BONUS";
|
|
41
|
+
TransactionCategory["FEES"] = "FEES";
|
|
42
|
+
TransactionCategory["FEE_COLLECTION"] = "FEE_COLLECTION";
|
|
43
|
+
TransactionCategory["PENALTY"] = "PENALTY";
|
|
44
|
+
TransactionCategory["LOAN_INTEREST"] = "LOAN_INTEREST";
|
|
45
|
+
TransactionCategory["AJO_FEE"] = "AJO_FEE";
|
|
46
|
+
})(TransactionCategory || (exports.TransactionCategory = TransactionCategory = {}));
|
|
47
|
+
var TransactionStatus;
|
|
48
|
+
(function (TransactionStatus) {
|
|
49
|
+
TransactionStatus["PENDING"] = "PENDING";
|
|
50
|
+
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
51
|
+
TransactionStatus["FAILED"] = "FAILED";
|
|
52
|
+
TransactionStatus["REVERSED"] = "REVERSED";
|
|
53
|
+
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
|
54
|
+
var LoanStatus;
|
|
55
|
+
(function (LoanStatus) {
|
|
56
|
+
LoanStatus["PENDING"] = "PENDING";
|
|
57
|
+
LoanStatus["APPROVED"] = "APPROVED";
|
|
58
|
+
LoanStatus["DISBURSED"] = "DISBURSED";
|
|
59
|
+
LoanStatus["REPAID"] = "REPAID";
|
|
60
|
+
LoanStatus["OVERDUE"] = "OVERDUE";
|
|
61
|
+
LoanStatus["DECLINED"] = "DECLINED";
|
|
62
|
+
})(LoanStatus || (exports.LoanStatus = LoanStatus = {}));
|
|
63
|
+
var SavingsStatus;
|
|
64
|
+
(function (SavingsStatus) {
|
|
65
|
+
SavingsStatus["ACTIVE"] = "ACTIVE";
|
|
66
|
+
SavingsStatus["MATURED"] = "MATURED";
|
|
67
|
+
SavingsStatus["CLOSED"] = "CLOSED";
|
|
68
|
+
SavingsStatus["PENDING"] = "PENDING";
|
|
69
|
+
SavingsStatus["SUSPENDED"] = "SUSPENDED";
|
|
70
|
+
})(SavingsStatus || (exports.SavingsStatus = SavingsStatus = {}));
|
|
71
|
+
var AjoStatus;
|
|
72
|
+
(function (AjoStatus) {
|
|
73
|
+
AjoStatus["ACTIVE"] = "ACTIVE";
|
|
74
|
+
AjoStatus["COMPLETED"] = "COMPLETED";
|
|
75
|
+
AjoStatus["CANCELLED"] = "CANCELLED";
|
|
76
|
+
AjoStatus["PAUSED"] = "PAUSED";
|
|
77
|
+
})(AjoStatus || (exports.AjoStatus = AjoStatus = {}));
|
|
78
|
+
var AjoMembershipStatus;
|
|
79
|
+
(function (AjoMembershipStatus) {
|
|
80
|
+
AjoMembershipStatus["PENDING"] = "PENDING";
|
|
81
|
+
AjoMembershipStatus["ACTIVE"] = "ACTIVE";
|
|
82
|
+
AjoMembershipStatus["INACTIVE"] = "INACTIVE";
|
|
83
|
+
AjoMembershipStatus["REMOVED"] = "REMOVED";
|
|
84
|
+
})(AjoMembershipStatus || (exports.AjoMembershipStatus = AjoMembershipStatus = {}));
|
|
85
|
+
var AjoType;
|
|
86
|
+
(function (AjoType) {
|
|
87
|
+
AjoType["PERSONAL"] = "PERSONAL";
|
|
88
|
+
AjoType["FAMILY"] = "FAMILY";
|
|
89
|
+
AjoType["FRIEND"] = "FRIEND";
|
|
90
|
+
AjoType["GROUP"] = "GROUP";
|
|
91
|
+
})(AjoType || (exports.AjoType = AjoType = {}));
|
|
92
|
+
var Frequency;
|
|
93
|
+
(function (Frequency) {
|
|
94
|
+
Frequency["DAILY"] = "DAILY";
|
|
95
|
+
Frequency["WEEKLY"] = "WEEKLY";
|
|
96
|
+
Frequency["MONTHLY"] = "MONTHLY";
|
|
97
|
+
})(Frequency || (exports.Frequency = Frequency = {}));
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./bullmq"), exports);
|
|
|
20
20
|
__exportStar(require("./cache"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
22
22
|
__exportStar(require("./rpc"), exports);
|
|
23
|
+
__exportStar(require("./logging"), exports);
|
|
23
24
|
__exportStar(require("./auth"), exports);
|
|
24
25
|
__exportStar(require("./notification"), exports);
|
|
25
26
|
__exportStar(require("./resilience"), exports);
|
|
@@ -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("./logger.service"), exports);
|
|
18
|
+
__exportStar(require("./logger.module"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
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.TntLoggerModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const logger_service_1 = require("./logger.service");
|
|
12
|
+
/**
|
|
13
|
+
* TNT Logger Module - Global module for logging
|
|
14
|
+
* Import this module to use TntLoggerService across your application
|
|
15
|
+
*/
|
|
16
|
+
let TntLoggerModule = class TntLoggerModule {
|
|
17
|
+
};
|
|
18
|
+
exports.TntLoggerModule = TntLoggerModule;
|
|
19
|
+
exports.TntLoggerModule = TntLoggerModule = __decorate([
|
|
20
|
+
(0, common_1.Global)(),
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
providers: [logger_service_1.TntLoggerService],
|
|
23
|
+
exports: [logger_service_1.TntLoggerService],
|
|
24
|
+
})
|
|
25
|
+
], TntLoggerModule);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LoggerService as NestLoggerService } from '@nestjs/common';
|
|
2
|
+
export interface LogContext {
|
|
3
|
+
correlationId?: string;
|
|
4
|
+
userId?: string;
|
|
5
|
+
service?: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* TNT Logger Service - Pino-based structured JSON logger
|
|
10
|
+
* Provides consistent logging across all microservices
|
|
11
|
+
*/
|
|
12
|
+
export declare class TntLoggerService implements NestLoggerService {
|
|
13
|
+
private logger;
|
|
14
|
+
private context;
|
|
15
|
+
constructor(context?: LogContext);
|
|
16
|
+
/**
|
|
17
|
+
* Set context for all subsequent log messages
|
|
18
|
+
*/
|
|
19
|
+
setContext(context: LogContext): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log info message
|
|
22
|
+
*/
|
|
23
|
+
log(message: string, context?: LogContext): void;
|
|
24
|
+
/**
|
|
25
|
+
* Log error message
|
|
26
|
+
*/
|
|
27
|
+
error(message: string, trace?: string, context?: LogContext): void;
|
|
28
|
+
/**
|
|
29
|
+
* Log warning message
|
|
30
|
+
*/
|
|
31
|
+
warn(message: string, context?: LogContext): void;
|
|
32
|
+
/**
|
|
33
|
+
* Log debug message
|
|
34
|
+
*/
|
|
35
|
+
debug(message: string, context?: LogContext): void;
|
|
36
|
+
/**
|
|
37
|
+
* Log verbose message
|
|
38
|
+
*/
|
|
39
|
+
verbose(message: string, context?: LogContext): void;
|
|
40
|
+
/**
|
|
41
|
+
* Log HTTP request
|
|
42
|
+
*/
|
|
43
|
+
logRequest(req: any, context?: LogContext): void;
|
|
44
|
+
/**
|
|
45
|
+
* Log HTTP response
|
|
46
|
+
*/
|
|
47
|
+
logResponse(req: any, res: any, responseTime: number, context?: LogContext): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TntLoggerService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const pino_1 = __importDefault(require("pino"));
|
|
15
|
+
/**
|
|
16
|
+
* TNT Logger Service - Pino-based structured JSON logger
|
|
17
|
+
* Provides consistent logging across all microservices
|
|
18
|
+
*/
|
|
19
|
+
let TntLoggerService = class TntLoggerService {
|
|
20
|
+
logger;
|
|
21
|
+
context = {};
|
|
22
|
+
constructor(context) {
|
|
23
|
+
const isDevelopment = process.env.NODE_ENV !== 'production';
|
|
24
|
+
this.logger = (0, pino_1.default)({
|
|
25
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
26
|
+
...(isDevelopment && {
|
|
27
|
+
transport: {
|
|
28
|
+
target: 'pino-pretty',
|
|
29
|
+
options: {
|
|
30
|
+
colorize: true,
|
|
31
|
+
translateTime: 'HH:MM:ss Z',
|
|
32
|
+
ignore: 'pid,hostname',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
if (context) {
|
|
38
|
+
this.context = context;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set context for all subsequent log messages
|
|
43
|
+
*/
|
|
44
|
+
setContext(context) {
|
|
45
|
+
this.context = { ...this.context, ...context };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Log info message
|
|
49
|
+
*/
|
|
50
|
+
log(message, context) {
|
|
51
|
+
this.logger.info({ ...this.context, ...context }, message);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Log error message
|
|
55
|
+
*/
|
|
56
|
+
error(message, trace, context) {
|
|
57
|
+
this.logger.error({ ...this.context, ...context, trace }, message);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Log warning message
|
|
61
|
+
*/
|
|
62
|
+
warn(message, context) {
|
|
63
|
+
this.logger.warn({ ...this.context, ...context }, message);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Log debug message
|
|
67
|
+
*/
|
|
68
|
+
debug(message, context) {
|
|
69
|
+
this.logger.debug({ ...this.context, ...context }, message);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Log verbose message
|
|
73
|
+
*/
|
|
74
|
+
verbose(message, context) {
|
|
75
|
+
this.logger.trace({ ...this.context, ...context }, message);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Log HTTP request
|
|
79
|
+
*/
|
|
80
|
+
logRequest(req, context) {
|
|
81
|
+
this.logger.info({
|
|
82
|
+
...this.context,
|
|
83
|
+
...context,
|
|
84
|
+
method: req.method,
|
|
85
|
+
url: req.url,
|
|
86
|
+
userAgent: req.headers?.['user-agent'],
|
|
87
|
+
ip: req.ip,
|
|
88
|
+
}, 'HTTP Request');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Log HTTP response
|
|
92
|
+
*/
|
|
93
|
+
logResponse(req, res, responseTime, context) {
|
|
94
|
+
this.logger.info({
|
|
95
|
+
...this.context,
|
|
96
|
+
...context,
|
|
97
|
+
method: req.method,
|
|
98
|
+
url: req.url,
|
|
99
|
+
statusCode: res.statusCode,
|
|
100
|
+
responseTime: `${responseTime}ms`,
|
|
101
|
+
}, 'HTTP Response');
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.TntLoggerService = TntLoggerService;
|
|
105
|
+
exports.TntLoggerService = TntLoggerService = __decorate([
|
|
106
|
+
(0, common_1.Injectable)()
|
|
107
|
+
], TntLoggerService);
|
|
@@ -8,14 +8,9 @@ export declare const DEFAULT_NATS_CONFIG: {
|
|
|
8
8
|
maxReconnectAttempts: number;
|
|
9
9
|
};
|
|
10
10
|
export declare enum NatsSubjects {
|
|
11
|
-
SUBACCOUNT_UPDATE_AMOUNT = "subaccount.amount.update",
|
|
12
|
-
SUBACCOUNT_GET_BY_ID = "subaccount.get.by.id",
|
|
13
|
-
SUBACCOUNT_GET_ALL = "subaccount.get.all",
|
|
14
11
|
USER_CHECK = "user.check",
|
|
15
12
|
USER_CREATED = "user.created",
|
|
16
13
|
USER_GET_PREFERENCE = "user.preference.get",
|
|
17
|
-
NOTIFICATION_UPDATE_TOKEN = "notification.token.update",
|
|
18
|
-
NOTIFICATION_SEND = "notification.send",
|
|
19
14
|
NOTIFICATION_GET_ALL = "notification.get.all",
|
|
20
15
|
NOTIFICATION_GET_BY_ID = "notification.get.by.id",
|
|
21
16
|
NOTIFICATION_MARK_AS_READ = "notification.mark.as.read",
|
|
@@ -25,27 +20,19 @@ export declare enum NatsSubjects {
|
|
|
25
20
|
GET_ALL_USERS_FCM_TOKENS = "user.get.all.fcm_tokens",
|
|
26
21
|
GET_USER_BY_ID = "user.get.by_id",
|
|
27
22
|
GET_USER_BALANCE = "user.get.balance",
|
|
28
|
-
CHAT_GET_CONVERSATIONS = "chat.conversations.get",
|
|
29
|
-
CHAT_GET_CONVERSATION = "chat.conversation.get",
|
|
30
|
-
CHAT_GET_MESSAGES = "chat.messages.get",
|
|
31
|
-
CHAT_CLOSE_CONVERSATION = "chat.conversation.close",
|
|
32
|
-
CHAT_ASSIGN_SUPPORT = "chat.conversation.assign",
|
|
33
|
-
AJO_PLANS_GET = "ajo.plans.get",
|
|
34
|
-
AJO_CREATE = "ajo.create",
|
|
35
|
-
AJO_LIST = "ajo.list",
|
|
36
|
-
AJO_GET = "ajo.get",
|
|
37
|
-
AJO_JOIN = "ajo.join",
|
|
38
|
-
AJO_CONTRIBUTE = "ajo.contribute",
|
|
39
|
-
AJO_PAYOUT = "ajo.payout",
|
|
40
|
-
AJO_CONTRIBUTIONS_GET = "ajo.contributions.get",
|
|
41
|
-
AJO_UPDATE = "ajo.update",
|
|
42
|
-
AJO_ADMIN_CYCLE = "ajo.admin.cycle",
|
|
43
23
|
PROVIDUS_GET_ACCOUNT = "providus.account.get",
|
|
44
24
|
PROVIDUS_DEBIT_CUSTOMER = "providus.customer.debit",
|
|
45
25
|
PROVIDUS_CREDIT_CUSTOMER = "providus.customer.credit",
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
CREATE_PROVIDUS_ACCOUNT = "providus.account.create",
|
|
27
|
+
KYC_VERIFIED = "kyc.verified",
|
|
28
|
+
KYC_REJECTED = "kyc.rejected",
|
|
29
|
+
VAS_TRANSACTION_SUCCESS = "vas.transaction.success",
|
|
30
|
+
VAS_TRANSACTION_FAILED = "vas.transaction.failed",
|
|
31
|
+
AJO_MEMBER_JOINED = "ajo.member.joined",
|
|
32
|
+
AJO_CONTRIBUTION_SUCCESS = "ajo.contribution.success",
|
|
33
|
+
AJO_MATURED = "ajo.matured",
|
|
34
|
+
REFERRAL_REWARD_CLAIMED = "referral.reward.claimed",
|
|
35
|
+
WITHDRAWAL_REQUESTED = "withdrawal.requested",
|
|
36
|
+
WITHDRAWAL_PROCESSED = "withdrawal.processed",
|
|
50
37
|
ADMIN_GET_TERMII_BALANCE = "admin.termii.balance.get"
|
|
51
38
|
}
|
|
@@ -12,17 +12,11 @@ exports.DEFAULT_NATS_CONFIG = {
|
|
|
12
12
|
};
|
|
13
13
|
var NatsSubjects;
|
|
14
14
|
(function (NatsSubjects) {
|
|
15
|
-
// Subaccount operations
|
|
16
|
-
NatsSubjects["SUBACCOUNT_UPDATE_AMOUNT"] = "subaccount.amount.update";
|
|
17
|
-
NatsSubjects["SUBACCOUNT_GET_BY_ID"] = "subaccount.get.by.id";
|
|
18
|
-
NatsSubjects["SUBACCOUNT_GET_ALL"] = "subaccount.get.all";
|
|
19
15
|
// User operations
|
|
20
16
|
NatsSubjects["USER_CHECK"] = "user.check";
|
|
21
17
|
NatsSubjects["USER_CREATED"] = "user.created";
|
|
22
18
|
NatsSubjects["USER_GET_PREFERENCE"] = "user.preference.get";
|
|
23
19
|
// Notification operations
|
|
24
|
-
NatsSubjects["NOTIFICATION_UPDATE_TOKEN"] = "notification.token.update";
|
|
25
|
-
NatsSubjects["NOTIFICATION_SEND"] = "notification.send";
|
|
26
20
|
NatsSubjects["NOTIFICATION_GET_ALL"] = "notification.get.all";
|
|
27
21
|
NatsSubjects["NOTIFICATION_GET_BY_ID"] = "notification.get.by.id";
|
|
28
22
|
NatsSubjects["NOTIFICATION_MARK_AS_READ"] = "notification.mark.as.read";
|
|
@@ -33,32 +27,26 @@ var NatsSubjects;
|
|
|
33
27
|
NatsSubjects["GET_ALL_USERS_FCM_TOKENS"] = "user.get.all.fcm_tokens";
|
|
34
28
|
NatsSubjects["GET_USER_BY_ID"] = "user.get.by_id";
|
|
35
29
|
NatsSubjects["GET_USER_BALANCE"] = "user.get.balance";
|
|
36
|
-
// Chat operations
|
|
37
|
-
NatsSubjects["CHAT_GET_CONVERSATIONS"] = "chat.conversations.get";
|
|
38
|
-
NatsSubjects["CHAT_GET_CONVERSATION"] = "chat.conversation.get";
|
|
39
|
-
NatsSubjects["CHAT_GET_MESSAGES"] = "chat.messages.get";
|
|
40
|
-
NatsSubjects["CHAT_CLOSE_CONVERSATION"] = "chat.conversation.close";
|
|
41
|
-
NatsSubjects["CHAT_ASSIGN_SUPPORT"] = "chat.conversation.assign";
|
|
42
|
-
// Ajo operations
|
|
43
|
-
NatsSubjects["AJO_PLANS_GET"] = "ajo.plans.get";
|
|
44
|
-
NatsSubjects["AJO_CREATE"] = "ajo.create";
|
|
45
|
-
NatsSubjects["AJO_LIST"] = "ajo.list";
|
|
46
|
-
NatsSubjects["AJO_GET"] = "ajo.get";
|
|
47
|
-
NatsSubjects["AJO_JOIN"] = "ajo.join";
|
|
48
|
-
NatsSubjects["AJO_CONTRIBUTE"] = "ajo.contribute";
|
|
49
|
-
NatsSubjects["AJO_PAYOUT"] = "ajo.payout";
|
|
50
|
-
NatsSubjects["AJO_CONTRIBUTIONS_GET"] = "ajo.contributions.get";
|
|
51
|
-
NatsSubjects["AJO_UPDATE"] = "ajo.update";
|
|
52
|
-
NatsSubjects["AJO_ADMIN_CYCLE"] = "ajo.admin.cycle";
|
|
53
30
|
// Providus account operations
|
|
54
31
|
NatsSubjects["PROVIDUS_GET_ACCOUNT"] = "providus.account.get";
|
|
55
32
|
NatsSubjects["PROVIDUS_DEBIT_CUSTOMER"] = "providus.customer.debit";
|
|
56
33
|
NatsSubjects["PROVIDUS_CREDIT_CUSTOMER"] = "providus.customer.credit";
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
NatsSubjects["
|
|
60
|
-
NatsSubjects["
|
|
61
|
-
|
|
34
|
+
NatsSubjects["CREATE_PROVIDUS_ACCOUNT"] = "providus.account.create";
|
|
35
|
+
// KYC operations
|
|
36
|
+
NatsSubjects["KYC_VERIFIED"] = "kyc.verified";
|
|
37
|
+
NatsSubjects["KYC_REJECTED"] = "kyc.rejected";
|
|
38
|
+
// VAS operations
|
|
39
|
+
NatsSubjects["VAS_TRANSACTION_SUCCESS"] = "vas.transaction.success";
|
|
40
|
+
NatsSubjects["VAS_TRANSACTION_FAILED"] = "vas.transaction.failed";
|
|
41
|
+
// Ajo / Thrift operations
|
|
42
|
+
NatsSubjects["AJO_MEMBER_JOINED"] = "ajo.member.joined";
|
|
43
|
+
NatsSubjects["AJO_CONTRIBUTION_SUCCESS"] = "ajo.contribution.success";
|
|
44
|
+
NatsSubjects["AJO_MATURED"] = "ajo.matured";
|
|
45
|
+
// Reward operations
|
|
46
|
+
NatsSubjects["REFERRAL_REWARD_CLAIMED"] = "referral.reward.claimed";
|
|
47
|
+
// Withdrawal operations
|
|
48
|
+
NatsSubjects["WITHDRAWAL_REQUESTED"] = "withdrawal.requested";
|
|
49
|
+
NatsSubjects["WITHDRAWAL_PROCESSED"] = "withdrawal.processed";
|
|
62
50
|
// Other Admin operations
|
|
63
51
|
NatsSubjects["ADMIN_GET_TERMII_BALANCE"] = "admin.termii.balance.get";
|
|
64
52
|
})(NatsSubjects || (exports.NatsSubjects = NatsSubjects = {}));
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { TransactionCategory, TransactionStatus } from '../../common/enums/transaction.enum';
|
|
2
|
+
/**
|
|
3
|
+
* NATS Event Contracts
|
|
4
|
+
* TypeScript interfaces for inter-service communication via NATS
|
|
5
|
+
*/
|
|
6
|
+
export interface UserCreatedEvent {
|
|
7
|
+
userId: string;
|
|
8
|
+
email: string;
|
|
9
|
+
phone: string;
|
|
10
|
+
username: string;
|
|
11
|
+
firstname?: string;
|
|
12
|
+
lastname?: string;
|
|
13
|
+
middlename?: string;
|
|
14
|
+
gender?: string;
|
|
15
|
+
dateOfBirth?: string;
|
|
16
|
+
referralCode?: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PaymentSuccessEvent {
|
|
20
|
+
transactionId: string;
|
|
21
|
+
userId: string;
|
|
22
|
+
amount: number;
|
|
23
|
+
fee?: number;
|
|
24
|
+
currency: string;
|
|
25
|
+
category?: string;
|
|
26
|
+
provider: 'PROVIDUS' | 'PAYSTACK';
|
|
27
|
+
reference: string;
|
|
28
|
+
providerReference?: string;
|
|
29
|
+
balanceBefore?: number;
|
|
30
|
+
balanceAfter?: number;
|
|
31
|
+
metadata?: Record<string, any>;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
}
|
|
34
|
+
export interface PaymentFailedEvent {
|
|
35
|
+
transactionId: string;
|
|
36
|
+
userId: string;
|
|
37
|
+
amount: number;
|
|
38
|
+
currency: string;
|
|
39
|
+
provider: 'PROVIDUS' | 'PAYSTACK';
|
|
40
|
+
reference: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
errorCode?: string;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
}
|
|
45
|
+
export interface TransactionProcessedEvent {
|
|
46
|
+
transactionId: string;
|
|
47
|
+
userId: string;
|
|
48
|
+
type: 'CREDIT' | 'DEBIT';
|
|
49
|
+
category: string;
|
|
50
|
+
amount: number;
|
|
51
|
+
fee: number;
|
|
52
|
+
balanceBefore: number;
|
|
53
|
+
balanceAfter: number;
|
|
54
|
+
reference: string;
|
|
55
|
+
description: string;
|
|
56
|
+
metadata?: Record<string, any>;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
}
|
|
59
|
+
export interface NotificationSentEvent {
|
|
60
|
+
notificationId: string;
|
|
61
|
+
userId: string;
|
|
62
|
+
channel: 'EMAIL' | 'SMS' | 'PUSH' | 'VOICE';
|
|
63
|
+
type: string;
|
|
64
|
+
status: 'SENT' | 'FAILED';
|
|
65
|
+
timestamp: string;
|
|
66
|
+
}
|
|
67
|
+
export interface SavingsMaturedEvent {
|
|
68
|
+
savingsId: string;
|
|
69
|
+
userId: string;
|
|
70
|
+
amount: number;
|
|
71
|
+
interest: number;
|
|
72
|
+
interestRate?: number;
|
|
73
|
+
balance: number;
|
|
74
|
+
plan: string;
|
|
75
|
+
maturityDate: string;
|
|
76
|
+
timestamp: string;
|
|
77
|
+
}
|
|
78
|
+
export interface LoanApprovedEvent {
|
|
79
|
+
loanId: string;
|
|
80
|
+
userId: string;
|
|
81
|
+
amount: number;
|
|
82
|
+
interestRate: number;
|
|
83
|
+
totalInterest: number;
|
|
84
|
+
processingFee: number;
|
|
85
|
+
duration: string;
|
|
86
|
+
repaymentDate: string;
|
|
87
|
+
timestamp: string;
|
|
88
|
+
}
|
|
89
|
+
export interface LoanRepaidEvent {
|
|
90
|
+
loanId: string;
|
|
91
|
+
userId: string;
|
|
92
|
+
amount: number;
|
|
93
|
+
remainingBalance: number;
|
|
94
|
+
reference?: string;
|
|
95
|
+
timestamp: string;
|
|
96
|
+
}
|
|
97
|
+
export interface CreateProvidusAccountEvent {
|
|
98
|
+
userId: string;
|
|
99
|
+
bvn?: string;
|
|
100
|
+
firstName?: string;
|
|
101
|
+
lastName?: string;
|
|
102
|
+
dateOfBirth?: string;
|
|
103
|
+
phoneNumber?: string;
|
|
104
|
+
email?: string;
|
|
105
|
+
address?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface KycVerifiedEvent {
|
|
108
|
+
userId: string;
|
|
109
|
+
verificationId: string;
|
|
110
|
+
bvn: string;
|
|
111
|
+
timestamp: string;
|
|
112
|
+
}
|
|
113
|
+
export interface KycRejectedEvent {
|
|
114
|
+
userId: string;
|
|
115
|
+
verificationId: string;
|
|
116
|
+
reason: string;
|
|
117
|
+
timestamp: string;
|
|
118
|
+
}
|
|
119
|
+
export interface VasTransactionEvent {
|
|
120
|
+
transactionId: string;
|
|
121
|
+
userId: string;
|
|
122
|
+
serviceId: string;
|
|
123
|
+
category: TransactionCategory;
|
|
124
|
+
amount: number;
|
|
125
|
+
recipientIdentifier: string;
|
|
126
|
+
status: TransactionStatus;
|
|
127
|
+
provider: string;
|
|
128
|
+
reference: string;
|
|
129
|
+
timestamp: string;
|
|
130
|
+
}
|
|
131
|
+
export interface AjoContributionEvent {
|
|
132
|
+
ajoId: string;
|
|
133
|
+
userId: string;
|
|
134
|
+
amount: number;
|
|
135
|
+
reference: string;
|
|
136
|
+
status: TransactionStatus;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
}
|
|
139
|
+
export interface AjoMemberJoinedEvent {
|
|
140
|
+
ajoId: string;
|
|
141
|
+
userId: string;
|
|
142
|
+
joinedAt: string;
|
|
143
|
+
timestamp: string;
|
|
144
|
+
}
|
|
145
|
+
export interface ReferralRewardClaimedEvent {
|
|
146
|
+
userId: string;
|
|
147
|
+
referralId: string;
|
|
148
|
+
amount: number;
|
|
149
|
+
reference: string;
|
|
150
|
+
timestamp: string;
|
|
151
|
+
}
|
|
152
|
+
export interface WithdrawalRequestedEvent {
|
|
153
|
+
withdrawalId: string;
|
|
154
|
+
userId: string;
|
|
155
|
+
amount: number;
|
|
156
|
+
bankName: string;
|
|
157
|
+
accountNumber: string;
|
|
158
|
+
status: TransactionStatus;
|
|
159
|
+
timestamp: string;
|
|
160
|
+
}
|
|
161
|
+
export interface ProvidusDebitEvent {
|
|
162
|
+
userId: string;
|
|
163
|
+
amount: number;
|
|
164
|
+
reference: string;
|
|
165
|
+
metadata?: Record<string, any>;
|
|
166
|
+
timestamp: string;
|
|
167
|
+
}
|
|
168
|
+
export interface ProvidusCreditEvent {
|
|
169
|
+
userId: string;
|
|
170
|
+
amount: number;
|
|
171
|
+
reference: string;
|
|
172
|
+
metadata?: Record<string, any>;
|
|
173
|
+
timestamp: string;
|
|
174
|
+
}
|
package/dist/nats/index.d.ts
CHANGED
package/dist/nats/index.js
CHANGED
|
@@ -19,3 +19,4 @@ __exportStar(require("./interfaces/nats-options.interface"), exports);
|
|
|
19
19
|
__exportStar(require("./dto/nats-message.dto"), exports);
|
|
20
20
|
__exportStar(require("./decorators/nats-event-pattern.decorator"), exports);
|
|
21
21
|
__exportStar(require("./interceptors/nats-logging.interceptor"), exports);
|
|
22
|
+
__exportStar(require("./events"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rpc-exception.filter';
|