rez_core 2.2.258 → 2.2.259
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/app.module.js +2 -2
- package/dist/app.module.js.map +1 -1
- package/dist/module/integration/controller/calender-event.controller.js.map +1 -0
- package/dist/module/integration/controller/integration.controller.d.ts +113 -0
- package/dist/module/{communication/controller/communication.controller.js → integration/controller/integration.controller.js} +197 -75
- package/dist/module/integration/controller/integration.controller.js.map +1 -0
- package/dist/module/{communication → integration}/controller/wrapper.controller.d.ts +1 -1
- package/dist/module/integration/controller/wrapper.controller.js.map +1 -0
- package/dist/module/{communication → integration}/dto/create-config.dto.d.ts +48 -4
- package/dist/module/{communication → integration}/dto/create-config.dto.js +96 -18
- package/dist/module/integration/dto/create-config.dto.js.map +1 -0
- package/dist/module/{communication/entity/communication-config.entity.d.ts → integration/entity/integration-config.entity.d.ts} +11 -1
- package/dist/module/integration/entity/integration-config.entity.js +78 -0
- package/dist/module/integration/entity/integration-config.entity.js.map +1 -0
- package/dist/module/{communication → integration}/entity/integration-source.entity.d.ts +1 -1
- package/dist/module/{communication → integration}/entity/integration-source.entity.js +8 -8
- package/dist/module/integration/entity/integration-source.entity.js.map +1 -0
- package/dist/module/integration/entity/user-integration.entity.d.ts +23 -0
- package/dist/module/integration/entity/user-integration.entity.js +70 -0
- package/dist/module/integration/entity/user-integration.entity.js.map +1 -0
- package/dist/module/integration/examples/usage.example.d.ts +16 -0
- package/dist/module/integration/examples/usage.example.js +217 -0
- package/dist/module/integration/examples/usage.example.js.map +1 -0
- package/dist/module/{communication → integration}/factories/base.factory.d.ts +2 -2
- package/dist/module/integration/factories/base.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/email.factory.d.ts +3 -7
- package/dist/module/{communication → integration}/factories/email.factory.js +1 -13
- package/dist/module/integration/factories/email.factory.js.map +1 -0
- package/dist/module/{communication/factories/communication.factory.d.ts → integration/factories/integration.factory.d.ts} +4 -4
- package/dist/module/{communication/factories/communication.factory.js → integration/factories/integration.factory.js} +26 -26
- package/dist/module/integration/factories/integration.factory.js.map +1 -0
- package/dist/module/integration/factories/sms.factory.d.ts +9 -0
- package/dist/module/integration/factories/sms.factory.js +26 -0
- package/dist/module/integration/factories/sms.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/telephone.factory.d.ts +3 -5
- package/dist/module/{communication → integration}/factories/telephone.factory.js +11 -17
- package/dist/module/integration/factories/telephone.factory.js.map +1 -0
- package/dist/module/{communication → integration}/factories/whatsapp.factory.d.ts +2 -2
- package/dist/module/integration/factories/whatsapp.factory.js.map +1 -0
- package/dist/module/integration/integration.module.d.ts +2 -0
- package/dist/module/{communication/communication.module.js → integration/integration.module.js} +22 -42
- package/dist/module/integration/integration.module.js.map +1 -0
- package/dist/module/integration/service/calendar-event.service.js.map +1 -0
- package/dist/module/{communication/service/communication-queue.service.d.ts → integration/service/integration-queue.service.d.ts} +1 -1
- package/dist/module/{communication/service/communication-queue.service.js → integration/service/integration-queue.service.js} +8 -8
- package/dist/module/integration/service/integration-queue.service.js.map +1 -0
- package/dist/module/integration/service/integration.service.d.ts +155 -0
- package/dist/module/{communication/service/communication.service.js → integration/service/integration.service.js} +391 -307
- package/dist/module/integration/service/integration.service.js.map +1 -0
- package/dist/module/{communication → integration}/service/oauth.service.js +1 -1
- package/dist/module/integration/service/oauth.service.js.map +1 -0
- package/dist/module/{communication → integration}/service/wrapper.service.d.ts +4 -4
- package/dist/module/{communication → integration}/service/wrapper.service.js +25 -26
- package/dist/module/integration/service/wrapper.service.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/email/gmail-api.strategy.d.ts +3 -3
- package/dist/module/{communication → integration}/strategies/email/gmail-api.strategy.js +2 -6
- package/dist/module/integration/strategies/email/gmail-api.strategy.js.map +1 -0
- package/dist/module/integration/strategies/email/outlook-api.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/email/outlook-api.strategy.js.map +1 -0
- package/dist/module/integration/strategies/email/outlook.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/email/outlook.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/email/sendgrid-api.strategy.d.ts +3 -3
- package/dist/module/integration/strategies/email/sendgrid-api.strategy.js.map +1 -0
- package/dist/module/{communication/strategies/communication.strategy.d.ts → integration/strategies/integration.strategy.d.ts} +4 -3
- package/dist/module/{communication/strategies/communication.strategy.js → integration/strategies/integration.strategy.js} +1 -1
- package/dist/module/integration/strategies/integration.strategy.js.map +1 -0
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.d.ts +17 -0
- package/dist/module/{communication → integration}/strategies/telephone/ozonetel-voice.strategy.js +13 -5
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.d.ts +6 -4
- package/dist/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.js +3 -7
- package/dist/module/integration/strategies/telephone/tubelight-voice.strategy.js.map +1 -0
- package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.d.ts +3 -3
- package/dist/module/integration/strategies/whatsapp/whatsapp-cloud.strategy.js.map +1 -0
- package/dist/module/integration/strategies/whatsapp/whatsapp.strategy.d.ts +5 -0
- package/dist/module/integration/strategies/whatsapp/whatsapp.strategy.js.map +1 -0
- package/dist/module/meta/entity/entity-master.entity.d.ts +1 -1
- package/dist/module/meta/entity/entity-master.entity.js +2 -2
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +47 -27
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +3 -3
- package/dist/module/user/controller/login.controller.js +5 -5
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/user.module.js +2 -2
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.d.ts +1 -0
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js +4 -0
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +2 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +8 -4
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/modules/event-driven-integration-design.md +92 -0
- package/docs/modules/integration.md +197 -0
- package/package.json +1 -1
- package/src/app.module.ts +2 -2
- package/src/module/integration/controller/integration.controller.ts +411 -0
- package/src/module/{communication → integration}/dto/create-config.dto.ts +110 -18
- package/src/module/{communication/entity/communication-config.entity.ts → integration/entity/integration-config.entity.ts} +33 -6
- package/src/module/{communication → integration}/entity/integration-source.entity.ts +1 -1
- package/src/module/integration/entity/user-integration.entity.ts +71 -0
- package/src/module/integration/examples/usage.example.ts +338 -0
- package/src/module/{communication → integration}/factories/base.factory.ts +2 -2
- package/src/module/{communication → integration}/factories/email.factory.ts +2 -12
- package/src/module/{communication/factories/communication.factory.ts → integration/factories/integration.factory.ts} +18 -18
- package/src/module/integration/factories/sms.factory.ts +19 -0
- package/src/module/integration/factories/telephone.factory.ts +41 -0
- package/src/module/{communication → integration}/factories/whatsapp.factory.ts +2 -2
- package/src/module/integration/integration.module.ts +86 -0
- package/src/module/{communication/service/communication-queue.service.ts → integration/service/integration-queue.service.ts} +2 -2
- package/src/module/{communication/service/communication.service.ts → integration/service/integration.service.ts} +598 -448
- package/src/module/{communication → integration}/service/oauth.service.ts +1 -1
- package/src/module/{communication → integration}/service/wrapper.service.ts +24 -25
- package/src/module/{communication → integration}/strategies/email/gmail-api.strategy.ts +6 -18
- package/src/module/{communication → integration}/strategies/email/outlook-api.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/email/outlook.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/email/sendgrid-api.strategy.ts +5 -5
- package/src/module/{communication/strategies/communication.strategy.ts → integration/strategies/integration.strategy.ts} +7 -3
- package/src/module/{communication → integration}/strategies/telephone/ozonetel-voice.strategy.ts +40 -12
- package/src/module/{communication → integration}/strategies/telephone/tubelight-voice.strategy.ts +24 -17
- package/src/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.ts +5 -5
- package/src/module/{communication → integration}/strategies/whatsapp/whatsapp.strategy.ts +5 -5
- package/src/module/meta/entity/entity-master.entity.ts +2 -2
- package/src/module/meta/service/entity-dynamic.service.ts +55 -28
- package/src/module/user/controller/login.controller.ts +3 -3
- package/src/module/user/user.module.ts +2 -2
- package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +3 -0
- package/src/module/workflow-automation/service/workflow-automation.service.ts +8 -4
- package/src/resources/dev.properties.yaml +3 -3
- package/.vscode/extensions.json +0 -5
- package/dist/module/communication/communication.module.d.ts +0 -2
- package/dist/module/communication/communication.module.js.map +0 -1
- package/dist/module/communication/controller/calender-event.controller.js.map +0 -1
- package/dist/module/communication/controller/communication.controller.d.ts +0 -99
- package/dist/module/communication/controller/communication.controller.js.map +0 -1
- package/dist/module/communication/controller/wrapper.controller.js.map +0 -1
- package/dist/module/communication/dto/create-config.dto.js.map +0 -1
- package/dist/module/communication/entity/communication-config.entity.js +0 -45
- package/dist/module/communication/entity/communication-config.entity.js.map +0 -1
- package/dist/module/communication/entity/communication-hub.entity.d.ts +0 -20
- package/dist/module/communication/entity/communication-hub.entity.js +0 -115
- package/dist/module/communication/entity/communication-hub.entity.js.map +0 -1
- package/dist/module/communication/entity/integration-source.entity.js.map +0 -1
- package/dist/module/communication/examples/usage.example.d.ts +0 -11
- package/dist/module/communication/examples/usage.example.js +0 -89
- package/dist/module/communication/examples/usage.example.js.map +0 -1
- package/dist/module/communication/factories/base.factory.js.map +0 -1
- package/dist/module/communication/factories/communication.factory.js.map +0 -1
- package/dist/module/communication/factories/email.factory.js.map +0 -1
- package/dist/module/communication/factories/sms.factory.d.ts +0 -15
- package/dist/module/communication/factories/sms.factory.js +0 -49
- package/dist/module/communication/factories/sms.factory.js.map +0 -1
- package/dist/module/communication/factories/telephone.factory.js.map +0 -1
- package/dist/module/communication/factories/whatsapp.factory.js.map +0 -1
- package/dist/module/communication/service/calendar-event.service.js.map +0 -1
- package/dist/module/communication/service/communication-queue.service.js.map +0 -1
- package/dist/module/communication/service/communication.service.d.ts +0 -155
- package/dist/module/communication/service/communication.service.js.map +0 -1
- package/dist/module/communication/service/oauth.service.js.map +0 -1
- package/dist/module/communication/service/wrapper.service.js.map +0 -1
- package/dist/module/communication/strategies/communication.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.js +0 -60
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js +0 -49
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook-api.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.js +0 -65
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/outlook.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/email/outlook.strategy.js.map +0 -1
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.d.ts +0 -6
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.js +0 -121
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/knowlarity.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js +0 -44
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.js +0 -48
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms/twilio.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/sms/twilio.strategy.js +0 -44
- package/dist/module/communication/strategies/sms/twilio.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.d.ts +0 -6
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js +0 -121
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js +0 -44
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/ozonetel-voice.strategy.d.ts +0 -15
- package/dist/module/communication/strategies/telephone/ozonetel-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/telephone/tubelight-voice.strategy.js.map +0 -1
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js.map +0 -1
- package/dist/module/communication/strategies/whatsapp/whatsapp.strategy.d.ts +0 -5
- package/dist/module/communication/strategies/whatsapp/whatsapp.strategy.js.map +0 -1
- package/docs/modules/communication.md +0 -177
- package/src/module/communication/communication.module.ts +0 -106
- package/src/module/communication/controller/communication.controller.ts +0 -293
- package/src/module/communication/entity/communication-hub.entity.ts +0 -103
- package/src/module/communication/examples/usage.example.ts +0 -170
- package/src/module/communication/factories/sms.factory.ts +0 -44
- package/src/module/communication/factories/telephone.factory.ts +0 -49
- package/src/module/communication/strategies/email/gmail-smtp-v2.strategy.ts +0 -68
- package/src/module/communication/strategies/email/gmail-smtp.strategy.ts +0 -51
- package/src/module/communication/strategies/email/outlook-smtp.strategy.ts +0 -73
- package/src/module/communication/strategies/sms/knowlarity-multi.strategy.ts +0 -158
- package/src/module/communication/strategies/sms/knowlarity.strategy.ts +0 -44
- package/src/module/communication/strategies/sms/twilio-v2.strategy.ts +0 -47
- package/src/module/communication/strategies/sms/twilio.strategy.ts +0 -44
- package/src/module/communication/strategies/telephone/knowlarity-multi.strategy.ts +0 -158
- package/src/module/communication/strategies/telephone/knowlarity-voice.strategy.ts +0 -44
- /package/dist/module/{communication → integration}/controller/calender-event.controller.d.ts +0 -0
- /package/dist/module/{communication → integration}/controller/calender-event.controller.js +0 -0
- /package/dist/module/{communication → integration}/controller/wrapper.controller.js +0 -0
- /package/dist/module/{communication → integration}/factories/base.factory.js +0 -0
- /package/dist/module/{communication → integration}/factories/whatsapp.factory.js +0 -0
- /package/dist/module/{communication → integration}/service/calendar-event.service.d.ts +0 -0
- /package/dist/module/{communication → integration}/service/calendar-event.service.js +0 -0
- /package/dist/module/{communication → integration}/service/oauth.service.d.ts +0 -0
- /package/dist/module/{communication → integration}/strategies/email/outlook-api.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/email/outlook.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/email/sendgrid-api.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp-cloud.strategy.js +0 -0
- /package/dist/module/{communication → integration}/strategies/whatsapp/whatsapp.strategy.js +0 -0
- /package/src/module/{communication → integration}/controller/calender-event.controller.ts +0 -0
- /package/src/module/{communication → integration}/controller/wrapper.controller.ts +0 -0
- /package/src/module/{communication → integration}/service/calendar-event.service.ts +0 -0
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BadRequestException,
|
|
3
|
-
Body,
|
|
4
|
-
Controller,
|
|
5
|
-
Get,
|
|
6
|
-
HttpCode,
|
|
7
|
-
HttpStatus,
|
|
8
|
-
Param,
|
|
9
|
-
ParseIntPipe,
|
|
10
|
-
Post,
|
|
11
|
-
Query,
|
|
12
|
-
} from '@nestjs/common';
|
|
13
|
-
import { CommunicationService } from '../service/communication.service';
|
|
14
|
-
import {
|
|
15
|
-
BulkMessageDto,
|
|
16
|
-
CreateConfigDto,
|
|
17
|
-
GenericSendMessageDto,
|
|
18
|
-
GmailOAuthInitDto,
|
|
19
|
-
OutlookOAuthInitDto,
|
|
20
|
-
SendGridTemplatesDto,
|
|
21
|
-
SendGridVerifiedSendersDto,
|
|
22
|
-
UpdateConfigDto,
|
|
23
|
-
} from '../dto/create-config.dto';
|
|
24
|
-
|
|
25
|
-
export class ScheduledMessageDto extends GenericSendMessageDto {
|
|
26
|
-
scheduleFor: Date;
|
|
27
|
-
timezone?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Controller('communication')
|
|
31
|
-
export class CommunicationController {
|
|
32
|
-
constructor(private readonly communicationService: CommunicationService) {}
|
|
33
|
-
|
|
34
|
-
@Post('send')
|
|
35
|
-
@HttpCode(HttpStatus.OK)
|
|
36
|
-
async sendMessage(@Body() sendMessageDto: GenericSendMessageDto) {
|
|
37
|
-
return this.communicationService.sendGenericMessage(sendMessageDto);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Post('send/bulk')
|
|
41
|
-
@HttpCode(HttpStatus.OK)
|
|
42
|
-
async sendBulkMessage(@Body() bulkMessageDto: BulkMessageDto) {
|
|
43
|
-
return this.communicationService.sendBulkMessage(bulkMessageDto);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Post('send/scheduled')
|
|
47
|
-
@HttpCode(HttpStatus.OK)
|
|
48
|
-
async scheduleMessage(@Body() scheduledMessageDto: ScheduledMessageDto) {
|
|
49
|
-
return this.communicationService.scheduleMessage(scheduledMessageDto);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Post('send/template')
|
|
53
|
-
@HttpCode(HttpStatus.OK)
|
|
54
|
-
async sendTemplateMessage(
|
|
55
|
-
@Body()
|
|
56
|
-
templateMessage: {
|
|
57
|
-
organisationId: number;
|
|
58
|
-
to: string | string[];
|
|
59
|
-
templateId: string;
|
|
60
|
-
variables: Record<string, any>;
|
|
61
|
-
type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE';
|
|
62
|
-
},
|
|
63
|
-
) {
|
|
64
|
-
return this.communicationService.sendTemplateMessage(templateMessage);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
@Post('config')
|
|
68
|
-
async createConfig(@Body() createConfigDto: CreateConfigDto) {
|
|
69
|
-
try {
|
|
70
|
-
const result = await this.communicationService.createCommunicationConfig(
|
|
71
|
-
createConfigDto.levelId,
|
|
72
|
-
createConfigDto.levelType,
|
|
73
|
-
createConfigDto.configType,
|
|
74
|
-
createConfigDto.service,
|
|
75
|
-
createConfigDto.provider,
|
|
76
|
-
createConfigDto.config,
|
|
77
|
-
createConfigDto.priority,
|
|
78
|
-
createConfigDto.is_default,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return result;
|
|
82
|
-
} catch (error) {
|
|
83
|
-
// Handle validation errors with BadRequest status
|
|
84
|
-
if (
|
|
85
|
-
error.message?.includes('active') &&
|
|
86
|
-
error.message?.includes('configuration already exists')
|
|
87
|
-
) {
|
|
88
|
-
throw new BadRequestException({
|
|
89
|
-
success: false,
|
|
90
|
-
error: 'DUPLICATE_CONFIGURATION',
|
|
91
|
-
message: error.message,
|
|
92
|
-
code: 'VALIDATION_ERROR',
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Handle unsupported combination errors
|
|
97
|
-
if (error.message?.includes('Unsupported combination')) {
|
|
98
|
-
throw new BadRequestException({
|
|
99
|
-
success: false,
|
|
100
|
-
error: 'UNSUPPORTED_COMBINATION',
|
|
101
|
-
message: error.message,
|
|
102
|
-
code: 'VALIDATION_ERROR',
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Handle OAuth redirect responses (return as success with OAuth info)
|
|
107
|
-
if (error.authUrl && error.state) {
|
|
108
|
-
return {
|
|
109
|
-
success: false,
|
|
110
|
-
requiresOAuth: true,
|
|
111
|
-
authUrl: error.authUrl,
|
|
112
|
-
state: error.state,
|
|
113
|
-
message: error.message || 'OAuth authorization required',
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Handle other errors as BadRequest
|
|
118
|
-
throw new BadRequestException({
|
|
119
|
-
success: false,
|
|
120
|
-
error: 'CONFIGURATION_ERROR',
|
|
121
|
-
message:
|
|
122
|
-
error.message || 'Failed to create communication configuration',
|
|
123
|
-
code: 'INTERNAL_ERROR',
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@Get('supported-combinations')
|
|
129
|
-
async getSupportedCombinations() {
|
|
130
|
-
return this.communicationService.getSupportedCombinations();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
@Get('level/:id/:type/configs')
|
|
134
|
-
async getLevelConfigs(
|
|
135
|
-
@Param('id', ParseIntPipe) levelId: number,
|
|
136
|
-
@Param('type') levelType: string,
|
|
137
|
-
@Query('communication_config_type')
|
|
138
|
-
configType?: 'WA' | 'SMS' | 'EMAIL' | 'TELEPHONE',
|
|
139
|
-
@Query('service') service?: 'API' | 'THIRD_PARTY' | 'SMTP',
|
|
140
|
-
@Query('provider') provider?: string,
|
|
141
|
-
) {
|
|
142
|
-
return this.communicationService.getLevelConfigs(levelId, levelType, {
|
|
143
|
-
communication_config_type: configType,
|
|
144
|
-
service,
|
|
145
|
-
provider,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@Get('config/:id')
|
|
150
|
-
async getCommunicationConfigById(@Param('id', ParseIntPipe) hubId: number) {
|
|
151
|
-
try {
|
|
152
|
-
const config =
|
|
153
|
-
await this.communicationService.getCommunicationConfigById(hubId);
|
|
154
|
-
|
|
155
|
-
if (!config) {
|
|
156
|
-
throw new BadRequestException({
|
|
157
|
-
success: false,
|
|
158
|
-
error: 'NOT_FOUND',
|
|
159
|
-
message: 'Communication configuration not found',
|
|
160
|
-
code: 'CONFIGURATION_NOT_FOUND',
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
success: true,
|
|
166
|
-
data: config,
|
|
167
|
-
};
|
|
168
|
-
} catch (error) {
|
|
169
|
-
if (error instanceof BadRequestException) {
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
throw new BadRequestException({
|
|
174
|
-
success: false,
|
|
175
|
-
error: 'FETCH_ERROR',
|
|
176
|
-
message: error.message || 'Failed to fetch communication configuration',
|
|
177
|
-
code: 'INTERNAL_ERROR',
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
@Post('config/:id/update')
|
|
183
|
-
@HttpCode(HttpStatus.OK)
|
|
184
|
-
async activateConfig(
|
|
185
|
-
@Param('id', ParseIntPipe) hubId: number,
|
|
186
|
-
@Query('status') status: string,
|
|
187
|
-
) {
|
|
188
|
-
try {
|
|
189
|
-
const statusNumber = parseInt(status, 10);
|
|
190
|
-
if (isNaN(statusNumber) || (statusNumber !== 0 && statusNumber !== 1)) {
|
|
191
|
-
throw new BadRequestException('Status must be 0 or 1');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
await this.communicationService.updateConfigStatus(hubId, statusNumber);
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
message: 'Configuration updated successfully',
|
|
198
|
-
};
|
|
199
|
-
} catch (error) {
|
|
200
|
-
throw new BadRequestException({
|
|
201
|
-
success: false,
|
|
202
|
-
error: 'UPDATE_STATUS_ERROR',
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@Post('gmail/oauth/init')
|
|
208
|
-
async initGmailOAuth(@Body() initDto: GmailOAuthInitDto) {
|
|
209
|
-
return this.communicationService.initGmailOAuth(
|
|
210
|
-
initDto.levelId,
|
|
211
|
-
initDto.levelType,
|
|
212
|
-
initDto.email,
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@Post('gmail/test')
|
|
217
|
-
async testGmailConfig(@Body() body: { hubId: number }) {
|
|
218
|
-
return this.communicationService.testGmailConfig(body.hubId);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
@Post('outlook/oauth/init')
|
|
222
|
-
async initOutlookOAuth(@Body() initDto: OutlookOAuthInitDto) {
|
|
223
|
-
return this.communicationService.initOutlookOAuth(
|
|
224
|
-
initDto.levelId,
|
|
225
|
-
initDto.levelType,
|
|
226
|
-
initDto.email,
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
@Post('sendgrid/verified-senders')
|
|
231
|
-
@HttpCode(HttpStatus.OK)
|
|
232
|
-
async getSendGridVerifiedSenders(@Body() dto: SendGridVerifiedSendersDto) {
|
|
233
|
-
return this.communicationService.getSendGridVerifiedSenders(dto.apiKey);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
@Post('sendgrid/templates')
|
|
237
|
-
@HttpCode(HttpStatus.OK)
|
|
238
|
-
async getSendGridTemplates(@Body() dto: SendGridTemplatesDto) {
|
|
239
|
-
return this.communicationService.getSendGridTemplates(
|
|
240
|
-
dto.levelId,
|
|
241
|
-
dto.levelType,
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@Post('config/delete/:hubId')
|
|
246
|
-
@HttpCode(HttpStatus.OK)
|
|
247
|
-
async disconnectConfig(@Param('hubId', ParseIntPipe) hubId: number) {
|
|
248
|
-
try {
|
|
249
|
-
await this.communicationService.deleteConfiguration(hubId);
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
success: true,
|
|
253
|
-
message: 'Communication configuration deleted successfully',
|
|
254
|
-
};
|
|
255
|
-
} catch (error) {
|
|
256
|
-
throw new BadRequestException({
|
|
257
|
-
success: false,
|
|
258
|
-
error: 'DELETE_ERROR',
|
|
259
|
-
message:
|
|
260
|
-
error.message || 'Failed to delete communication configuration',
|
|
261
|
-
code: 'CONFIGURATION_ERROR',
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
@Post('config/update/:hubId')
|
|
267
|
-
@HttpCode(HttpStatus.OK)
|
|
268
|
-
async updateConfig(
|
|
269
|
-
@Param('hubId', ParseIntPipe) hubId: number,
|
|
270
|
-
@Body() updateDto: UpdateConfigDto,
|
|
271
|
-
) {
|
|
272
|
-
try {
|
|
273
|
-
const result = await this.communicationService.updateConfiguration(
|
|
274
|
-
hubId,
|
|
275
|
-
updateDto,
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
return {
|
|
279
|
-
success: true,
|
|
280
|
-
message: 'Communication configuration updated successfully',
|
|
281
|
-
data: result,
|
|
282
|
-
};
|
|
283
|
-
} catch (error) {
|
|
284
|
-
throw new BadRequestException({
|
|
285
|
-
success: false,
|
|
286
|
-
error: 'UPDATE_ERROR',
|
|
287
|
-
message:
|
|
288
|
-
error.message || 'Failed to update communication configuration',
|
|
289
|
-
code: 'CONFIGURATION_ERROR',
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Column,
|
|
3
|
-
Entity,
|
|
4
|
-
PrimaryGeneratedColumn,
|
|
5
|
-
CreateDateColumn,
|
|
6
|
-
UpdateDateColumn,
|
|
7
|
-
Index,
|
|
8
|
-
} from 'typeorm';
|
|
9
|
-
import { IsNotEmpty, IsIn, IsBoolean, IsInt, Min } from 'class-validator';
|
|
10
|
-
|
|
11
|
-
export enum CommunicationConfigType {
|
|
12
|
-
WA = 'WA',
|
|
13
|
-
SMS = 'SMS',
|
|
14
|
-
EMAIL = 'EMAIL',
|
|
15
|
-
TELEPHONE = 'TELEPHONE',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Entity({ name: 'cr_communication_hub' })
|
|
19
|
-
@Index('idx_level_status', ['level_id', 'level_type', 'status'])
|
|
20
|
-
@Index('idx_config_type', ['communication_config_type'])
|
|
21
|
-
@Index('idx_service_provider', ['service', 'provider'])
|
|
22
|
-
export class CommunicationHub {
|
|
23
|
-
@PrimaryGeneratedColumn({ name: 'id', type: 'int' })
|
|
24
|
-
id: number;
|
|
25
|
-
|
|
26
|
-
@Column({ name: 'level_id', type: 'int' })
|
|
27
|
-
@IsNotEmpty()
|
|
28
|
-
@IsInt()
|
|
29
|
-
level_id: number;
|
|
30
|
-
|
|
31
|
-
@Column({ name: 'level_type', type: 'varchar', length: 100 })
|
|
32
|
-
@IsNotEmpty()
|
|
33
|
-
level_type: string;
|
|
34
|
-
|
|
35
|
-
@Column({ name: 'status', type: 'tinyint', default: 1 })
|
|
36
|
-
@IsInt()
|
|
37
|
-
@Min(0)
|
|
38
|
-
status: number;
|
|
39
|
-
|
|
40
|
-
@Column({ name: 'config_id', type: 'int' })
|
|
41
|
-
@IsNotEmpty()
|
|
42
|
-
@IsInt()
|
|
43
|
-
config_id: number;
|
|
44
|
-
|
|
45
|
-
@Column({
|
|
46
|
-
name: 'communication_config_type',
|
|
47
|
-
type: 'enum',
|
|
48
|
-
enum: CommunicationConfigType,
|
|
49
|
-
})
|
|
50
|
-
@IsNotEmpty()
|
|
51
|
-
@IsIn(['WA', 'SMS', 'EMAIL', 'TELEPHONE'])
|
|
52
|
-
communication_config_type: CommunicationConfigType;
|
|
53
|
-
|
|
54
|
-
@Column({ name: 'service', type: 'varchar', length: 100 })
|
|
55
|
-
@IsNotEmpty()
|
|
56
|
-
@IsIn(['API', 'THIRD_PARTY', 'SMTP'])
|
|
57
|
-
service: 'API' | 'THIRD_PARTY' | 'SMTP';
|
|
58
|
-
|
|
59
|
-
@Column({ name: 'provider', type: 'varchar', length: 100 })
|
|
60
|
-
@IsNotEmpty()
|
|
61
|
-
@IsIn([
|
|
62
|
-
'gmail',
|
|
63
|
-
'outlook',
|
|
64
|
-
'whatsapp',
|
|
65
|
-
'twilio',
|
|
66
|
-
'aws-ses',
|
|
67
|
-
'sendgrid',
|
|
68
|
-
'custom',
|
|
69
|
-
'generic',
|
|
70
|
-
'knowlarity',
|
|
71
|
-
])
|
|
72
|
-
provider:
|
|
73
|
-
| 'gmail'
|
|
74
|
-
| 'outlook'
|
|
75
|
-
| 'whatsapp'
|
|
76
|
-
| 'twilio'
|
|
77
|
-
| 'aws-ses'
|
|
78
|
-
| 'sendgrid'
|
|
79
|
-
| 'custom'
|
|
80
|
-
| 'generic'
|
|
81
|
-
| 'knowlarity';
|
|
82
|
-
|
|
83
|
-
@Column({ name: 'priority', type: 'int', default: 1 })
|
|
84
|
-
@IsInt()
|
|
85
|
-
@Min(1)
|
|
86
|
-
priority: number;
|
|
87
|
-
|
|
88
|
-
@Column({ name: 'is_default', type: 'boolean', default: false })
|
|
89
|
-
@IsBoolean()
|
|
90
|
-
is_default: boolean;
|
|
91
|
-
|
|
92
|
-
@CreateDateColumn({
|
|
93
|
-
name: 'created_at',
|
|
94
|
-
type: 'datetime',
|
|
95
|
-
})
|
|
96
|
-
created_at: Date;
|
|
97
|
-
|
|
98
|
-
@UpdateDateColumn({
|
|
99
|
-
name: 'updated_at',
|
|
100
|
-
type: 'datetime',
|
|
101
|
-
})
|
|
102
|
-
updated_at: Date;
|
|
103
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Communication Hub Usage Examples
|
|
3
|
-
*
|
|
4
|
-
* This file demonstrates how to use the hierarchical communication system.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { CommunicationService } from '../service/communication.service';
|
|
8
|
-
import { CommunicationConfigType } from '../entity/communication-hub.entity';
|
|
9
|
-
|
|
10
|
-
export class CommunicationUsageExamples {
|
|
11
|
-
constructor(private readonly communicationService: CommunicationService) {}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Example 1: Send an email using Gmail API
|
|
15
|
-
*/
|
|
16
|
-
async sendEmailViaGmailApi() {
|
|
17
|
-
// First, create a configuration for Gmail API
|
|
18
|
-
const emailConfig = {
|
|
19
|
-
clientId: 'your-gmail-client-id',
|
|
20
|
-
clientSecret: 'your-gmail-client-secret',
|
|
21
|
-
refreshToken: 'your-refresh-token',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const hub = await this.communicationService.createCommunicationConfig(
|
|
25
|
-
1, // levelId
|
|
26
|
-
'organization', // levelType
|
|
27
|
-
CommunicationConfigType.EMAIL,
|
|
28
|
-
'API',
|
|
29
|
-
'gmail',
|
|
30
|
-
emailConfig,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
console.log('Created email config:', hub);
|
|
34
|
-
|
|
35
|
-
// Send a message
|
|
36
|
-
const result = await this.communicationService.sendMessage({
|
|
37
|
-
levelId: 1,
|
|
38
|
-
levelType: 'organization',
|
|
39
|
-
to: 'recipient@example.com',
|
|
40
|
-
message: 'Hello from Gmail API!',
|
|
41
|
-
mode: CommunicationConfigType.EMAIL,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
console.log('Email sent:', result);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Example 2: Send SMS using Twilio
|
|
49
|
-
*/
|
|
50
|
-
async sendSmsViaTwilio() {
|
|
51
|
-
const smsConfig = {
|
|
52
|
-
accountSid: 'your-twilio-account-sid',
|
|
53
|
-
authToken: 'your-twilio-auth-token',
|
|
54
|
-
fromNumber: '+1234567890',
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
await this.communicationService.createCommunicationConfig(
|
|
58
|
-
1,
|
|
59
|
-
'organization',
|
|
60
|
-
CommunicationConfigType.SMS,
|
|
61
|
-
'THIRD_PARTY',
|
|
62
|
-
'twilio',
|
|
63
|
-
smsConfig,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const result = await this.communicationService.sendMessage({
|
|
67
|
-
levelId: 1,
|
|
68
|
-
levelType: 'organization',
|
|
69
|
-
to: '+9876543210',
|
|
70
|
-
message: 'Hello from Twilio SMS!',
|
|
71
|
-
mode: CommunicationConfigType.SMS,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
console.log('SMS sent:', result);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Example 3: Send WhatsApp message
|
|
79
|
-
*/
|
|
80
|
-
async sendWhatsAppMessage() {
|
|
81
|
-
const whatsappConfig = {
|
|
82
|
-
accessToken: 'your-whatsapp-access-token',
|
|
83
|
-
phoneNumberId: 'your-phone-number-id',
|
|
84
|
-
businessAccountId: 'your-business-account-id',
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
await this.communicationService.createCommunicationConfig(
|
|
88
|
-
1,
|
|
89
|
-
'organization',
|
|
90
|
-
CommunicationConfigType.WA,
|
|
91
|
-
'API',
|
|
92
|
-
'whatsapp',
|
|
93
|
-
whatsappConfig,
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const result = await this.communicationService.sendMessage({
|
|
97
|
-
levelId: 1,
|
|
98
|
-
levelType: 'organization',
|
|
99
|
-
to: '+9876543210',
|
|
100
|
-
message: 'Hello from WhatsApp!',
|
|
101
|
-
mode: CommunicationConfigType.WA,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
console.log('WhatsApp sent:', result);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Example 4: Make a voice call using Knowlarity
|
|
109
|
-
*/
|
|
110
|
-
async makeVoiceCall() {
|
|
111
|
-
const voiceConfig = {
|
|
112
|
-
apiKey: 'your-knowlarity-api-key',
|
|
113
|
-
callerId: '+1234567890',
|
|
114
|
-
voiceUrl: 'https://your-voice-script-url.com',
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
await this.communicationService.createCommunicationConfig(
|
|
118
|
-
1,
|
|
119
|
-
'organization',
|
|
120
|
-
CommunicationConfigType.TELEPHONE,
|
|
121
|
-
'THIRD_PARTY',
|
|
122
|
-
'knowlarity',
|
|
123
|
-
voiceConfig,
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
const result = await this.communicationService.sendMessage({
|
|
127
|
-
levelId: 1,
|
|
128
|
-
levelType: 'organization',
|
|
129
|
-
to: '+9876543210',
|
|
130
|
-
message: 'Voice message content',
|
|
131
|
-
mode: CommunicationConfigType.TELEPHONE,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
console.log('Voice call initiated:', result);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Example 5: Get all supported combinations
|
|
139
|
-
*/
|
|
140
|
-
async getSupportedCombinations() {
|
|
141
|
-
const combinations =
|
|
142
|
-
await this.communicationService.getSupportedCombinations();
|
|
143
|
-
console.log('Supported combinations:', combinations);
|
|
144
|
-
|
|
145
|
-
// Output will be:
|
|
146
|
-
// [
|
|
147
|
-
// { mode: 'EMAIL', service: 'API', provider: 'gmail' },
|
|
148
|
-
// { mode: 'EMAIL', service: 'SMTP', provider: 'gmail' },
|
|
149
|
-
// { mode: 'EMAIL', service: 'API', provider: 'outlook' },
|
|
150
|
-
// { mode: 'SMS', service: 'THIRD_PARTY', provider: 'twilio' },
|
|
151
|
-
// { mode: 'SMS', service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
152
|
-
// { mode: 'WA', service: 'API', provider: 'whatsapp' },
|
|
153
|
-
// { mode: 'TELEPHONE', service: 'THIRD_PARTY', provider: 'knowlarity' }
|
|
154
|
-
// ]
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Example 6: Send message without specifying mode (uses first available)
|
|
159
|
-
*/
|
|
160
|
-
async sendMessageAutoMode() {
|
|
161
|
-
const result = await this.communicationService.sendMessage({
|
|
162
|
-
levelId: 1,
|
|
163
|
-
levelType: 'organization',
|
|
164
|
-
to: 'recipient@example.com',
|
|
165
|
-
message: 'Hello! This will use the first available communication method.',
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
console.log('Message sent via auto-selected provider:', result);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { BaseFactory } from './base.factory';
|
|
3
|
-
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
4
|
-
import { SmsStrategy } from '../strategies/sms/twilio-v2.strategy';
|
|
5
|
-
import { KnowlarityStrategy } from '../strategies/sms/knowlarity-multi.strategy';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class SmsFactory implements BaseFactory {
|
|
9
|
-
constructor(
|
|
10
|
-
private twilioStrategy: SmsStrategy,
|
|
11
|
-
private knowlarityStrategy: KnowlarityStrategy,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
createProvider(service: string, provider: string): CommunicationStrategy {
|
|
15
|
-
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
16
|
-
|
|
17
|
-
switch (key) {
|
|
18
|
-
case 'third_party_twilio':
|
|
19
|
-
return this.twilioStrategy;
|
|
20
|
-
case 'third_party_knowlarity':
|
|
21
|
-
return this.knowlarityStrategy;
|
|
22
|
-
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(
|
|
25
|
-
`Unsupported SMS service/provider: ${service}/${provider}`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
31
|
-
return [
|
|
32
|
-
{ service: 'THIRD_PARTY', provider: 'twilio' },
|
|
33
|
-
{ service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
validateCombination(service: string, provider: string): boolean {
|
|
38
|
-
return this.getSupportedCombinations().some(
|
|
39
|
-
(combo) =>
|
|
40
|
-
combo.service.toLowerCase() === service.toLowerCase() &&
|
|
41
|
-
combo.provider.toLowerCase() === provider.toLowerCase(),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { BaseFactory } from './base.factory';
|
|
3
|
-
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
4
|
-
import { KnowlarityStrategy as TelephoneKnowlarityStrategy } from '../strategies/telephone/knowlarity-multi.strategy';
|
|
5
|
-
import { OzonetelVoiceStrategy } from '../strategies/telephone/ozonetel-voice.strategy';
|
|
6
|
-
import { TubelightVoiceStrategy } from '../strategies/telephone/tubelight-voice.strategy';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class TelephoneFactory implements BaseFactory {
|
|
10
|
-
constructor(
|
|
11
|
-
private knowlarityStrategy: TelephoneKnowlarityStrategy,
|
|
12
|
-
private ozonetelVoiceStrategy: OzonetelVoiceStrategy,
|
|
13
|
-
private tubelightVoiceStrategy: TubelightVoiceStrategy,
|
|
14
|
-
) {}
|
|
15
|
-
|
|
16
|
-
createProvider(service: string, provider: string): CommunicationStrategy {
|
|
17
|
-
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
18
|
-
|
|
19
|
-
switch (key) {
|
|
20
|
-
case 'third_party_knowlarity':
|
|
21
|
-
return this.knowlarityStrategy;
|
|
22
|
-
case 'third_party_ozonetel':
|
|
23
|
-
return this.ozonetelVoiceStrategy;
|
|
24
|
-
case 'third_party_tubelight':
|
|
25
|
-
return this.tubelightVoiceStrategy;
|
|
26
|
-
|
|
27
|
-
default:
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Unsupported Telephone service/provider: ${service}/${provider}`,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
35
|
-
return [
|
|
36
|
-
{ service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
37
|
-
{ service: 'THIRD_PARTY', provider: 'ozonetel' },
|
|
38
|
-
{ service: 'THIRD_PARTY', provider: 'tubelight' }
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
validateCombination(service: string, provider: string): boolean {
|
|
43
|
-
return this.getSupportedCombinations().some(
|
|
44
|
-
(combo) =>
|
|
45
|
-
combo.service.toLowerCase() === service.toLowerCase() &&
|
|
46
|
-
combo.provider.toLowerCase() === provider.toLowerCase(),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|