@takentrade/takentrade-libs 4.2.4 → 4.3.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.
Files changed (36) hide show
  1. package/dist/common/config/index.d.ts +1 -1
  2. package/dist/common/config/index.js +15 -0
  3. package/dist/common/constants/jobs.constants.d.ts +27 -0
  4. package/dist/common/constants/jobs.constants.js +28 -1
  5. package/dist/common/constants/queues.constants.d.ts +2 -0
  6. package/dist/common/constants/queues.constants.js +3 -1
  7. package/dist/common/health/index.d.ts +2 -0
  8. package/dist/common/health/index.js +18 -0
  9. package/dist/common/index.d.ts +2 -0
  10. package/dist/common/index.js +2 -0
  11. package/dist/nats/constants/nats.constants.d.ts +23 -0
  12. package/dist/nats/constants/nats.constants.js +27 -0
  13. package/dist/nats/index.d.ts +1 -0
  14. package/dist/nats/index.js +1 -0
  15. package/dist/nats/nats-client.module.d.ts +2 -0
  16. package/dist/nats/nats-client.module.js +44 -0
  17. package/dist/rpc/index.d.ts +2 -0
  18. package/dist/rpc/index.js +2 -0
  19. package/dist/rpc/ledger/index.d.ts +3 -0
  20. package/dist/rpc/ledger/index.js +19 -0
  21. package/dist/rpc/ledger/ledger.interface.d.ts +50 -0
  22. package/dist/rpc/ledger/ledger.interface.js +2 -0
  23. package/dist/rpc/ledger/ledger.module.d.ts +2 -0
  24. package/dist/rpc/ledger/ledger.module.js +20 -0
  25. package/dist/rpc/ledger/ledger.service.d.ts +14 -0
  26. package/dist/rpc/ledger/ledger.service.js +53 -0
  27. package/dist/rpc/users-rpc-client/index.d.ts +3 -0
  28. package/dist/rpc/users-rpc-client/index.js +19 -0
  29. package/dist/rpc/users-rpc-client/users-rpc-client.interface.d.ts +23 -0
  30. package/dist/rpc/users-rpc-client/users-rpc-client.interface.js +2 -0
  31. package/dist/rpc/users-rpc-client/users-rpc-client.module.d.ts +2 -0
  32. package/dist/rpc/users-rpc-client/users-rpc-client.module.js +20 -0
  33. package/dist/rpc/users-rpc-client/users-rpc-client.service.d.ts +10 -0
  34. package/dist/rpc/users-rpc-client/users-rpc-client.service.js +50 -0
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
@@ -1 +1 @@
1
- export {};
1
+ export * from './nats.config';
@@ -1,2 +1,17 @@
1
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
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./nats.config"), exports);
@@ -29,3 +29,30 @@ export declare const FINANCE_JOBS: {
29
29
  COLLECT_ARREARS: string;
30
30
  PROCESS_BANK_TRANSFER: string;
31
31
  };
