@heavybit/pendoadmin-shared-lib 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.
Files changed (132) hide show
  1. package/dist/common/index.d.ts +6 -0
  2. package/dist/common/index.d.ts.map +1 -0
  3. package/dist/common/index.js +6 -0
  4. package/dist/common/index.js.map +1 -0
  5. package/dist/common/jwt.utils.d.ts +7 -0
  6. package/dist/common/jwt.utils.d.ts.map +1 -0
  7. package/dist/common/jwt.utils.js +31 -0
  8. package/dist/common/jwt.utils.js.map +1 -0
  9. package/dist/common/password.utils.d.ts +4 -0
  10. package/dist/common/password.utils.d.ts.map +1 -0
  11. package/dist/common/password.utils.js +17 -0
  12. package/dist/common/password.utils.js.map +1 -0
  13. package/dist/common/phone.utils.d.ts +4 -0
  14. package/dist/common/phone.utils.d.ts.map +1 -0
  15. package/dist/common/phone.utils.js +36 -0
  16. package/dist/common/phone.utils.js.map +1 -0
  17. package/dist/common/response.utils.d.ts +6 -0
  18. package/dist/common/response.utils.d.ts.map +1 -0
  19. package/dist/common/response.utils.js +33 -0
  20. package/dist/common/response.utils.js.map +1 -0
  21. package/dist/common/uuid.utils.d.ts +5 -0
  22. package/dist/common/uuid.utils.d.ts.map +1 -0
  23. package/dist/common/uuid.utils.js +10 -0
  24. package/dist/common/uuid.utils.js.map +1 -0
  25. package/dist/config/index.d.ts +95 -0
  26. package/dist/config/index.d.ts.map +1 -0
  27. package/dist/config/index.js +71 -0
  28. package/dist/config/index.js.map +1 -0
  29. package/dist/database/index.d.ts +25 -0
  30. package/dist/database/index.d.ts.map +1 -0
  31. package/dist/database/index.js +62 -0
  32. package/dist/database/index.js.map +1 -0
  33. package/dist/express/auth.middleware.d.ts +20 -0
  34. package/dist/express/auth.middleware.d.ts.map +1 -0
  35. package/dist/express/auth.middleware.js +83 -0
  36. package/dist/express/auth.middleware.js.map +1 -0
  37. package/dist/express/correlation.middleware.d.ts +6 -0
  38. package/dist/express/correlation.middleware.d.ts.map +1 -0
  39. package/dist/express/correlation.middleware.js +15 -0
  40. package/dist/express/correlation.middleware.js.map +1 -0
  41. package/dist/express/error-handler.d.ts +8 -0
  42. package/dist/express/error-handler.d.ts.map +1 -0
  43. package/dist/express/error-handler.js +18 -0
  44. package/dist/express/error-handler.js.map +1 -0
  45. package/dist/express/index.d.ts +6 -0
  46. package/dist/express/index.d.ts.map +1 -0
  47. package/dist/express/index.js +6 -0
  48. package/dist/express/index.js.map +1 -0
  49. package/dist/express/permission.guard.d.ts +14 -0
  50. package/dist/express/permission.guard.d.ts.map +1 -0
  51. package/dist/express/permission.guard.js +66 -0
  52. package/dist/express/permission.guard.js.map +1 -0
  53. package/dist/express/validation.middleware.d.ts +14 -0
  54. package/dist/express/validation.middleware.d.ts.map +1 -0
  55. package/dist/express/validation.middleware.js +80 -0
  56. package/dist/express/validation.middleware.js.map +1 -0
  57. package/dist/index.d.ts +9 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +17 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/logging/index.d.ts +4 -0
  62. package/dist/logging/index.d.ts.map +1 -0
  63. package/dist/logging/index.js +24 -0
  64. package/dist/logging/index.js.map +1 -0
  65. package/dist/messaging/index.d.ts +58 -0
  66. package/dist/messaging/index.d.ts.map +1 -0
  67. package/dist/messaging/index.js +132 -0
  68. package/dist/messaging/index.js.map +1 -0
  69. package/dist/nestjs/auth.guard.d.ts +12 -0
  70. package/dist/nestjs/auth.guard.d.ts.map +1 -0
  71. package/dist/nestjs/auth.guard.js +75 -0
  72. package/dist/nestjs/auth.guard.js.map +1 -0
  73. package/dist/nestjs/correlation.interceptor.d.ts +9 -0
  74. package/dist/nestjs/correlation.interceptor.d.ts.map +1 -0
  75. package/dist/nestjs/correlation.interceptor.js +29 -0
  76. package/dist/nestjs/correlation.interceptor.js.map +1 -0
  77. package/dist/nestjs/exception.filter.d.ts +8 -0
  78. package/dist/nestjs/exception.filter.d.ts.map +1 -0
  79. package/dist/nestjs/exception.filter.js +54 -0
  80. package/dist/nestjs/exception.filter.js.map +1 -0
  81. package/dist/nestjs/index.d.ts +7 -0
  82. package/dist/nestjs/index.d.ts.map +1 -0
  83. package/dist/nestjs/index.js +7 -0
  84. package/dist/nestjs/index.js.map +1 -0
  85. package/dist/nestjs/permission.decorator.d.ts +22 -0
  86. package/dist/nestjs/permission.decorator.d.ts.map +1 -0
  87. package/dist/nestjs/permission.decorator.js +30 -0
  88. package/dist/nestjs/permission.decorator.js.map +1 -0
  89. package/dist/nestjs/permission.guard.d.ts +12 -0
  90. package/dist/nestjs/permission.guard.d.ts.map +1 -0
  91. package/dist/nestjs/permission.guard.js +66 -0
  92. package/dist/nestjs/permission.guard.js.map +1 -0
  93. package/dist/nestjs/user.decorator.d.ts +12 -0
  94. package/dist/nestjs/user.decorator.d.ts.map +1 -0
  95. package/dist/nestjs/user.decorator.js +16 -0
  96. package/dist/nestjs/user.decorator.js.map +1 -0
  97. package/dist/types/index.d.ts +193 -0
  98. package/dist/types/index.d.ts.map +1 -0
  99. package/dist/types/index.js +17 -0
  100. package/dist/types/index.js.map +1 -0
  101. package/dist/validation/index.d.ts +32 -0
  102. package/dist/validation/index.d.ts.map +1 -0
  103. package/dist/validation/index.js +21 -0
  104. package/dist/validation/index.js.map +1 -0
  105. package/package.json +100 -0
  106. package/src/common/index.ts +5 -0
  107. package/src/common/jwt.utils.ts +43 -0
  108. package/src/common/password.utils.ts +20 -0
  109. package/src/common/phone.utils.ts +36 -0
  110. package/src/common/response.utils.ts +48 -0
  111. package/src/common/uuid.utils.ts +11 -0
  112. package/src/config/index.ts +73 -0
  113. package/src/database/index.ts +77 -0
  114. package/src/express/auth.middleware.ts +93 -0
  115. package/src/express/correlation.middleware.ts +16 -0
  116. package/src/express/error-handler.ts +28 -0
  117. package/src/express/index.ts +5 -0
  118. package/src/express/permission.guard.ts +72 -0
  119. package/src/express/validation.middleware.ts +76 -0
  120. package/src/index.ts +23 -0
  121. package/src/logging/index.ts +31 -0
  122. package/src/messaging/index.ts +161 -0
  123. package/src/nestjs/auth.guard.ts +69 -0
  124. package/src/nestjs/correlation.interceptor.ts +30 -0
  125. package/src/nestjs/exception.filter.ts +53 -0
  126. package/src/nestjs/index.ts +11 -0
  127. package/src/nestjs/permission.decorator.ts +36 -0
  128. package/src/nestjs/permission.guard.ts +76 -0
  129. package/src/nestjs/user.decorator.ts +19 -0
  130. package/src/types/index.ts +239 -0
  131. package/src/validation/index.ts +26 -0
  132. package/tsconfig.json +22 -0
