rez_core 2.2.154 → 2.2.156
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 -0
- package/dist/app.module.js.map +1 -1
- package/dist/constant/global.constant.d.ts +1 -1
- package/dist/constant/global.constant.js +1 -1
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/auth/strategies/google.strategy.js +1 -1
- package/dist/module/auth/strategies/google.strategy.js.map +1 -1
- package/dist/module/communication/communication.module.d.ts +2 -0
- package/dist/module/communication/communication.module.js +69 -0
- package/dist/module/communication/communication.module.js.map +1 -0
- package/dist/module/communication/controller/communication.controller.d.ts +54 -0
- package/dist/module/communication/controller/communication.controller.js +148 -0
- package/dist/module/communication/controller/communication.controller.js.map +1 -0
- package/dist/module/communication/dto/create-config.dto.d.ts +91 -0
- package/dist/module/communication/dto/create-config.dto.js +243 -0
- package/dist/module/communication/dto/create-config.dto.js.map +1 -0
- package/dist/module/communication/entity/communication-config.entity.d.ts +44 -0
- package/dist/module/communication/entity/communication-config.entity.js +45 -0
- package/dist/module/communication/entity/communication-config.entity.js.map +1 -0
- package/dist/module/communication/entity/communication-hub.entity.d.ts +20 -0
- package/dist/module/communication/entity/communication-hub.entity.js +105 -0
- package/dist/module/communication/entity/communication-hub.entity.js.map +1 -0
- package/dist/module/communication/examples/usage.example.d.ts +11 -0
- package/dist/module/communication/examples/usage.example.js +89 -0
- package/dist/module/communication/examples/usage.example.js.map +1 -0
- package/dist/module/communication/factories/base.factory.d.ts +9 -0
- package/dist/module/communication/factories/base.factory.js +3 -0
- package/dist/module/communication/factories/base.factory.js.map +1 -0
- package/dist/module/communication/factories/communication.factory.d.ts +33 -0
- package/dist/module/communication/factories/communication.factory.js +104 -0
- package/dist/module/communication/factories/communication.factory.js.map +1 -0
- package/dist/module/communication/factories/email.factory.d.ts +19 -0
- package/dist/module/communication/factories/email.factory.js +61 -0
- package/dist/module/communication/factories/email.factory.js.map +1 -0
- package/dist/module/communication/factories/sms.factory.d.ts +15 -0
- package/dist/module/communication/factories/sms.factory.js +49 -0
- package/dist/module/communication/factories/sms.factory.js.map +1 -0
- package/dist/module/communication/factories/telephone.factory.d.ts +13 -0
- package/dist/module/communication/factories/telephone.factory.js +43 -0
- package/dist/module/communication/factories/telephone.factory.js.map +1 -0
- package/dist/module/communication/factories/whatsapp.factory.d.ts +13 -0
- package/dist/module/communication/factories/whatsapp.factory.js +43 -0
- package/dist/module/communication/factories/whatsapp.factory.js.map +1 -0
- package/dist/module/communication/service/communication.service.d.ts +111 -0
- package/dist/module/communication/service/communication.service.js +726 -0
- package/dist/module/communication/service/communication.service.js.map +1 -0
- package/dist/module/communication/service/oauth.service.d.ts +18 -0
- package/dist/module/communication/service/oauth.service.js +185 -0
- package/dist/module/communication/service/oauth.service.js.map +1 -0
- package/dist/module/communication/strategies/communication.strategy.d.ts +17 -0
- package/dist/module/communication/strategies/communication.strategy.js +3 -0
- package/dist/module/communication/strategies/communication.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.d.ts +7 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.js +135 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js +49 -0
- package/dist/module/communication/strategies/email/gmail-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.js +44 -0
- package/dist/module/communication/strategies/email/outlook-api.strategy.js.map +1 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.js +61 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/gmail.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/gmail.strategy.js +71 -0
- package/dist/module/communication/strategies/gmail.strategy.js.map +1 -0
- package/dist/module/communication/strategies/knowlarity.strategy.d.ts +6 -0
- package/dist/module/communication/strategies/knowlarity.strategy.js +115 -0
- package/dist/module/communication/strategies/knowlarity.strategy.js.map +1 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.js +66 -0
- package/dist/module/communication/strategies/outlook-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/outlook.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/outlook.strategy.js +64 -0
- package/dist/module/communication/strategies/outlook.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js +44 -0
- package/dist/module/communication/strategies/sms/knowlarity.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.js +44 -0
- package/dist/module/communication/strategies/sms/twilio.strategy.js.map +1 -0
- package/dist/module/communication/strategies/sms.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/sms.strategy.js +50 -0
- package/dist/module/communication/strategies/sms.strategy.js.map +1 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js +44 -0
- package/dist/module/communication/strategies/telephone/knowlarity-voice.strategy.js.map +1 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js +47 -0
- package/dist/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.js.map +1 -0
- package/dist/module/communication/strategies/whatsapp.strategy.d.ts +5 -0
- package/dist/module/communication/strategies/whatsapp.strategy.js +58 -0
- package/dist/module/communication/strategies/whatsapp.strategy.js.map +1 -0
- package/dist/module/meta/entity.module.js +2 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +4 -2
- package/dist/module/user/controller/login.controller.js +26 -4
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js +2 -2
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/stage.service.js +1 -1
- package/dist/module/workflow/service/stage.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/src/app.module.ts +2 -0
- package/src/constant/global.constant.ts +1 -1
- package/src/module/auth/strategies/google.strategy.ts +1 -1
- package/src/module/communication/communication.module.ts +77 -0
- package/src/module/communication/controller/communication.controller.ts +122 -0
- package/src/module/communication/dto/create-config.dto.ts +234 -0
- package/src/module/communication/entity/communication-config.entity.ts +80 -0
- package/src/module/communication/entity/communication-hub.entity.ts +77 -0
- package/src/module/communication/examples/usage.example.ts +169 -0
- package/src/module/communication/factories/base.factory.ts +7 -0
- package/src/module/communication/factories/communication.factory.ts +103 -0
- package/src/module/communication/factories/email.factory.ts +51 -0
- package/src/module/communication/factories/sms.factory.ts +41 -0
- package/src/module/communication/factories/telephone.factory.ts +34 -0
- package/src/module/communication/factories/whatsapp.factory.ts +34 -0
- package/src/module/communication/service/communication.service.ts +1118 -0
- package/src/module/communication/service/oauth.service.ts +203 -0
- package/src/module/communication/strategies/communication.strategy.ts +23 -0
- package/src/module/communication/strategies/email/gmail-api.strategy.ts +161 -0
- package/src/module/communication/strategies/email/gmail-smtp.strategy.ts +51 -0
- package/src/module/communication/strategies/email/outlook-api.strategy.ts +44 -0
- package/src/module/communication/strategies/gmail-smtp.strategy.ts +64 -0
- package/src/module/communication/strategies/gmail.strategy.ts +68 -0
- package/src/module/communication/strategies/knowlarity.strategy.ts +124 -0
- package/src/module/communication/strategies/outlook-smtp.strategy.ts +69 -0
- package/src/module/communication/strategies/outlook.strategy.ts +57 -0
- package/src/module/communication/strategies/sms/knowlarity.strategy.ts +44 -0
- package/src/module/communication/strategies/sms/twilio.strategy.ts +44 -0
- package/src/module/communication/strategies/sms.strategy.ts +44 -0
- package/src/module/communication/strategies/telephone/knowlarity-voice.strategy.ts +44 -0
- package/src/module/communication/strategies/whatsapp/whatsapp-cloud.strategy.ts +49 -0
- package/src/module/communication/strategies/whatsapp.strategy.ts +53 -0
- package/src/module/meta/entity.module.ts +2 -1
- package/src/module/user/controller/login.controller.ts +34 -3
- package/src/module/workflow/service/populate-workflow.service.ts +3 -3
- package/src/module/workflow/service/stage.service.ts +1 -1
- package/src/resources/dev.properties.yaml +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rez_core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.156",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"private": false,
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@aws-sdk/client-s3": "^3.804.0",
|
|
25
|
+
"@microsoft/microsoft-graph-client": "^3.0.7",
|
|
25
26
|
"@nestjs-modules/mailer": "^2.0.2",
|
|
26
27
|
"@nestjs/axios": "^4.0.0",
|
|
27
28
|
"@nestjs/common": "^11.0.1",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"crypto-js": "^4.2.0",
|
|
43
44
|
"dotenv": "^16.4.7",
|
|
44
45
|
"exceljs": "^4.4.0",
|
|
46
|
+
"googleapis": "^159.0.0",
|
|
45
47
|
"handlebars": "^4.7.8",
|
|
46
48
|
"ics": "^3.8.1",
|
|
47
49
|
"moment": "^2.30.1",
|
|
@@ -55,6 +57,7 @@
|
|
|
55
57
|
"passport-local": "^1.0.0",
|
|
56
58
|
"reflect-metadata": "^0.2.2",
|
|
57
59
|
"rxjs": "^7.8.1",
|
|
60
|
+
"twilio": "^5.9.0",
|
|
58
61
|
"typeorm": "^0.3.20",
|
|
59
62
|
"uuid": "^11.1.0",
|
|
60
63
|
"winston": "^3.17.0",
|
package/src/app.module.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { LayoutPreferenceModule } from './module/layout_preference/layout_prefer
|
|
|
16
16
|
import { WorkflowModule } from './module/workflow/workflow.module';
|
|
17
17
|
import { IcsMeetingModule } from './module/ics/ics.module';
|
|
18
18
|
import { DashboardModule } from './module/dashboard/dashboard.module';
|
|
19
|
+
import { CommunicationModule } from './module/communication/communication.module';
|
|
19
20
|
|
|
20
21
|
@Module({
|
|
21
22
|
imports: [
|
|
@@ -36,6 +37,7 @@ import { DashboardModule } from './module/dashboard/dashboard.module';
|
|
|
36
37
|
WorkflowModule,
|
|
37
38
|
IcsMeetingModule,
|
|
38
39
|
DashboardModule,
|
|
40
|
+
CommunicationModule,
|
|
39
41
|
],
|
|
40
42
|
})
|
|
41
43
|
export class AppModule {}
|
|
@@ -43,7 +43,7 @@ export const DISPLAY_REPORT = 'REPORT';
|
|
|
43
43
|
|
|
44
44
|
//WorkFlow Type
|
|
45
45
|
export const WORKFLOW = 'WRFW';
|
|
46
|
-
export const ACTION = '
|
|
46
|
+
export const ACTION = 'WFAC';
|
|
47
47
|
export const STAGE = 'WFS';
|
|
48
48
|
export const STAGE_GROUP = 'WFSG';
|
|
49
49
|
export const ACTION_CATEGORY = 'WFAC';
|
|
@@ -10,7 +10,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
|
|
10
10
|
clientID: configService.get<string>('CLIENT_ID')!,
|
|
11
11
|
clientSecret: configService.get<string>('CLIENT_SECRET')!,
|
|
12
12
|
callbackURL: configService.get<string>('CALLBACK_URL')!,
|
|
13
|
-
scope: ['openid', 'email', 'profile'],
|
|
13
|
+
scope: ['openid', 'email', 'profile', 'https://www.googleapis.com/auth/gmail.send'],
|
|
14
14
|
accessType: 'offline', // good: gets refresh_token on first consent
|
|
15
15
|
includeGrantedScopes: true, // optional, keeps prior grants
|
|
16
16
|
// ⛔️ don't rely on 'prompt' here; add via authorizationParams()
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
3
|
+
|
|
4
|
+
// Entities
|
|
5
|
+
import { CommunicationConfig } from './entity/communication-config.entity';
|
|
6
|
+
import { CommunicationHub } from './entity/communication-hub.entity';
|
|
7
|
+
|
|
8
|
+
// Services
|
|
9
|
+
import { CommunicationService } from './service/communication.service';
|
|
10
|
+
|
|
11
|
+
// Controllers
|
|
12
|
+
import { CommunicationController } from './controller/communication.controller';
|
|
13
|
+
|
|
14
|
+
// Strategies - Using both existing and new strategies
|
|
15
|
+
import { GmailApiStrategy } from './strategies/email/gmail-api.strategy';
|
|
16
|
+
import { GmailSmtpStrategy } from './strategies/email/gmail-smtp.strategy';
|
|
17
|
+
import { OutlookApiStrategy } from './strategies/email/outlook-api.strategy';
|
|
18
|
+
import { TwilioStrategy } from './strategies/sms/twilio.strategy';
|
|
19
|
+
import { KnowlarityStrategy as KnowlaritySMSStrategy } from './strategies/sms/knowlarity.strategy';
|
|
20
|
+
import { WhatsAppCloudStrategy } from './strategies/whatsapp/whatsapp-cloud.strategy';
|
|
21
|
+
import { KnowlarityVoiceStrategy } from './strategies/telephone/knowlarity-voice.strategy';
|
|
22
|
+
|
|
23
|
+
// New unified strategies
|
|
24
|
+
import { GmailStrategy } from './strategies/gmail.strategy';
|
|
25
|
+
import { OutlookStrategy } from './strategies/outlook.strategy';
|
|
26
|
+
import { GmailSMTPStrategy } from './strategies/gmail-smtp.strategy';
|
|
27
|
+
import { OutlookSMTPStrategy } from './strategies/outlook-smtp.strategy';
|
|
28
|
+
import { SmsStrategy } from './strategies/sms.strategy';
|
|
29
|
+
import { KnowlarityStrategy } from './strategies/knowlarity.strategy';
|
|
30
|
+
import { WhatsAppStrategy } from './strategies/whatsapp.strategy';
|
|
31
|
+
import { OAuthService } from './service/oauth.service';
|
|
32
|
+
|
|
33
|
+
// Factories
|
|
34
|
+
import { EmailFactory } from './factories/email.factory';
|
|
35
|
+
import { SmsFactory } from './factories/sms.factory';
|
|
36
|
+
import { WhatsAppFactory } from './factories/whatsapp.factory';
|
|
37
|
+
import { TelephoneFactory } from './factories/telephone.factory';
|
|
38
|
+
import { CommunicationFactory } from './factories/communication.factory';
|
|
39
|
+
|
|
40
|
+
@Module({
|
|
41
|
+
imports: [TypeOrmModule.forFeature([CommunicationConfig, CommunicationHub])],
|
|
42
|
+
controllers: [CommunicationController],
|
|
43
|
+
providers: [
|
|
44
|
+
// Main Services
|
|
45
|
+
CommunicationService,
|
|
46
|
+
OAuthService,
|
|
47
|
+
|
|
48
|
+
// Existing Email Strategies (for backward compatibility)
|
|
49
|
+
GmailApiStrategy,
|
|
50
|
+
GmailSmtpStrategy,
|
|
51
|
+
OutlookApiStrategy,
|
|
52
|
+
|
|
53
|
+
// Existing SMS/WhatsApp/Telephone Strategies
|
|
54
|
+
TwilioStrategy,
|
|
55
|
+
KnowlaritySMSStrategy,
|
|
56
|
+
WhatsAppCloudStrategy,
|
|
57
|
+
KnowlarityVoiceStrategy,
|
|
58
|
+
|
|
59
|
+
// New unified strategies
|
|
60
|
+
GmailStrategy,
|
|
61
|
+
OutlookStrategy,
|
|
62
|
+
GmailSMTPStrategy,
|
|
63
|
+
OutlookSMTPStrategy,
|
|
64
|
+
SmsStrategy,
|
|
65
|
+
KnowlarityStrategy,
|
|
66
|
+
WhatsAppStrategy,
|
|
67
|
+
|
|
68
|
+
// Factories
|
|
69
|
+
EmailFactory,
|
|
70
|
+
SmsFactory,
|
|
71
|
+
WhatsAppFactory,
|
|
72
|
+
TelephoneFactory,
|
|
73
|
+
CommunicationFactory,
|
|
74
|
+
],
|
|
75
|
+
exports: [CommunicationService, CommunicationFactory],
|
|
76
|
+
})
|
|
77
|
+
export class CommunicationModule {}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
Get,
|
|
5
|
+
Param,
|
|
6
|
+
Post,
|
|
7
|
+
Put,
|
|
8
|
+
ParseIntPipe,
|
|
9
|
+
HttpStatus,
|
|
10
|
+
HttpCode,
|
|
11
|
+
} from '@nestjs/common';
|
|
12
|
+
import {
|
|
13
|
+
CommunicationService,
|
|
14
|
+
} from '../service/communication.service';
|
|
15
|
+
import {
|
|
16
|
+
CreateConfigDto,
|
|
17
|
+
UpdateConfigStatusDto,
|
|
18
|
+
GenericSendMessageDto,
|
|
19
|
+
BulkMessageDto,
|
|
20
|
+
GmailOAuthInitDto,
|
|
21
|
+
OutlookOAuthInitDto
|
|
22
|
+
} from '../dto/create-config.dto';
|
|
23
|
+
|
|
24
|
+
export class ScheduledMessageDto extends GenericSendMessageDto {
|
|
25
|
+
scheduleFor: Date;
|
|
26
|
+
timezone?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Controller('communication')
|
|
30
|
+
export class CommunicationController {
|
|
31
|
+
constructor(private readonly communicationService: CommunicationService) {}
|
|
32
|
+
|
|
33
|
+
@Post('send')
|
|
34
|
+
@HttpCode(HttpStatus.OK)
|
|
35
|
+
async sendMessage(@Body() sendMessageDto: GenericSendMessageDto) {
|
|
36
|
+
return this.communicationService.sendGenericMessage(sendMessageDto);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Post('send/bulk')
|
|
40
|
+
@HttpCode(HttpStatus.OK)
|
|
41
|
+
async sendBulkMessage(@Body() bulkMessageDto: BulkMessageDto) {
|
|
42
|
+
return this.communicationService.sendBulkMessage(bulkMessageDto);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Post('send/scheduled')
|
|
46
|
+
@HttpCode(HttpStatus.OK)
|
|
47
|
+
async scheduleMessage(@Body() scheduledMessageDto: ScheduledMessageDto) {
|
|
48
|
+
return this.communicationService.scheduleMessage(scheduledMessageDto);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Post('send/template')
|
|
52
|
+
@HttpCode(HttpStatus.OK)
|
|
53
|
+
async sendTemplateMessage(@Body() templateMessage: {
|
|
54
|
+
organisationId: number;
|
|
55
|
+
to: string | string[];
|
|
56
|
+
templateId: string;
|
|
57
|
+
variables: Record<string, any>;
|
|
58
|
+
type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE';
|
|
59
|
+
}) {
|
|
60
|
+
return this.communicationService.sendTemplateMessage(templateMessage);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Post('config')
|
|
64
|
+
async createConfig(@Body() createConfigDto: CreateConfigDto) {
|
|
65
|
+
return this.communicationService.createCommunicationConfig(
|
|
66
|
+
createConfigDto.levelId,
|
|
67
|
+
createConfigDto.levelType,
|
|
68
|
+
createConfigDto.configType,
|
|
69
|
+
createConfigDto.service,
|
|
70
|
+
createConfigDto.provider,
|
|
71
|
+
createConfigDto.config,
|
|
72
|
+
createConfigDto.priority,
|
|
73
|
+
createConfigDto.is_default,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Get('supported-combinations')
|
|
78
|
+
async getSupportedCombinations() {
|
|
79
|
+
return this.communicationService.getSupportedCombinations();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Get('level/:id/:type/configs')
|
|
83
|
+
async getLevelConfigs(
|
|
84
|
+
@Param('id', ParseIntPipe) levelId: number,
|
|
85
|
+
@Param('type') levelType: string,
|
|
86
|
+
) {
|
|
87
|
+
return this.communicationService.getLevelConfigs(levelId, levelType);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Put('config/:id/status')
|
|
91
|
+
async updateConfigStatus(
|
|
92
|
+
@Param('id', ParseIntPipe) hubId: number,
|
|
93
|
+
@Body() updateStatusDto: UpdateConfigStatusDto,
|
|
94
|
+
) {
|
|
95
|
+
await this.communicationService.updateConfigStatus(
|
|
96
|
+
hubId,
|
|
97
|
+
updateStatusDto.status,
|
|
98
|
+
);
|
|
99
|
+
return { message: 'Status updated successfully' };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@Post('gmail/oauth/init')
|
|
103
|
+
async initGmailOAuth(@Body() initDto: GmailOAuthInitDto) {
|
|
104
|
+
return this.communicationService.initGmailOAuth(
|
|
105
|
+
initDto.levelId,
|
|
106
|
+
initDto.levelType,
|
|
107
|
+
initDto.email,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@Post('gmail/test')
|
|
113
|
+
async testGmailConfig(@Body() body: { hubId: number }) {
|
|
114
|
+
return this.communicationService.testGmailConfig(body.hubId);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@Post('outlook/oauth/init')
|
|
119
|
+
async initOutlookOAuth(@Body() initDto: OutlookOAuthInitDto) {
|
|
120
|
+
return this.communicationService.initOutlookOAuth(initDto.levelId, initDto.levelType, initDto.email);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { IsNotEmpty, IsNumber, IsString, IsObject, IsOptional, IsEnum, IsIn, IsBoolean } from 'class-validator';
|
|
2
|
+
import { CommunicationConfigType } from '../entity/communication-hub.entity';
|
|
3
|
+
|
|
4
|
+
export class CreateConfigDto {
|
|
5
|
+
@IsNotEmpty()
|
|
6
|
+
@IsNumber()
|
|
7
|
+
levelId: number;
|
|
8
|
+
|
|
9
|
+
@IsNotEmpty()
|
|
10
|
+
@IsString()
|
|
11
|
+
levelType: string;
|
|
12
|
+
|
|
13
|
+
@IsNotEmpty()
|
|
14
|
+
@IsEnum(CommunicationConfigType)
|
|
15
|
+
configType: CommunicationConfigType;
|
|
16
|
+
|
|
17
|
+
@IsNotEmpty()
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsIn(['API', 'THIRD_PARTY', 'SMTP'])
|
|
20
|
+
service: string;
|
|
21
|
+
|
|
22
|
+
@IsNotEmpty()
|
|
23
|
+
@IsString()
|
|
24
|
+
@IsIn(['gmail', 'outlook', 'whatsapp', 'twilio', 'aws-ses', 'sendgrid', 'custom', 'generic', 'knowlarity'])
|
|
25
|
+
provider: string;
|
|
26
|
+
|
|
27
|
+
@IsNotEmpty()
|
|
28
|
+
@IsObject()
|
|
29
|
+
config: {
|
|
30
|
+
// OAuth Control
|
|
31
|
+
useOAuth?: boolean; // Set to true to force OAuth flow even if tokens are provided
|
|
32
|
+
|
|
33
|
+
// Gmail API Config
|
|
34
|
+
clientId?: string;
|
|
35
|
+
clientSecret?: string;
|
|
36
|
+
refreshToken?: string;
|
|
37
|
+
accessToken?: string;
|
|
38
|
+
|
|
39
|
+
// Outlook API Config
|
|
40
|
+
tenantId?: string;
|
|
41
|
+
|
|
42
|
+
// WhatsApp Config
|
|
43
|
+
phoneNumberId?: string;
|
|
44
|
+
apiVersion?: string;
|
|
45
|
+
|
|
46
|
+
// Twilio Config
|
|
47
|
+
accountSid?: string;
|
|
48
|
+
authToken?: string;
|
|
49
|
+
fromNumber?: string;
|
|
50
|
+
|
|
51
|
+
// AWS SES Config
|
|
52
|
+
accessKeyId?: string;
|
|
53
|
+
secretAccessKey?: string;
|
|
54
|
+
region?: string;
|
|
55
|
+
fromEmail?: string;
|
|
56
|
+
|
|
57
|
+
// SMTP Config (Gmail, Outlook, Generic)
|
|
58
|
+
email?: string;
|
|
59
|
+
password?: string;
|
|
60
|
+
host?: string;
|
|
61
|
+
port?: number;
|
|
62
|
+
secure?: boolean;
|
|
63
|
+
user?: string;
|
|
64
|
+
from?: string;
|
|
65
|
+
tls?: any;
|
|
66
|
+
|
|
67
|
+
// SendGrid SMTP Config
|
|
68
|
+
apiKey?: string;
|
|
69
|
+
templateId?: string;
|
|
70
|
+
dynamicTemplateData?: any;
|
|
71
|
+
|
|
72
|
+
// Knowlarity Config
|
|
73
|
+
callerNumber?: string;
|
|
74
|
+
apiSecret?: string;
|
|
75
|
+
baseUrl?: string;
|
|
76
|
+
callType?: 'voice' | 'sms';
|
|
77
|
+
voiceMessage?: string;
|
|
78
|
+
language?: string;
|
|
79
|
+
|
|
80
|
+
// Common optional fields
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
@IsOptional()
|
|
85
|
+
@IsNumber()
|
|
86
|
+
priority?: number;
|
|
87
|
+
|
|
88
|
+
@IsOptional()
|
|
89
|
+
@IsBoolean()
|
|
90
|
+
is_default?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class UpdateConfigStatusDto {
|
|
94
|
+
@IsNotEmpty()
|
|
95
|
+
@IsNumber()
|
|
96
|
+
status: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class GenericSendMessageDto {
|
|
100
|
+
@IsNotEmpty()
|
|
101
|
+
@IsNumber()
|
|
102
|
+
levelId: number;
|
|
103
|
+
|
|
104
|
+
@IsNotEmpty()
|
|
105
|
+
@IsString()
|
|
106
|
+
levelType: string;
|
|
107
|
+
|
|
108
|
+
@IsNotEmpty()
|
|
109
|
+
to: string | string[];
|
|
110
|
+
|
|
111
|
+
@IsNotEmpty()
|
|
112
|
+
@IsString()
|
|
113
|
+
message: string;
|
|
114
|
+
|
|
115
|
+
@IsOptional()
|
|
116
|
+
@IsString()
|
|
117
|
+
subject?: string;
|
|
118
|
+
|
|
119
|
+
@IsOptional()
|
|
120
|
+
@IsIn(['EMAIL', 'SMS', 'WA', 'TELEPHONE'])
|
|
121
|
+
type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE';
|
|
122
|
+
|
|
123
|
+
@IsOptional()
|
|
124
|
+
@IsIn(['high', 'medium', 'low'])
|
|
125
|
+
priority?: 'high' | 'medium' | 'low';
|
|
126
|
+
|
|
127
|
+
@IsOptional()
|
|
128
|
+
cc?: string | string[];
|
|
129
|
+
|
|
130
|
+
@IsOptional()
|
|
131
|
+
bcc?: string | string[];
|
|
132
|
+
|
|
133
|
+
@IsOptional()
|
|
134
|
+
@IsString()
|
|
135
|
+
html?: string;
|
|
136
|
+
|
|
137
|
+
@IsOptional()
|
|
138
|
+
attachments?: any[];
|
|
139
|
+
|
|
140
|
+
@IsOptional()
|
|
141
|
+
@IsString()
|
|
142
|
+
mediaUrl?: string;
|
|
143
|
+
|
|
144
|
+
@IsOptional()
|
|
145
|
+
@IsString()
|
|
146
|
+
templateId?: string;
|
|
147
|
+
|
|
148
|
+
@IsOptional()
|
|
149
|
+
@IsObject()
|
|
150
|
+
variables?: Record<string, any>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export class BulkMessageDto {
|
|
154
|
+
@IsNotEmpty()
|
|
155
|
+
@IsNumber()
|
|
156
|
+
levelId: number;
|
|
157
|
+
|
|
158
|
+
@IsNotEmpty()
|
|
159
|
+
@IsString()
|
|
160
|
+
levelType: string;
|
|
161
|
+
|
|
162
|
+
@IsNotEmpty()
|
|
163
|
+
recipients: string[];
|
|
164
|
+
|
|
165
|
+
@IsNotEmpty()
|
|
166
|
+
@IsString()
|
|
167
|
+
message: string;
|
|
168
|
+
|
|
169
|
+
@IsOptional()
|
|
170
|
+
@IsString()
|
|
171
|
+
subject?: string;
|
|
172
|
+
|
|
173
|
+
@IsOptional()
|
|
174
|
+
@IsIn(['EMAIL', 'SMS', 'WA', 'TELEPHONE'])
|
|
175
|
+
type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE';
|
|
176
|
+
|
|
177
|
+
@IsOptional()
|
|
178
|
+
@IsIn(['high', 'medium', 'low'])
|
|
179
|
+
priority?: 'high' | 'medium' | 'low';
|
|
180
|
+
|
|
181
|
+
@IsOptional()
|
|
182
|
+
@IsString()
|
|
183
|
+
html?: string;
|
|
184
|
+
|
|
185
|
+
@IsOptional()
|
|
186
|
+
@IsString()
|
|
187
|
+
templateId?: string;
|
|
188
|
+
|
|
189
|
+
@IsOptional()
|
|
190
|
+
@IsObject()
|
|
191
|
+
variables?: Record<string, any>;
|
|
192
|
+
|
|
193
|
+
@IsOptional()
|
|
194
|
+
@IsNumber()
|
|
195
|
+
batchSize?: number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export class GmailOAuthInitDto {
|
|
199
|
+
@IsNotEmpty()
|
|
200
|
+
@IsNumber()
|
|
201
|
+
levelId: number;
|
|
202
|
+
|
|
203
|
+
@IsNotEmpty()
|
|
204
|
+
@IsString()
|
|
205
|
+
levelType: string;
|
|
206
|
+
|
|
207
|
+
@IsOptional()
|
|
208
|
+
@IsString()
|
|
209
|
+
email?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export class OAuthCallbackDto {
|
|
213
|
+
@IsNotEmpty()
|
|
214
|
+
@IsString()
|
|
215
|
+
code: string;
|
|
216
|
+
|
|
217
|
+
@IsNotEmpty()
|
|
218
|
+
@IsString()
|
|
219
|
+
state: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export class OutlookOAuthInitDto {
|
|
223
|
+
@IsNotEmpty()
|
|
224
|
+
@IsNumber()
|
|
225
|
+
levelId: number;
|
|
226
|
+
|
|
227
|
+
@IsNotEmpty()
|
|
228
|
+
@IsString()
|
|
229
|
+
levelType: string;
|
|
230
|
+
|
|
231
|
+
@IsOptional()
|
|
232
|
+
@IsString()
|
|
233
|
+
email?: string;
|
|
234
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
2
|
+
import { IsNotEmpty, IsObject } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
@Entity({ name: 'communication_config' })
|
|
5
|
+
export class CommunicationConfig {
|
|
6
|
+
@PrimaryGeneratedColumn({ name: 'id', type: 'int' })
|
|
7
|
+
id: number;
|
|
8
|
+
|
|
9
|
+
@Column({ name: 'config_json', type: 'json' })
|
|
10
|
+
@IsNotEmpty()
|
|
11
|
+
@IsObject()
|
|
12
|
+
config_json: {
|
|
13
|
+
// Gmail Config
|
|
14
|
+
clientId?: string;
|
|
15
|
+
clientSecret?: string;
|
|
16
|
+
refreshToken?: string;
|
|
17
|
+
accessToken?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
|
|
20
|
+
// Outlook Config
|
|
21
|
+
tenantId?: string;
|
|
22
|
+
|
|
23
|
+
// WhatsApp Config
|
|
24
|
+
phoneNumberId?: string;
|
|
25
|
+
apiVersion?: string;
|
|
26
|
+
|
|
27
|
+
// Twilio Config
|
|
28
|
+
accountSid?: string;
|
|
29
|
+
authToken?: string;
|
|
30
|
+
fromNumber?: string;
|
|
31
|
+
|
|
32
|
+
// AWS SES Config
|
|
33
|
+
accessKeyId?: string;
|
|
34
|
+
secretAccessKey?: string;
|
|
35
|
+
region?: string;
|
|
36
|
+
fromEmail?: string;
|
|
37
|
+
|
|
38
|
+
// SMTP Config (Gmail, Outlook, Generic)
|
|
39
|
+
password?: string;
|
|
40
|
+
host?: string;
|
|
41
|
+
port?: number;
|
|
42
|
+
secure?: boolean;
|
|
43
|
+
user?: string;
|
|
44
|
+
from?: string;
|
|
45
|
+
tls?: any;
|
|
46
|
+
|
|
47
|
+
// SendGrid SMTP Config
|
|
48
|
+
apiKey?: string;
|
|
49
|
+
templateId?: string;
|
|
50
|
+
dynamicTemplateData?: any;
|
|
51
|
+
|
|
52
|
+
// Knowlarity Config
|
|
53
|
+
callerNumber?: string;
|
|
54
|
+
apiSecret?: string;
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
callType?: 'voice' | 'sms';
|
|
57
|
+
voiceMessage?: string;
|
|
58
|
+
language?: string;
|
|
59
|
+
|
|
60
|
+
// Common fields
|
|
61
|
+
subject?: string;
|
|
62
|
+
html?: string;
|
|
63
|
+
attachments?: any[];
|
|
64
|
+
cc?: string | string[];
|
|
65
|
+
bcc?: string | string[];
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
@CreateDateColumn({
|
|
70
|
+
name: 'created_at',
|
|
71
|
+
type: 'datetime',
|
|
72
|
+
})
|
|
73
|
+
created_at: Date;
|
|
74
|
+
|
|
75
|
+
@UpdateDateColumn({
|
|
76
|
+
name: 'updated_at',
|
|
77
|
+
type: 'datetime',
|
|
78
|
+
})
|
|
79
|
+
updated_at: Date;
|
|
80
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Column, Entity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';
|
|
2
|
+
import { IsNotEmpty, IsIn, IsBoolean, IsInt, Min } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export enum CommunicationConfigType {
|
|
5
|
+
WA = 'WA',
|
|
6
|
+
SMS = 'SMS',
|
|
7
|
+
EMAIL = 'EMAIL',
|
|
8
|
+
TELEPHONE = 'TELEPHONE',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@Entity({ name: 'communication_hub' })
|
|
12
|
+
@Index('idx_level_status', ['level_id', 'level_type', 'status'])
|
|
13
|
+
@Index('idx_config_type', ['communication_config_type'])
|
|
14
|
+
@Index('idx_service_provider', ['service', 'provider'])
|
|
15
|
+
export class CommunicationHub {
|
|
16
|
+
@PrimaryGeneratedColumn({ name: 'id', type: 'int' })
|
|
17
|
+
id: number;
|
|
18
|
+
|
|
19
|
+
@Column({ name: 'level_id', type: 'int' })
|
|
20
|
+
@IsNotEmpty()
|
|
21
|
+
@IsInt()
|
|
22
|
+
level_id: number;
|
|
23
|
+
|
|
24
|
+
@Column({ name: 'level_type', type: 'varchar', length: 100 })
|
|
25
|
+
@IsNotEmpty()
|
|
26
|
+
level_type: string;
|
|
27
|
+
|
|
28
|
+
@Column({ name: 'status', type: 'tinyint', default: 1 })
|
|
29
|
+
@IsInt()
|
|
30
|
+
@Min(0)
|
|
31
|
+
status: number;
|
|
32
|
+
|
|
33
|
+
@Column({ name: 'config_id', type: 'int' })
|
|
34
|
+
@IsNotEmpty()
|
|
35
|
+
@IsInt()
|
|
36
|
+
config_id: number;
|
|
37
|
+
|
|
38
|
+
@Column({
|
|
39
|
+
name: 'communication_config_type',
|
|
40
|
+
type: 'enum',
|
|
41
|
+
enum: CommunicationConfigType,
|
|
42
|
+
})
|
|
43
|
+
@IsNotEmpty()
|
|
44
|
+
@IsIn(['WA', 'SMS', 'EMAIL', 'TELEPHONE'])
|
|
45
|
+
communication_config_type: CommunicationConfigType;
|
|
46
|
+
|
|
47
|
+
@Column({ name: 'service', type: 'varchar', length: 100 })
|
|
48
|
+
@IsNotEmpty()
|
|
49
|
+
@IsIn(['API', 'THIRD_PARTY', 'SMTP'])
|
|
50
|
+
service: 'API' | 'THIRD_PARTY' | 'SMTP';
|
|
51
|
+
|
|
52
|
+
@Column({ name: 'provider', type: 'varchar', length: 100 })
|
|
53
|
+
@IsNotEmpty()
|
|
54
|
+
@IsIn(['gmail', 'outlook', 'whatsapp', 'twilio', 'aws-ses', 'sendgrid', 'custom', 'generic', 'knowlarity'])
|
|
55
|
+
provider: 'gmail' | 'outlook' | 'whatsapp' | 'twilio' | 'aws-ses' | 'sendgrid' | 'custom' | 'generic' | 'knowlarity';
|
|
56
|
+
|
|
57
|
+
@Column({ name: 'priority', type: 'int', default: 1 })
|
|
58
|
+
@IsInt()
|
|
59
|
+
@Min(1)
|
|
60
|
+
priority: number;
|
|
61
|
+
|
|
62
|
+
@Column({ name: 'is_default', type: 'boolean', default: false })
|
|
63
|
+
@IsBoolean()
|
|
64
|
+
is_default: boolean;
|
|
65
|
+
|
|
66
|
+
@CreateDateColumn({
|
|
67
|
+
name: 'created_at',
|
|
68
|
+
type: 'datetime',
|
|
69
|
+
})
|
|
70
|
+
created_at: Date;
|
|
71
|
+
|
|
72
|
+
@UpdateDateColumn({
|
|
73
|
+
name: 'updated_at',
|
|
74
|
+
type: 'datetime',
|
|
75
|
+
})
|
|
76
|
+
updated_at: Date;
|
|
77
|
+
}
|