@alacard-project/shared 1.0.10 → 1.1.1

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 (134) hide show
  1. package/README.md +24 -0
  2. package/dist/constants/auth-config.constants.d.ts +7 -0
  3. package/dist/constants/auth-config.constants.js +8 -1
  4. package/dist/constants/auth-config.constants.js.map +1 -1
  5. package/dist/constants/auth.constants.d.ts +25 -0
  6. package/dist/constants/auth.constants.js +15 -1
  7. package/dist/constants/auth.constants.js.map +1 -1
  8. package/dist/constants/index.d.ts +1 -0
  9. package/dist/constants/index.js +1 -0
  10. package/dist/constants/index.js.map +1 -1
  11. package/dist/constants/queue.constants.d.ts +8 -0
  12. package/dist/constants/queue.constants.js +12 -0
  13. package/dist/constants/queue.constants.js.map +1 -0
  14. package/dist/contracts/auth.contract.d.ts +12 -9
  15. package/dist/dto/account.dto.d.ts +10 -0
  16. package/dist/dto/account.dto.js +49 -0
  17. package/dist/dto/account.dto.js.map +1 -0
  18. package/dist/dto/auth.dto.d.ts +43 -0
  19. package/dist/dto/auth.dto.js +136 -1
  20. package/dist/dto/auth.dto.js.map +1 -1
  21. package/dist/dto/card.dto.js.map +1 -1
  22. package/dist/dto/client.dto.js.map +1 -1
  23. package/dist/dto/index.d.ts +2 -0
  24. package/dist/dto/index.js +2 -0
  25. package/dist/dto/index.js.map +1 -1
  26. package/dist/dto/logging.dto.js.map +1 -1
  27. package/dist/dto/partner.dto.d.ts +1 -1
  28. package/dist/dto/partner.dto.js +7 -9
  29. package/dist/dto/partner.dto.js.map +1 -1
  30. package/dist/dto/transaction.dto.d.ts +2 -1
  31. package/dist/dto/transaction.dto.js.map +1 -1
  32. package/dist/dto/user.dto.d.ts +11 -0
  33. package/dist/dto/user.dto.js +45 -0
  34. package/dist/dto/user.dto.js.map +1 -0
  35. package/dist/enums/auth.enum.d.ts +12 -0
  36. package/dist/enums/auth.enum.js +18 -0
  37. package/dist/enums/auth.enum.js.map +1 -0
  38. package/dist/enums/iam.enum.d.ts +14 -0
  39. package/dist/enums/iam.enum.js +21 -0
  40. package/dist/enums/iam.enum.js.map +1 -0
  41. package/dist/enums/index.d.ts +2 -0
  42. package/dist/enums/index.js +2 -0
  43. package/dist/enums/index.js.map +1 -1
  44. package/dist/errors/app.error.d.ts +1 -1
  45. package/dist/filters/http-exception.filter.d.ts +5 -0
  46. package/dist/filters/http-exception.filter.js +48 -0
  47. package/dist/filters/http-exception.filter.js.map +1 -0
  48. package/dist/filters/index.d.ts +1 -0
  49. package/dist/filters/index.js +18 -0
  50. package/dist/filters/index.js.map +1 -0
  51. package/dist/index.d.ts +5 -0
  52. package/dist/index.js +5 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/interceptors/index.d.ts +2 -0
  55. package/dist/interceptors/index.js +19 -0
  56. package/dist/interceptors/index.js.map +1 -0
  57. package/dist/interceptors/logging.interceptor.d.ts +6 -0
  58. package/dist/interceptors/logging.interceptor.js +41 -0
  59. package/dist/interceptors/logging.interceptor.js.map +1 -0
  60. package/dist/interceptors/transform.interceptor.d.ts +9 -0
  61. package/dist/interceptors/transform.interceptor.js +24 -0
  62. package/dist/interceptors/transform.interceptor.js.map +1 -0
  63. package/dist/observability/index.d.ts +2 -0
  64. package/dist/observability/index.js +19 -0
  65. package/dist/observability/index.js.map +1 -0
  66. package/dist/observability/metrics/metrics.module.d.ts +2 -0
  67. package/dist/observability/metrics/metrics.module.js +28 -0
  68. package/dist/observability/metrics/metrics.module.js.map +1 -0
  69. package/dist/observability/tracing.d.ts +1 -0
  70. package/dist/observability/tracing.js +28 -0
  71. package/dist/observability/tracing.js.map +1 -0
  72. package/dist/resilience/circuit-breaker.service.d.ts +7 -0
  73. package/dist/resilience/circuit-breaker.service.js +45 -0
  74. package/dist/resilience/circuit-breaker.service.js.map +1 -0
  75. package/dist/resilience/resilience.module.d.ts +2 -0
  76. package/dist/resilience/resilience.module.js +22 -0
  77. package/dist/resilience/resilience.module.js.map +1 -0
  78. package/dist/types/auth.types.d.ts +22 -4
  79. package/dist/types/common.types.d.ts +11 -0
  80. package/dist/types/common.types.js +3 -0
  81. package/dist/types/common.types.js.map +1 -0
  82. package/dist/types/iam.types.d.ts +46 -0
  83. package/dist/types/iam.types.js +3 -0
  84. package/dist/types/iam.types.js.map +1 -0
  85. package/dist/types/index.d.ts +2 -0
  86. package/dist/types/index.js +2 -0
  87. package/dist/types/index.js.map +1 -1
  88. package/dist/types/monitoring.types.d.ts +2 -1
  89. package/dist/types/user.types.d.ts +7 -3
  90. package/dist/utils/app.utils.d.ts +1 -0
  91. package/dist/utils/app.utils.js +7 -1
  92. package/dist/utils/app.utils.js.map +1 -1
  93. package/dist/utils/health.utils.d.ts +6 -2
  94. package/dist/utils/health.utils.js +2 -1
  95. package/dist/utils/health.utils.js.map +1 -1
  96. package/package.json +27 -14
  97. package/proto/dbf.proto +1 -1
  98. package/src/constants/auth-config.constants.ts +7 -0
  99. package/src/constants/auth.constants.ts +16 -0
  100. package/src/constants/index.ts +1 -0
  101. package/src/constants/queue.constants.ts +8 -0
  102. package/src/contracts/auth.contract.ts +10 -9
  103. package/src/dto/account.dto.ts +28 -0
  104. package/src/dto/auth.dto.ts +126 -0
  105. package/src/dto/card.dto.ts +1 -1
  106. package/src/dto/client.dto.ts +7 -7
  107. package/src/dto/index.ts +2 -0
  108. package/src/dto/logging.dto.ts +3 -3
  109. package/src/dto/partner.dto.ts +3 -6
  110. package/src/dto/transaction.dto.ts +4 -3
  111. package/src/dto/user.dto.ts +28 -0
  112. package/src/enums/auth.enum.ts +13 -0
  113. package/src/enums/iam.enum.ts +28 -0
  114. package/src/enums/index.ts +2 -0
  115. package/src/filters/http-exception.filter.ts +49 -0
  116. package/src/filters/index.ts +2 -0
  117. package/src/index.ts +5 -0
  118. package/src/interceptors/index.ts +3 -0
  119. package/src/interceptors/logging.interceptor.ts +37 -0
  120. package/src/interceptors/transform.interceptor.ts +21 -0
  121. package/src/observability/index.ts +3 -0
  122. package/src/observability/metrics/metrics.module.ts +16 -0
  123. package/src/observability/tracing.ts +33 -0
  124. package/src/resilience/circuit-breaker.service.ts +46 -0
  125. package/src/resilience/resilience.module.ts +9 -0
  126. package/src/types/auth.types.ts +23 -4
  127. package/src/types/common.types.ts +18 -0
  128. package/src/types/iam.types.ts +78 -0
  129. package/src/types/index.ts +2 -0
  130. package/src/types/monitoring.types.ts +2 -4
  131. package/src/types/user.types.ts +3 -3
  132. package/src/utils/app.utils.ts +9 -0
  133. package/src/utils/health.utils.ts +11 -4
  134. package/tsconfig.json +5 -1
