@takentrade/takentrade-libs 3.3.2 → 3.3.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 (52) hide show
  1. package/dist/auth/decorators/get-user.decorator.d.ts +1 -1
  2. package/dist/auth/guards/index.d.ts +1 -0
  3. package/dist/auth/guards/index.js +17 -0
  4. package/dist/auth/guards/roles.guard.d.ts +20 -0
  5. package/dist/auth/guards/roles.guard.js +47 -0
  6. package/dist/auth/index.d.ts +3 -1
  7. package/dist/auth/index.js +3 -1
  8. package/dist/auth/interfaces/auth.interface.d.ts +21 -0
  9. package/dist/auth/interfaces/index.d.ts +1 -0
  10. package/dist/auth/interfaces/index.js +17 -0
  11. package/dist/auth/strategies/index.d.ts +1 -0
  12. package/dist/auth/strategies/index.js +17 -0
  13. package/dist/auth/strategies/tnt-jwt.strategy.d.ts +23 -0
  14. package/dist/auth/strategies/tnt-jwt.strategy.js +37 -0
  15. package/dist/common/constants/jobs.constants.d.ts +5 -0
  16. package/dist/common/constants/jobs.constants.js +6 -1
  17. package/dist/common/dto/account.dto.d.ts +18 -0
  18. package/dist/common/dto/account.dto.js +68 -0
  19. package/dist/common/dto/index.d.ts +2 -0
  20. package/dist/common/dto/index.js +18 -0
  21. package/dist/common/dto/user.dto.d.ts +34 -0
  22. package/dist/common/dto/user.dto.js +132 -0
  23. package/dist/common/index.d.ts +1 -0
  24. package/dist/common/index.js +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/logging/index.d.ts +3 -0
  28. package/dist/logging/index.js +18 -0
  29. package/dist/logging/logger.module.d.ts +6 -0
  30. package/dist/logging/logger.module.js +25 -0
  31. package/dist/logging/logger.service.d.ts +48 -0
  32. package/dist/logging/logger.service.js +107 -0
  33. package/dist/nats/events/index.d.ts +76 -0
  34. package/dist/nats/events/index.js +6 -0
  35. package/dist/nats/index.d.ts +1 -0
  36. package/dist/nats/index.js +1 -0
  37. package/dist/rpc/filters/index.d.ts +1 -0
  38. package/dist/rpc/filters/index.js +17 -0
  39. package/dist/rpc/filters/rpc-exception.filter.d.ts +10 -0
  40. package/dist/rpc/filters/rpc-exception.filter.js +38 -0
  41. package/dist/rpc/index.d.ts +4 -54
  42. package/dist/rpc/index.js +18 -133
  43. package/dist/rpc/rpc-error.d.ts +10 -0
  44. package/dist/rpc/rpc-error.js +2 -0
  45. package/dist/rpc/rpc-response.d.ts +6 -0
  46. package/dist/rpc/rpc-response.js +2 -0
  47. package/dist/rpc/rpc.client.d.ts +46 -0
  48. package/dist/rpc/rpc.client.js +135 -0
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +6 -1
  51. package/dist/auth/auth.interface.d.ts +0 -8
  52. /package/dist/auth/{auth.interface.js → interfaces/auth.interface.js} +0 -0