32
+ export declare const SAVINGS_JOBS: {
33
+ INTEREST_ACCRUAL: string;
34
+ MATURITY_CHECK: string;
35
+ WITHDRAWAL_RESET: string;
36
+ AUTO_SAVE: string;
37
+ };
38
+ export declare const LOAN_JOBS: {
39
+ PROCESS_AUTOMATIC_REPAYMENT: string;
40
+ };
41
+ export declare const AJO_JOBS: {
42
+ DUE_CONTRIBUTIONS: string;
43
+ COMPLETE_AJOS: string;
44
+ };
45
+ export declare const INVESTMENT_JOBS: {
46
+ SYNC_INSTRUMENTS: string;
47
+ RECONCILE_ORDERS: string;
48
+ SYNC_PORTFOLIO: string;
49
+ SYNC_CORPORATE_ACTIONS: string;
50
+ };
51
+ export declare const COOPERATIVE_JOBS: {
52
+ PROCESS_CYCLE_COMPLETION: string;
53
+ };
54
+ export declare const VAS_JOBS_EXT: {
55
+ ESIM_SYNC: string;
56
+ PROVIDER_REFRESH: string;
57
+ STALE_JOB_CLEANUP: string;
58
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FINANCE_JOBS = exports.REWARD_JOBS = exports.VAS_JOBS = exports.STATEMENT_JOBS = exports.KYC_JOBS = exports.WEBHOOK_JOBS = exports.THRIFT_JOBS = void 0;
3
+ exports.VAS_JOBS_EXT = exports.COOPERATIVE_JOBS = exports.INVESTMENT_JOBS = exports.AJO_JOBS = exports.LOAN_JOBS = exports.SAVINGS_JOBS = exports.FINANCE_JOBS = exports.REWARD_JOBS = exports.VAS_JOBS = exports.STATEMENT_JOBS = exports.KYC_JOBS = exports.WEBHOOK_JOBS = exports.THRIFT_JOBS = void 0;
4
4
  exports.THRIFT_JOBS = {
5
5
  PROCESS_AJO_CONTRIBUTION: 'process_ajo_contribution',
6
6
  PROCESS_AJO_COMPLETION: 'process_ajo_completion',
@@ -32,3 +32,30 @@ exports.FINANCE_JOBS = {
32
32
  COLLECT_ARREARS: 'collect_arrears',
33
33
  PROCESS_BANK_TRANSFER: 'process_bank_transfer',
34
34
  };
35
+ exports.SAVINGS_JOBS = {
36
+ INTEREST_ACCRUAL: 'savings_interest_accrual',
37
+ MATURITY_CHECK: 'savings_maturity_check',
38
+ WITHDRAWAL_RESET: 'savings_withdrawal_reset',
39
+ AUTO_SAVE: 'savings_auto_save',
40
+ };
41
+ exports.LOAN_JOBS = {
42
+ PROCESS_AUTOMATIC_REPAYMENT: 'loan_automatic_repayment',
43
+ };
44
+ exports.AJO_JOBS = {
45
+ DUE_CONTRIBUTIONS: 'ajo_due_contributions',
46
+ COMPLETE_AJOS: 'ajo_complete',
47
+ };
48
+ exports.INVESTMENT_JOBS = {
49
+ SYNC_INSTRUMENTS: 'investment_sync_instruments',
50
+ RECONCILE_ORDERS: 'investment_reconcile_orders',
51
+ SYNC_PORTFOLIO: 'investment_sync_portfolio',
52
+ SYNC_CORPORATE_ACTIONS: 'investment_sync_corporate_actions',
53
+ };
54
+ exports.COOPERATIVE_JOBS = {
55
+ PROCESS_CYCLE_COMPLETION: 'coop_cycle_completion',
56
+ };
57
+ exports.VAS_JOBS_EXT = {
58
+ ESIM_SYNC: 'vas_esim_sync',
59
+ PROVIDER_REFRESH: 'vas_provider_refresh',
60
+ STALE_JOB_CLEANUP: 'vas_stale_job_cleanup',
61
+ };
@@ -19,3 +19,5 @@ export declare const THRIFT_QUEUE = "thrift_queue";
19
19
  export declare const KYC_QUEUE = "kyc_queue";
20
20
  export declare const STATEMENT_QUEUE = "statement_queue";
21
21
  export declare const REWARD_REFERRAL_QUEUE = "reward_referral_queue";
22
+ export declare const INVESTMENT_QUEUE = "investment_queue";
23
+ export declare const BANK_TRANSFER_QUEUE = "bank_transfer_queue";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REWARD_REFERRAL_QUEUE = exports.STATEMENT_QUEUE = exports.KYC_QUEUE = exports.THRIFT_QUEUE = exports.FINANCE_QUEUE = exports.WEBHOOK_QUEUE = exports.WALLET_QUEUE = exports.VAS_QUEUE = exports.USER_QUEUE = exports.TRANSACTION_QUEUE = exports.SUBACCOUNT_QUEUE = exports.SAVINGS_QUEUE = exports.PAYMENT_QUEUE = exports.NOTIFICATION_QUEUE = exports.LOAN_QUEUE = exports.COOPERATIVE_QUEUE = exports.CONTRIBUTION_QUEUE = exports.CARD_QUEUE = exports.BULK_EMAIL_QUEUE = exports.BATCH_TRANSACTION_QUEUE = exports.AJO_QUEUE = void 0;
3
+ exports.BANK_TRANSFER_QUEUE = exports.INVESTMENT_QUEUE = exports.REWARD_REFERRAL_QUEUE = exports.STATEMENT_QUEUE = exports.KYC_QUEUE = exports.THRIFT_QUEUE = exports.FINANCE_QUEUE = exports.WEBHOOK_QUEUE = exports.WALLET_QUEUE = exports.VAS_QUEUE = exports.USER_QUEUE = exports.TRANSACTION_QUEUE = exports.SUBACCOUNT_QUEUE = exports.SAVINGS_QUEUE = exports.PAYMENT_QUEUE = exports.NOTIFICATION_QUEUE = exports.LOAN_QUEUE = exports.COOPERATIVE_QUEUE = exports.CONTRIBUTION_QUEUE = exports.CARD_QUEUE = exports.BULK_EMAIL_QUEUE = exports.BATCH_TRANSACTION_QUEUE = exports.AJO_QUEUE = void 0;
4
4
  exports.AJO_QUEUE = 'ajos_queue';
5
5
  exports.BATCH_TRANSACTION_QUEUE = 'batch_transaction_queue';
6
6
  exports.BULK_EMAIL_QUEUE = 'bulk_email_queue';
@@ -22,3 +22,5 @@ exports.THRIFT_QUEUE = 'thrift_queue';
22
22
  exports.KYC_QUEUE = 'kyc_queue';
23
23
  exports.STATEMENT_QUEUE = 'statement_queue';
24
24
  exports.REWARD_REFERRAL_QUEUE = 'reward_referral_queue';
25
+ exports.INVESTMENT_QUEUE = 'investment_queue';
26
+ exports.BANK_TRANSFER_QUEUE = 'bank_transfer_queue';
@@ -0,0 +1,2 @@
1
+ export * from './health.module';
2
+ export * from './health.controller';
@@ -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("./health.module"), exports);
18
+ __exportStar(require("./health.controller"), exports);
@@ -1,2 +1,4 @@
1
1
  export * from './constants';
2
2
  export * from './utils';
3
+ export * from './config';
4
+ export * from './health';
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./utils"), exports);
19
+ __exportStar(require("./config"), exports);
20
+ __exportStar(require("./health"), exports);
@@ -43,5 +43,28 @@ export declare enum NatsSubjects {
43
43
  ADMIN_GET_TERMII_BALANCE = "admin.termii.balance.get",
44
44
  ADMIN_GET_KUDISMS_BALANCE = "admin.kudisms.balance.get",
45
45
  GIFTCARD_SALE_CREATED = "giftcard.sale.created",
46
+ INVESTMENT_ORDER_CREATED = "investment.order.created",
47
+ INVESTMENT_ORDER_FILLED = "investment.order.filled",
48
+ INVESTMENT_ORDER_CANCELLED = "investment.order.cancelled",
49
+ INVESTMENT_ORDER_REJECTED = "investment.order.rejected",
50
+ INVESTMENT_PORTFOLIO_SYNCED = "investment.portfolio.synced",
51
+ INVESTMENT_DIVIDEND_PAID = "investment.dividend.paid",
52
+ SAVINGS_CONTRIBUTION_RECEIVED = "savings.contribution.received",
53
+ SAVINGS_WITHDRAWAL_PROCESSED = "savings.withdrawal.processed",
54
+ SAVINGS_INTEREST_ACCRUED = "savings.interest.accrued",
55
+ SAVINGS_MATURITY_REACHED = "savings.maturity.reached",
56
+ COOPERATIVE_CREATED = "cooperative.created",
57
+ COOPERATIVE_MEMBER_ADDED = "cooperative.member.added",
58
+ COOPERATIVE_MEMBER_REMOVED = "cooperative.member.removed",
59
+ COOPERATIVE_CONTRIBUTION_RECORDED = "cooperative.contribution.recorded",
60
+ COOPERATIVE_DISTRIBUTION_COMPLETED = "cooperative.distribution.completed",
61
+ COOPERATIVE_CYCLE_COMPLETED = "cooperative.cycle.completed",
62
+ LOAN_CREATED = "loan.created",
63
+ LOAN_APPROVED = "loan.approved",
64
+ LOAN_DECLINED = "loan.declined",
65
+ LOAN_DISBURSED = "loan.disbursed",
66
+ LOAN_REPAYMENT_SUCCEEDED = "loan.repayment.succeeded",
67
+ LOAN_REPAYMENT_FAILED = "loan.repayment.failed",
68
+ LOAN_DEFAULTED = "loan.defaulted",
46
69
  AUDIT_LOG_CREATED = "audit.log.created"
47
70
  }
@@ -59,6 +59,33 @@ var NatsSubjects;
59
59
  NatsSubjects["ADMIN_GET_KUDISMS_BALANCE"] = "admin.kudisms.balance.get";
60
60
  // Giftcard operations
61
61
  NatsSubjects["GIFTCARD_SALE_CREATED"] = "giftcard.sale.created";
62
+ // Investment domain operations
63
+ NatsSubjects["INVESTMENT_ORDER_CREATED"] = "investment.order.created";
64
+ NatsSubjects["INVESTMENT_ORDER_FILLED"] = "investment.order.filled";
65
+ NatsSubjects["INVESTMENT_ORDER_CANCELLED"] = "investment.order.cancelled";
66
+ NatsSubjects["INVESTMENT_ORDER_REJECTED"] = "investment.order.rejected";
67
+ NatsSubjects["INVESTMENT_PORTFOLIO_SYNCED"] = "investment.portfolio.synced";
68
+ NatsSubjects["INVESTMENT_DIVIDEND_PAID"] = "investment.dividend.paid";
69
+ // Savings domain operations
70
+ NatsSubjects["SAVINGS_CONTRIBUTION_RECEIVED"] = "savings.contribution.received";
71
+ NatsSubjects["SAVINGS_WITHDRAWAL_PROCESSED"] = "savings.withdrawal.processed";
72
+ NatsSubjects["SAVINGS_INTEREST_ACCRUED"] = "savings.interest.accrued";
73
+ NatsSubjects["SAVINGS_MATURITY_REACHED"] = "savings.maturity.reached";
74
+ // Cooperative domain operations
75
+ NatsSubjects["COOPERATIVE_CREATED"] = "cooperative.created";
76
+ NatsSubjects["COOPERATIVE_MEMBER_ADDED"] = "cooperative.member.added";
77
+ NatsSubjects["COOPERATIVE_MEMBER_REMOVED"] = "cooperative.member.removed";
78
+ NatsSubjects["COOPERATIVE_CONTRIBUTION_RECORDED"] = "cooperative.contribution.recorded";
79
+ NatsSubjects["COOPERATIVE_DISTRIBUTION_COMPLETED"] = "cooperative.distribution.completed";
80
+ NatsSubjects["COOPERATIVE_CYCLE_COMPLETED"] = "cooperative.cycle.completed";
81
+ // Loan domain operations
82
+ NatsSubjects["LOAN_CREATED"] = "loan.created";
83
+ NatsSubjects["LOAN_APPROVED"] = "loan.approved";
84
+ NatsSubjects["LOAN_DECLINED"] = "loan.declined";
85
+ NatsSubjects["LOAN_DISBURSED"] = "loan.disbursed";
86
+ NatsSubjects["LOAN_REPAYMENT_SUCCEEDED"] = "loan.repayment.succeeded";
87
+ NatsSubjects["LOAN_REPAYMENT_FAILED"] = "loan.repayment.failed";
88
+ NatsSubjects["LOAN_DEFAULTED"] = "loan.defaulted";
62
89
  // Audit operations
63
90
  NatsSubjects["AUDIT_LOG_CREATED"] = "audit.log.created";
64
91
  })(NatsSubjects || (exports.NatsSubjects = NatsSubjects = {}));