@@ -0,0 +1,78 @@
1
+ import { SubjectType, IdentityStatus, UserRole, IdentifierType } from '../enums';
2
+ import { JsonValue } from './common.types';
3
+
4
+ /**
5
+ * Identity
6
+ * Core identity model for IAM service
7
+ */
8
+ export interface Identity {
9
+ identityId: string;
10
+ subjectType: SubjectType;
11
+ role: UserRole;
12
+ status: IdentityStatus;
13
+ createdAt?: Date;
14
+ updatedAt?: Date;
15
+ }
16
+
17
+ /**
18
+ * Identity Attributes
19
+ * ABAC attributes for fine-grained access control
20
+ */
21
+ export interface IdentityAttributes {
22
+ department?: string;
23
+ companyId?: string;
24
+ permissions: string[];
25
+ metadata?: Record<string, JsonValue>;
26
+ }
27
+
28
+ /**
29
+ * Policy Check Request
30
+ * Request structure for policy engine checks
31
+ */
32
+ export interface PolicyCheckRequest {
33
+ identityId: string;
34
+ resource: string;
35
+ action: string;
36
+ context?: Record<string, JsonValue>;
37
+ }
38
+
39
+ /**
40
+ * Policy Check Response
41
+ */
42
+ export interface PolicyCheckResponse {
43
+ allowed: boolean;
44
+ reason?: string;
45
+ }
46
+
47
+ /**
48
+ * Ownership Check Request
49
+ */
50
+ export interface OwnershipCheckRequest {
51
+ identityId: string;
52
+ resourceId: string;
53
+ resourceType: string;
54
+ }
55
+
56
+ /**
57
+ * Scope Check Request
58
+ */
59
+ export interface ScopeCheckRequest {
60
+ identityId: string;
61
+ scope: string;
62
+ context?: Record<string, JsonValue>;
63
+ }
64
+
65
+ /**
66
+ * Credential Model
67
+ * Authentication credential structure
68
+ */
69
+ export interface Credential {
70
+ id: string;
71
+ identityId: string;
72
+ identifierType: IdentifierType;
73
+ identifierValue: string;
74
+ passwordHash: string;
75
+ status: string;
76
+ createdAt?: Date;
77
+ updatedAt?: Date;
78
+ }
@@ -1,4 +1,6 @@
1
1
  export * from './config.types';