@@ -0,0 +1,75 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Injectable, UnauthorizedException, } from '@nestjs/common';
11
+ import { Reflector } from '@nestjs/core';
12
+ import { verifyToken } from '../common/jwt.utils.js';
13
+ import { GATEWAY_HEADERS } from '../types/index.js';
14
+ export const IS_PUBLIC_KEY = 'isPublic';
15
+ /**
16
+ * NestJS Guard: validates JWT or trusts gateway-injected headers.
17
+ */
18
+ let AuthGuard = class AuthGuard {
19
+ reflector;
20
+ constructor(reflector) {
21
+ this.reflector = reflector;
22
+ }
23
+ async canActivate(context) {
24
+ const isPublic = this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [
25
+ context.getHandler(),
26
+ context.getClass(),
27
+ ]);
28
+ if (isPublic)
29
+ return true;
30
+ const request = context.switchToHttp().getRequest();
31
+ // Trust gateway-injected headers first
32
+ const gatewayUserId = request.headers[GATEWAY_HEADERS.USER_ID];
33
+ if (gatewayUserId) {
34
+ const permissions = request.headers[GATEWAY_HEADERS.USER_PERMISSIONS];
35
+ request.user = {
36
+ id: gatewayUserId,
37
+ companyId: request.headers[GATEWAY_HEADERS.COMPANY_ID] || undefined,
38
+ email: request.headers[GATEWAY_HEADERS.USER_EMAIL] || undefined,
39
+ roles: request.headers[GATEWAY_HEADERS.USER_ROLES]
40
+ ? request.headers[GATEWAY_HEADERS.USER_ROLES].split(',')
41
+ : [],
42
+ permissions: permissions ? permissions.split(',') : [],
43
+ isSuperAdmin: request.headers[GATEWAY_HEADERS.IS_SUPERADMIN] === 'true',
44
+ };
45
+ return true;
46
+ }
47
+ // Fallback to direct JWT validation
48
+ const authHeader = request.headers.authorization;
49
+ if (!authHeader?.startsWith('Bearer ')) {
50
+ throw new UnauthorizedException('Missing authentication token');
51
+ }
52
+ try {
53
+ const token = authHeader.slice(7);
54
+ const payload = verifyToken(token, process.env.JWT_SECRET);
55
+ request.user = {
56
+ id: payload.sub,
57
+ companyId: payload.companyId,
58
+ email: payload.email,
59
+ roles: payload.roles || [],
60
+ permissions: payload.permissions || [],
61
+ isSuperAdmin: payload.isSuperAdmin || false,
62
+ };
63
+ return true;
64
+ }
65
+ catch {
66
+ throw new UnauthorizedException('Invalid or expired token');
67
+ }
68
+ }
69
+ };
70
+ AuthGuard = __decorate([
71
+ Injectable(),
72
+ __metadata("design:paramtypes", [Reflector])
73
+ ], AuthGuard);
74
+ export { AuthGuard };
75
+ //# sourceMappingURL=auth.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/nestjs/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,UAAU,EAGV,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE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CAAC,CAAC,CAAC,CAAC,EAAE;gBAClE,YAAY,EACV,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,MAAM;aAC/C,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QAED,oCAAoC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;QACjD,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,qBAAqB,CAAC,8BAA8B,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,UAAW,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,GAAG;gBACb,EAAE,EAAE,OAAO,CAAC,GAAG;gBACf,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;gBAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;gBACtC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;aAC/B,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF,CAAA;AApDY,SAAS;IADrB,UAAU,EAAE;qCAEoB,SAAS;GAD7B,SAAS,CAoDrB"}
@@ -0,0 +1,9 @@
1
+ import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ /**
4
+ * NestJS Interceptor: propagates or generates x-correlation-id header.
5
+ */
6
+ export declare class CorrelationInterceptor implements NestInterceptor {
7
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
8
+ }
9
+ //# sourceMappingURL=correlation.interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlation.interceptor.d.ts","sourceRoot":"","sources":["../../src/nestjs/correlation.interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAO,MAAM,MAAM,CAAC;AAGvC;;GAEG;AACH,qBACa,sBAAuB,YAAW,eAAe;IAC5D,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC;CAezE"}
@@ -0,0 +1,29 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Injectable, } from '@nestjs/common';
8
+ import { tap } from 'rxjs';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ /**
11
+ * NestJS Interceptor: propagates or generates x-correlation-id header.
12
+ */
13
+ let CorrelationInterceptor = class CorrelationInterceptor {
14
+ intercept(context, next) {
15
+ const request = context.switchToHttp().getRequest();
16
+ const response = context.switchToHttp().getResponse();
17
+ const correlationId = request.headers['x-correlation-id'] || uuidv4();
18
+ request.correlationId = correlationId;
19
+ response.setHeader('x-correlation-id', correlationId);
20
+ return next.handle().pipe(tap(() => {
21
+ // correlation id already set on response
22
+ }));
23
+ }
24
+ };
25
+ CorrelationInterceptor = __decorate([
26
+ Injectable()
27
+ ], CorrelationInterceptor);
28
+ export { CorrelationInterceptor };
29
+ //# sourceMappingURL=correlation.interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlation.interceptor.js","sourceRoot":"","sources":["../../src/nestjs/correlation.interceptor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,UAAU,GAIX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAc,GAAG,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;GAEG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;QAEtD,MAAM,aAAa,GACjB,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,MAAM,EAAE,CAAC;QAClD,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;QACtC,QAAQ,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,GAAG,CAAC,GAAG,EAAE;YACP,yCAAyC;QAC3C,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,sBAAsB;IADlC,UAAU,EAAE;GACA,sBAAsB,CAgBlC"}
@@ -0,0 +1,8 @@
1
+ import { ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ /**
3
+ * NestJS Exception Filter: standardises error responses.
4
+ */
5
+ export declare class GlobalExceptionFilter implements ExceptionFilter {
6
+ catch(exception: unknown, host: ArgumentsHost): void;
7
+ }
8
+ //# sourceMappingURL=exception.filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.filter.d.ts","sourceRoot":"","sources":["../../src/nestjs/exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,aAAa,EAGd,MAAM,gBAAgB,CAAC;AAKxB;;GAEG;AACH,qBACa,qBAAsB,YAAW,eAAe;IAC3D,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa;CAoC9C"}
@@ -0,0 +1,54 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Catch, HttpException, HttpStatus, } from '@nestjs/common';
8
+ import { createLogger } from '../logging/index.js';
9
+ const logger = createLogger('exception-filter');
10
+ /**
11
+ * NestJS Exception Filter: standardises error responses.
12
+ */
13
+ let GlobalExceptionFilter = class GlobalExceptionFilter {
14
+ catch(exception, host) {
15
+ const ctx = host.switchToHttp();
16
+ const response = ctx.getResponse();
17
+ const request = ctx.getRequest();
18
+ let status = HttpStatus.INTERNAL_SERVER_ERROR;
19
+ let message = 'Internal server error';
20
+ let errors = undefined;
21
+ if (exception instanceof HttpException) {
22
+ status = exception.getStatus();
23
+ const exResponse = exception.getResponse();
24
+ if (typeof exResponse === 'string') {
25
+ message = exResponse;
26
+ }
27
+ else if (typeof exResponse === 'object') {
28
+ message = exResponse.message || message;
29
+ errors = exResponse.errors;
30
+ }
31
+ }
32
+ else if (exception instanceof Error) {
33
+ message = exception.message;
34
+ logger.error('Unhandled exception', {
35
+ error: exception.message,
36
+ stack: exception.stack,
37
+ path: request.url,
38
+ });
39
+ }
40
+ response.status(status).json({
41
+ success: false,
42
+ message,
43
+ ...(errors ? { errors } : {}),
44
+ statusCode: status,
45
+ timestamp: new Date().toISOString(),
46
+ path: request.url,
47
+ });
48
+ }
49
+ };
50
+ GlobalExceptionFilter = __decorate([
51
+ Catch()
52
+ ], GlobalExceptionFilter);
53
+ export { GlobalExceptionFilter };
54
+ //# sourceMappingURL=exception.filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.filter.js","sourceRoot":"","sources":["../../src/nestjs/exception.filter.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,KAAK,EAEL,aAAa,EACb,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAEhD;;GAEG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,KAAK,CAAC,SAAkB,EAAE,IAAmB;QAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,IAAI,MAAM,GAAG,UAAU,CAAC,qBAAqB,CAAC;QAC9C,IAAI,OAAO,GAAG,uBAAuB,CAAC;QACtC,IAAI,MAAM,GAAQ,SAAS,CAAC;QAE5B,IAAI,SAAS,YAAY,aAAa,EAAE,CAAC;YACvC,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBACnC,OAAO,GAAG,UAAU,CAAC;YACvB,CAAC;iBAAM,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBAC1C,OAAO,GAAI,UAAkB,CAAC,OAAO,IAAI,OAAO,CAAC;gBACjD,MAAM,GAAI,UAAkB,CAAC,MAAM,CAAC;YACtC,CAAC;QACH,CAAC;aAAM,IAAI,SAAS,YAAY,KAAK,EAAE,CAAC;YACtC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE;gBAClC,KAAK,EAAE,SAAS,CAAC,OAAO;gBACxB,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,IAAI,EAAE,OAAO,CAAC,GAAG;aAClB,CAAC,CAAC;QACL,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,KAAK;YACd,OAAO;YACP,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,UAAU,EAAE,MAAM;YAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;SAClB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AArCY,qBAAqB;IADjC,KAAK,EAAE;GACK,qBAAqB,CAqCjC"}
@@ -0,0 +1,7 @@
1
+ export { AuthGuard } from './auth.guard.js';
2
+ export { RequirePermission, RequireAllPermissions, RequireRole, Public, } from './permission.decorator.js';
3
+ export { PermissionGuard } from './permission.guard.js';
4
+ export { CurrentUser } from './user.decorator.js';
5
+ export { CorrelationInterceptor } from './correlation.interceptor.js';
6
+ export { GlobalExceptionFilter } from './exception.filter.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,MAAM,GACP,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { AuthGuard } from './auth.guard.js';
2
+ export { RequirePermission, RequireAllPermissions, RequireRole, Public, } from './permission.decorator.js';
3
+ export { PermissionGuard } from './permission.guard.js';
4
+ export { CurrentUser } from './user.decorator.js';
5
+ export { CorrelationInterceptor } from './correlation.interceptor.js';
6
+ export { GlobalExceptionFilter } from './exception.filter.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,EACX,MAAM,GACP,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,22 @@
1
+ export declare const PERMISSIONS_KEY = "permissions";
2
+ export declare const REQUIRE_ALL_KEY = "requireAll";
3
+ export declare const ROLES_KEY = "roles";
4
+ /**
5
+ * Decorator: require at least one of the listed permissions.
6
+ * @example @RequirePermission('sms.messages:read', 'sms.messages:list')
7
+ */
8
+ export declare const RequirePermission: (...permissions: string[]) => import("@nestjs/common").CustomDecorator<string>;
9
+ /**
10
+ * Decorator: require ALL of the listed permissions.
11
+ */
12
+ export declare const RequireAllPermissions: (...permissions: string[]) => (target: any, key?: string | symbol, descriptor?: any) => any;
13
+ /**
14
+ * Decorator: require at least one of the listed roles.
15
+ * @example @RequireRole('admin', 'manager')
16
+ */
17
+ export declare const RequireRole: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
18
+ /**
19
+ * Decorator: mark route as public (skip auth guard).
20
+ */
21
+ export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
22
+ //# sourceMappingURL=permission.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.decorator.d.ts","sourceRoot":"","sources":["../../src/nestjs/permission.decorator.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,SAAS,UAAU,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,aAAa,MAAM,EAAE,qDACf,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,GAAG,aAAa,MAAM,EAAE,MACpD,QAAQ,GAAG,EAAE,MAAM,MAAM,GAAG,MAAM,EAAE,aAAa,GAAG,QAK7D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,MAAM,EAAE,qDACf,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,MAAM,wDAAyC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { SetMetadata } from '@nestjs/common';
2
+ import { IS_PUBLIC_KEY } from './auth.guard.js';
3
+ export const PERMISSIONS_KEY = 'permissions';
4
+ export const REQUIRE_ALL_KEY = 'requireAll';
5
+ export const ROLES_KEY = 'roles';
6
+ /**
7
+ * Decorator: require at least one of the listed permissions.
8
+ * @example @RequirePermission('sms.messages:read', 'sms.messages:list')
9
+ */
10
+ export const RequirePermission = (...permissions) => SetMetadata(PERMISSIONS_KEY, permissions);
11
+ /**
12
+ * Decorator: require ALL of the listed permissions.
13
+ */
14
+ export const RequireAllPermissions = (...permissions) => {
15
+ return (target, key, descriptor) => {
16
+ SetMetadata(PERMISSIONS_KEY, permissions)(target, key, descriptor);
17
+ SetMetadata(REQUIRE_ALL_KEY, true)(target, key, descriptor);
18
+ return descriptor;
19
+ };
20
+ };
21
+ /**
22
+ * Decorator: require at least one of the listed roles.
23
+ * @example @RequireRole('admin', 'manager')
24
+ */
25
+ export const RequireRole = (...roles) => SetMetadata(ROLES_KEY, roles);
26
+ /**
27
+ * Decorator: mark route as public (skip auth guard).
28
+ */
29
+ export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);
30
+ //# sourceMappingURL=permission.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.decorator.js","sourceRoot":"","sources":["../../src/nestjs/permission.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAC5C,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,WAAqB,EAAE,EAAE,CAC5D,WAAW,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,WAAqB,EAAE,EAAE;IAChE,OAAO,CAAC,MAAW,EAAE,GAAqB,EAAE,UAAgB,EAAE,EAAE;QAC9D,WAAW,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,MAAM,EAAE,GAAI,EAAE,UAAU,CAAC,CAAC;QACpE,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,GAAI,EAAE,UAAU,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE,CAChD,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { CanActivate, ExecutionContext } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ /**
4
+ * NestJS Guard: checks permissions/roles from decorators.
5
+ * Must be used after AuthGuard so that request.user is populated.
6
+ */
7
+ export declare class PermissionGuard implements CanActivate {
8
+ private reflector;
9
+ constructor(reflector: Reflector);
10
+ canActivate(context: ExecutionContext): boolean;
11
+ }
12
+ //# sourceMappingURL=permission.guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.guard.d.ts","sourceRoot":"","sources":["../../src/nestjs/permission.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC;;;GAGG;AACH,qBACa,eAAgB,YAAW,WAAW;IACrC,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;CAoDhD"}
@@ -0,0 +1,66 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Injectable, ForbiddenException, } from '@nestjs/common';
11
+ import { Reflector } from '@nestjs/core';
12
+ import { PERMISSIONS_KEY, REQUIRE_ALL_KEY, ROLES_KEY, } from './permission.decorator.js';
13
+ import { IS_PUBLIC_KEY } from './auth.guard.js';
14
+ /**
15
+ * NestJS Guard: checks permissions/roles from decorators.
16
+ * Must be used after AuthGuard so that request.user is populated.
17
+ */
18
+ let PermissionGuard = class PermissionGuard {
19
+ reflector;
20
+ constructor(reflector) {
21
+ this.reflector = reflector;
22
+ }
23
+ canActivate(context) {
24
+ // Skip permission check for public routes
25
+ const isPublic = this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [
26
+ context.getHandler(),
27
+ context.getClass(),
28
+ ]);
29
+ if (isPublic)
30
+ return true;
31
+ const request = context.switchToHttp().getRequest();
32
+ const user = request.user;
33
+ if (!user) {
34
+ throw new ForbiddenException('User context not found');
35
+ }
36
+ // Super admins bypass all permission checks
37
+ if (user.isSuperAdmin)
38
+ return true;
39
+ // Check roles
40
+ const requiredRoles = this.reflector.getAllAndOverride(ROLES_KEY, [context.getHandler(), context.getClass()]);
41
+ if (requiredRoles?.length) {
42
+ const hasRole = requiredRoles.some((role) => user.roles.includes(role));
43
+ if (!hasRole) {
44
+ throw new ForbiddenException('Insufficient role');
45
+ }
46
+ }
47
+ // Check permissions
48
+ const requiredPermissions = this.reflector.getAllAndOverride(PERMISSIONS_KEY, [context.getHandler(), context.getClass()]);
49
+ if (!requiredPermissions?.length)
50
+ return true;
51
+ const requireAll = this.reflector.getAllAndOverride(REQUIRE_ALL_KEY, [context.getHandler(), context.getClass()]);
52
+ const hasPermission = requireAll
53
+ ? requiredPermissions.every((p) => user.permissions.includes(p))
54
+ : requiredPermissions.some((p) => user.permissions.includes(p));
55
+ if (!hasPermission) {
56
+ throw new ForbiddenException('Insufficient permissions');
57
+ }
58
+ return true;
59
+ }
60
+ };
61
+ PermissionGuard = __decorate([
62
+ Injectable(),
63
+ __metadata("design:paramtypes", [Reflector])
64
+ ], PermissionGuard);
65
+ export { PermissionGuard };
66
+ //# sourceMappingURL=permission.guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.guard.js","sourceRoot":"","sources":["../../src/nestjs/permission.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,UAAU,EAGV,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,eAAe,EACf,eAAe,EACf,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACN;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,WAAW,CAAC,OAAyB;QACnC,0CAA0C;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,aAAa,EAAE;YACxE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QACH,IAAI,QAAQ;YAAE,OAAO,IAAI,CAAC;QAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAA0B,OAAO,CAAC,IAAI,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;QACzD,CAAC;QAED,4CAA4C;QAC5C,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC;QAEnC,cAAc;QAC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QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAvDY,eAAe;IAD3B,UAAU,EAAE;qCAEoB,SAAS;GAD7B,eAAe,CAuD3B"}
@@ -0,0 +1,12 @@
1
+ import type { IAuthUser } from '../types/index.js';
2
+ /**
3
+ * Decorator: extract the authenticated user from the request.
4
+ * @example
5
+ * @Get('profile')
6
+ * getProfile(@CurrentUser() user: IAuthUser) { ... }
7
+ *
8
+ * @Get('id')
9
+ * getId(@CurrentUser('id') userId: string) { ... }
10
+ */
11
+ export declare const CurrentUser: (...dataOrPipes: (keyof IAuthUser | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
12
+ //# sourceMappingURL=user.decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.decorator.d.ts","sourceRoot":"","sources":["../../src/nestjs/user.decorator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,8MAMvB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { createParamDecorator } from '@nestjs/common';
2
+ /**
3
+ * Decorator: extract the authenticated user from the request.
4
+ * @example
5
+ * @Get('profile')
6
+ * getProfile(@CurrentUser() user: IAuthUser) { ... }
7
+ *
8
+ * @Get('id')
9
+ * getId(@CurrentUser('id') userId: string) { ... }
10
+ */
11
+ export const CurrentUser = createParamDecorator((data, ctx) => {
12
+ const request = ctx.switchToHttp().getRequest();
13
+ const user = request.user;
14
+ return data ? user?.[data] : user;
15
+ });
16
+ //# sourceMappingURL=user.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.decorator.js","sourceRoot":"","sources":["../../src/nestjs/user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AAGxE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAC7C,CAAC,IAAiC,EAAE,GAAqB,EAAE,EAAE;IAC3D,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,MAAM,IAAI,GAAc,OAAO,CAAC,IAAI,CAAC;IACrC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACpC,CAAC,CACF,CAAC"}
@@ -0,0 +1,193 @@
1
+ export interface IUser {
2
+ id: string;
3
+ email: string;
4
+ first_name: string;
5
+ last_name: string;
6
+ phone?: string | null;
7
+ password_hash: string;
8
+ company_id: string;
9
+ is_superadmin: boolean;
10
+ is_active: boolean;
11
+ email_verified: boolean;
12
+ failed_login_attempts: number;
13
+ locked_until: Date | null;
14
+ change_password_next_login: boolean;
15
+ last_login_at: Date | null;
16
+ created_at: Date;
17
+ updated_at: Date;
18
+ }
19
+ export interface IUserCreate {
20
+ email: string;
21
+ first_name: string;
22
+ last_name: string;
23
+ phone?: string;
24
+ password_hash: string;
25
+ company_id: string;
26
+ is_superadmin?: boolean;
27
+ }
28
+ export interface IUserUpdate {
29
+ email?: string;
30
+ first_name?: string;
31
+ last_name?: string;
32
+ phone?: string;
33
+ password_hash?: string;
34
+ company_id?: string;
35
+ is_active?: boolean;
36
+ email_verified?: boolean;
37
+ failed_login_attempts?: number;
38
+ locked_until?: Date | null;
39
+ change_password_next_login?: boolean;
40
+ last_login_at?: Date | null;
41
+ }
42
+ export interface IJwtPayload {
43
+ sub: string;
44
+ email: string;
45
+ companyId: string;
46
+ roles: string[];
47
+ permissions: string[];
48
+ isSuperAdmin: boolean;
49
+ iat?: number;
50
+ exp?: number;
51
+ iss?: string;
52
+ }
53
+ export interface ITokenPair {
54
+ accessToken: string;
55
+ refreshToken: string;
56
+ expiresIn: number;
57
+ }
58
+ export interface IAuthUser {
59
+ id: string;
60
+ email: string;
61
+ companyId: string;
62
+ roles: string[];
63
+ permissions: string[];
64
+ isSuperAdmin: boolean;
65
+ }
66
+ export interface ICompany {
67
+ id: string;
68
+ name: string;
69
+ short_name?: string | null;
70
+ company_type?: string | null;
71
+ email?: string | null;
72
+ phone?: string | null;
73
+ address?: string | null;
74
+ city?: string | null;
75
+ country?: string | null;
76
+ logo_url?: string | null;
77
+ website?: string | null;
78
+ is_active: boolean;
79
+ created_at: Date;
80
+ updated_at: Date;
81
+ }
82
+ export interface ICompanyCreate {
83
+ name: string;
84
+ short_name?: string;
85
+ company_type?: string;
86
+ email?: string;
87
+ phone?: string;
88
+ address?: string;
89
+ city?: string;
90
+ country?: string;
91
+ }
92
+ export interface ICompanyUpdate {
93
+ name?: string;
94
+ short_name?: string;
95
+ company_type?: string;
96
+ email?: string;
97
+ phone?: string;
98
+ address?: string;
99
+ city?: string;
100
+ country?: string;
101
+ logo_url?: string;
102
+ website?: string;
103
+ is_active?: boolean;
104
+ }
105
+ export interface ICompanyBranch {
106
+ id: string;
107
+ company_id: string;
108
+ name: string;
109
+ code?: string | null;
110
+ address?: string | null;
111
+ city?: string | null;
112
+ phone?: string | null;
113
+ email?: string | null;
114
+ is_active: boolean;
115
+ created_at: Date;
116
+ updated_at: Date;
117
+ }
118
+ export interface ICompanyServiceConfig {
119
+ id: string;
120
+ company_id: string;
121
+ service_name: string;
122
+ config: Record<string, unknown>;
123
+ is_active: boolean;
124
+ created_at: Date;
125
+ updated_at: Date;
126
+ }
127
+ export interface IRole {
128
+ id: string;
129
+ name: string;
130
+ slug: string;
131
+ description?: string | null;
132
+ company_id?: string | null;
133
+ is_system_role: boolean;
134
+ is_editable: boolean;
135
+ created_at: Date;
136
+ updated_at: Date;
137
+ }
138
+ export interface IPermission {
139
+ id: string;
140
+ name: string;
141
+ description?: string | null;
142
+ category: string;
143
+ is_active: boolean;
144
+ created_at: Date;
145
+ }
146
+ export interface IApiResponse<T = unknown> {
147
+ success: boolean;
148
+ message: string;
149
+ data?: T;
150
+ errors?: Record<string, string[]>;
151
+ meta?: IPaginationMeta;
152
+ }
153
+ export interface IPaginationMeta {
154
+ page: number;
155
+ limit: number;
156
+ total: number;
157
+ totalPages: number;
158
+ hasNext: boolean;
159
+ hasPrev: boolean;
160
+ }
161
+ export interface IPaginationParams {
162
+ page: number;
163
+ limit: number;
164
+ search?: string;
165
+ sortBy?: string;
166
+ sortOrder?: 'asc' | 'desc';
167
+ }
168
+ export interface IPaginatedResult<T> {
169
+ data: T[];
170
+ meta: IPaginationMeta;
171
+ }
172
+ export interface IAnalyticsEvent {
173
+ event_type: string;
174
+ event_data: Record<string, unknown>;
175
+ company_id?: string;
176
+ timestamp?: Date;
177
+ }
178
+ export interface IServiceConfig {
179
+ serviceName: string;
180
+ serviceUrl: string;
181
+ healthEndpoint: string;
182
+ }
183
+ export declare const GATEWAY_HEADERS: {
184
+ readonly USER_ID: "x-user-id";
185
+ readonly COMPANY_ID: "x-company-id";
186
+ readonly USER_EMAIL: "x-user-email";
187
+ readonly USER_ROLES: "x-user-roles";
188
+ readonly USER_PERMISSIONS: "x-user-permissions";
189
+ readonly IS_SUPERADMIN: "x-is-superadmin";
190
+ readonly CORRELATION_ID: "x-correlation-id";
191
+ readonly SERVICE_NAME: "x-service-name";
192
+ };
193
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE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AAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,eAAe,CAAC;CACvB;AAMD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAMD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAMD,eAAO,MAAM,eAAe;;;;;;;;;CASlB,CAAC"}
@@ -0,0 +1,17 @@
1
+ // ──────────────────────────────────────────────
2
+ // User & Auth Types
3
+ // ──────────────────────────────────────────────
4
+ // ──────────────────────────────────────────────
5
+ // Gateway Header Types
6
+ // ──────────────────────────────────────────────
7
+ export const GATEWAY_HEADERS = {
8
+ USER_ID: 'x-user-id',
9
+ COMPANY_ID: 'x-company-id',
10
+ USER_EMAIL: 'x-user-email',
11
+ USER_ROLES: 'x-user-roles',
12
+ USER_PERMISSIONS: 'x-user-permissions',
13
+ IS_SUPERADMIN: 'x-is-superadmin',
14
+ CORRELATION_ID: 'x-correlation-id',
15
+ SERVICE_NAME: 'x-service-name',
16
+ };
17
+ //# sourceMappingURL=index.js.map