@@ -5,3 +5,4 @@ export * from './decorators/nats-event-pattern.decorator';
5
5
  export * from './interceptors/nats-logging.interceptor';
6
6
  export * from './events';
7
7
  export * from './dto/audit-log.dto';
8
+ export * from './nats-client.module';
@@ -21,3 +21,4 @@ __exportStar(require("./decorators/nats-event-pattern.decorator"), exports);
21
21
  __exportStar(require("./interceptors/nats-logging.interceptor"), exports);
22
22
  __exportStar(require("./events"), exports);
23
23
  __exportStar(require("./dto/audit-log.dto"), exports);
24
+ __exportStar(require("./nats-client.module"), exports);
@@ -0,0 +1,2 @@
1
+ export declare class NatsClientModule {
2
+ }
@@ -0,0 +1,44 @@
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.NatsClientModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const config_1 = require("@nestjs/config");
12
+ const microservices_1 = require("@nestjs/microservices");
13
+ const nats_constants_1 = require("./constants/nats.constants");
14
+ let NatsClientModule = class NatsClientModule {
15
+ };
16
+ exports.NatsClientModule = NatsClientModule;
17
+ exports.NatsClientModule = NatsClientModule = __decorate([
18
+ (0, common_1.Global)(),
19
+ (0, common_1.Module)({
20
+ imports: [
21
+ microservices_1.ClientsModule.registerAsync([
22
+ {
23
+ name: nats_constants_1.NATS_CLIENT,
24
+ imports: [config_1.ConfigModule],
25
+ useFactory: async (configService) => ({
26
+ transport: microservices_1.Transport.NATS,
27
+ options: {
28
+ servers: [
29
+ configService.get('NATS_URL', 'nats://localhost:4222'),
30
+ ],
31
+ user: configService.get('NATS_USER'),
32
+ pass: configService.get('NATS_PASS'),
33
+ maxReconnectAttempts: configService.get('NATS_MAX_RECONNECT_ATTEMPTS', -1),
34
+ reconnectTimeWait: configService.get('NATS_RECONNECT_TIME_WAIT', 2000),
35
+ waitOnFirstConnect: configService.get('NATS_WAIT_ON_FIRST_CONNECT', true),
36
+ },
37
+ }),
38
+ inject: [config_1.ConfigService],
39
+ },
40
+ ]),
41
+ ],
42
+ exports: [microservices_1.ClientsModule],
43
+ })
44
+ ], NatsClientModule);
@@ -2,3 +2,5 @@ export * from './rpc.client';
2
2
  export * from './rpc-error';
