@alacard-project/shared 1.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/constants/env.constants.d.ts +24 -0
- package/dist/constants/env.constants.js +28 -0
- package/dist/constants/env.constants.js.map +1 -0
- package/dist/constants/grpc.constants.d.ts +14 -0
- package/dist/constants/grpc.constants.js +18 -0
- package/dist/constants/grpc.constants.js.map +1 -0
- package/dist/constants/http.constants.d.ts +10 -0
- package/dist/constants/http.constants.js +14 -0
- package/dist/constants/http.constants.js.map +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +22 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/logging.constants.d.ts +24 -0
- package/dist/constants/logging.constants.js +28 -0
- package/dist/constants/logging.constants.js.map +1 -0
- package/dist/constants/services.constants.d.ts +6 -0
- package/dist/constants/services.constants.js +10 -0
- package/dist/constants/services.constants.js.map +1 -0
- package/dist/contracts/config.contract.d.ts +12 -0
- package/dist/contracts/config.contract.js +3 -0
- package/dist/contracts/config.contract.js.map +1 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +19 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/logging.contract.d.ts +101 -0
- package/dist/contracts/logging.contract.js +3 -0
- package/dist/contracts/logging.contract.js.map +1 -0
- package/dist/enums/environment.enum.d.ts +7 -0
- package/dist/enums/environment.enum.js +12 -0
- package/dist/enums/environment.enum.js.map +1 -0
- package/dist/enums/error-code.enum.d.ts +8 -0
- package/dist/enums/error-code.enum.js +13 -0
- package/dist/enums/error-code.enum.js.map +1 -0
- package/dist/enums/index.d.ts +5 -0
- package/dist/enums/index.js +22 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/log-level.enum.d.ts +7 -0
- package/dist/enums/log-level.enum.js +12 -0
- package/dist/enums/log-level.enum.js.map +1 -0
- package/dist/enums/notification-type.enum.d.ts +5 -0
- package/dist/enums/notification-type.enum.js +10 -0
- package/dist/enums/notification-type.enum.js.map +1 -0
- package/dist/enums/user-role.enum.d.ts +6 -0
- package/dist/enums/user-role.enum.js +11 -0
- package/dist/enums/user-role.enum.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/dto/log-filter.dto.d.ts +29 -0
- package/dist/logging/dto/log-filter.dto.js +146 -0
- package/dist/logging/dto/log-filter.dto.js.map +1 -0
- package/dist/logging/enums/log-level.enum.d.ts +7 -0
- package/dist/logging/enums/log-level.enum.js +12 -0
- package/dist/logging/enums/log-level.enum.js.map +1 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +18 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/auth.types.d.ts +9 -0
- package/dist/types/auth.types.js +3 -0
- package/dist/types/auth.types.js.map +1 -0
- package/dist/types/config.types.d.ts +26 -0
- package/dist/types/config.types.js +3 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/proto-path.d.ts +1 -0
- package/dist/utils/proto-path.js +11 -0
- package/dist/utils/proto-path.js.map +1 -0
- package/package.json +23 -0
- package/proto/auth.proto +109 -0
- package/proto/config.proto +39 -0
- package/proto/dbf.proto +183 -0
- package/proto/logging.proto +143 -0
- package/proto/token.proto +50 -0
- package/proto/user.proto +87 -0
- package/src/constants/env.constants.ts +25 -0
- package/src/constants/grpc.constants.ts +15 -0
- package/src/constants/http.constants.ts +11 -0
- package/src/constants/index.ts +5 -0
- package/src/constants/logging.constants.ts +26 -0
- package/src/constants/services.constants.ts +6 -0
- package/src/contracts/config.contract.ts +14 -0
- package/src/contracts/index.ts +2 -0
- package/src/contracts/logging.contract.ts +115 -0
- package/src/enums/environment.enum.ts +7 -0
- package/src/enums/error-code.enum.ts +8 -0
- package/src/enums/index.ts +5 -0
- package/src/enums/log-level.enum.ts +7 -0
- package/src/enums/notification-type.enum.ts +5 -0
- package/src/enums/user-role.enum.ts +6 -0
- package/src/index.ts +6 -0
- package/src/logging/dto/log-filter.dto.ts +101 -0
- package/src/logging/index.ts +1 -0
- package/src/types/auth.types.ts +9 -0
- package/src/types/config.types.ts +30 -0
- package/src/types/index.ts +3 -0
- package/src/utils/proto-path.ts +15 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface LogEventGrpcRequest {
|
|
2
|
+
serviceId: string;
|
|
3
|
+
serviceName: string;
|
|
4
|
+
level: string;
|
|
5
|
+
message: string;
|
|
6
|
+
metadata: string;
|
|
7
|
+
userId?: string;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface LogEventGrpcResponse {
|
|
12
|
+
success: boolean;
|
|
13
|
+
logId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LogUserActionGrpcRequest {
|
|
17
|
+
userId: string;
|
|
18
|
+
userName: string;
|
|
19
|
+
action: string;
|
|
20
|
+
resource: string;
|
|
21
|
+
details?: string;
|
|
22
|
+
ipAddress?: string;
|
|
23
|
+
userAgent?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface LogUserActionGrpcResponse {
|
|
27
|
+
success: boolean;
|
|
28
|
+
actionId: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UpdateServiceStatusGrpcRequest {
|
|
32
|
+
serviceName: string;
|
|
33
|
+
status: string;
|
|
34
|
+
version?: string;
|
|
35
|
+
uptime?: number;
|
|
36
|
+
metadata?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface UpdateServiceStatusGrpcResponse {
|
|
40
|
+
success: boolean;
|
|
41
|
+
statusId: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface GetServiceLogsGrpcRequest {
|
|
45
|
+
serviceName?: string;
|
|
46
|
+
level?: string;
|
|
47
|
+
userId?: string;
|
|
48
|
+
requestId?: string;
|
|
49
|
+
startDate?: string;
|
|
50
|
+
endDate?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
offset?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ServiceLogEntry {
|
|
56
|
+
id: string;
|
|
57
|
+
serviceId: string;
|
|
58
|
+
serviceName: string;
|
|
59
|
+
level: string;
|
|
60
|
+
message: string;
|
|
61
|
+
metadata: string;
|
|
62
|
+
timestamp: string;
|
|
63
|
+
userId?: string;
|
|
64
|
+
requestId?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface GetServiceLogsGrpcResponse {
|
|
68
|
+
logs: ServiceLogEntry[];
|
|
69
|
+
total: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GetServiceStatusGrpcRequest {
|
|
73
|
+
serviceName?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ServiceStatusEntry {
|
|
77
|
+
id: string;
|
|
78
|
+
serviceName: string;
|
|
79
|
+
status: string;
|
|
80
|
+
lastHeartbeat: string;
|
|
81
|
+
version?: string;
|
|
82
|
+
uptime?: number;
|
|
83
|
+
metadata?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface GetServiceStatusGrpcResponse {
|
|
87
|
+
statuses: ServiceStatusEntry[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface GetUserActionsGrpcRequest {
|
|
91
|
+
userId?: string;
|
|
92
|
+
action?: string;
|
|
93
|
+
resource?: string;
|
|
94
|
+
startDate?: string;
|
|
95
|
+
endDate?: string;
|
|
96
|
+
limit?: number;
|
|
97
|
+
offset?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface UserActionEntry {
|
|
101
|
+
id: string;
|
|
102
|
+
userId: string;
|
|
103
|
+
userName: string;
|
|
104
|
+
action: string;
|
|
105
|
+
resource: string;
|
|
106
|
+
details: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
ipAddress?: string;
|
|
109
|
+
userAgent?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface GetUserActionsGrpcResponse {
|
|
113
|
+
actions: UserActionEntry[];
|
|
114
|
+
total: number;
|
|
115
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { IsOptional, IsString, IsEnum, IsDateString, IsInt, Min, Max } from 'class-validator';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { LogLevel } from '../../enums';
|
|
4
|
+
|
|
5
|
+
export class LogFilterDto {
|
|
6
|
+
@IsOptional()
|
|
7
|
+
@IsDateString()
|
|
8
|
+
startDate?: string;
|
|
9
|
+
|
|
10
|
+
@IsOptional()
|
|
11
|
+
@IsDateString()
|
|
12
|
+
endDate?: string;
|
|
13
|
+
|
|
14
|
+
@IsOptional()
|
|
15
|
+
@IsString()
|
|
16
|
+
serviceName?: string;
|
|
17
|
+
|
|
18
|
+
@IsOptional()
|
|
19
|
+
@IsEnum(LogLevel)
|
|
20
|
+
level?: LogLevel;
|
|
21
|
+
|
|
22
|
+
@IsOptional()
|
|
23
|
+
@IsString()
|
|
24
|
+
userId?: string;
|
|
25
|
+
|
|
26
|
+
@IsOptional()
|
|
27
|
+
@IsString()
|
|
28
|
+
requestId?: string;
|
|
29
|
+
|
|
30
|
+
@IsOptional()
|
|
31
|
+
@Type(() => Number)
|
|
32
|
+
@IsInt()
|
|
33
|
+
@Min(1)
|
|
34
|
+
page?: number = 1;
|
|
35
|
+
|
|
36
|
+
@IsOptional()
|
|
37
|
+
@Type(() => Number)
|
|
38
|
+
@IsInt()
|
|
39
|
+
@Min(1)
|
|
40
|
+
@Max(100)
|
|
41
|
+
pageSize?: number = 20;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class LogCleanupDto {
|
|
45
|
+
@IsDateString()
|
|
46
|
+
startDate: string;
|
|
47
|
+
|
|
48
|
+
@IsDateString()
|
|
49
|
+
endDate: string;
|
|
50
|
+
|
|
51
|
+
@IsOptional()
|
|
52
|
+
@IsString()
|
|
53
|
+
serviceName?: string;
|
|
54
|
+
|
|
55
|
+
@IsOptional()
|
|
56
|
+
@IsEnum(LogLevel)
|
|
57
|
+
level?: LogLevel;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class RetentionPeriodDto {
|
|
61
|
+
@Type(() => Number)
|
|
62
|
+
@IsInt()
|
|
63
|
+
@Min(1)
|
|
64
|
+
@Max(365)
|
|
65
|
+
retentionDays: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class UserActionFilterDto {
|
|
69
|
+
@IsOptional()
|
|
70
|
+
@IsDateString()
|
|
71
|
+
startDate?: string;
|
|
72
|
+
|
|
73
|
+
@IsOptional()
|
|
74
|
+
@IsDateString()
|
|
75
|
+
endDate?: string;
|
|
76
|
+
|
|
77
|
+
@IsOptional()
|
|
78
|
+
@IsString()
|
|
79
|
+
userId?: string;
|
|
80
|
+
|
|
81
|
+
@IsOptional()
|
|
82
|
+
@IsString()
|
|
83
|
+
action?: string;
|
|
84
|
+
|
|
85
|
+
@IsOptional()
|
|
86
|
+
@IsString()
|
|
87
|
+
resource?: string;
|
|
88
|
+
|
|
89
|
+
@IsOptional()
|
|
90
|
+
@Type(() => Number)
|
|
91
|
+
@IsInt()
|
|
92
|
+
@Min(1)
|
|
93
|
+
page?: number = 1;
|
|
94
|
+
|
|
95
|
+
@IsOptional()
|
|
96
|
+
@Type(() => Number)
|
|
97
|
+
@IsInt()
|
|
98
|
+
@Min(1)
|
|
99
|
+
@Max(100)
|
|
100
|
+
pageSize?: number = 20;
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dto/log-filter.dto';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface IBaseConfig {
|
|
2
|
+
environment: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface DbConfig {
|
|
6
|
+
url: string;
|
|
7
|
+
poolSize?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface RedisConfig {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
password?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BrokerConfig {
|
|
17
|
+
brokers: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AppConfig {
|
|
21
|
+
port: number;
|
|
22
|
+
host?: string;
|
|
23
|
+
serviceName: string;
|
|
24
|
+
environment?: string;
|
|
25
|
+
version?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
databaseUrl?: string;
|
|
28
|
+
rabbitMqUrl?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the absolute path to a proto file.
|
|
5
|
+
* Assumes protos are in the 'proto' directory at the shared library root.
|
|
6
|
+
*/
|
|
7
|
+
export function getProtoPath(serviceName: string): string {
|
|
8
|
+
// In Docker/Production, this might be absolute
|
|
9
|
+
if (process.env.PROTO_PATH_OVERRIDE) {
|
|
10
|
+
return join(process.env.PROTO_PATH_OVERRIDE, `${serviceName}.proto`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Default path relative to the shared/proto directory
|
|
14
|
+
return join(__dirname, '../../proto', `${serviceName}.proto`);
|
|
15
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "es2021",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./src",
|
|
13
|
+
"incremental": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"strict": false
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"src/**/*"
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
"node_modules",
|
|
22
|
+
"dist"
|
|
23
|
+
]
|
|
24
|
+
}
|