grm-shared-library 1.1.40 → 1.1.42
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/common/services/index.js +1 -0
- package/dist/cjs/modules/common/services/index.js.map +1 -1
- package/dist/cjs/modules/common/services/user-context-header.service.js +74 -0
- package/dist/cjs/modules/common/services/user-context-header.service.js.map +1 -0
- package/dist/cjs/modules/dms/dtos/document-file-upload-options.dto.js +58 -0
- package/dist/cjs/modules/dms/dtos/document-file-upload-options.dto.js.map +1 -0
- package/dist/cjs/modules/dms/index.js +6 -0
- package/dist/cjs/modules/dms/index.js.map +1 -1
- package/dist/cjs/modules/dms/interfaces/document-file-metadata.js +3 -0
- package/dist/cjs/modules/dms/interfaces/document-file-metadata.js.map +1 -0
- package/dist/cjs/modules/dms/interfaces/document-file-upload-options.js +3 -0
- package/dist/cjs/modules/dms/interfaces/document-file-upload-options.js.map +1 -0
- package/dist/cjs/modules/dms/interfaces/document-file.js +3 -0
- package/dist/cjs/modules/dms/interfaces/document-file.js.map +1 -0
- package/dist/cjs/modules/dms/interfaces/document-files-by-user.js +3 -0
- package/dist/cjs/modules/dms/interfaces/document-files-by-user.js.map +1 -0
- package/dist/cjs/modules/dms/interfaces/document-files-user-storage-info.js +3 -0
- package/dist/cjs/modules/dms/interfaces/document-files-user-storage-info.js.map +1 -0
- package/dist/cjs/utilities/user-context-header.service.js +0 -72
- package/dist/cjs/utilities/user-context-header.service.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/common/services/index.js +1 -0
- package/dist/esm/modules/common/services/index.js.map +1 -1
- package/dist/esm/modules/common/services/user-context-header.service.js +70 -0
- package/dist/esm/modules/common/services/user-context-header.service.js.map +1 -0
- package/dist/esm/modules/dms/dtos/document-file-upload-options.dto.js +54 -0
- package/dist/esm/modules/dms/dtos/document-file-upload-options.dto.js.map +1 -0
- package/dist/esm/modules/dms/index.js +6 -0
- package/dist/esm/modules/dms/index.js.map +1 -1
- package/dist/esm/modules/dms/interfaces/document-file-metadata.js +2 -0
- package/dist/esm/modules/dms/interfaces/document-file-metadata.js.map +1 -0
- package/dist/esm/modules/dms/interfaces/document-file-upload-options.js +2 -0
- package/dist/esm/modules/dms/interfaces/document-file-upload-options.js.map +1 -0
- package/dist/esm/modules/dms/interfaces/document-file.js +2 -0
- package/dist/esm/modules/dms/interfaces/document-file.js.map +1 -0
- package/dist/esm/modules/dms/interfaces/document-files-by-user.js +2 -0
- package/dist/esm/modules/dms/interfaces/document-files-by-user.js.map +1 -0
- package/dist/esm/modules/dms/interfaces/document-files-user-storage-info.js +2 -0
- package/dist/esm/modules/dms/interfaces/document-files-user-storage-info.js.map +1 -0
- package/dist/esm/utilities/user-context-header.service.js +1 -69
- package/dist/esm/utilities/user-context-header.service.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/modules/common/services/index.d.ts +1 -0
- package/dist/types/modules/common/services/user-context-header.service.d.ts +19 -0
- package/dist/types/modules/dms/dtos/document-file-upload-options.dto.d.ts +10 -0
- package/dist/types/modules/dms/index.d.ts +6 -0
- package/dist/types/modules/dms/interfaces/document-file-metadata.d.ts +17 -0
- package/dist/types/modules/dms/interfaces/document-file-upload-options.d.ts +10 -0
- package/dist/types/modules/dms/interfaces/document-file.d.ts +25 -0
- package/dist/types/modules/dms/interfaces/document-files-by-user.d.ts +8 -0
- package/dist/types/modules/dms/interfaces/document-files-user-storage-info.d.ts +6 -0
- package/dist/types/utilities/user-context-header.service.d.ts +0 -19
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -39,7 +39,7 @@ __exportStar(require("./constants/http-headers"), exports);
|
|
|
39
39
|
__exportStar(require("./kafka/index"), exports);
|
|
40
40
|
// Utilities
|
|
41
41
|
__exportStar(require("./decorators/case-decorators"), exports);
|
|
42
|
-
__exportStar(require("./
|
|
42
|
+
__exportStar(require("./modules/common/services/user-context-header.service"), exports);
|
|
43
43
|
// Exceptions
|
|
44
44
|
__exportStar(require("./exceptions/index"), exports);
|
|
45
45
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AAEpC,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AAEpC,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./access-validation.service"), exports);
|
|
18
|
+
__exportStar(require("./user-context-header.service"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,gEAA8C"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserContextHeaderService = void 0;
|
|
4
|
+
const http_headers_1 = require("../../../constants/http-headers");
|
|
5
|
+
/**
|
|
6
|
+
* Utility service for handling user context via HTTP headers
|
|
7
|
+
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
8
|
+
*/
|
|
9
|
+
class UserContextHeaderService {
|
|
10
|
+
/**
|
|
11
|
+
* Convert UserContext to HTTP headers for microservice communication
|
|
12
|
+
*/
|
|
13
|
+
static buildHeaders(userContext) {
|
|
14
|
+
const headers = {};
|
|
15
|
+
headers[http_headers_1.HTTP_HEADERS.USER_ID] = userContext.userId.toString();
|
|
16
|
+
headers[http_headers_1.HTTP_HEADERS.USER_ROLES] = JSON.stringify(userContext.roles);
|
|
17
|
+
headers[http_headers_1.HTTP_HEADERS.ACCESS_SCOPE] = JSON.stringify(userContext.accessScope);
|
|
18
|
+
if (userContext.organizationId) {
|
|
19
|
+
headers[http_headers_1.HTTP_HEADERS.ORGANIZATION_ID] = userContext.organizationId.toString();
|
|
20
|
+
}
|
|
21
|
+
if (userContext.controlCentreId) {
|
|
22
|
+
headers[http_headers_1.HTTP_HEADERS.CONTROL_CENTRE_ID] = userContext.controlCentreId.toString();
|
|
23
|
+
}
|
|
24
|
+
// Also provide full context as single header for convenience
|
|
25
|
+
headers[http_headers_1.HTTP_HEADERS.USER_CONTEXT] = JSON.stringify(userContext);
|
|
26
|
+
return headers;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract UserContext from HTTP headers in microservices
|
|
30
|
+
*/
|
|
31
|
+
static extractFromHeaders(headers) {
|
|
32
|
+
try {
|
|
33
|
+
// First try to get full context from single header
|
|
34
|
+
const fullContextHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_CONTEXT);
|
|
35
|
+
if (fullContextHeader) {
|
|
36
|
+
return JSON.parse(fullContextHeader);
|
|
37
|
+
}
|
|
38
|
+
// Fallback: reconstruct from individual headers
|
|
39
|
+
const userIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_ID);
|
|
40
|
+
const rolesHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_ROLES);
|
|
41
|
+
const accessScopeHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.ACCESS_SCOPE);
|
|
42
|
+
if (!userIdHeader || !rolesHeader || !accessScopeHeader) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const userId = parseInt(userIdHeader);
|
|
46
|
+
const roles = JSON.parse(rolesHeader);
|
|
47
|
+
const accessScope = JSON.parse(accessScopeHeader);
|
|
48
|
+
const organizationIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.ORGANIZATION_ID);
|
|
49
|
+
const controlCentreIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.CONTROL_CENTRE_ID);
|
|
50
|
+
return {
|
|
51
|
+
userId,
|
|
52
|
+
roles,
|
|
53
|
+
accessScope,
|
|
54
|
+
organizationId: organizationIdHeader ? parseInt(organizationIdHeader) : undefined,
|
|
55
|
+
controlCentreId: controlCentreIdHeader ? parseInt(controlCentreIdHeader) : undefined
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.error('Error extracting user context from headers:', error);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Helper to get header value (handles string | string[] types)
|
|
65
|
+
*/
|
|
66
|
+
static getHeaderValue(headers, key) {
|
|
67
|
+
const value = headers[key.toLowerCase()] || headers[key];
|
|
68
|
+
if (!value)
|
|
69
|
+
return null;
|
|
70
|
+
return Array.isArray(value) ? value[0] : value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.UserContextHeaderService = UserContextHeaderService;
|
|
74
|
+
//# sourceMappingURL=user-context-header.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/user-context-header.service.ts"],"names":[],"mappings":";;;AAEA,kEAA+D;AAE/D;;;GAGG;AACH,MAAa,wBAAwB;IAEjC;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,WAAwB;QACxC,MAAM,OAAO,GAA2B,EAAE,CAAC;QAE3C,OAAO,CAAC,2BAAY,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC9D,OAAO,CAAC,2BAAY,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACrE,OAAO,CAAC,2BAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAE7E,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;YAC7B,OAAO,CAAC,2BAAY,CAAC,eAAe,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;QAClF,CAAC;QAED,IAAI,WAAW,CAAC,eAAe,EAAE,CAAC;YAC9B,OAAO,CAAC,2BAAY,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;QACrF,CAAC;QAED,6DAA6D;QAC7D,OAAO,CAAC,2BAAY,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAEjE,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,OAA0C;QAChE,IAAI,CAAC;YACD,mDAAmD;YACnD,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,YAAY,CAAC,CAAC;YAClF,IAAI,iBAAiB,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAgB,CAAC;YACxD,CAAC;YAED,gDAAgD;YAChD,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,OAAO,CAAC,CAAC;YACxE,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,UAAU,CAAC,CAAC;YAC1E,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,YAAY,CAAC,CAAC;YAElF,IAAI,CAAC,YAAY,IAAI,CAAC,WAAW,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBACtD,OAAO,IAAI,CAAC;YAChB,CAAC;YAED,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAa,CAAC;YAClD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAgB,CAAC;YAEjE,MAAM,oBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,eAAe,CAAC,CAAC;YACxF,MAAM,qBAAqB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,2BAAY,CAAC,iBAAiB,CAAC,CAAC;YAE3F,OAAO;gBACH,MAAM;gBACN,KAAK;gBACL,WAAW;gBACX,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS;gBACjF,eAAe,EAAE,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS;aACvF,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;YACpE,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,cAAc,CAAC,OAA0C,EAAE,GAAW;QACjF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;CACJ;AA1ED,4DA0EC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DocumentFileUploadOptionsDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class DocumentFileUploadOptionsDto {
|
|
15
|
+
}
|
|
16
|
+
exports.DocumentFileUploadOptionsDto = DocumentFileUploadOptionsDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsOptional)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], DocumentFileUploadOptionsDto.prototype, "folder", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsNumber)(),
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], DocumentFileUploadOptionsDto.prototype, "maxSizeInMB", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsString)({ each: true }),
|
|
29
|
+
(0, class_validator_1.IsOptional)(),
|
|
30
|
+
__metadata("design:type", Array)
|
|
31
|
+
], DocumentFileUploadOptionsDto.prototype, "allowedMimeTypes", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsBoolean)(),
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
__metadata("design:type", Boolean)
|
|
36
|
+
], DocumentFileUploadOptionsDto.prototype, "isPublic", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, class_validator_1.IsArray)(),
|
|
39
|
+
(0, class_validator_1.IsString)({ each: true }),
|
|
40
|
+
(0, class_validator_1.IsOptional)(),
|
|
41
|
+
__metadata("design:type", Array)
|
|
42
|
+
], DocumentFileUploadOptionsDto.prototype, "tags", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, class_validator_1.IsString)(),
|
|
45
|
+
(0, class_validator_1.IsOptional)(),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], DocumentFileUploadOptionsDto.prototype, "description", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, class_validator_1.IsBoolean)(),
|
|
50
|
+
(0, class_validator_1.IsOptional)(),
|
|
51
|
+
__metadata("design:type", Boolean)
|
|
52
|
+
], DocumentFileUploadOptionsDto.prototype, "preserveOriginalName", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, class_validator_1.IsBoolean)(),
|
|
55
|
+
(0, class_validator_1.IsOptional)(),
|
|
56
|
+
__metadata("design:type", Boolean)
|
|
57
|
+
], DocumentFileUploadOptionsDto.prototype, "enableVersioning", void 0);
|
|
58
|
+
//# sourceMappingURL=document-file-upload-options.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-upload-options.dto.js","sourceRoot":"","sources":["../../../../../src/modules/dms/dtos/document-file-upload-options.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAqF;AAErF,MAAa,4BAA4B;CAiCxC;AAjCD,oEAiCC;AA9BG;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;4DACG;AAIhB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;iEACQ;AAIrB;IAFC,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;;sEACe;AAI5B;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;8DACM;AAKnB;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,IAAA,4BAAU,GAAE;;0DACG;AAIhB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;iEACQ;AAIrB;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;0EACkB;AAI/B;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;sEACc"}
|
|
@@ -20,8 +20,14 @@ __exportStar(require("./interfaces/image-file-upload-options"), exports);
|
|
|
20
20
|
__exportStar(require("./interfaces/image-file-metadata"), exports);
|
|
21
21
|
__exportStar(require("./interfaces/image-files-user-storage-info"), exports);
|
|
22
22
|
__exportStar(require("./interfaces/image-files-by-user"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/document-file"), exports);
|
|
24
|
+
__exportStar(require("./interfaces/document-file-upload-options"), exports);
|
|
25
|
+
__exportStar(require("./interfaces/document-file-metadata"), exports);
|
|
26
|
+
__exportStar(require("./interfaces/document-files-user-storage-info"), exports);
|
|
27
|
+
__exportStar(require("./interfaces/document-files-by-user"), exports);
|
|
23
28
|
// Enums
|
|
24
29
|
__exportStar(require("./enums/file-status"), exports);
|
|
25
30
|
// DTOs
|
|
26
31
|
__exportStar(require("./dtos/image-file-upload-options.dto"), exports);
|
|
32
|
+
__exportStar(require("./dtos/document-file-upload-options.dto"), exports);
|
|
27
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/dms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,aAAa;AACb,0DAAwC;AACxC,yEAAuD;AACvD,mEAAiD;AACjD,6EAA2D;AAC3D,mEAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/dms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,aAAa;AACb,0DAAwC;AACxC,yEAAuD;AACvD,mEAAiD;AACjD,6EAA2D;AAC3D,mEAAiD;AACjD,6DAA2C;AAC3C,4EAA0D;AAC1D,sEAAoD;AACpD,gFAA8D;AAC9D,sEAAoD;AAEpD,QAAQ;AACR,sDAAoC;AAEpC,OAAO;AACP,uEAAqD;AACrD,0EAAwD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-metadata.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file-metadata.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-upload-options.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file-upload-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-files-by-user.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-files-by-user.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-files-user-storage-info.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-files-user-storage-info.ts"],"names":[],"mappings":""}
|
|
@@ -1,74 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserContextHeaderService = void 0;
|
|
4
|
-
const http_headers_1 = require("../constants/http-headers");
|
|
5
|
-
/**
|
|
6
|
-
* Utility service for handling user context via HTTP headers
|
|
7
|
-
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
8
|
-
*/
|
|
9
|
-
class UserContextHeaderService {
|
|
10
|
-
/**
|
|
11
|
-
* Convert UserContext to HTTP headers for microservice communication
|
|
12
|
-
*/
|
|
13
|
-
static buildHeaders(userContext) {
|
|
14
|
-
const headers = {};
|
|
15
|
-
headers[http_headers_1.HTTP_HEADERS.USER_ID] = userContext.userId.toString();
|
|
16
|
-
headers[http_headers_1.HTTP_HEADERS.USER_ROLES] = JSON.stringify(userContext.roles);
|
|
17
|
-
headers[http_headers_1.HTTP_HEADERS.ACCESS_SCOPE] = JSON.stringify(userContext.accessScope);
|
|
18
|
-
if (userContext.organizationId) {
|
|
19
|
-
headers[http_headers_1.HTTP_HEADERS.ORGANIZATION_ID] = userContext.organizationId.toString();
|
|
20
|
-
}
|
|
21
|
-
if (userContext.controlCentreId) {
|
|
22
|
-
headers[http_headers_1.HTTP_HEADERS.CONTROL_CENTRE_ID] = userContext.controlCentreId.toString();
|
|
23
|
-
}
|
|
24
|
-
// Also provide full context as single header for convenience
|
|
25
|
-
headers[http_headers_1.HTTP_HEADERS.USER_CONTEXT] = JSON.stringify(userContext);
|
|
26
|
-
return headers;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Extract UserContext from HTTP headers in microservices
|
|
30
|
-
*/
|
|
31
|
-
static extractFromHeaders(headers) {
|
|
32
|
-
try {
|
|
33
|
-
// First try to get full context from single header
|
|
34
|
-
const fullContextHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_CONTEXT);
|
|
35
|
-
if (fullContextHeader) {
|
|
36
|
-
return JSON.parse(fullContextHeader);
|
|
37
|
-
}
|
|
38
|
-
// Fallback: reconstruct from individual headers
|
|
39
|
-
const userIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_ID);
|
|
40
|
-
const rolesHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.USER_ROLES);
|
|
41
|
-
const accessScopeHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.ACCESS_SCOPE);
|
|
42
|
-
if (!userIdHeader || !rolesHeader || !accessScopeHeader) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const userId = parseInt(userIdHeader);
|
|
46
|
-
const roles = JSON.parse(rolesHeader);
|
|
47
|
-
const accessScope = JSON.parse(accessScopeHeader);
|
|
48
|
-
const organizationIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.ORGANIZATION_ID);
|
|
49
|
-
const controlCentreIdHeader = this.getHeaderValue(headers, http_headers_1.HTTP_HEADERS.CONTROL_CENTRE_ID);
|
|
50
|
-
return {
|
|
51
|
-
userId,
|
|
52
|
-
roles,
|
|
53
|
-
accessScope,
|
|
54
|
-
organizationId: organizationIdHeader ? parseInt(organizationIdHeader) : undefined,
|
|
55
|
-
controlCentreId: controlCentreIdHeader ? parseInt(controlCentreIdHeader) : undefined
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error('Error extracting user context from headers:', error);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Helper to get header value (handles string | string[] types)
|
|
65
|
-
*/
|
|
66
|
-
static getHeaderValue(headers, key) {
|
|
67
|
-
const value = headers[key.toLowerCase()] || headers[key];
|
|
68
|
-
if (!value)
|
|
69
|
-
return null;
|
|
70
|
-
return Array.isArray(value) ? value[0] : value;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.UserContextHeaderService = UserContextHeaderService;
|
|
74
2
|
//# sourceMappingURL=user-context-header.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../src/utilities/user-context-header.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../src/utilities/user-context-header.service.ts"],"names":[],"mappings":""}
|
package/dist/esm/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export * from './constants/http-headers';
|
|
|
23
23
|
export * from './kafka/index';
|
|
24
24
|
// Utilities
|
|
25
25
|
export * from './decorators/case-decorators';
|
|
26
|
-
export * from './
|
|
26
|
+
export * from './modules/common/services/user-context-header.service';
|
|
27
27
|
// Exceptions
|
|
28
28
|
export * from './exceptions/index';
|
|
29
29
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAEpC,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AAEzC,QAAQ;AACR,cAAc,eAAe,CAAC;AAE9B,YAAY;AACZ,cAAc,8BAA8B,CAAC;AAC7C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AAEpC,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AAEzC,QAAQ;AACR,cAAc,eAAe,CAAC;AAE9B,YAAY;AACZ,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uDAAuD,CAAC;AAEtE,aAAa;AACb,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { HTTP_HEADERS } from '../../../constants/http-headers';
|
|
2
|
+
/**
|
|
3
|
+
* Utility service for handling user context via HTTP headers
|
|
4
|
+
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
5
|
+
*/
|
|
6
|
+
export class UserContextHeaderService {
|
|
7
|
+
/**
|
|
8
|
+
* Convert UserContext to HTTP headers for microservice communication
|
|
9
|
+
*/
|
|
10
|
+
static buildHeaders(userContext) {
|
|
11
|
+
const headers = {};
|
|
12
|
+
headers[HTTP_HEADERS.USER_ID] = userContext.userId.toString();
|
|
13
|
+
headers[HTTP_HEADERS.USER_ROLES] = JSON.stringify(userContext.roles);
|
|
14
|
+
headers[HTTP_HEADERS.ACCESS_SCOPE] = JSON.stringify(userContext.accessScope);
|
|
15
|
+
if (userContext.organizationId) {
|
|
16
|
+
headers[HTTP_HEADERS.ORGANIZATION_ID] = userContext.organizationId.toString();
|
|
17
|
+
}
|
|
18
|
+
if (userContext.controlCentreId) {
|
|
19
|
+
headers[HTTP_HEADERS.CONTROL_CENTRE_ID] = userContext.controlCentreId.toString();
|
|
20
|
+
}
|
|
21
|
+
// Also provide full context as single header for convenience
|
|
22
|
+
headers[HTTP_HEADERS.USER_CONTEXT] = JSON.stringify(userContext);
|
|
23
|
+
return headers;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extract UserContext from HTTP headers in microservices
|
|
27
|
+
*/
|
|
28
|
+
static extractFromHeaders(headers) {
|
|
29
|
+
try {
|
|
30
|
+
// First try to get full context from single header
|
|
31
|
+
const fullContextHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_CONTEXT);
|
|
32
|
+
if (fullContextHeader) {
|
|
33
|
+
return JSON.parse(fullContextHeader);
|
|
34
|
+
}
|
|
35
|
+
// Fallback: reconstruct from individual headers
|
|
36
|
+
const userIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_ID);
|
|
37
|
+
const rolesHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_ROLES);
|
|
38
|
+
const accessScopeHeader = this.getHeaderValue(headers, HTTP_HEADERS.ACCESS_SCOPE);
|
|
39
|
+
if (!userIdHeader || !rolesHeader || !accessScopeHeader) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const userId = parseInt(userIdHeader);
|
|
43
|
+
const roles = JSON.parse(rolesHeader);
|
|
44
|
+
const accessScope = JSON.parse(accessScopeHeader);
|
|
45
|
+
const organizationIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.ORGANIZATION_ID);
|
|
46
|
+
const controlCentreIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.CONTROL_CENTRE_ID);
|
|
47
|
+
return {
|
|
48
|
+
userId,
|
|
49
|
+
roles,
|
|
50
|
+
accessScope,
|
|
51
|
+
organizationId: organizationIdHeader ? parseInt(organizationIdHeader) : undefined,
|
|
52
|
+
controlCentreId: controlCentreIdHeader ? parseInt(controlCentreIdHeader) : undefined
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('Error extracting user context from headers:', error);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Helper to get header value (handles string | string[] types)
|
|
62
|
+
*/
|
|
63
|
+
static getHeaderValue(headers, key) {
|
|
64
|
+
const value = headers[key.toLowerCase()] || headers[key];
|
|
65
|
+
if (!value)
|
|
66
|
+
return null;
|
|
67
|
+
return Array.isArray(value) ? value[0] : value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=user-context-header.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../../../src/modules/common/services/user-context-header.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -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
|
+
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 { IsArray, IsBoolean, IsNumber, IsOptional, IsString } from "class-validator";
|
|
11
|
+
export class DocumentFileUploadOptionsDto {
|
|
12
|
+
}
|
|
13
|
+
__decorate([
|
|
14
|
+
IsString(),
|
|
15
|
+
IsOptional(),
|
|
16
|
+
__metadata("design:type", String)
|
|
17
|
+
], DocumentFileUploadOptionsDto.prototype, "folder", void 0);
|
|
18
|
+
__decorate([
|
|
19
|
+
IsNumber(),
|
|
20
|
+
IsOptional(),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], DocumentFileUploadOptionsDto.prototype, "maxSizeInMB", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
IsString({ each: true }),
|
|
25
|
+
IsOptional(),
|
|
26
|
+
__metadata("design:type", Array)
|
|
27
|
+
], DocumentFileUploadOptionsDto.prototype, "allowedMimeTypes", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
IsBoolean(),
|
|
30
|
+
IsOptional(),
|
|
31
|
+
__metadata("design:type", Boolean)
|
|
32
|
+
], DocumentFileUploadOptionsDto.prototype, "isPublic", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
IsArray(),
|
|
35
|
+
IsString({ each: true }),
|
|
36
|
+
IsOptional(),
|
|
37
|
+
__metadata("design:type", Array)
|
|
38
|
+
], DocumentFileUploadOptionsDto.prototype, "tags", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
IsString(),
|
|
41
|
+
IsOptional(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], DocumentFileUploadOptionsDto.prototype, "description", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
IsBoolean(),
|
|
46
|
+
IsOptional(),
|
|
47
|
+
__metadata("design:type", Boolean)
|
|
48
|
+
], DocumentFileUploadOptionsDto.prototype, "preserveOriginalName", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
IsBoolean(),
|
|
51
|
+
IsOptional(),
|
|
52
|
+
__metadata("design:type", Boolean)
|
|
53
|
+
], DocumentFileUploadOptionsDto.prototype, "enableVersioning", void 0);
|
|
54
|
+
//# sourceMappingURL=document-file-upload-options.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-upload-options.dto.js","sourceRoot":"","sources":["../../../../../src/modules/dms/dtos/document-file-upload-options.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAErF,MAAM,OAAO,4BAA4B;CAiCxC;AA9BG;IAFC,QAAQ,EAAE;IACV,UAAU,EAAE;;4DACG;AAIhB;IAFC,QAAQ,EAAE;IACV,UAAU,EAAE;;iEACQ;AAIrB;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,UAAU,EAAE;;sEACe;AAI5B;IAFC,SAAS,EAAE;IACX,UAAU,EAAE;;8DACM;AAKnB;IAHC,OAAO,EAAE;IACT,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,UAAU,EAAE;;0DACG;AAIhB;IAFC,QAAQ,EAAE;IACV,UAAU,EAAE;;iEACQ;AAIrB;IAFC,SAAS,EAAE;IACX,UAAU,EAAE;;0EACkB;AAI/B;IAFC,SAAS,EAAE;IACX,UAAU,EAAE;;sEACc"}
|
|
@@ -4,8 +4,14 @@ export * from './interfaces/image-file-upload-options';
|
|
|
4
4
|
export * from './interfaces/image-file-metadata';
|
|
5
5
|
export * from './interfaces/image-files-user-storage-info';
|
|
6
6
|
export * from './interfaces/image-files-by-user';
|
|
7
|
+
export * from './interfaces/document-file';
|
|
8
|
+
export * from './interfaces/document-file-upload-options';
|
|
9
|
+
export * from './interfaces/document-file-metadata';
|
|
10
|
+
export * from './interfaces/document-files-user-storage-info';
|
|
11
|
+
export * from './interfaces/document-files-by-user';
|
|
7
12
|
// Enums
|
|
8
13
|
export * from './enums/file-status';
|
|
9
14
|
// DTOs
|
|
10
15
|
export * from './dtos/image-file-upload-options.dto';
|
|
16
|
+
export * from './dtos/document-file-upload-options.dto';
|
|
11
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/dms/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/dms/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,qCAAqC,CAAC;AAEpD,QAAQ;AACR,cAAc,qBAAqB,CAAC;AAEpC,OAAO;AACP,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-metadata.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file-metadata.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file-upload-options.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file-upload-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-file.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-file.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-files-by-user.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-files-by-user.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-files-user-storage-info.js","sourceRoot":"","sources":["../../../../../src/modules/dms/interfaces/document-files-user-storage-info.ts"],"names":[],"mappings":""}
|
|
@@ -1,70 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Utility service for handling user context via HTTP headers
|
|
4
|
-
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
5
|
-
*/
|
|
6
|
-
export class UserContextHeaderService {
|
|
7
|
-
/**
|
|
8
|
-
* Convert UserContext to HTTP headers for microservice communication
|
|
9
|
-
*/
|
|
10
|
-
static buildHeaders(userContext) {
|
|
11
|
-
const headers = {};
|
|
12
|
-
headers[HTTP_HEADERS.USER_ID] = userContext.userId.toString();
|
|
13
|
-
headers[HTTP_HEADERS.USER_ROLES] = JSON.stringify(userContext.roles);
|
|
14
|
-
headers[HTTP_HEADERS.ACCESS_SCOPE] = JSON.stringify(userContext.accessScope);
|
|
15
|
-
if (userContext.organizationId) {
|
|
16
|
-
headers[HTTP_HEADERS.ORGANIZATION_ID] = userContext.organizationId.toString();
|
|
17
|
-
}
|
|
18
|
-
if (userContext.controlCentreId) {
|
|
19
|
-
headers[HTTP_HEADERS.CONTROL_CENTRE_ID] = userContext.controlCentreId.toString();
|
|
20
|
-
}
|
|
21
|
-
// Also provide full context as single header for convenience
|
|
22
|
-
headers[HTTP_HEADERS.USER_CONTEXT] = JSON.stringify(userContext);
|
|
23
|
-
return headers;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Extract UserContext from HTTP headers in microservices
|
|
27
|
-
*/
|
|
28
|
-
static extractFromHeaders(headers) {
|
|
29
|
-
try {
|
|
30
|
-
// First try to get full context from single header
|
|
31
|
-
const fullContextHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_CONTEXT);
|
|
32
|
-
if (fullContextHeader) {
|
|
33
|
-
return JSON.parse(fullContextHeader);
|
|
34
|
-
}
|
|
35
|
-
// Fallback: reconstruct from individual headers
|
|
36
|
-
const userIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_ID);
|
|
37
|
-
const rolesHeader = this.getHeaderValue(headers, HTTP_HEADERS.USER_ROLES);
|
|
38
|
-
const accessScopeHeader = this.getHeaderValue(headers, HTTP_HEADERS.ACCESS_SCOPE);
|
|
39
|
-
if (!userIdHeader || !rolesHeader || !accessScopeHeader) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const userId = parseInt(userIdHeader);
|
|
43
|
-
const roles = JSON.parse(rolesHeader);
|
|
44
|
-
const accessScope = JSON.parse(accessScopeHeader);
|
|
45
|
-
const organizationIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.ORGANIZATION_ID);
|
|
46
|
-
const controlCentreIdHeader = this.getHeaderValue(headers, HTTP_HEADERS.CONTROL_CENTRE_ID);
|
|
47
|
-
return {
|
|
48
|
-
userId,
|
|
49
|
-
roles,
|
|
50
|
-
accessScope,
|
|
51
|
-
organizationId: organizationIdHeader ? parseInt(organizationIdHeader) : undefined,
|
|
52
|
-
controlCentreId: controlCentreIdHeader ? parseInt(controlCentreIdHeader) : undefined
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
console.error('Error extracting user context from headers:', error);
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Helper to get header value (handles string | string[] types)
|
|
62
|
-
*/
|
|
63
|
-
static getHeaderValue(headers, key) {
|
|
64
|
-
const value = headers[key.toLowerCase()] || headers[key];
|
|
65
|
-
if (!value)
|
|
66
|
-
return null;
|
|
67
|
-
return Array.isArray(value) ? value[0] : value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
"use strict";
|
|
70
2
|
//# sourceMappingURL=user-context-header.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../src/utilities/user-context-header.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-context-header.service.js","sourceRoot":"","sources":["../../../src/utilities/user-context-header.service.ts"],"names":[],"mappings":""}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export * from './interfaces/pagination';
|
|
|
18
18
|
export * from './constants/http-headers';
|
|
19
19
|
export * from './kafka/index';
|
|
20
20
|
export * from './decorators/case-decorators';
|
|
21
|
-
export * from './
|
|
21
|
+
export * from './modules/common/services/user-context-header.service';
|
|
22
22
|
export * from './exceptions/index';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UserContext } from '../../user/interfaces/user-context';
|
|
2
|
+
/**
|
|
3
|
+
* Utility service for handling user context via HTTP headers
|
|
4
|
+
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
5
|
+
*/
|
|
6
|
+
export declare class UserContextHeaderService {
|
|
7
|
+
/**
|
|
8
|
+
* Convert UserContext to HTTP headers for microservice communication
|
|
9
|
+
*/
|
|
10
|
+
static buildHeaders(userContext: UserContext): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Extract UserContext from HTTP headers in microservices
|
|
13
|
+
*/
|
|
14
|
+
static extractFromHeaders(headers: Record<string, string | string[]>): UserContext | null;
|
|
15
|
+
/**
|
|
16
|
+
* Helper to get header value (handles string | string[] types)
|
|
17
|
+
*/
|
|
18
|
+
private static getHeaderValue;
|
|
19
|
+
}
|
|
@@ -3,5 +3,11 @@ export * from './interfaces/image-file-upload-options';
|
|
|
3
3
|
export * from './interfaces/image-file-metadata';
|
|
4
4
|
export * from './interfaces/image-files-user-storage-info';
|
|
5
5
|
export * from './interfaces/image-files-by-user';
|
|
6
|
+
export * from './interfaces/document-file';
|
|
7
|
+
export * from './interfaces/document-file-upload-options';
|
|
8
|
+
export * from './interfaces/document-file-metadata';
|
|
9
|
+
export * from './interfaces/document-files-user-storage-info';
|
|
10
|
+
export * from './interfaces/document-files-by-user';
|
|
6
11
|
export * from './enums/file-status';
|
|
7
12
|
export * from './dtos/image-file-upload-options.dto';
|
|
13
|
+
export * from './dtos/document-file-upload-options.dto';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DocumentFileMetadata {
|
|
2
|
+
pageCount?: number;
|
|
3
|
+
wordCount?: number;
|
|
4
|
+
author?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
subject?: string;
|
|
7
|
+
creator?: string;
|
|
8
|
+
producer?: string;
|
|
9
|
+
creationDate?: string;
|
|
10
|
+
modificationDate?: string;
|
|
11
|
+
language?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
hasPassword?: boolean;
|
|
14
|
+
isEncrypted?: boolean;
|
|
15
|
+
fileType: string;
|
|
16
|
+
encoding?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FileStatus } from "../enums/file-status";
|
|
2
|
+
export interface DocumentFile {
|
|
3
|
+
id: number;
|
|
4
|
+
fileName: string;
|
|
5
|
+
originalFileName: string;
|
|
6
|
+
url: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
size: number;
|
|
9
|
+
originalSize: number;
|
|
10
|
+
fileExtension: string;
|
|
11
|
+
status: FileStatus;
|
|
12
|
+
description?: string;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
metadata?: Record<string, any>;
|
|
15
|
+
userId: number;
|
|
16
|
+
folder?: string;
|
|
17
|
+
cdnUrl?: string;
|
|
18
|
+
lastAccessedAt?: Date;
|
|
19
|
+
accessCount: number;
|
|
20
|
+
isPublic: boolean;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
deletedAt?: Date;
|
|
24
|
+
signedUrl?: string;
|
|
25
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { UserContext } from '../modules/user/interfaces/user-context';
|
|
2
|
-
/**
|
|
3
|
-
* Utility service for handling user context via HTTP headers
|
|
4
|
-
* This provides a consistent way to pass user context between API Gateway and microservices
|
|
5
|
-
*/
|
|
6
|
-
export declare class UserContextHeaderService {
|
|
7
|
-
/**
|
|
8
|
-
* Convert UserContext to HTTP headers for microservice communication
|
|
9
|
-
*/
|
|
10
|
-
static buildHeaders(userContext: UserContext): Record<string, string>;
|
|
11
|
-
/**
|
|
12
|
-
* Extract UserContext from HTTP headers in microservices
|
|
13
|
-
*/
|
|
14
|
-
static extractFromHeaders(headers: Record<string, string | string[]>): UserContext | null;
|
|
15
|
-
/**
|
|
16
|
-
* Helper to get header value (handles string | string[] types)
|
|
17
|
-
*/
|
|
18
|
-
private static getHeaderValue;
|
|
19
|
-
}
|