@servicelabsco/slabs-access-manager 0.1.61 → 0.1.62
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/access/libraries/conversation.controller.d.ts +10 -1
- package/dist/access/libraries/conversation.controller.js +60 -1
- package/dist/access/libraries/conversation.controller.js.map +1 -1
- package/dist/accessUtility/libraries/process.common.data.d.ts +2 -0
- package/dist/accessUtility/libraries/process.common.data.js +6 -1
- package/dist/accessUtility/libraries/process.common.data.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentEntity, DocumentService } from '@servicelabsco/nestjs-utility-services';
|
|
2
|
+
import { DocumentFileUploadDto } from '../../accessUtility/dtos/document.file.upload.dto';
|
|
2
3
|
import { AccessBusinessParamDto } from '../dtos/access.business.param.dto';
|
|
3
4
|
import { AddConversationDto } from '../dtos/add.conversation.dto';
|
|
5
|
+
import { BusinessParamDto } from '../dtos/business.param.dto';
|
|
6
|
+
import { ConversationEntity } from '../entities/conversation.entity';
|
|
4
7
|
export declare class ConversationController {
|
|
5
8
|
protected sourceType: string;
|
|
6
9
|
protected parentValidator: any;
|
|
10
|
+
protected readonly documentService: DocumentService;
|
|
11
|
+
protected type_id: number;
|
|
7
12
|
show(params: AccessBusinessParamDto): Promise<ConversationEntity[]>;
|
|
8
13
|
create(params: AccessBusinessParamDto, body: AddConversationDto): Promise<ConversationEntity>;
|
|
9
14
|
delete(params: AccessBusinessParamDto): Promise<ConversationEntity>;
|
|
15
|
+
getDocuments(params: BusinessParamDto): Promise<any>;
|
|
16
|
+
createDocument(params: BusinessParamDto, body: DocumentFileUploadDto): Promise<DocumentEntity[]>;
|
|
17
|
+
deleteDocument(params: BusinessParamDto): Promise<DocumentEntity>;
|
|
18
|
+
private getSource;
|
|
10
19
|
protected checkAccess(params: AccessBusinessParamDto): Promise<any>;
|
|
11
20
|
}
|
|
@@ -15,9 +15,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ConversationController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
18
|
-
const
|
|
18
|
+
const document_file_upload_dto_1 = require("../../accessUtility/dtos/document.file.upload.dto");
|
|
19
19
|
const access_business_param_dto_1 = require("../dtos/access.business.param.dto");
|
|
20
20
|
const add_conversation_dto_1 = require("../dtos/add.conversation.dto");
|
|
21
|
+
const business_param_dto_1 = require("../dtos/business.param.dto");
|
|
22
|
+
const conversation_entity_1 = require("../entities/conversation.entity");
|
|
21
23
|
const process_conversation_data_1 = require("./process.conversation.data");
|
|
22
24
|
class ConversationController {
|
|
23
25
|
async show(params) {
|
|
@@ -41,6 +43,41 @@ class ConversationController {
|
|
|
41
43
|
throw new nestjs_utility_services_1.AccessException(`You don't have access to this record`);
|
|
42
44
|
return record.softDelete();
|
|
43
45
|
}
|
|
46
|
+
async getDocuments(params) {
|
|
47
|
+
await this.checkAccess(params);
|
|
48
|
+
const where = this.getSource(params);
|
|
49
|
+
return this.documentService.getDocuments(where);
|
|
50
|
+
}
|
|
51
|
+
async createDocument(params, body) {
|
|
52
|
+
await this.checkAccess(params);
|
|
53
|
+
const source = this.getSource(params);
|
|
54
|
+
if (this.type_id) {
|
|
55
|
+
const r = [];
|
|
56
|
+
for (const file of body.files) {
|
|
57
|
+
r.push({ ...file, type_id: this.type_id });
|
|
58
|
+
}
|
|
59
|
+
body.files = r;
|
|
60
|
+
}
|
|
61
|
+
return this.documentService.setDocuments(source, body.files);
|
|
62
|
+
}
|
|
63
|
+
async deleteDocument(params) {
|
|
64
|
+
await this.checkAccess(params);
|
|
65
|
+
const document = await nestjs_utility_services_1.DocumentEntity.first(params.account_id);
|
|
66
|
+
if (!document)
|
|
67
|
+
throw new common_1.NotFoundException();
|
|
68
|
+
if (!(document.source_type === this.sourceType && document.source_id === params.id))
|
|
69
|
+
throw new nestjs_utility_services_1.AccessException();
|
|
70
|
+
const user = nestjs_utility_services_1.Auth.user();
|
|
71
|
+
if (document.created_by !== user.id)
|
|
72
|
+
throw new nestjs_utility_services_1.OperationException(`Only creator can delete the document`);
|
|
73
|
+
return document.softDelete();
|
|
74
|
+
}
|
|
75
|
+
getSource(params) {
|
|
76
|
+
let where = { source_type: this.sourceType, source_id: params.id };
|
|
77
|
+
if (this.type_id)
|
|
78
|
+
where = { ...where, type_id: this.type_id };
|
|
79
|
+
return where;
|
|
80
|
+
}
|
|
44
81
|
async checkAccess(params) {
|
|
45
82
|
return this.parentValidator(params.id);
|
|
46
83
|
}
|
|
@@ -68,4 +105,26 @@ __decorate([
|
|
|
68
105
|
__metadata("design:paramtypes", [access_business_param_dto_1.AccessBusinessParamDto]),
|
|
69
106
|
__metadata("design:returntype", Promise)
|
|
70
107
|
], ConversationController.prototype, "delete", null);
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, common_1.Get)(':id/documents'),
|
|
110
|
+
__param(0, (0, common_1.Param)()),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [business_param_dto_1.BusinessParamDto]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], ConversationController.prototype, "getDocuments", null);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, common_1.Post)(':id/document'),
|
|
117
|
+
__param(0, (0, common_1.Param)()),
|
|
118
|
+
__param(1, (0, common_1.Body)()),
|
|
119
|
+
__metadata("design:type", Function),
|
|
120
|
+
__metadata("design:paramtypes", [business_param_dto_1.BusinessParamDto, document_file_upload_dto_1.DocumentFileUploadDto]),
|
|
121
|
+
__metadata("design:returntype", Promise)
|
|
122
|
+
], ConversationController.prototype, "createDocument", null);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, common_1.Delete)(':id/document/:account_id'),
|
|
125
|
+
__param(0, (0, common_1.Param)()),
|
|
126
|
+
__metadata("design:type", Function),
|
|
127
|
+
__metadata("design:paramtypes", [business_param_dto_1.BusinessParamDto]),
|
|
128
|
+
__metadata("design:returntype", Promise)
|
|
129
|
+
], ConversationController.prototype, "deleteDocument", null);
|
|
71
130
|
//# sourceMappingURL=conversation.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.controller.js","sourceRoot":"","sources":["../../../src/access/libraries/conversation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"conversation.controller.js","sourceRoot":"","sources":["../../../src/access/libraries/conversation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,oFAQgD;AAChD,gGAA0F;AAC1F,iFAA2E;AAC3E,uEAAkE;AAClE,mEAA8D;AAC9D,yEAAqE;AACrE,2EAAsE;AAEtE,MAAa,sBAAsB;IAQzB,AAAN,KAAK,CAAC,IAAI,CAAU,MAA8B;QAC9C,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE/B,OAAO,wCAAkB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACtG,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAU,MAA8B,EAAU,IAAwB;QAClF,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAoB,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QAEvF,OAAO,IAAI,mDAAuB,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAGK,AAAN,KAAK,CAAC,MAAM,CAAU,MAA8B;QAChD,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE/B,MAAM,IAAI,GAAG,8B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A;;qCAAS,kDAAsB;;kDAIjD;AAGK;IADL,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACX,WAAA,IAAA,cAAK,GAAE,CAAA;IAAkC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAA/B,kDAAsB,EAAgB,yCAAkB;;oDAMrF;AAGK;IADL,IAAA,eAAM,EAAC,4BAA4B,CAAC;IACvB,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAS,kDAAsB;;oDAcnD;AAGK;IADL,IAAA,YAAG,EAAC,eAAe,CAAC;IACD,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAS,qCAAgB;;0DAKnD;AAGK;IADL,IAAA,aAAI,EAAC,cAAc,CAAC;IACC,WAAA,IAAA,cAAK,GAAE,CAAA;IAA4B,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAzB,qCAAgB,EAAgB,gDAAqB;;4DAe1F;AAGK;IADL,IAAA,eAAM,EAAC,0BAA0B,CAAC;IACb,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAS,qCAAgB;;4DAarD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ErrorHandlingDto } from '../dtos/error.handling.dto';
|
|
2
2
|
export declare class ProcessCommonData {
|
|
3
3
|
protected payload: any;
|
|
4
|
+
protected allowedColumns: string[];
|
|
4
5
|
protected errors: ErrorHandlingDto;
|
|
5
6
|
protected setColumnError(column: string, error: string): void;
|
|
6
7
|
protected setError(error: string): void;
|
|
7
8
|
protected throwExceptionOnError(): boolean;
|
|
8
9
|
protected getPayloadData(column: string): any;
|
|
10
|
+
protected setEntity(entity: any): Promise<any>;
|
|
9
11
|
}
|
|
@@ -4,6 +4,7 @@ exports.ProcessCommonData = void 0;
|
|
|
4
4
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
5
5
|
class ProcessCommonData {
|
|
6
6
|
constructor() {
|
|
7
|
+
this.allowedColumns = [];
|
|
7
8
|
this.errors = { columns: {}, others: [] };
|
|
8
9
|
}
|
|
9
10
|
setColumnError(column, error) {
|
|
@@ -15,7 +16,6 @@ class ProcessCommonData {
|
|
|
15
16
|
this.errors.others.push(error);
|
|
16
17
|
}
|
|
17
18
|
throwExceptionOnError() {
|
|
18
|
-
global.console.log('this.errors.columns', this.errors.columns);
|
|
19
19
|
const keys = Object.keys(this.errors.columns);
|
|
20
20
|
if (keys.length)
|
|
21
21
|
throw new nestjs_utility_services_1.OperationException(this.errors);
|
|
@@ -29,6 +29,11 @@ class ProcessCommonData {
|
|
|
29
29
|
return null;
|
|
30
30
|
return data;
|
|
31
31
|
}
|
|
32
|
+
async setEntity(entity) {
|
|
33
|
+
for (const column of this.allowedColumns)
|
|
34
|
+
entity[column] = this.payload[column];
|
|
35
|
+
return entity.save();
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
exports.ProcessCommonData = ProcessCommonData;
|
|
34
39
|
//# sourceMappingURL=process.common.data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.common.data.js","sourceRoot":"","sources":["../../../src/accessUtility/libraries/process.common.data.ts"],"names":[],"mappings":";;;AAAA,oFAA4E;AAG5E,MAAa,iBAAiB;IAA9B;
|
|
1
|
+
{"version":3,"file":"process.common.data.js","sourceRoot":"","sources":["../../../src/accessUtility/libraries/process.common.data.ts"],"names":[],"mappings":";;;AAAA,oFAA4E;AAG5E,MAAa,iBAAiB;IAA9B;QAEc,mBAAc,GAAa,EAAE,CAAC;QAQ9B,WAAM,GAAqB,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAkErE,CAAC;IAzDa,cAAc,CAAC,MAAc,EAAE,KAAa;QAClD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAEnE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAA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