@@ -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);
@@ -0,0 +1,76 @@
1
+ /**
2
+ * NATS Event Contracts
3
+ * TypeScript interfaces for inter-service communication via NATS
4
+ */
5
+ export interface UserCreatedEvent {
6
+ userId: string;
7
+ email: string;
8
+ phone: string;
9
+ firstname?: string;
10
+ lastname?: string;
11
+ referralCode?: string;
12
+ createdAt: string;
13
+ }
14
+ export interface PaymentSuccessEvent {
15
+ transactionId: string;
16
+ userId: string;
17
+ amount: number;
18
+ currency: string;
19
+ provider: 'PROVIDUS' | 'PAYSTACK';
20
+ reference: string;
21
+ metadata?: Record<string, any>;
22
+ timestamp: string;
23
+ }
24
+ export interface PaymentFailedEvent {
25
+ transactionId: string;
26
+ userId: string;
27
+ amount: number;
28
+ currency: string;
29
+ provider: 'PROVIDUS' | 'PAYSTACK';
30
+ reference: string;
31
+ reason: string;
32
+ errorCode?: string;
33
+ timestamp: string;
34
+ }
35
+ export interface TransactionProcessedEvent {
36
+ transactionId: string;
37
+ userId: string;
38
+ type: 'CREDIT' | 'DEBIT';
39
+ amount: number;
40
+ balance: number;
41
+ description: string;
42
+ metadata?: Record<string, any>;
43
+ timestamp: string;
44
+ }
45
+ export interface NotificationSentEvent {
46
+ notificationId: string;
47
+ userId: string;
48
+ channel: 'EMAIL' | 'SMS' | 'PUSH';
49
+ type: string;
50
+ status: 'SENT' | 'FAILED';
51
+ timestamp: string;
52
+ }
53
+ export interface SavingsMaturedEvent {
54
+ savingsId: string;
55
+ userId: string;
56
+ amount: number;
57
+ interest: number;
58
+ plan: string;
59
+ maturityDate: string;
60
+ timestamp: string;
61
+ }
62
+ export interface LoanApprovedEvent {
63
+ loanId: string;
64
+ userId: string;
65
+ amount: number;
66
+ interestRate: number;
67
+ repaymentDate: string;
68
+ timestamp: string;
69
+ }
70
+ export interface LoanRepaidEvent {
71
+ loanId: string;
72
+ userId: string;
73
+ amount: number;
74
+ remainingBalance: number;
75
+ timestamp: string;
76
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * NATS Event Contracts
4
+ * TypeScript interfaces for inter-service communication via NATS
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -3,3 +3,4 @@ export * from './interfaces/nats-options.interface';
3
3
  export * from './dto/nats-message.dto';
4
4
  export * from './decorators/nats-event-pattern.decorator';
5
5
  export * from './interceptors/nats-logging.interceptor';
6
+ export * from './events';
@@ -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';
@@ -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("./rpc-exception.filter"), exports);
@@ -0,0 +1,10 @@
1
+ import { RpcExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ import { RpcException } from '@nestjs/microservices';
4
+ /**
5
+ * TNT RPC Exception Filter
6
+ * Standardizes error handling and propagation in microservice communication
7
+ */
8
+ export declare class TntRpcExceptionFilter implements RpcExceptionFilter<RpcException> {
9
+ catch(exception: any, host: ArgumentsHost): Observable<any>;
10
+ }
@@ -0,0 +1,38 @@
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.TntRpcExceptionFilter = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const rxjs_1 = require("rxjs");
12
+ const microservices_1 = require("@nestjs/microservices");
13
+ /**
14
+ * TNT RPC Exception Filter
15
+ * Standardizes error handling and propagation in microservice communication
16
+ */
17
+ let TntRpcExceptionFilter = class TntRpcExceptionFilter {
18
+ catch(exception, host) {
19
+ // Extract error details
20
+ const error = exception instanceof microservices_1.RpcException ? exception.getError() : exception;
21
+ // Format error response
22
+ const errorResponse = {
23
+ statusCode: error?.statusCode || 500,
24
+ message: error?.message || exception.message || 'Internal server error',
25
+ error: error?.error || 'InternalServerError',
26
+ timestamp: new Date().toISOString(),
27
+ path: error?.path,
28
+ ...(process.env.NODE_ENV !== 'production' && {
29
+ stack: exception.stack,
30
+ }),
31
+ };
32
+ return (0, rxjs_1.throwError)(() => errorResponse);
33
+ }
34
+ };
35
+ exports.TntRpcExceptionFilter = TntRpcExceptionFilter;
36
+ exports.TntRpcExceptionFilter = TntRpcExceptionFilter = __decorate([
37
+ (0, common_1.Catch)()
38
+ ], TntRpcExceptionFilter);
@@ -1,54 +1,4 @@
1
- import { NatsContext, RpcException } from '@nestjs/microservices';
2
- import { Observable } from 'rxjs';
3
- export interface TakeNTradeRPCError {
4
- success: boolean;
5
- subject: string | null;
6
- message: string;
7
- statusCode: number;
8
- errors: string[];
9
- }
10
- export interface TakeNTradeRPCSuccess<T> {
11
- data?: T;
12
- }
13
- export declare class TakeNTradeRpc {
14
- /**
15
- * Wraps a promise returned by an RPC request handler.
16
- * @param promise - A Promise resolving to the response value.
17
- * @param ctx - Optional NatsContext object.
18
- * @param successMessage - Optional success message
19
- */
20
- static handleRequest<V>(promise: Promise<V>, ctx?: NatsContext): Promise<TakeNTradeRPCSuccess<V> | RpcException>;
21
- /**
22
- * Handles errors from an RPC request handler and returns a TakeNTradeRPCError wrapped in RpcException.
23
- * @param err - Error to be handled.
24
- * @param ctx - A NATS Context.
25
- */
26
- static handleRequestError(err: unknown, ctx: NatsContext): RpcException;
27
- private static catch;
28
- /**
29
- * Handles NATS request response.
30
- * @param obs - An instance of an Observable.
31
- * @param successMessage - Optional success message
32
- */
33
- static withReply<V>(obs: Observable<V>, successMessage?: string): Promise<TakeNTradeRPCSuccess<V>>;
34
- }
35
- export declare class TakeNTradeRpcV2 {
36
- /**
37
- * Wraps a promise returned by an RPC request handler.
38
- * @param promise - A Promise resolving to the response value.
39
- * @param ctx - Optional NatsContext object.
40
- */
41
- static handleRequest<V>(promise: Promise<V>, ctx?: NatsContext): Promise<TakeNTradeRPCSuccess<V> | TakeNTradeRPCError>;
42
- /**
43
- * Handles errors from an RPC request handler and returns a TakeNTradeRPCError.
44
- * @param err - Error to be handled.
45
- * @param ctx - A NATS Context.
46
- */
47
- static handleRequestError(err: unknown, ctx: NatsContext): TakeNTradeRPCError;
48
- private static catch;
49
- /**
50
- * Handles NATS request response.
51
- * @param obs - An instance of an Observable.
52
- */
53
- static withReply<V>(obs: Observable<V>): Promise<TakeNTradeRPCSuccess<V>>;
54
- }
1
+ export * from './rpc.client';
2
+ export * from './rpc-error';
3
+ export * from './rpc-response';
4
+ export * from './filters';
package/dist/rpc/index.js CHANGED
@@ -1,135 +1,20 @@
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 });
3
- exports.TakeNTradeRpcV2 = exports.TakeNTradeRpc = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const microservices_1 = require("@nestjs/microservices");
6
- class TakeNTradeRpcUtils {
7
- static getValidationErrors(err) {
8
- if (err instanceof common_1.BadRequestException) {
9
- const response = err.getResponse();
10
- if (typeof response === 'object' &&
11
- response !== null &&
12
- 'errors' in response) {
13
- return Array.isArray(response.errors)
14
- ? response.errors
15
- : [];
16
- }
17
- }
18
- return [];
19
- }
20
- static isErrorResponse(result) {
21
- return typeof result === 'object' && result !== null && 'error' in result;
22
- }
23
- static formatSuccessResponse(data) {
24
- return {
25
- data,
26
- };
27
- }
28
- }
29
- class TakeNTradeRpc {
30
- /**
31
- * Wraps a promise returned by an RPC request handler.
32
- * @param promise - A Promise resolving to the response value.
33
- * @param ctx - Optional NatsContext object.
34
- * @param successMessage - Optional success message
35
- */
36
- static async handleRequest(promise, ctx) {
37
- return promise
38
- .then((value) => TakeNTradeRpcUtils.formatSuccessResponse(value))
39
- .catch((err) => this.catch(err, ctx));
40
- }
41
- /**
42
- * Handles errors from an RPC request handler and returns a TakeNTradeRPCError wrapped in RpcException.
43
- * @param err - Error to be handled.
44
- * @param ctx - A NATS Context.
45
- */
46
- static handleRequestError(err, ctx) {
47
- return this.catch(err, ctx);
48
- }
49
- static catch(err, ctx) {
50
- const subject = ctx ? ctx.getArgs()[0] : null;
51
- const error = err instanceof Error ? err : new Error(String(err));
52
- const statusCode = err instanceof common_1.HttpException ? err.getStatus() : 500;
53
- const errorDetails = {
54
- success: false,
55
- subject,
56
- message: error.message,
57
- statusCode,
58
- errors: TakeNTradeRpcUtils.getValidationErrors(err),
59
- };
60
- return new microservices_1.RpcException(errorDetails);
61
- }
62
- /**
63
- * Handles NATS request response.
64
- * @param obs - An instance of an Observable.
65
- * @param successMessage - Optional success message
66
- */
67
- static async withReply(obs, successMessage = 'Operation successful') {
68
- const result = await new Promise((resolve, reject) => {
69
- obs.subscribe({
70
- next: (value) => resolve(value),
71
- error: (err) => reject(err instanceof Error ? err : new Error(String(err))),
72
- });
73
- });
74
- if (TakeNTradeRpcUtils.isErrorResponse(result)) {
75
- common_1.Logger.error(result.error);
76
- throw new common_1.HttpException(result.error, result.error.statusCode, {
77
- cause: result.error.errors,
78
- });
79
- }
80
- return TakeNTradeRpcUtils.formatSuccessResponse(result);
81
- }
82
- }
83
- exports.TakeNTradeRpc = TakeNTradeRpc;
84
- class TakeNTradeRpcV2 {
85
- /**
86
- * Wraps a promise returned by an RPC request handler.
87
- * @param promise - A Promise resolving to the response value.
88
- * @param ctx - Optional NatsContext object.
89
- */
90
- static async handleRequest(promise, ctx) {
91
- return promise
92
- .then((value) => TakeNTradeRpcUtils.formatSuccessResponse(value))
93
- .catch((err) => this.catch(err, ctx));
94
- }
95
- /**
96
- * Handles errors from an RPC request handler and returns a TakeNTradeRPCError.
97
- * @param err - Error to be handled.
98
- * @param ctx - A NATS Context.
99
- */
100
- static handleRequestError(err, ctx) {
101
- return this.catch(err, ctx);
102
- }
103
- static catch(err, ctx) {
104
- const subject = ctx ? ctx.getArgs()[0] : null;
105
- const error = err instanceof Error ? err : new Error(String(err));
106
- const statusCode = err instanceof common_1.HttpException ? err.getStatus() : 500;
107
- return {
108
- success: false,
109
- subject,
110
- message: error.message,
111
- statusCode,
112
- errors: TakeNTradeRpcUtils.getValidationErrors(err),
113
- };
114
- }
115
- /**
116
- * Handles NATS request response.
117
- * @param obs - An instance of an Observable.
118
- */
119
- static async withReply(obs) {
120
- const result = await new Promise((resolve, reject) => {
121
- obs.subscribe({
122
- next: (value) => resolve(value),
123
- error: (err) => reject(err instanceof Error ? err : new Error(String(err))),
124
- });
125
- });
126
- if (TakeNTradeRpcUtils.isErrorResponse(result)) {
127
- common_1.Logger.error(result.error);
128
- throw new common_1.HttpException(result.error, result.error.statusCode, {
129
- cause: result.error.errors,
130
- });
131
- }
132
- return TakeNTradeRpcUtils.formatSuccessResponse(result);
133
- }
134
- }
135
- exports.TakeNTradeRpcV2 = TakeNTradeRpcV2;
17
+ __exportStar(require("./rpc.client"), exports);
18
+ __exportStar(require("./rpc-error"), exports);
19
+ __exportStar(require("./rpc-response"), exports);
20
+ __exportStar(require("./filters"), exports);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * RPC Error Interface
3
+ */
4
+ export interface TakeNTradeRPCError {
5
+ success: boolean;
6
+ subject: string | null;
7
+ message: string;
8
+ statusCode: number;
9
+ errors: string[];
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * RPC Success Response Interface
3
+ */
4
+ export interface TakeNTradeRPCSuccess<T> {
5
+ data?: T;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,46 @@
1
+ import { NatsContext, RpcException } from '@nestjs/microservices';
2
+ import { Observable } from 'rxjs';
3
+ import { TakeNTradeRPCError } from './rpc-error';
4
+ import { TakeNTradeRPCSuccess } from './rpc-response';
5
+ export declare class TakeNTradeRpc {
6
+ /**
7
+ * Wraps a promise returned by an RPC request handler.
8
+ * @param promise - A Promise resolving to the response value.
9
+ * @param ctx - Optional NatsContext object.
10
+ * @param successMessage - Optional success message
11
+ */
12
+ static handleRequest<V>(promise: Promise<V>, ctx?: NatsContext): Promise<TakeNTradeRPCSuccess<V> | RpcException>;
13
+ /**
14
+ * Handles errors from an RPC request handler and returns a TakeNTradeRPCError wrapped in RpcException.
15
+ * @param err - Error to be handled.
16
+ * @param ctx - A NATS Context.
17
+ */
18
+ static handleRequestError(err: unknown, ctx: NatsContext): RpcException;
19
+ private static catch;
20
+ /**
21
+ * Handles NATS request response.
22
+ * @param obs - An instance of an Observable.
23
+ * @param successMessage - Optional success message
24
+ */
25
+ static withReply<V>(obs: Observable<V>, successMessage?: string): Promise<TakeNTradeRPCSuccess<V>>;
26
+ }
27
+ export declare class TakeNTradeRpcV2 {
28
+ /**
29
+ * Wraps a promise returned by an RPC request handler.
30
+ * @param promise - A Promise resolving to the response value.
31
+ * @param ctx - Optional NatsContext object.
32
+ */
33
+ static handleRequest<V>(promise: Promise<V>, ctx?: NatsContext): Promise<TakeNTradeRPCSuccess<V> | TakeNTradeRPCError>;
34
+ /**
35
+ * Handles errors from an RPC request handler and returns a TakeNTradeRPCError.
36
+ * @param err - Error to be handled.
37
+ * @param ctx - A NATS Context.
38
+ */
39
+ static handleRequestError(err: unknown, ctx: NatsContext): TakeNTradeRPCError;
40
+ private static catch;
41
+ /**
42
+ * Handles NATS request response.
43
+ * @param obs - An instance of an Observable.
44
+ */
45
+ static withReply<V>(obs: Observable<V>): Promise<TakeNTradeRPCSuccess<V>>;
46
+ }