rez_core 2.2.188 → 2.2.190
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/module/communication/controller/communication.controller.d.ts +22 -2
- package/dist/module/communication/controller/communication.controller.js +79 -3
- package/dist/module/communication/controller/communication.controller.js.map +1 -1
- package/dist/module/communication/dto/create-config.dto.d.ts +12 -0
- package/dist/module/communication/dto/create-config.dto.js +36 -1
- package/dist/module/communication/dto/create-config.dto.js.map +1 -1
- package/dist/module/communication/service/communication.service.d.ts +2 -30
- package/dist/module/communication/service/communication.service.js +30 -73
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.d.ts +8 -0
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js +52 -0
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js.map +1 -1
- package/dist/module/ics/service/ics.service.d.ts +2 -3
- package/dist/module/ics/service/ics.service.js +41 -35
- package/dist/module/ics/service/ics.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +2 -4
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/notification/controller/notification.controller.d.ts +5 -1
- package/dist/module/notification/controller/notification.controller.js +16 -3
- package/dist/module/notification/controller/notification.controller.js.map +1 -1
- package/dist/module/notification/service/notification.service.d.ts +7 -1
- package/dist/module/notification/service/notification.service.js +27 -12
- package/dist/module/notification/service/notification.service.js.map +1 -1
- package/dist/module/workflow/controller/comm-template.controller.d.ts +1 -1
- package/dist/module/workflow/controller/comm-template.controller.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +2 -2
- package/dist/module/workflow/entity/task-data.entity.js +3 -3
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -1
- package/dist/module/workflow/repository/comm-template.repository.d.ts +1 -1
- package/dist/module/workflow/repository/comm-template.repository.js +17 -11
- package/dist/module/workflow/repository/comm-template.repository.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.d.ts +1 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/controller/communication.controller.ts +96 -16
- package/src/module/communication/dto/create-config.dto.ts +26 -0
- package/src/module/communication/service/communication.service.ts +69 -128
- package/src/module/communication/strategies/email/sendgrid-api.strategy.ts +65 -0
- package/src/module/ics/service/ics.service.ts +49 -37
- package/src/module/listmaster/service/list-master.service.ts +3 -6
- package/src/module/notification/controller/notification.controller.ts +21 -3
- package/src/module/notification/service/notification.service.ts +45 -20
- package/src/module/workflow/controller/comm-template.controller.ts +1 -1
- package/src/module/workflow/entity/task-data.entity.ts +3 -3
- package/src/module/workflow/repository/comm-template.repository.ts +30 -19
- package/src/module/workflow/service/comm-template.service.ts +2 -2
- package/src/module/workflow/service/task.service.ts +1 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { CommunicationService } from '../service/communication.service';
|
|
2
|
-
import {
|
|
2
|
+
import { SendGridApiStrategy } from '../strategies/email/sendgrid-api.strategy';
|
|
3
|
+
import { BulkMessageDto, CreateConfigDto, GenericSendMessageDto, GmailOAuthInitDto, OutlookOAuthInitDto, SendGridVerifiedSendersDto, UpdateConfigStatusDto } from '../dto/create-config.dto';
|
|
3
4
|
export declare class ScheduledMessageDto extends GenericSendMessageDto {
|
|
4
5
|
scheduleFor: Date;
|
|
5
6
|
timezone?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class CommunicationController {
|
|
8
9
|
private readonly communicationService;
|
|
9
|
-
|
|
10
|
+
private readonly sendGridApiStrategy;
|
|
11
|
+
constructor(communicationService: CommunicationService, sendGridApiStrategy: SendGridApiStrategy);
|
|
10
12
|
sendMessage(sendMessageDto: GenericSendMessageDto): Promise<import("../strategies/communication.strategy").CommunicationResult>;
|
|
11
13
|
sendBulkMessage(bulkMessageDto: BulkMessageDto): Promise<{
|
|
12
14
|
results: import("../strategies/communication.strategy").CommunicationResult[];
|
|
@@ -27,6 +29,12 @@ export declare class CommunicationController {
|
|
|
27
29
|
authUrl: string;
|
|
28
30
|
state: string;
|
|
29
31
|
message: string;
|
|
32
|
+
} | {
|
|
33
|
+
success: boolean;
|
|
34
|
+
requiresOAuth: boolean;
|
|
35
|
+
authUrl: any;
|
|
36
|
+
state: any;
|
|
37
|
+
message: any;
|
|
30
38
|
}>;
|
|
31
39
|
getSupportedCombinations(): Promise<{
|
|
32
40
|
mode: string;
|
|
@@ -57,4 +65,16 @@ export declare class CommunicationController {
|
|
|
57
65
|
authUrl: string;
|
|
58
66
|
state: string;
|
|
59
67
|
}>;
|
|
68
|
+
getSendGridVerifiedSenders(dto: SendGridVerifiedSendersDto): Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
data?: Array<{
|
|
71
|
+
label: string;
|
|
72
|
+
value: string;
|
|
73
|
+
}>;
|
|
74
|
+
error?: string;
|
|
75
|
+
}>;
|
|
76
|
+
disconnectConfig(hubId: number): Promise<{
|
|
77
|
+
success: boolean;
|
|
78
|
+
message: string;
|
|
79
|
+
}>;
|
|
60
80
|
}
|
|
@@ -15,13 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.CommunicationController = exports.ScheduledMessageDto = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const communication_service_1 = require("../service/communication.service");
|
|
18
|
+
const sendgrid_api_strategy_1 = require("../strategies/email/sendgrid-api.strategy");
|
|
18
19
|
const create_config_dto_1 = require("../dto/create-config.dto");
|
|
19
20
|
class ScheduledMessageDto extends create_config_dto_1.GenericSendMessageDto {
|
|
20
21
|
}
|
|
21
22
|
exports.ScheduledMessageDto = ScheduledMessageDto;
|
|
22
23
|
let CommunicationController = class CommunicationController {
|
|
23
|
-
constructor(communicationService) {
|
|
24
|
+
constructor(communicationService, sendGridApiStrategy) {
|
|
24
25
|
this.communicationService = communicationService;
|
|
26
|
+
this.sendGridApiStrategy = sendGridApiStrategy;
|
|
25
27
|
}
|
|
26
28
|
async sendMessage(sendMessageDto) {
|
|
27
29
|
return this.communicationService.sendGenericMessage(sendMessageDto);
|
|
@@ -36,7 +38,44 @@ let CommunicationController = class CommunicationController {
|
|
|
36
38
|
return this.communicationService.sendTemplateMessage(templateMessage);
|
|
37
39
|
}
|
|
38
40
|
async createConfig(createConfigDto) {
|
|
39
|
-
|
|
41
|
+
try {
|
|
42
|
+
const result = await this.communicationService.createCommunicationConfig(createConfigDto.levelId, createConfigDto.levelType, createConfigDto.configType, createConfigDto.service, createConfigDto.provider, createConfigDto.config, createConfigDto.priority, createConfigDto.is_default);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.message?.includes('active') &&
|
|
47
|
+
error.message?.includes('configuration already exists')) {
|
|
48
|
+
throw new common_1.BadRequestException({
|
|
49
|
+
success: false,
|
|
50
|
+
error: 'DUPLICATE_CONFIGURATION',
|
|
51
|
+
message: error.message,
|
|
52
|
+
code: 'VALIDATION_ERROR',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (error.message?.includes('Unsupported combination')) {
|
|
56
|
+
throw new common_1.BadRequestException({
|
|
57
|
+
success: false,
|
|
58
|
+
error: 'UNSUPPORTED_COMBINATION',
|
|
59
|
+
message: error.message,
|
|
60
|
+
code: 'VALIDATION_ERROR',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (error.authUrl && error.state) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
requiresOAuth: true,
|
|
67
|
+
authUrl: error.authUrl,
|
|
68
|
+
state: error.state,
|
|
69
|
+
message: error.message || 'OAuth authorization required',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
throw new common_1.BadRequestException({
|
|
73
|
+
success: false,
|
|
74
|
+
error: 'CONFIGURATION_ERROR',
|
|
75
|
+
message: error.message || 'Failed to create communication configuration',
|
|
76
|
+
code: 'INTERNAL_ERROR',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
40
79
|
}
|
|
41
80
|
async getSupportedCombinations() {
|
|
42
81
|
return this.communicationService.getSupportedCombinations();
|
|
@@ -65,6 +104,26 @@ let CommunicationController = class CommunicationController {
|
|
|
65
104
|
async initOutlookOAuth(initDto) {
|
|
66
105
|
return this.communicationService.initOutlookOAuth(initDto.levelId, initDto.levelType, initDto.email);
|
|
67
106
|
}
|
|
107
|
+
async getSendGridVerifiedSenders(dto) {
|
|
108
|
+
return this.sendGridApiStrategy.getVerifiedSenders(dto.apiKey);
|
|
109
|
+
}
|
|
110
|
+
async disconnectConfig(hubId) {
|
|
111
|
+
try {
|
|
112
|
+
await this.communicationService.deleteConfiguration(hubId);
|
|
113
|
+
return {
|
|
114
|
+
success: true,
|
|
115
|
+
message: 'Communication configuration deleted successfully',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw new common_1.BadRequestException({
|
|
120
|
+
success: false,
|
|
121
|
+
error: 'DELETE_ERROR',
|
|
122
|
+
message: error.message || 'Failed to delete communication configuration',
|
|
123
|
+
code: 'CONFIGURATION_ERROR',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
68
127
|
};
|
|
69
128
|
exports.CommunicationController = CommunicationController;
|
|
70
129
|
__decorate([
|
|
@@ -161,8 +220,25 @@ __decorate([
|
|
|
161
220
|
__metadata("design:paramtypes", [create_config_dto_1.OutlookOAuthInitDto]),
|
|
162
221
|
__metadata("design:returntype", Promise)
|
|
163
222
|
], CommunicationController.prototype, "initOutlookOAuth", null);
|
|
223
|
+
__decorate([
|
|
224
|
+
(0, common_1.Post)('sendgrid/verified-senders'),
|
|
225
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
226
|
+
__param(0, (0, common_1.Body)()),
|
|
227
|
+
__metadata("design:type", Function),
|
|
228
|
+
__metadata("design:paramtypes", [create_config_dto_1.SendGridVerifiedSendersDto]),
|
|
229
|
+
__metadata("design:returntype", Promise)
|
|
230
|
+
], CommunicationController.prototype, "getSendGridVerifiedSenders", null);
|
|
231
|
+
__decorate([
|
|
232
|
+
(0, common_1.Post)('config/delete/:hubId'),
|
|
233
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
234
|
+
__param(0, (0, common_1.Param)('hubId', common_1.ParseIntPipe)),
|
|
235
|
+
__metadata("design:type", Function),
|
|
236
|
+
__metadata("design:paramtypes", [Number]),
|
|
237
|
+
__metadata("design:returntype", Promise)
|
|
238
|
+
], CommunicationController.prototype, "disconnectConfig", null);
|
|
164
239
|
exports.CommunicationController = CommunicationController = __decorate([
|
|
165
240
|
(0, common_1.Controller)('communication'),
|
|
166
|
-
__metadata("design:paramtypes", [communication_service_1.CommunicationService
|
|
241
|
+
__metadata("design:paramtypes", [communication_service_1.CommunicationService,
|
|
242
|
+
sendgrid_api_strategy_1.SendGridApiStrategy])
|
|
167
243
|
], CommunicationController);
|
|
168
244
|
//# sourceMappingURL=communication.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication.controller.js","sourceRoot":"","sources":["../../../../src/module/communication/controller/communication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"communication.controller.js","sourceRoot":"","sources":["../../../../src/module/communication/controller/communication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAYwB;AACxB,4EAAwE;AACxE,qFAAgF;AAChF,gEAQkC;AAElC,MAAa,mBAAoB,SAAQ,yCAAqB;CAG7D;AAHD,kDAGC;AAGM,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,YACmB,oBAA0C,EAC1C,mBAAwC;QADxC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,wBAAmB,GAAnB,mBAAmB,CAAqB;IACxD,CAAC;IAIE,AAAN,KAAK,CAAC,WAAW,CAAS,cAAqC;QAC7D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
|
|
93
|
+
apiKey: string;
|
|
94
|
+
}
|
|
95
|
+
export declare class VerifiedSenderDto {
|
|
96
|
+
label: string;
|
|
97
|
+
value: string;
|
|
98
|
+
}
|
|
99
|
+
export declare class VerifiedSendersResponseDto {
|
|
100
|
+
success: boolean;
|
|
101
|
+
data?: VerifiedSenderDto[];
|
|
102
|
+
error?: string;
|
|
103
|
+
}
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OutlookOAuthInitDto = exports.OAuthCallbackDto = exports.GmailOAuthInitDto = exports.BulkMessageDto = exports.GenericSendMessageDto = exports.UpdateConfigStatusDto = exports.CreateConfigDto = void 0;
|
|
12
|
+
exports.VerifiedSendersResponseDto = exports.VerifiedSenderDto = exports.SendGridVerifiedSendersDto = exports.OutlookOAuthInitDto = exports.OAuthCallbackDto = exports.GmailOAuthInitDto = exports.BulkMessageDto = exports.GenericSendMessageDto = exports.UpdateConfigStatusDto = exports.CreateConfigDto = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const communication_hub_entity_1 = require("../entity/communication-hub.entity");
|
|
15
15
|
class CreateConfigDto {
|
|
@@ -250,4 +250,39 @@ __decorate([
|
|
|
250
250
|
(0, class_validator_1.IsString)(),
|
|
251
251
|
__metadata("design:type", String)
|
|
252
252
|
], OutlookOAuthInitDto.prototype, "email", void 0);
|
|
253
|
+
class SendGridVerifiedSendersDto {
|
|
254
|
+
}
|
|
255
|
+
exports.SendGridVerifiedSendersDto = SendGridVerifiedSendersDto;
|
|
256
|
+
__decorate([
|
|
257
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
258
|
+
(0, class_validator_1.IsString)(),
|
|
259
|
+
__metadata("design:type", String)
|
|
260
|
+
], SendGridVerifiedSendersDto.prototype, "apiKey", void 0);
|
|
261
|
+
class VerifiedSenderDto {
|
|
262
|
+
}
|
|
263
|
+
exports.VerifiedSenderDto = VerifiedSenderDto;
|
|
264
|
+
__decorate([
|
|
265
|
+
(0, class_validator_1.IsString)(),
|
|
266
|
+
__metadata("design:type", String)
|
|
267
|
+
], VerifiedSenderDto.prototype, "label", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
(0, class_validator_1.IsString)(),
|
|
270
|
+
__metadata("design:type", String)
|
|
271
|
+
], VerifiedSenderDto.prototype, "value", void 0);
|
|
272
|
+
class VerifiedSendersResponseDto {
|
|
273
|
+
}
|
|
274
|
+
exports.VerifiedSendersResponseDto = VerifiedSendersResponseDto;
|
|
275
|
+
__decorate([
|
|
276
|
+
(0, class_validator_1.IsBoolean)(),
|
|
277
|
+
__metadata("design:type", Boolean)
|
|
278
|
+
], VerifiedSendersResponseDto.prototype, "success", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
(0, class_validator_1.IsOptional)(),
|
|
281
|
+
__metadata("design:type", Array)
|
|
282
|
+
], VerifiedSendersResponseDto.prototype, "data", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
(0, class_validator_1.IsOptional)(),
|
|
285
|
+
(0, class_validator_1.IsString)(),
|
|
286
|
+
__metadata("design:type", String)
|
|
287
|
+
], VerifiedSendersResponseDto.prototype, "error", void 0);
|
|
253
288
|
//# sourceMappingURL=create-config.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-config.dto.js","sourceRoot":"","sources":["../../../../src/module/communication/dto/create-config.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDASyB;AACzB,iFAA6E;AAE7E,MAAa,eAAe;CAiG3B;AAjGD,0CAiGC;AA9FC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACK;AAIhB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACO;AAI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IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACO;AAIlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACI;AAGjB,MAAa,gBAAgB;CAQ5B;AARD,4CAQC;AALC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;8CACE;AAIb;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACG;AAGhB,MAAa,mBAAmB;CAY/B;AAZD,kDAYC;AATC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACK;AAIhB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sDACO;AAIlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACI;AAGjB,MAAa,0BAA0B;CAItC;AAJD,gEAIC;AADC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;0DACI;AAGjB,MAAa,iBAAiB;CAM7B;AAND,8CAMC;AAJC;IADC,IAAA,0BAAQ,GAAE;;gDACG;AAGd;IADC,IAAA,0BAAQ,GAAE;;gDACG;AAGhB,MAAa,0BAA0B;CAUtC;AAVD,gEAUC;AARC;IADC,IAAA,2BAAS,GAAE;;2DACK;AAGjB;IADC,IAAA,4BAAU,GAAE;;wDACc;AAI3B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;yDACI"}
|
|
@@ -85,6 +85,7 @@ export declare class CommunicationService {
|
|
|
85
85
|
private extractLinkedSource;
|
|
86
86
|
private extractConfigDetails;
|
|
87
87
|
updateConfigStatus(hubId: number, status: number): Promise<void>;
|
|
88
|
+
deleteConfiguration(hubId: number): Promise<void>;
|
|
88
89
|
sendGenericMessage(messageDto: GenericMessageDto): Promise<CommunicationResult>;
|
|
89
90
|
sendBulkMessage(bulkDto: BulkMessageDto): Promise<{
|
|
90
91
|
results: CommunicationResult[];
|
|
@@ -111,6 +112,7 @@ export declare class CommunicationService {
|
|
|
111
112
|
error?: string;
|
|
112
113
|
}>;
|
|
113
114
|
private generateSecureState;
|
|
115
|
+
private validateUniqueActiveConfig;
|
|
114
116
|
private requiresOAuthFlow;
|
|
115
117
|
private generateOAuthUrl;
|
|
116
118
|
private createDirectConfig;
|
|
@@ -119,34 +121,4 @@ export declare class CommunicationService {
|
|
|
119
121
|
state: string;
|
|
120
122
|
}>;
|
|
121
123
|
handleOutlookOAuthCallback(code: string, state: string): Promise<GmailSSOResult>;
|
|
122
|
-
queueMessage(messageDto: GenericMessageDto & {
|
|
123
|
-
useQueue?: boolean;
|
|
124
|
-
scheduledFor?: Date;
|
|
125
|
-
}): Promise<{
|
|
126
|
-
queued: boolean;
|
|
127
|
-
messageId?: string;
|
|
128
|
-
result?: CommunicationResult;
|
|
129
|
-
}>;
|
|
130
|
-
queueBulkMessage(bulkDto: BulkMessageDto & {
|
|
131
|
-
useQueue?: boolean;
|
|
132
|
-
scheduledFor?: Date;
|
|
133
|
-
}): Promise<{
|
|
134
|
-
queued: boolean;
|
|
135
|
-
messageIds?: string[];
|
|
136
|
-
result?: any;
|
|
137
|
-
}>;
|
|
138
|
-
isQueueAvailable(): boolean;
|
|
139
|
-
getQueueStats(): {
|
|
140
|
-
total: number;
|
|
141
|
-
pending: number;
|
|
142
|
-
scheduled: number;
|
|
143
|
-
byPriority: {
|
|
144
|
-
high: number;
|
|
145
|
-
medium: number;
|
|
146
|
-
low: number;
|
|
147
|
-
};
|
|
148
|
-
processing: boolean;
|
|
149
|
-
} | null;
|
|
150
|
-
cancelQueuedMessage(messageId: string): boolean;
|
|
151
|
-
private mapPriorityToSimpleQueue;
|
|
152
124
|
}
|
|
@@ -139,6 +139,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
async createCommunicationConfig(levelId, levelType, configType, service, provider, config, priority, is_default) {
|
|
142
|
+
await this.validateUniqueActiveConfig(levelId, levelType, configType);
|
|
142
143
|
const supportedCombinations = await this.getSupportedCombinations();
|
|
143
144
|
const isValidCombination = supportedCombinations.some((combo) => combo.mode === configType &&
|
|
144
145
|
combo.service.toLowerCase() === service.toLowerCase() &&
|
|
@@ -384,6 +385,17 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
384
385
|
async updateConfigStatus(hubId, status) {
|
|
385
386
|
await this.hubRepository.update(hubId, { status });
|
|
386
387
|
}
|
|
388
|
+
async deleteConfiguration(hubId) {
|
|
389
|
+
const hub = await this.hubRepository.findOne({
|
|
390
|
+
where: { id: hubId },
|
|
391
|
+
});
|
|
392
|
+
if (!hub) {
|
|
393
|
+
throw new Error('Communication configuration not found');
|
|
394
|
+
}
|
|
395
|
+
await this.hubRepository.delete(hubId);
|
|
396
|
+
await this.configRepository.delete(hub.config_id);
|
|
397
|
+
this.logger.log(`Communication configuration deleted: Hub ${hubId}, Config ${hub.config_id}`);
|
|
398
|
+
}
|
|
387
399
|
async sendGenericMessage(messageDto) {
|
|
388
400
|
try {
|
|
389
401
|
const { levelId, levelType, to, message, type, priority = 'medium', subject, html, cc, bcc, attachments, mediaUrl, templateId, variables, } = messageDto;
|
|
@@ -636,6 +648,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
636
648
|
'https://www.googleapis.com/auth/gmail.send',
|
|
637
649
|
'https://www.googleapis.com/auth/gmail.readonly',
|
|
638
650
|
'https://www.googleapis.com/auth/userinfo.email',
|
|
651
|
+
'https://www.googleapis.com/auth/calendar',
|
|
639
652
|
];
|
|
640
653
|
const authUrl = oauth2Client.generateAuthUrl({
|
|
641
654
|
access_type: 'offline',
|
|
@@ -690,6 +703,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
690
703
|
tokenType: tokens.token_type,
|
|
691
704
|
expiryDate: tokens.expiry_date,
|
|
692
705
|
};
|
|
706
|
+
await this.validateUniqueActiveConfig(oauthState.levelId, oauthState.levelType, communication_hub_entity_1.CommunicationConfigType.EMAIL);
|
|
693
707
|
const communicationConfig = this.configRepository.create({
|
|
694
708
|
config_json: gmailConfig,
|
|
695
709
|
});
|
|
@@ -728,6 +742,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
728
742
|
if (oauthState.email && oauthState.email !== email) {
|
|
729
743
|
throw new Error('Email mismatch with OAuth hint');
|
|
730
744
|
}
|
|
745
|
+
await this.validateUniqueActiveConfig(oauthState.levelId, oauthState.levelType, communication_hub_entity_1.CommunicationConfigType.EMAIL);
|
|
731
746
|
const gmailConfig = {
|
|
732
747
|
email: email,
|
|
733
748
|
accessToken: accessToken,
|
|
@@ -794,6 +809,19 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
794
809
|
generateSecureState() {
|
|
795
810
|
return Math.random().toString(36).substring(2) + Date.now().toString(36);
|
|
796
811
|
}
|
|
812
|
+
async validateUniqueActiveConfig(levelId, levelType, configType) {
|
|
813
|
+
const existingActiveConfig = await this.hubRepository.findOne({
|
|
814
|
+
where: {
|
|
815
|
+
level_id: levelId,
|
|
816
|
+
level_type: levelType,
|
|
817
|
+
communication_config_type: configType,
|
|
818
|
+
status: 1,
|
|
819
|
+
},
|
|
820
|
+
});
|
|
821
|
+
if (existingActiveConfig) {
|
|
822
|
+
throw new Error(`An active ${configType} configuration already exists for ${levelType} ${levelId}. Please deactivate the existing configuration first.`);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
797
825
|
requiresOAuthFlow(configType, service, provider, config) {
|
|
798
826
|
const key = `${configType.toLowerCase()}_${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
799
827
|
switch (key) {
|
|
@@ -827,6 +855,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
827
855
|
}
|
|
828
856
|
}
|
|
829
857
|
async createDirectConfig(levelId, levelType, configType, service, provider, config, priority, is_default) {
|
|
858
|
+
await this.validateUniqueActiveConfig(levelId, levelType, configType);
|
|
830
859
|
if (is_default) {
|
|
831
860
|
await this.hubRepository.update({
|
|
832
861
|
level_id: levelId,
|
|
@@ -934,6 +963,7 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
934
963
|
if (!email) {
|
|
935
964
|
throw new Error('Failed to get user email');
|
|
936
965
|
}
|
|
966
|
+
await this.validateUniqueActiveConfig(oauthState.levelId, oauthState.levelType, communication_hub_entity_1.CommunicationConfigType.EMAIL);
|
|
937
967
|
const outlookConfig = {
|
|
938
968
|
clientId,
|
|
939
969
|
tenantId,
|
|
@@ -969,79 +999,6 @@ let CommunicationService = CommunicationService_1 = class CommunicationService {
|
|
|
969
999
|
throw new Error(`Failed to complete Outlook OAuth: ${error.message}`);
|
|
970
1000
|
}
|
|
971
1001
|
}
|
|
972
|
-
async queueMessage(messageDto) {
|
|
973
|
-
if (!this.queueService || !messageDto.useQueue) {
|
|
974
|
-
const result = await this.sendGenericMessage(messageDto);
|
|
975
|
-
return { queued: false, result };
|
|
976
|
-
}
|
|
977
|
-
try {
|
|
978
|
-
const priority = this.mapPriorityToSimpleQueue(messageDto.priority);
|
|
979
|
-
const messageId = await this.queueService.queueMessage(messageDto.levelId, messageDto.levelType, Array.isArray(messageDto.to) ? messageDto.to[0] : messageDto.to, messageDto.message, messageDto.type, priority, messageDto.scheduledFor, {
|
|
980
|
-
subject: messageDto.subject,
|
|
981
|
-
html: messageDto.html,
|
|
982
|
-
cc: messageDto.cc,
|
|
983
|
-
bcc: messageDto.bcc,
|
|
984
|
-
attachments: messageDto.attachments,
|
|
985
|
-
mediaUrl: messageDto.mediaUrl,
|
|
986
|
-
templateId: messageDto.templateId,
|
|
987
|
-
variables: messageDto.variables,
|
|
988
|
-
});
|
|
989
|
-
return { queued: true, messageId };
|
|
990
|
-
}
|
|
991
|
-
catch (error) {
|
|
992
|
-
this.logger.error('Error queuing message, falling back to immediate send:', error.message);
|
|
993
|
-
const result = await this.sendGenericMessage(messageDto);
|
|
994
|
-
return { queued: false, result };
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
async queueBulkMessage(bulkDto) {
|
|
998
|
-
if (!this.queueService || !bulkDto.useQueue) {
|
|
999
|
-
const result = await this.sendBulkMessage(bulkDto);
|
|
1000
|
-
return { queued: false, result };
|
|
1001
|
-
}
|
|
1002
|
-
try {
|
|
1003
|
-
const priority = this.mapPriorityToSimpleQueue(bulkDto.priority) || 'low';
|
|
1004
|
-
const messageIds = await this.queueService.queueBulkMessages(bulkDto.levelId, bulkDto.levelType, bulkDto.recipients, bulkDto.message, bulkDto.type, priority, {
|
|
1005
|
-
subject: bulkDto.subject,
|
|
1006
|
-
html: bulkDto.html,
|
|
1007
|
-
templateId: bulkDto.templateId,
|
|
1008
|
-
variables: bulkDto.variables,
|
|
1009
|
-
});
|
|
1010
|
-
return { queued: true, messageIds };
|
|
1011
|
-
}
|
|
1012
|
-
catch (error) {
|
|
1013
|
-
this.logger.error('Error queuing bulk message, falling back to immediate send:', error.message);
|
|
1014
|
-
const result = await this.sendBulkMessage(bulkDto);
|
|
1015
|
-
return { queued: false, result };
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
isQueueAvailable() {
|
|
1019
|
-
return !!this.queueService;
|
|
1020
|
-
}
|
|
1021
|
-
getQueueStats() {
|
|
1022
|
-
if (!this.queueService) {
|
|
1023
|
-
return null;
|
|
1024
|
-
}
|
|
1025
|
-
return this.queueService.getQueueStats();
|
|
1026
|
-
}
|
|
1027
|
-
cancelQueuedMessage(messageId) {
|
|
1028
|
-
if (!this.queueService) {
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1031
|
-
return this.queueService.cancelMessage(messageId);
|
|
1032
|
-
}
|
|
1033
|
-
mapPriorityToSimpleQueue(priority) {
|
|
1034
|
-
switch (priority?.toLowerCase()) {
|
|
1035
|
-
case 'high':
|
|
1036
|
-
case 'urgent':
|
|
1037
|
-
return 'high';
|
|
1038
|
-
case 'low':
|
|
1039
|
-
return 'low';
|
|
1040
|
-
case 'medium':
|
|
1041
|
-
default:
|
|
1042
|
-
return 'medium';
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
1002
|
};
|
|
1046
1003
|
exports.CommunicationService = CommunicationService;
|
|
1047
1004
|
exports.CommunicationService = CommunicationService = CommunicationService_1 = __decorate([
|