3
3
  export * from './rpc-response';
4
4
  export * from './filters';
5
+ export * from './ledger';
6
+ export * from './users-rpc-client';
package/dist/rpc/index.js CHANGED
@@ -18,3 +18,5 @@ __exportStar(require("./rpc.client"), exports);
18
18
  __exportStar(require("./rpc-error"), exports);
19
19
  __exportStar(require("./rpc-response"), exports);
20
20
  __exportStar(require("./filters"), exports);
21
+ __exportStar(require("./ledger"), exports);
22
+ __exportStar(require("./users-rpc-client"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './ledger.interface';
2
+ export * from './ledger.service';
3
+ export * from './ledger.module';
@@ -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("./ledger.interface"), exports);
18
+ __exportStar(require("./ledger.service"), exports);
19
+ __exportStar(require("./ledger.module"), exports);
@@ -0,0 +1,50 @@
1
+ export interface WalletMutationPayload {
2
+ customerId: string;
3
+ amount: number;
4
+ type?: string;
5
+ additionalMetadata?: Record<string, unknown>;
6
+ source?: string;
7
+ }
8
+ export interface ProvidusAccountPayload {
9
+ userId: string;
10
+ payload: Record<string, unknown>;
11
+ }
12
+ export interface LedgerAccount {
13
+ id: string;
14
+ userId: string;
15
+ availableBalance: number;
16
+ bookBalance: number;
17
+ }
18
+ export interface VirtualAccount {
19
+ id: string;
20
+ userId: string;
21
+ bankName: string;
22
+ accountName: string;
23
+ accountNumber: string;
24
+ providerName: string;
25
+ providerReference: string;
26
+ providerAccountType: string;
27
+ providerWalletId: string;
28
+ providerCustomerId: string;
29
+ isDefault: boolean;
30
+ }
31
+ export interface LedgerAccountSummary {
32
+ account: LedgerAccount;
33
+ virtualAccounts: VirtualAccount[];
34
+ }
35
+ export interface LedgerTransaction {
36
+ id: string;
37
+ reference: string;
38
+ amount: number;
39
+ }
40
+ export interface WalletMutationResponse {
41
+ reference: string;
42
+ account: LedgerAccount;
43
+ transaction: LedgerTransaction;
44
+ providerResponse: Record<string, unknown>;
45
+ }
46
+ import { SubAccountType } from '../../utils/enums/subaccount.enum';
47
+ export interface LedgerSubAccountBalanceEvent {
48
+ type: SubAccountType;
49
+ amount: number;
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare class LedgerModule {
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.LedgerModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const ledger_service_1 = require("./ledger.service");
12
+ let LedgerModule = class LedgerModule {
13
+ };
14
+ exports.LedgerModule = LedgerModule;
15
+ exports.LedgerModule = LedgerModule = __decorate([
16
+ (0, common_1.Module)({
17
+ providers: [ledger_service_1.LedgerService],
18
+ exports: [ledger_service_1.LedgerService],
19
+ })
20
+ ], LedgerModule);
@@ -0,0 +1,14 @@
1
+ import { ClientProxy } from '@nestjs/microservices';
2
+ import { SubAccountType } from '../../utils/enums/subaccount.enum';
3
+ import type { LedgerAccountSummary, ProvidusAccountPayload, WalletMutationPayload, WalletMutationResponse } from './ledger.interface';
4
+ export declare class LedgerService {
5
+ private readonly natsClient;
6
+ constructor(natsClient: ClientProxy);
7
+ getUserBalance(userId: string): Promise<LedgerAccountSummary>;
8
+ debitCustomer(payload: WalletMutationPayload): Promise<WalletMutationResponse>;
9
+ creditCustomer(payload: WalletMutationPayload): Promise<WalletMutationResponse>;
10
+ getProvidusAccount(userId: string): Promise<Record<string, unknown>>;
11
+ createProvidusAccount(payload: ProvidusAccountPayload): Promise<Record<string, unknown>>;
12
+ updateProvidusAccount(payload: ProvidusAccountPayload): Promise<Record<string, unknown>>;
13
+ updateSubAccountBalance(type: SubAccountType, amount: number): Promise<void>;
14
+ }
@@ -0,0 +1,53 @@
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.LedgerService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const nats_1 = require("../../nats");
15
+ const rpc_client_1 = require("../rpc.client");
16
+ let LedgerService = class LedgerService {
17
+ natsClient;
18
+ constructor(natsClient) {
19
+ this.natsClient = natsClient;
20
+ }
21
+ async getUserBalance(userId) {
22
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.GET_USER_BALANCE, userId));
23
+ return response.data;
24
+ }
25
+ async debitCustomer(payload) {
26
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.PROVIDUS_DEBIT_CUSTOMER, payload));
27
+ return response.data;
28
+ }
29
+ async creditCustomer(payload) {
30
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.PROVIDUS_CREDIT_CUSTOMER, payload));
31
+ return response.data;
32
+ }
33
+ async getProvidusAccount(userId) {
34
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.PROVIDUS_GET_ACCOUNT, userId));
35
+ return response.data;
36
+ }
37
+ async createProvidusAccount(payload) {
38
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.CREATE_PROVIDUS_ACCOUNT, payload));
39
+ return response.data;
40
+ }
41
+ async updateProvidusAccount(payload) {
42
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.UPDATE_PROVIDUS_ACCOUNT, payload));
43
+ return response.data;
44
+ }
45
+ async updateSubAccountBalance(type, amount) {
46
+ this.natsClient.emit('subaccount.update.balance', { type, amount });
47
+ }
48
+ };
49
+ exports.LedgerService = LedgerService;
50
+ exports.LedgerService = LedgerService = __decorate([
51
+ (0, common_1.Injectable)(),
52
+ __param(0, (0, common_1.Inject)(nats_1.NATS_CLIENT))
53
+ ], LedgerService);
@@ -0,0 +1,3 @@
1
+ export * from './users-rpc-client.interface';
2
+ export * from './users-rpc-client.service';
3
+ export * from './users-rpc-client.module';
@@ -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("./users-rpc-client.interface"), exports);
18
+ __exportStar(require("./users-rpc-client.service"), exports);
19
+ __exportStar(require("./users-rpc-client.module"), exports);
@@ -0,0 +1,23 @@
1
+ export interface UserProfile {
2
+ id: string;
3
+ email?: string | null;
4
+ firstname?: string | null;
5
+ lastname?: string | null;
6
+ username?: string | null;
7
+ phone?: string | null;
8
+ image?: string | null;
9
+ }
10
+ export interface KycStatusResponse {
11
+ isVerified: boolean;
12
+ verificationStatus: string;
13
+ level: number;
14
+ isBvnVerified: boolean;
15
+ isNinVerified: boolean;
16
+ isIdVerified: boolean;
17
+ addressVerified: boolean;
18
+ isSelfieVerified: boolean;
19
+ }
20
+ export interface CreditScoreResponse {
21
+ score?: number;
22
+ details?: Record<string, unknown>;
23
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare class UsersRpcClientModule {
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.UsersRpcClientModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const users_rpc_client_service_1 = require("./users-rpc-client.service");
12
+ let UsersRpcClientModule = class UsersRpcClientModule {
13
+ };
14
+ exports.UsersRpcClientModule = UsersRpcClientModule;
15
+ exports.UsersRpcClientModule = UsersRpcClientModule = __decorate([
16
+ (0, common_1.Module)({
17
+ providers: [users_rpc_client_service_1.UsersRpcClientService],
18
+ exports: [users_rpc_client_service_1.UsersRpcClientService],
19
+ })
20
+ ], UsersRpcClientModule);
@@ -0,0 +1,10 @@
1
+ import { ClientProxy } from '@nestjs/microservices';
2
+ import type { CreditScoreResponse, KycStatusResponse, UserProfile } from './users-rpc-client.interface';
3
+ export declare class UsersRpcClientService {
4
+ private readonly natsClient;
5
+ constructor(natsClient: ClientProxy);
6
+ getUserById(userId: string): Promise<UserProfile>;
7
+ getUserByEmail(email: string): Promise<UserProfile | null>;
8
+ getUserKycStatus(userId: string): Promise<KycStatusResponse>;
9
+ getUserCreditScore(userId: string): Promise<CreditScoreResponse>;
10
+ }
@@ -0,0 +1,50 @@
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.UsersRpcClientService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const nats_1 = require("../../nats");
15
+ const rpc_client_1 = require("../rpc.client");
16
+ let UsersRpcClientService = class UsersRpcClientService {
17
+ natsClient;
18
+ constructor(natsClient) {
19
+ this.natsClient = natsClient;
20
+ }
21
+ async getUserById(userId) {
22
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.GET_USER_BY_ID, userId));
23
+ return response.data;
24
+ }
25
+ async getUserByEmail(email) {
26
+ try {
27
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.GET_USER_BY_EMAIL, email));
28
+ return response.data;
29
+ }
30
+ catch (error) {
31
+ if (error instanceof common_1.HttpException && error.getStatus() === 404) {
32
+ return null;
33
+ }
34
+ throw error;
35
+ }
36
+ }
37
+ async getUserKycStatus(userId) {
38
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.GET_USER_KYC_STATUS, userId));
39
+ return response.data;
40
+ }
41
+ async getUserCreditScore(userId) {
42
+ const response = await rpc_client_1.TakeNTradeRpcV2.withReply(this.natsClient.send(nats_1.NatsSubjects.GET_USER_CREDIT_SCORE, userId));
43
+ return response.data;
44
+ }
45
+ };
46
+ exports.UsersRpcClientService = UsersRpcClientService;
47
+ exports.UsersRpcClientService = UsersRpcClientService = __decorate([
48
+ (0, common_1.Injectable)(),
49
+ __param(0, (0, common_1.Inject)(nats_1.NATS_CLIENT))
50
+ ], UsersRpcClientService);