rez_core 2.2.155 → 2.2.157
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/enterprise/entity/organization.entity.d.ts +1 -0
- package/dist/module/enterprise/entity/organization.entity.js +4 -0
- package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
- package/dist/module/enterprise/repository/organization.repository.d.ts +1 -0
- package/dist/module/enterprise/repository/organization.repository.js +5 -0
- package/dist/module/enterprise/repository/organization.repository.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +0 -1
- package/dist/module/master/service/master.service.js +20 -24
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/controller/entity-master.controller.d.ts +8 -0
- package/dist/module/meta/controller/entity-master.controller.js +44 -0
- package/dist/module/meta/controller/entity-master.controller.js.map +1 -0
- package/dist/module/meta/entity.module.js +6 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/entity-master.repository.d.ts +8 -0
- package/dist/module/meta/repository/entity-master.repository.js +36 -0
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -0
- package/dist/module/meta/service/entity-master.service.d.ts +4 -1
- package/dist/module/meta/service/entity-master.service.js +8 -2
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +1 -0
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +1 -0
- package/dist/module/notification/service/otp.service.js +2 -2
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +4 -2
- package/dist/module/user/controller/login.controller.js +28 -6
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +1 -1
- package/dist/module/user/service/login.service.js +15 -6
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/user.module.js +2 -0
- package/dist/module/user/user.module.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/enterprise/entity/organization.entity.ts +3 -0
- package/src/module/enterprise/repository/organization.repository.ts +6 -0
- package/src/module/master/service/master.service.ts +29 -24
- package/src/module/meta/controller/entity-master.controller.ts +28 -0
- package/src/module/meta/entity.module.ts +6 -1
- package/src/module/meta/repository/entity-master.repository.ts +17 -0
- package/src/module/meta/service/entity-master.service.ts +7 -0
- package/src/module/notification/controller/otp.controller.ts +1 -1
- package/src/module/notification/service/otp.service.ts +3 -3
- package/src/module/user/controller/login.controller.ts +36 -5
- package/src/module/user/service/login.service.ts +48 -23
- package/src/module/user/user.module.ts +2 -0
- 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
|
@@ -0,0 +1,169 @@
|
|
|
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 = await this.communicationService.getSupportedCombinations();
|
|
142
|
+
console.log('Supported combinations:', combinations);
|
|
143
|
+
|
|
144
|
+
// Output will be:
|
|
145
|
+
// [
|
|
146
|
+
// { mode: 'EMAIL', service: 'API', provider: 'gmail' },
|
|
147
|
+
// { mode: 'EMAIL', service: 'SMTP', provider: 'gmail' },
|
|
148
|
+
// { mode: 'EMAIL', service: 'API', provider: 'outlook' },
|
|
149
|
+
// { mode: 'SMS', service: 'THIRD_PARTY', provider: 'twilio' },
|
|
150
|
+
// { mode: 'SMS', service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
151
|
+
// { mode: 'WA', service: 'API', provider: 'whatsapp' },
|
|
152
|
+
// { mode: 'TELEPHONE', service: 'THIRD_PARTY', provider: 'knowlarity' }
|
|
153
|
+
// ]
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Example 6: Send message without specifying mode (uses first available)
|
|
158
|
+
*/
|
|
159
|
+
async sendMessageAutoMode() {
|
|
160
|
+
const result = await this.communicationService.sendMessage({
|
|
161
|
+
levelId: 1,
|
|
162
|
+
levelType: 'organization',
|
|
163
|
+
to: 'recipient@example.com',
|
|
164
|
+
message: 'Hello! This will use the first available communication method.'
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
console.log('Message sent via auto-selected provider:', result);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
2
|
+
|
|
3
|
+
export interface BaseFactory {
|
|
4
|
+
createProvider(service: string, provider: string): CommunicationStrategy;
|
|
5
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }>;
|
|
6
|
+
validateCombination(service: string, provider: string): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
3
|
+
import { EmailFactory } from './email.factory';
|
|
4
|
+
import { SmsFactory } from './sms.factory';
|
|
5
|
+
import { WhatsAppFactory } from './whatsapp.factory';
|
|
6
|
+
import { TelephoneFactory } from './telephone.factory';
|
|
7
|
+
|
|
8
|
+
export enum CommunicationMode {
|
|
9
|
+
EMAIL = 'EMAIL',
|
|
10
|
+
SMS = 'SMS',
|
|
11
|
+
WA = 'WA',
|
|
12
|
+
TELEPHONE = 'TELEPHONE'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Injectable()
|
|
16
|
+
export class CommunicationFactory {
|
|
17
|
+
private readonly modeFactoryMap = new Map<CommunicationMode, any>();
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
private emailFactory: EmailFactory,
|
|
21
|
+
private smsFactory: SmsFactory,
|
|
22
|
+
private whatsappFactory: WhatsAppFactory,
|
|
23
|
+
private telephoneFactory: TelephoneFactory,
|
|
24
|
+
) {
|
|
25
|
+
this.initializeFactoryMap();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private initializeFactoryMap(): void {
|
|
29
|
+
this.modeFactoryMap.set(CommunicationMode.EMAIL, this.emailFactory);
|
|
30
|
+
this.modeFactoryMap.set(CommunicationMode.SMS, this.smsFactory);
|
|
31
|
+
this.modeFactoryMap.set(CommunicationMode.WA, this.whatsappFactory);
|
|
32
|
+
this.modeFactoryMap.set(CommunicationMode.TELEPHONE, this.telephoneFactory);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
create(mode: string, service: string, provider: string): CommunicationStrategy {
|
|
36
|
+
const communicationMode = mode.toUpperCase() as CommunicationMode;
|
|
37
|
+
|
|
38
|
+
if (!Object.values(CommunicationMode).includes(communicationMode)) {
|
|
39
|
+
throw new Error(`Unsupported communication mode: ${mode}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const factory = this.modeFactoryMap.get(communicationMode);
|
|
43
|
+
if (!factory) {
|
|
44
|
+
throw new Error(`Factory not found for mode: ${mode}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return factory.createProvider(service, provider);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getAllSupportedCombinations(): Array<{ mode: string; service: string; provider: string }> {
|
|
51
|
+
const combinations: Array<{ mode: string; service: string; provider: string }> = [];
|
|
52
|
+
|
|
53
|
+
this.modeFactoryMap.forEach((factory, mode) => {
|
|
54
|
+
const factoryCombinations = factory.getSupportedCombinations();
|
|
55
|
+
factoryCombinations.forEach(combo => {
|
|
56
|
+
combinations.push({
|
|
57
|
+
mode: mode,
|
|
58
|
+
service: combo.service,
|
|
59
|
+
provider: combo.provider
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return combinations;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getSupportedCombinationsForMode(mode: string): Array<{ service: string; provider: string }> {
|
|
68
|
+
const communicationMode = mode.toUpperCase() as CommunicationMode;
|
|
69
|
+
const factory = this.modeFactoryMap.get(communicationMode);
|
|
70
|
+
|
|
71
|
+
if (!factory) {
|
|
72
|
+
throw new Error(`Factory not found for mode: ${mode}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return factory.getSupportedCombinations();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
validateCombination(mode: string, service: string, provider: string): boolean {
|
|
79
|
+
try {
|
|
80
|
+
const communicationMode = mode.toUpperCase() as CommunicationMode;
|
|
81
|
+
const factory = this.modeFactoryMap.get(communicationMode);
|
|
82
|
+
|
|
83
|
+
if (!factory) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return factory.validateCombination(service, provider);
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getAvailableModes(): string[] {
|
|
94
|
+
return Object.values(CommunicationMode);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getProvidersByModeAndService(mode: string, service: string): string[] {
|
|
98
|
+
const combinations = this.getSupportedCombinationsForMode(mode);
|
|
99
|
+
return combinations
|
|
100
|
+
.filter(combo => combo.service.toLowerCase() === service.toLowerCase())
|
|
101
|
+
.map(combo => combo.provider);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseFactory } from './base.factory';
|
|
3
|
+
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
4
|
+
import { GmailStrategy } from '../strategies/gmail.strategy';
|
|
5
|
+
import { OutlookStrategy } from '../strategies/outlook.strategy';
|
|
6
|
+
import { GmailSMTPStrategy } from '../strategies/gmail-smtp.strategy';
|
|
7
|
+
import { OutlookSMTPStrategy } from '../strategies/outlook-smtp.strategy';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class EmailFactory implements BaseFactory {
|
|
11
|
+
constructor(
|
|
12
|
+
private gmailStrategy: GmailStrategy,
|
|
13
|
+
private outlookStrategy: OutlookStrategy,
|
|
14
|
+
private gmailSMTPStrategy: GmailSMTPStrategy,
|
|
15
|
+
private outlookSMTPStrategy: OutlookSMTPStrategy,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
createProvider(service: string, provider: string): CommunicationStrategy {
|
|
19
|
+
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
20
|
+
|
|
21
|
+
switch (key) {
|
|
22
|
+
case 'api_gmail':
|
|
23
|
+
return this.gmailStrategy;
|
|
24
|
+
case 'api_outlook':
|
|
25
|
+
return this.outlookStrategy;
|
|
26
|
+
case 'smtp_gmail':
|
|
27
|
+
return this.gmailSMTPStrategy;
|
|
28
|
+
case 'smtp_outlook':
|
|
29
|
+
return this.outlookSMTPStrategy;
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`Unsupported EMAIL service/provider: ${service}/${provider}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
37
|
+
return [
|
|
38
|
+
{ service: 'API', provider: 'gmail' },
|
|
39
|
+
{ service: 'API', provider: 'outlook' },
|
|
40
|
+
{ service: 'SMTP', provider: 'gmail' },
|
|
41
|
+
{ service: 'SMTP', provider: 'outlook' },
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
validateCombination(service: string, provider: string): boolean {
|
|
46
|
+
return this.getSupportedCombinations().some(
|
|
47
|
+
combo => combo.service.toLowerCase() === service.toLowerCase() &&
|
|
48
|
+
combo.provider.toLowerCase() === provider.toLowerCase()
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.strategy';
|
|
5
|
+
import { KnowlarityStrategy } from '../strategies/knowlarity.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(`Unsupported SMS service/provider: ${service}/${provider}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
29
|
+
return [
|
|
30
|
+
{ service: 'THIRD_PARTY', provider: 'twilio' },
|
|
31
|
+
{ service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
validateCombination(service: string, provider: string): boolean {
|
|
36
|
+
return this.getSupportedCombinations().some(
|
|
37
|
+
combo => combo.service.toLowerCase() === service.toLowerCase() &&
|
|
38
|
+
combo.provider.toLowerCase() === provider.toLowerCase()
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseFactory } from './base.factory';
|
|
3
|
+
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
4
|
+
import { KnowlarityStrategy } from '../strategies/knowlarity.strategy';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class TelephoneFactory implements BaseFactory {
|
|
8
|
+
constructor(private knowlarityStrategy: KnowlarityStrategy) {}
|
|
9
|
+
|
|
10
|
+
createProvider(service: string, provider: string): CommunicationStrategy {
|
|
11
|
+
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
12
|
+
|
|
13
|
+
switch (key) {
|
|
14
|
+
case 'third_party_knowlarity':
|
|
15
|
+
return this.knowlarityStrategy;
|
|
16
|
+
|
|
17
|
+
default:
|
|
18
|
+
throw new Error(`Unsupported Telephone service/provider: ${service}/${provider}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
23
|
+
return [
|
|
24
|
+
{ service: 'THIRD_PARTY', provider: 'knowlarity' },
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validateCombination(service: string, provider: string): boolean {
|
|
29
|
+
return this.getSupportedCombinations().some(
|
|
30
|
+
combo => combo.service.toLowerCase() === service.toLowerCase() &&
|
|
31
|
+
combo.provider.toLowerCase() === provider.toLowerCase()
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { BaseFactory } from './base.factory';
|
|
3
|
+
import { CommunicationStrategy } from '../strategies/communication.strategy';
|
|
4
|
+
import { WhatsAppStrategy } from '../strategies/whatsapp.strategy';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class WhatsAppFactory implements BaseFactory {
|
|
8
|
+
constructor(private whatsappStrategy: WhatsAppStrategy) {}
|
|
9
|
+
|
|
10
|
+
createProvider(service: string, provider: string): CommunicationStrategy {
|
|
11
|
+
const key = `${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
12
|
+
|
|
13
|
+
switch (key) {
|
|
14
|
+
case 'api_whatsapp':
|
|
15
|
+
return this.whatsappStrategy;
|
|
16
|
+
|
|
17
|
+
default:
|
|
18
|
+
throw new Error(`Unsupported WhatsApp service/provider: ${service}/${provider}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getSupportedCombinations(): Array<{ service: string; provider: string }> {
|
|
23
|
+
return [
|
|
24
|
+
{ service: 'API', provider: 'whatsapp' },
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validateCombination(service: string, provider: string): boolean {
|
|
29
|
+
return this.getSupportedCombinations().some(
|
|
30
|
+
combo => combo.service.toLowerCase() === service.toLowerCase() &&
|
|
31
|
+
combo.provider.toLowerCase() === provider.toLowerCase()
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|