2
2
  export * from './auth.types';
3
+ export * from './iam.types';
3
4
  export * from './user.types';
5
+ export * from './common.types';
4
6
  export * from './monitoring.types';
@@ -1,11 +1,9 @@
1
- /**
2
- * Prometheus Metrics Types
3
- */
1
+ import { MetricType } from './common.types';
4
2
 
5
3
  export interface PrometheusMetric {
6
4
  name: string;
7
5
  help: string;
8
- type: 'counter' | 'gauge' | 'histogram' | 'summary';
6
+ type: MetricType;
9
7
  labelNames?: string[];
10
8
  }
11
9
 
@@ -5,7 +5,7 @@ import { GetUserByIdGrpcRequest, GetUserByEmailGrpcRequest } from '../contracts/
5
5
  export interface IUserService {
6
6
  getUserById(data: GetUserByIdGrpcRequest): Observable<UserResponse>;
7
7
  getUserByEmail(data: GetUserByEmailGrpcRequest): Observable<UserResponse>;
8
- createUser(data: any): Observable<UserResponse>;
9
- updateUser(data: any): Observable<UserResponse>;
10
- deleteUser(data: any): Observable<any>;
8
+ createUser(data: unknown): Observable<UserResponse>;
9
+ updateUser(data: unknown): Observable<UserResponse>;
10
+ deleteUser(data: { id: string }): Observable<{ success: boolean }>;
11
11
  }
@@ -7,6 +7,7 @@ export interface AppSetupOptions {
7
7
  apiPrefix?: string;
8
8
  helmet?: boolean;
9
9
  validation?: boolean;
10
+ shutdownHooks?: boolean;
10
11
  }
11
12
 
12
13
  export function setupStandardApp(
@@ -18,8 +19,13 @@ export function setupStandardApp(
18
19
  apiPrefix = API_PREFIX.V1,
19
20
  helmet: useHelmet = true,
20
21
  validation = true,
22
+ shutdownHooks = true,
21
23
  } = options;
22
24
 
25
+ if (shutdownHooks) {
26
+ app.enableShutdownHooks();
27
+ }
28
+
23
29
  app.enableCors({
24
30
  origin: corsOrigins,
25
31
  credentials: true,
@@ -37,6 +43,9 @@ export function setupStandardApp(
37
43
  whitelist: true,
38
44
  forbidNonWhitelisted: true,
39
45
  transform: true,
46
+ transformOptions: {
47
+ enableImplicitConversion: true,
48
+ },
40
49
  })
41
50
  );
42
51
  }
@@ -1,17 +1,24 @@
1
+ import { JsonValue } from '../types/common.types';
2
+
1
3
  export type HealthCheckStatus = 'up' | 'down';
2
4
 
3
5
  export interface ComponentHealth {
4
6
  status: HealthCheckStatus;
5
- [key: string]: any;
7
+ [key: string]: JsonValue;
8
+ }
9
+
10
+ export interface PrismaLike {
11
+ $queryRaw: (query: TemplateStringsArray, ...values: unknown[]) => Promise<unknown>;
6
12
  }
7
13
 
8
- export const createPrismaHealthCheck = (prisma: any) => {
14
+ export const createPrismaHealthCheck = (prisma: PrismaLike) => {
9
15
  return async (): Promise<ComponentHealth> => {
10
16
  try {
11
17
  await prisma.$queryRaw`SELECT 1`;
12
18
  return { status: 'up' };
13
- } catch (e: any) {
14
- return { status: 'down', error: e.message };
19
+ } catch (e: unknown) {
20
+ const message = e instanceof Error ? e.message : 'Unknown error';
21
+ return { status: 'down', error: message };
15
22
  }
16
23
  };
17
24
  };
package/tsconfig.json CHANGED
@@ -12,7 +12,11 @@
12
12
  "baseUrl": "./src",
13
13
  "incremental": true,
14
14
  "skipLibCheck": true,
15
- "strict": false
15
+ "strict": true,
16
+ "noImplicitAny": true,
17
+ "strictNullChecks": true,
18
+ "strictPropertyInitialization": false,
19
+ "forceConsistentCasingInFileNames": true
16
20
  },
17
21
  "include": [
18
22
  "src/**/*"