@alacard-project/shared 1.0.4 → 1.0.6
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/constants/common.constants.d.ts +6 -0
- package/dist/constants/common.constants.js +7 -1
- package/dist/constants/common.constants.js.map +1 -1
- package/dist/constants/env.constants.d.ts +13 -11
- package/dist/constants/env.constants.js +13 -11
- package/dist/constants/env.constants.js.map +1 -1
- package/dist/constants/grpc.constants.d.ts +1 -0
- package/dist/constants/grpc.constants.js +1 -0
- package/dist/constants/grpc.constants.js.map +1 -1
- package/dist/constants/index.d.ts +0 -3
- package/dist/constants/index.js +0 -3
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/logging-messages.constants.d.ts +25 -0
- package/dist/constants/logging-messages.constants.js +25 -0
- package/dist/constants/logging-messages.constants.js.map +1 -1
- package/dist/constants/microservices.constants.d.ts +48 -4
- package/dist/constants/microservices.constants.js +48 -4
- package/dist/constants/microservices.constants.js.map +1 -1
- package/dist/contracts/auth.contract.d.ts +22 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/token.contract.d.ts +39 -0
- package/dist/contracts/token.contract.js +3 -0
- package/dist/contracts/token.contract.js.map +1 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/{logging → decorators}/index.js +3 -1
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/permissions.decorator.d.ts +3 -0
- package/dist/decorators/permissions.decorator.js +8 -0
- package/dist/decorators/permissions.decorator.js.map +1 -0
- package/dist/decorators/roles.decorator.d.ts +3 -0
- package/dist/decorators/roles.decorator.js +8 -0
- package/dist/decorators/roles.decorator.js.map +1 -0
- package/dist/dto/auth.dto.d.ts +15 -0
- package/dist/dto/auth.dto.js +43 -1
- package/dist/dto/auth.dto.js.map +1 -1
- package/dist/dto/card.dto.d.ts +18 -0
- package/dist/dto/card.dto.js +93 -0
- package/dist/dto/card.dto.js.map +1 -0
- package/dist/dto/client.dto.d.ts +41 -0
- package/dist/dto/client.dto.js +185 -0
- package/dist/dto/client.dto.js.map +1 -0
- package/dist/dto/index.d.ts +4 -0
- package/dist/dto/index.js +4 -0
- package/dist/dto/index.js.map +1 -1
- package/dist/dto/partner.dto.d.ts +7 -0
- package/dist/dto/partner.dto.js +39 -0
- package/dist/dto/partner.dto.js.map +1 -0
- package/dist/dto/transaction.dto.d.ts +16 -0
- package/dist/dto/transaction.dto.js +78 -0
- package/dist/dto/transaction.dto.js.map +1 -0
- package/dist/enums/error.enum.d.ts +3 -1
- package/dist/enums/error.enum.js +2 -0
- package/dist/enums/error.enum.js.map +1 -1
- package/dist/enums/user.enum.d.ts +19 -1
- package/dist/enums/user.enum.js +21 -1
- package/dist/enums/user.enum.js.map +1 -1
- package/dist/errors/error-map.js +10 -0
- package/dist/errors/error-map.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/interceptors/http-logging.interceptor.d.ts +10 -0
- package/dist/interceptors/http-logging.interceptor.js +74 -0
- package/dist/interceptors/http-logging.interceptor.js.map +1 -0
- package/dist/types/auth.types.d.ts +4 -0
- package/dist/utils/health.utils.d.ts +4 -6
- package/dist/utils/health.utils.js +7 -51
- package/dist/utils/health.utils.js.map +1 -1
- package/dist/utils/logging-client.d.ts +7 -5
- package/dist/utils/logging-client.js +49 -13
- package/dist/utils/logging-client.js.map +1 -1
- package/dist/utils/proto-path.js +5 -1
- package/dist/utils/proto-path.js.map +1 -1
- package/package.json +12 -1
- package/proto/card.proto +43 -0
- package/proto/client.proto +45 -0
- package/proto/partner.proto +18 -0
- package/proto/terminal.proto +18 -0
- package/proto/transaction.proto +45 -0
- package/src/constants/common.constants.ts +7 -0
- package/src/constants/env.constants.ts +17 -11
- package/src/constants/grpc.constants.ts +1 -0
- package/src/constants/index.ts +0 -3
- package/src/constants/logging-messages.constants.ts +28 -0
- package/src/constants/microservices.constants.ts +48 -4
- package/src/contracts/auth.contract.ts +17 -0
- package/src/contracts/index.ts +1 -0
- package/src/contracts/token.contract.ts +47 -0
- package/src/decorators/index.ts +3 -0
- package/src/decorators/permissions.decorator.ts +5 -0
- package/src/decorators/roles.decorator.ts +5 -0
- package/src/dto/auth.dto.ts +31 -0
- package/src/dto/card.dto.ts +64 -0
- package/src/dto/client.dto.ts +137 -0
- package/src/dto/index.ts +4 -0
- package/src/dto/partner.dto.ts +21 -0
- package/src/dto/transaction.dto.ts +51 -0
- package/src/enums/error.enum.ts +2 -0
- package/src/enums/user.enum.ts +20 -0
- package/src/errors/error-map.ts +10 -0
- package/src/index.ts +1 -4
- package/src/types/auth.types.ts +5 -0
- package/src/utils/health.utils.ts +8 -63
- package/src/utils/proto-path.ts +13 -7
- package/dist/logging/dto/log-filter.dto.d.ts +0 -29
- package/dist/logging/dto/log-filter.dto.js +0 -146
- package/dist/logging/dto/log-filter.dto.js.map +0 -1
- package/dist/logging/index.d.ts +0 -1
- package/dist/logging/index.js.map +0 -1
- package/src/config/base-config.service.ts +0 -101
- package/src/constants/logging.constants.ts +0 -26
- package/src/constants/monitoring.constants.ts +0 -71
- package/src/constants/tokens.constants.ts +0 -6
- package/src/utils/logging-client.ts +0 -21
- package/src/utils/prometheus.utils.ts +0 -114
|
@@ -6,29 +6,35 @@ export const ENV_KEYS = {
|
|
|
6
6
|
REDIS_PORT: 'REDIS_PORT',
|
|
7
7
|
REDIS_PASSWORD: 'REDIS_PASSWORD',
|
|
8
8
|
KAFKA_BROKERS: 'KAFKA_BROKERS',
|
|
9
|
-
RABBITMQ_URL: 'RABBITMQ_URL',
|
|
10
9
|
JWT_SECRET: 'JWT_SECRET',
|
|
11
10
|
JWT_EXPIRES_IN: 'JWT_EXPIRES_IN',
|
|
12
11
|
JWT_REFRESH_EXPIRES_IN: 'JWT_REFRESH_EXPIRES_IN',
|
|
13
12
|
GRPC_PORT: 'GRPC_PORT',
|
|
14
13
|
GRPC_URL: 'GRPC_URL',
|
|
14
|
+
|
|
15
15
|
LOGGING_PROTO_PATH: 'LOGGING_PROTO_PATH',
|
|
16
|
+
USER_PROTO_PATH: 'USER_PROTO_PATH',
|
|
17
|
+
AUTH_PROTO_PATH: 'AUTH_PROTO_PATH',
|
|
18
|
+
CLIENT_PROTO_PATH: 'CLIENT_PROTO_PATH',
|
|
19
|
+
CARD_PROTO_PATH: 'CARD_PROTO_PATH',
|
|
20
|
+
TRANSACTION_PROTO_PATH: 'TRANSACTION_PROTO_PATH',
|
|
21
|
+
TOKEN_PROTO_PATH: 'TOKEN_PROTO_PATH',
|
|
22
|
+
|
|
23
|
+
LOGGING_SERVICE_URL: 'LOGGING_SERVICE_URL',
|
|
24
|
+
CONFIG_SERVICE_URL: 'CONFIG_SERVICE_URL',
|
|
25
|
+
USER_SERVICE_URL: 'USER_SERVICE_URL',
|
|
26
|
+
AUTH_SERVICE_URL: 'AUTH_SERVICE_URL',
|
|
27
|
+
NOTIFICATION_SERVICE_URL: 'NOTIFICATION_SERVICE_URL',
|
|
28
|
+
TOKEN_SERVICE_URL: 'TOKEN_SERVICE_URL',
|
|
29
|
+
|
|
30
|
+
CONFIG_SERVICE_ENABLED: 'CONFIG_SERVICE_ENABLED',
|
|
16
31
|
INTERNAL_CONFIG_KEY: 'INTERNAL_CONFIG_KEY',
|
|
17
32
|
RATE_LIMIT_TTL: 'RATE_LIMIT_TTL',
|
|
18
33
|
RATE_LIMIT_MAX: 'RATE_LIMIT_MAX',
|
|
19
|
-
|
|
34
|
+
|
|
20
35
|
LOG_FILE_PATH: 'LOG_FILE_PATH',
|
|
21
36
|
LOG_RETENTION_DAYS: 'LOG_RETENTION_DAYS',
|
|
22
37
|
CORS_ORIGINS: 'CORS_ORIGINS',
|
|
23
|
-
USER_SERVICE_URL: 'USER_SERVICE_URL',
|
|
24
|
-
USER_PROTO_PATH: 'USER_PROTO_PATH',
|
|
25
|
-
AUTH_SERVICE_URL: 'AUTH_SERVICE_URL',
|
|
26
|
-
AUTH_PROTO_PATH: 'AUTH_PROTO_PATH',
|
|
27
|
-
LOGGING_SERVICE_URL: 'LOGGING_SERVICE_URL',
|
|
28
|
-
TOKEN_SERVICE_URL: 'TOKEN_SERVICE_URL',
|
|
29
|
-
TOKEN_PROTO_PATH: 'TOKEN_PROTO_PATH',
|
|
30
|
-
CONFIG_SERVICE_URL: 'CONFIG_SERVICE_URL',
|
|
31
|
-
CONFIG_SERVICE_ENABLED: 'CONFIG_SERVICE_ENABLED',
|
|
32
38
|
} as const;
|
|
33
39
|
|
|
34
40
|
export const ENV_VALUES = {
|
package/src/constants/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './env.constants';
|
|
2
2
|
export * from './http.constants';
|
|
3
|
-
export * from './logging.constants';
|
|
4
3
|
export * from './microservices.constants';
|
|
5
4
|
export * from './grpc.constants';
|
|
6
5
|
export * from './error-messages';
|
|
@@ -8,6 +7,4 @@ export * from './auth.constants';
|
|
|
8
7
|
export * from './logging-messages.constants';
|
|
9
8
|
export * from './routes.constants';
|
|
10
9
|
export * from './common.constants';
|
|
11
|
-
export * from './tokens.constants';
|
|
12
10
|
export * from './auth-config.constants';
|
|
13
|
-
export * from './monitoring.constants';
|
|
@@ -12,4 +12,32 @@ export const LOGGING_MESSAGES = {
|
|
|
12
12
|
CONFIG_RELOADED: 'Configuration successfully reloaded',
|
|
13
13
|
VAULT_CONNECTED: 'Connected to HashiCorp Vault',
|
|
14
14
|
VAULT_CONNECTION_FAILED: 'Failed to connect to HashiCorp Vault',
|
|
15
|
+
|
|
16
|
+
LOGIN_FAILED: 'Login failed',
|
|
17
|
+
LOGIN_ATTEMPT_INACTIVE_USER: 'Login attempt from inactive user',
|
|
18
|
+
USER_VALIDATED: 'User validated',
|
|
19
|
+
USER_VALIDATION_FAILED: 'User validation failed',
|
|
20
|
+
JWT_PAYLOAD_VALIDATED: 'JWT payload validated',
|
|
21
|
+
JWT_PAYLOAD_VALIDATION_FAILED: 'JWT payload validation failed',
|
|
22
|
+
JWT_VALIDATION_ERROR: 'JWT validation error',
|
|
23
|
+
REGISTRATION_ATTEMPT_EXISTING_EMAIL: 'Registration attempt with existing email',
|
|
24
|
+
REGISTRATION_FAILED: 'Registration failed',
|
|
25
|
+
REFRESH_TOKEN_INVALID: 'Refresh token invalid',
|
|
26
|
+
REFRESH_TOKEN_REVOKED: 'Refresh token revoked',
|
|
27
|
+
REFRESH_TOKEN_REVOKED_MANUALLY: 'Refresh token revoked manually',
|
|
28
|
+
REFRESH_TOKEN_REVOKE_ATTEMPT_FAILED: 'Refresh token revoke attempt failed',
|
|
29
|
+
TOKEN_REVOKE_ERROR: 'Token revoke error',
|
|
30
|
+
PERMISSION_CHECK_PERFORMED: 'Permission check performed',
|
|
31
|
+
PERMISSION_CHECK_ERROR: 'Permission check error',
|
|
32
|
+
USER_PERMISSIONS_RETRIEVED: 'User permissions retrieved',
|
|
33
|
+
USER_PERMISSIONS_RETRIEVAL_ERROR: 'User permissions retrieval error',
|
|
34
|
+
|
|
35
|
+
INVITATION_CREATED: 'Invitation created',
|
|
36
|
+
INVITATION_VALIDATED: 'Invitation validated',
|
|
37
|
+
INVITATION_VALIDATION_FAILED: 'Invitation validation failed',
|
|
38
|
+
INVITATION_USED: 'Invitation used',
|
|
39
|
+
|
|
40
|
+
PASSWORD_RESET_TOKEN_CREATED: 'Password reset token created',
|
|
41
|
+
PASSWORD_RESET_SUCCESSFUL: 'Password reset successful',
|
|
42
|
+
PASSWORD_RESET_FAILED: 'Password reset failed',
|
|
15
43
|
};
|
|
@@ -1,18 +1,62 @@
|
|
|
1
1
|
export const MICROSERVICES = {
|
|
2
2
|
CONFIG: {
|
|
3
|
-
SERVICE_NAME: '
|
|
3
|
+
SERVICE_NAME: 'ConfigService',
|
|
4
4
|
PACKAGE: 'config',
|
|
5
5
|
},
|
|
6
6
|
LOGGING: {
|
|
7
|
-
SERVICE_NAME: '
|
|
7
|
+
SERVICE_NAME: 'LoggingService',
|
|
8
8
|
PACKAGE: 'logging',
|
|
9
9
|
},
|
|
10
|
+
KAFKA: {
|
|
11
|
+
SERVICE_NAME: 'KafkaService',
|
|
12
|
+
PACKAGE: 'kafka',
|
|
13
|
+
},
|
|
10
14
|
AUTH: {
|
|
11
|
-
SERVICE_NAME: '
|
|
15
|
+
SERVICE_NAME: 'AuthService',
|
|
12
16
|
PACKAGE: 'auth',
|
|
13
17
|
},
|
|
14
18
|
USER: {
|
|
15
|
-
SERVICE_NAME: '
|
|
19
|
+
SERVICE_NAME: 'UserService',
|
|
16
20
|
PACKAGE: 'user',
|
|
17
21
|
},
|
|
22
|
+
CLIENT: {
|
|
23
|
+
SERVICE_NAME: 'ClientService',
|
|
24
|
+
PACKAGE: 'client',
|
|
25
|
+
},
|
|
26
|
+
CARD: {
|
|
27
|
+
SERVICE_NAME: 'CardService',
|
|
28
|
+
PACKAGE: 'card',
|
|
29
|
+
},
|
|
30
|
+
TRANSACTION: {
|
|
31
|
+
SERVICE_NAME: 'TransactionService',
|
|
32
|
+
PACKAGE: 'transaction',
|
|
33
|
+
},
|
|
34
|
+
ACCOUNT: {
|
|
35
|
+
SERVICE_NAME: 'AccountService',
|
|
36
|
+
PACKAGE: 'account',
|
|
37
|
+
},
|
|
38
|
+
INVOICE: {
|
|
39
|
+
SERVICE_NAME: 'InvoiceService',
|
|
40
|
+
PACKAGE: 'invoice',
|
|
41
|
+
},
|
|
42
|
+
NOTIFICATION: {
|
|
43
|
+
SERVICE_NAME: 'NotificationService',
|
|
44
|
+
PACKAGE: 'notification',
|
|
45
|
+
},
|
|
46
|
+
ATTACHMENT: {
|
|
47
|
+
SERVICE_NAME: 'AttachmentService',
|
|
48
|
+
PACKAGE: 'attachment',
|
|
49
|
+
},
|
|
50
|
+
TERMINAL: {
|
|
51
|
+
SERVICE_NAME: 'TerminalService',
|
|
52
|
+
PACKAGE: 'terminal',
|
|
53
|
+
},
|
|
54
|
+
PARTNER: {
|
|
55
|
+
SERVICE_NAME: 'PartnerService',
|
|
56
|
+
PACKAGE: 'partner',
|
|
57
|
+
},
|
|
58
|
+
TOKEN: {
|
|
59
|
+
SERVICE_NAME: 'TokenService',
|
|
60
|
+
PACKAGE: 'token',
|
|
61
|
+
},
|
|
18
62
|
} as const;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { RegisterDto, LoginDto } from '../dto/auth.dto';
|
|
3
|
+
import { JwtTokens } from '../types/auth.types';
|
|
4
|
+
|
|
1
5
|
export interface GetUserByIdGrpcRequest {
|
|
2
6
|
userId: string;
|
|
3
7
|
}
|
|
@@ -96,3 +100,16 @@ export type GetUserByIdRequest = GetUserByIdGrpcRequest;
|
|
|
96
100
|
export type GetUserByEmailRequest = GetUserByEmailGrpcRequest;
|
|
97
101
|
export type GetUserPermissionsRequest = GetUserPermissionsGrpcRequest;
|
|
98
102
|
export type DeleteUserResponse = { success: boolean };
|
|
103
|
+
|
|
104
|
+
export interface IAuthService {
|
|
105
|
+
loginGrpc(data: LoginDto): Observable<JwtTokens>;
|
|
106
|
+
registerGrpc(data: RegisterDto): Observable<any>;
|
|
107
|
+
validateGrpc(data: { token: string }): Observable<{ valid: boolean; userId?: string; email?: string; role?: string }>;
|
|
108
|
+
validateTokenGrpc(data: ValidateTokenGrpcRequest): Observable<ValidateTokenGrpcResponse>;
|
|
109
|
+
refreshTokenGrpc(data: RefreshTokenGrpcRequest): Observable<JwtTokens>;
|
|
110
|
+
revokeTokenGrpc(data: RevokeTokenGrpcRequest): Observable<RevokeTokenGrpcResponse>;
|
|
111
|
+
checkPermissionGrpc(data: CheckPermissionGrpcRequest): Observable<CheckPermissionGrpcResponse>;
|
|
112
|
+
getUserPermissionsGrpc(data: GetUserPermissionsGrpcRequest): Observable<GetUserPermissionsGrpcResponse>;
|
|
113
|
+
getUserByIdGrpc(data: GetUserByIdGrpcRequest): Observable<GetUserByIdGrpcResponse>;
|
|
114
|
+
getUserByEmailGrpc(data: GetUserByEmailGrpcRequest): Observable<GetUserByEmailGrpcResponse>;
|
|
115
|
+
}
|
package/src/contracts/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
export interface GenerateTokensRequest {
|
|
4
|
+
userId: string;
|
|
5
|
+
email: string;
|
|
6
|
+
role: string;
|
|
7
|
+
scopes?: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TokensResponse {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
expiresIn: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ValidateTokenRequest {
|
|
17
|
+
token: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ValidateTokenResponse {
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
userId: string;
|
|
23
|
+
role: string;
|
|
24
|
+
scopes: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RefreshTokensRequest {
|
|
28
|
+
refreshToken: string;
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
ipAddress?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RevokeTokenRequest {
|
|
34
|
+
userId: string;
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface RevokeTokenResponse {
|
|
39
|
+
success: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ITokenService {
|
|
43
|
+
generateTokens(request: GenerateTokensRequest): Observable<TokensResponse>;
|
|
44
|
+
validateToken(request: ValidateTokenRequest): Observable<ValidateTokenResponse>;
|
|
45
|
+
refreshTokens(request: RefreshTokensRequest): Observable<TokensResponse>;
|
|
46
|
+
revokeToken(request: RevokeTokenRequest): Observable<RevokeTokenResponse>;
|
|
47
|
+
}
|
package/src/dto/auth.dto.ts
CHANGED
|
@@ -20,6 +20,10 @@ export class RegisterDto {
|
|
|
20
20
|
@IsString()
|
|
21
21
|
@IsOptional()
|
|
22
22
|
lastName?: string;
|
|
23
|
+
|
|
24
|
+
@IsString()
|
|
25
|
+
@IsOptional()
|
|
26
|
+
userId?: string;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export class LoginDto {
|
|
@@ -60,3 +64,30 @@ export interface UserProfileDto {
|
|
|
60
64
|
department: string;
|
|
61
65
|
emailVerified: boolean;
|
|
62
66
|
}
|
|
67
|
+
|
|
68
|
+
export class InviteRequestBody {
|
|
69
|
+
@IsEmail()
|
|
70
|
+
email!: string;
|
|
71
|
+
|
|
72
|
+
@IsEnum(UserRole)
|
|
73
|
+
role!: UserRole;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class RegisterByInviteBody extends RegisterDto {
|
|
77
|
+
@IsString()
|
|
78
|
+
token!: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class ResetPasswordRequestBody {
|
|
82
|
+
@IsEmail()
|
|
83
|
+
email!: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class ResetPasswordConfirmBody {
|
|
87
|
+
@IsString()
|
|
88
|
+
token!: string;
|
|
89
|
+
|
|
90
|
+
@IsString()
|
|
91
|
+
@MinLength(8)
|
|
92
|
+
newPassword!: string;
|
|
93
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IsString, IsOptional, IsNumber, IsDate } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
|
|
4
|
+
export class CreateCardDto {
|
|
5
|
+
@IsString()
|
|
6
|
+
cardNumber: string;
|
|
7
|
+
|
|
8
|
+
@IsOptional()
|
|
9
|
+
@IsString()
|
|
10
|
+
clientId?: string;
|
|
11
|
+
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsString()
|
|
14
|
+
accountId?: string;
|
|
15
|
+
|
|
16
|
+
@IsOptional()
|
|
17
|
+
@IsString()
|
|
18
|
+
cardType?: string;
|
|
19
|
+
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsString()
|
|
22
|
+
cardStatus?: string;
|
|
23
|
+
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@Type(() => Date)
|
|
26
|
+
@IsDate()
|
|
27
|
+
issuedAt?: Date;
|
|
28
|
+
|
|
29
|
+
@IsOptional()
|
|
30
|
+
@Type(() => Date)
|
|
31
|
+
@IsDate()
|
|
32
|
+
expiresAt?: Date;
|
|
33
|
+
|
|
34
|
+
@IsOptional()
|
|
35
|
+
@IsNumber()
|
|
36
|
+
balance?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class UpdateCardDto {
|
|
40
|
+
@IsOptional()
|
|
41
|
+
@IsString()
|
|
42
|
+
clientId?: string;
|
|
43
|
+
|
|
44
|
+
@IsOptional()
|
|
45
|
+
@IsString()
|
|
46
|
+
accountId?: string;
|
|
47
|
+
|
|
48
|
+
@IsOptional()
|
|
49
|
+
@IsString()
|
|
50
|
+
cardType?: string;
|
|
51
|
+
|
|
52
|
+
@IsOptional()
|
|
53
|
+
@IsString()
|
|
54
|
+
cardStatus?: string;
|
|
55
|
+
|
|
56
|
+
@IsOptional()
|
|
57
|
+
@Type(() => Date)
|
|
58
|
+
@IsDate()
|
|
59
|
+
expiresAt?: Date;
|
|
60
|
+
|
|
61
|
+
@IsOptional()
|
|
62
|
+
@IsNumber()
|
|
63
|
+
balance?: number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { IsString, IsOptional, IsBoolean, IsArray, ValidateNested, IsNumber, IsEnum, IsObject } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { RegisterDto } from './auth.dto';
|
|
4
|
+
|
|
5
|
+
export class CreateClientContactDto {
|
|
6
|
+
@IsString()
|
|
7
|
+
contactType: string;
|
|
8
|
+
|
|
9
|
+
@IsString()
|
|
10
|
+
value: string;
|
|
11
|
+
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsBoolean()
|
|
14
|
+
isPrimary?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class CreateClientDetailDto {
|
|
18
|
+
@IsString()
|
|
19
|
+
detailType: string;
|
|
20
|
+
|
|
21
|
+
@IsString()
|
|
22
|
+
value: string;
|
|
23
|
+
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsBoolean()
|
|
26
|
+
isActive?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class CreateClientDto {
|
|
30
|
+
@IsString()
|
|
31
|
+
clientNumber: string;
|
|
32
|
+
|
|
33
|
+
@IsOptional()
|
|
34
|
+
@IsString()
|
|
35
|
+
clientNumberFormatted?: string;
|
|
36
|
+
|
|
37
|
+
@IsString()
|
|
38
|
+
clientType: string;
|
|
39
|
+
|
|
40
|
+
@IsOptional()
|
|
41
|
+
@IsString()
|
|
42
|
+
shortName?: string;
|
|
43
|
+
|
|
44
|
+
@IsString()
|
|
45
|
+
fullName: string;
|
|
46
|
+
|
|
47
|
+
@IsOptional()
|
|
48
|
+
@IsBoolean()
|
|
49
|
+
isActive?: boolean;
|
|
50
|
+
|
|
51
|
+
@IsOptional()
|
|
52
|
+
@IsArray()
|
|
53
|
+
@ValidateNested({ each: true })
|
|
54
|
+
@Type(() => CreateClientContactDto)
|
|
55
|
+
contacts?: CreateClientContactDto[];
|
|
56
|
+
|
|
57
|
+
@IsOptional()
|
|
58
|
+
@IsArray()
|
|
59
|
+
@ValidateNested({ each: true })
|
|
60
|
+
@Type(() => CreateClientDetailDto)
|
|
61
|
+
details?: CreateClientDetailDto[];
|
|
62
|
+
|
|
63
|
+
@IsOptional()
|
|
64
|
+
@ValidateNested()
|
|
65
|
+
@Type(() => RegisterDto)
|
|
66
|
+
adminUser?: RegisterDto;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class UpdateClientDto {
|
|
70
|
+
@IsOptional()
|
|
71
|
+
@IsString()
|
|
72
|
+
clientNumber?: string;
|
|
73
|
+
|
|
74
|
+
@IsOptional()
|
|
75
|
+
@IsString()
|
|
76
|
+
clientNumberFormatted?: string;
|
|
77
|
+
|
|
78
|
+
@IsOptional()
|
|
79
|
+
@IsString()
|
|
80
|
+
clientType?: string;
|
|
81
|
+
|
|
82
|
+
@IsOptional()
|
|
83
|
+
@IsString()
|
|
84
|
+
shortName?: string;
|
|
85
|
+
|
|
86
|
+
@IsOptional()
|
|
87
|
+
@IsString()
|
|
88
|
+
fullName?: string;
|
|
89
|
+
|
|
90
|
+
@IsOptional()
|
|
91
|
+
@IsBoolean()
|
|
92
|
+
isActive?: boolean;
|
|
93
|
+
|
|
94
|
+
@IsOptional()
|
|
95
|
+
@IsArray()
|
|
96
|
+
@ValidateNested({ each: true })
|
|
97
|
+
@Type(() => CreateClientContactDto)
|
|
98
|
+
contacts?: CreateClientContactDto[];
|
|
99
|
+
|
|
100
|
+
@IsOptional()
|
|
101
|
+
@IsArray()
|
|
102
|
+
@ValidateNested({ each: true })
|
|
103
|
+
@Type(() => CreateClientDetailDto)
|
|
104
|
+
details?: CreateClientDetailDto[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class FindClientsQueryDto {
|
|
108
|
+
@IsOptional()
|
|
109
|
+
@IsString()
|
|
110
|
+
search?: string;
|
|
111
|
+
|
|
112
|
+
@IsOptional()
|
|
113
|
+
@IsString()
|
|
114
|
+
searchType?: string;
|
|
115
|
+
|
|
116
|
+
@IsOptional()
|
|
117
|
+
@IsString()
|
|
118
|
+
status?: string;
|
|
119
|
+
|
|
120
|
+
@IsOptional()
|
|
121
|
+
@Type(() => Number)
|
|
122
|
+
@IsNumber()
|
|
123
|
+
skip?: number;
|
|
124
|
+
|
|
125
|
+
@IsOptional()
|
|
126
|
+
@Type(() => Number)
|
|
127
|
+
@IsNumber()
|
|
128
|
+
take?: number;
|
|
129
|
+
|
|
130
|
+
@IsOptional()
|
|
131
|
+
@IsString()
|
|
132
|
+
sortBy?: string;
|
|
133
|
+
|
|
134
|
+
@IsOptional()
|
|
135
|
+
@IsString()
|
|
136
|
+
sortOrder?: 'asc' | 'desc';
|
|
137
|
+
}
|
package/src/dto/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IsString, IsOptional, IsBoolean, ValidateNested, IsObject } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { RegisterDto } from './auth.dto';
|
|
4
|
+
|
|
5
|
+
export class CreatePartnerDto {
|
|
6
|
+
@IsString()
|
|
7
|
+
name: string;
|
|
8
|
+
|
|
9
|
+
@IsString()
|
|
10
|
+
type: string;
|
|
11
|
+
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsBoolean()
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
|
|
16
|
+
@IsOptional()
|
|
17
|
+
@ValidateNested()
|
|
18
|
+
@IsObject()
|
|
19
|
+
@Type(() => RegisterDto)
|
|
20
|
+
adminUser?: RegisterDto;
|
|
21
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IsString, IsOptional, IsNumber, Min, IsUUID } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
|
|
4
|
+
export class CreateTransactionDto {
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsString()
|
|
7
|
+
externalId?: string;
|
|
8
|
+
|
|
9
|
+
@IsString()
|
|
10
|
+
cardId: string;
|
|
11
|
+
|
|
12
|
+
@IsNumber()
|
|
13
|
+
@Min(0)
|
|
14
|
+
amount: number;
|
|
15
|
+
|
|
16
|
+
@IsOptional()
|
|
17
|
+
@IsString()
|
|
18
|
+
currency?: string;
|
|
19
|
+
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsString()
|
|
22
|
+
description?: string;
|
|
23
|
+
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsString()
|
|
26
|
+
type?: string;
|
|
27
|
+
|
|
28
|
+
@IsOptional()
|
|
29
|
+
@IsString()
|
|
30
|
+
status?: string;
|
|
31
|
+
|
|
32
|
+
@IsOptional()
|
|
33
|
+
@IsUUID()
|
|
34
|
+
id?: string;
|
|
35
|
+
|
|
36
|
+
@IsOptional()
|
|
37
|
+
@Type(() => Date)
|
|
38
|
+
transactionDate?: Date;
|
|
39
|
+
|
|
40
|
+
@IsOptional()
|
|
41
|
+
metadata?: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class UpdateTransactionDto {
|
|
45
|
+
@IsOptional()
|
|
46
|
+
@IsString()
|
|
47
|
+
status?: string;
|
|
48
|
+
|
|
49
|
+
@IsOptional()
|
|
50
|
+
metadata?: any;
|
|
51
|
+
}
|
package/src/enums/error.enum.ts
CHANGED
package/src/enums/user.enum.ts
CHANGED
|
@@ -5,4 +5,24 @@ export enum UserRole {
|
|
|
5
5
|
ACCOUNTANT = 'ACCOUNTANT',
|
|
6
6
|
PARTNER = 'PARTNER',
|
|
7
7
|
CLIENT = 'CLIENT',
|
|
8
|
+
USER = 'USER',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum UserStatus {
|
|
12
|
+
ACTIVE = 'ACTIVE',
|
|
13
|
+
INACTIVE = 'INACTIVE',
|
|
14
|
+
PENDING = 'PENDING',
|
|
15
|
+
SUSPENDED = 'SUSPENDED',
|
|
16
|
+
BLOCKED = 'BLOCKED',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum UserScope {
|
|
20
|
+
READ = 'READ',
|
|
21
|
+
WRITE = 'WRITE',
|
|
22
|
+
DELETE = 'DELETE',
|
|
23
|
+
ADMIN = 'ADMIN',
|
|
24
|
+
PROFILE_READ = 'PROFILE_READ',
|
|
25
|
+
CARDS_READ = 'CARDS_READ',
|
|
26
|
+
TRANSACTIONS_READ = 'TRANSACTIONS_READ',
|
|
27
|
+
LOGS_READ = 'LOGS_READ',
|
|
8
28
|
}
|
package/src/errors/error-map.ts
CHANGED
|
@@ -92,4 +92,14 @@ export const ERROR_MAP: Record<ErrorCode, ErrorDetail> = {
|
|
|
92
92
|
statusCode: 422,
|
|
93
93
|
description: 'The provided data failed validation.',
|
|
94
94
|
},
|
|
95
|
+
[ErrorCode.AUTH_USER_BLOCKED]: {
|
|
96
|
+
message: 'User blocked',
|
|
97
|
+
statusCode: 403,
|
|
98
|
+
description: 'The user account has been blocked.',
|
|
99
|
+
},
|
|
100
|
+
[ErrorCode.INVALID_TOKEN]: {
|
|
101
|
+
message: 'Invalid token',
|
|
102
|
+
statusCode: 401,
|
|
103
|
+
description: 'The provided token is invalid.',
|
|
104
|
+
},
|
|
95
105
|
};
|
package/src/index.ts
CHANGED
|
@@ -5,11 +5,8 @@ export * from './contracts';
|
|
|
5
5
|
export * from './dto';
|
|
6
6
|
export * from './errors/app.error';
|
|
7
7
|
export * from './errors/error-map';
|
|
8
|
-
export * from './decorators
|
|
8
|
+
export * from './decorators';
|
|
9
9
|
export * from './utils/proto-path';
|
|
10
|
-
export * from './utils/logging-client';
|
|
11
|
-
export * from './config/base-config.service';
|
|
12
10
|
export * from './utils/user.utils';
|
|
13
|
-
export * from './utils/prometheus.utils';
|
|
14
11
|
export * from './utils/app.utils';
|
|
15
12
|
export * from './utils/health.utils';
|