rez_core 2.2.177 → 2.2.180
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/communication/controller/communication.controller.d.ts +1 -4
- package/dist/module/communication/service/communication.service.d.ts +1 -6
- package/dist/module/communication/service/communication.service.js +1 -190
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/user/controller/user.controller.js +3 -2
- package/dist/module/user/controller/user.controller.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +1 -1
- package/dist/module/user/service/user.service.js +3 -5
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/service/communication.service.ts +2 -264
- package/src/module/user/controller/user.controller.ts +3 -2
- package/src/module/user/service/user.service.ts +4 -8
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -327,7 +327,7 @@ export class CommunicationService {
|
|
|
327
327
|
service?: 'API' | 'THIRD_PARTY' | 'SMTP';
|
|
328
328
|
provider?: string;
|
|
329
329
|
},
|
|
330
|
-
): Promise<
|
|
330
|
+
): Promise<CommunicationHub[]> {
|
|
331
331
|
const where: any = { level_id: levelId, level_type: levelType };
|
|
332
332
|
|
|
333
333
|
if (filters?.communication_config_type) {
|
|
@@ -342,272 +342,10 @@ export class CommunicationService {
|
|
|
342
342
|
where.provider = filters.provider;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
return this.hubRepository.find({
|
|
346
346
|
where,
|
|
347
347
|
order: { created_at: 'DESC' },
|
|
348
348
|
});
|
|
349
|
-
|
|
350
|
-
// Enhance hubs with linked source information
|
|
351
|
-
const enhancedHubs = await Promise.all(
|
|
352
|
-
hubs.map(async (hub) => {
|
|
353
|
-
try {
|
|
354
|
-
const config = await this.configRepository.findOne({
|
|
355
|
-
where: { id: hub.config_id },
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
if (!config) {
|
|
359
|
-
return {
|
|
360
|
-
...hub,
|
|
361
|
-
linkedSource: 'Configuration not found',
|
|
362
|
-
configDetails: null,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const linkedSource = this.extractLinkedSource(
|
|
367
|
-
hub.communication_config_type,
|
|
368
|
-
hub.service,
|
|
369
|
-
hub.provider,
|
|
370
|
-
config.config_json,
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
const configDetails = this.extractConfigDetails(
|
|
374
|
-
hub.communication_config_type,
|
|
375
|
-
hub.service,
|
|
376
|
-
hub.provider,
|
|
377
|
-
config.config_json,
|
|
378
|
-
);
|
|
379
|
-
|
|
380
|
-
return {
|
|
381
|
-
...hub,
|
|
382
|
-
linkedSource,
|
|
383
|
-
configDetails,
|
|
384
|
-
};
|
|
385
|
-
} catch (error) {
|
|
386
|
-
this.logger.warn(
|
|
387
|
-
`Error extracting linked source for hub ${hub.id}:`,
|
|
388
|
-
error.message,
|
|
389
|
-
);
|
|
390
|
-
return {
|
|
391
|
-
...hub,
|
|
392
|
-
linkedSource: 'Error retrieving source',
|
|
393
|
-
configDetails: null,
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
}),
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
return enhancedHubs;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
private extractLinkedSource(
|
|
403
|
-
configType: string,
|
|
404
|
-
service: string,
|
|
405
|
-
provider: string,
|
|
406
|
-
configJson: any,
|
|
407
|
-
): string {
|
|
408
|
-
const key = `${configType.toLowerCase()}_${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
409
|
-
|
|
410
|
-
try {
|
|
411
|
-
switch (key) {
|
|
412
|
-
// Gmail configurations
|
|
413
|
-
case 'email_api_gmail':
|
|
414
|
-
case 'email_smtp_gmail':
|
|
415
|
-
return configJson?.email || 'Gmail account not configured';
|
|
416
|
-
|
|
417
|
-
// Outlook configurations
|
|
418
|
-
case 'email_api_outlook':
|
|
419
|
-
case 'email_smtp_outlook':
|
|
420
|
-
return configJson?.email || 'Outlook account not configured';
|
|
421
|
-
|
|
422
|
-
// WhatsApp configurations
|
|
423
|
-
case 'wa_api_whatsapp':
|
|
424
|
-
return configJson?.phoneNumberId
|
|
425
|
-
? `WhatsApp Business: ${configJson.phoneNumberId}`
|
|
426
|
-
: 'WhatsApp not configured';
|
|
427
|
-
|
|
428
|
-
// SMS configurations
|
|
429
|
-
case 'sms_third_party_twilio':
|
|
430
|
-
return configJson?.fromNumber
|
|
431
|
-
? `Twilio: ${configJson.fromNumber}`
|
|
432
|
-
: 'Twilio number not configured';
|
|
433
|
-
|
|
434
|
-
case 'sms_third_party_knowlarity':
|
|
435
|
-
return configJson?.callerNumber
|
|
436
|
-
? `Knowlarity: ${configJson.callerNumber}`
|
|
437
|
-
: 'Knowlarity number not configured';
|
|
438
|
-
|
|
439
|
-
// Telephone configurations
|
|
440
|
-
case 'telephone_third_party_knowlarity':
|
|
441
|
-
return configJson?.callerNumber
|
|
442
|
-
? `Knowlarity Voice: ${configJson.callerNumber}`
|
|
443
|
-
: 'Knowlarity voice number not configured';
|
|
444
|
-
|
|
445
|
-
// AWS SES configurations
|
|
446
|
-
case 'email_api_aws-ses':
|
|
447
|
-
case 'email_api_ses':
|
|
448
|
-
return configJson?.fromEmail || 'AWS SES not configured';
|
|
449
|
-
|
|
450
|
-
// SendGrid configurations
|
|
451
|
-
case 'email_smtp_sendgrid':
|
|
452
|
-
return configJson?.from || 'SendGrid not configured';
|
|
453
|
-
|
|
454
|
-
// Generic SMTP configurations
|
|
455
|
-
case 'email_smtp_custom':
|
|
456
|
-
case 'email_smtp_generic':
|
|
457
|
-
return configJson?.from || configJson?.user || 'SMTP not configured';
|
|
458
|
-
|
|
459
|
-
default:
|
|
460
|
-
// Generic fallback - try to find common identifier fields
|
|
461
|
-
if (configJson?.email) return configJson.email;
|
|
462
|
-
if (configJson?.from) return configJson.from;
|
|
463
|
-
if (configJson?.user) return configJson.user;
|
|
464
|
-
if (configJson?.phoneNumberId) return configJson.phoneNumberId;
|
|
465
|
-
if (configJson?.fromNumber) return configJson.fromNumber;
|
|
466
|
-
if (configJson?.callerNumber) return configJson.callerNumber;
|
|
467
|
-
|
|
468
|
-
return `${provider} configured`;
|
|
469
|
-
}
|
|
470
|
-
} catch (error) {
|
|
471
|
-
return 'Configuration error';
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
private extractConfigDetails(
|
|
476
|
-
configType: string,
|
|
477
|
-
service: string,
|
|
478
|
-
provider: string,
|
|
479
|
-
configJson: any,
|
|
480
|
-
): any {
|
|
481
|
-
const key = `${configType.toLowerCase()}_${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
482
|
-
|
|
483
|
-
try {
|
|
484
|
-
switch (key) {
|
|
485
|
-
// Gmail configurations
|
|
486
|
-
case 'email_api_gmail':
|
|
487
|
-
return {
|
|
488
|
-
email: configJson?.email,
|
|
489
|
-
authMethod: configJson?.authMethod || 'OAUTH2',
|
|
490
|
-
hasRefreshToken: !!configJson?.refreshToken,
|
|
491
|
-
isExpired: configJson?.expiryDate ? new Date(configJson.expiryDate) < new Date() : false,
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
case 'email_smtp_gmail':
|
|
495
|
-
return {
|
|
496
|
-
email: configJson?.email,
|
|
497
|
-
authMethod: 'SMTP',
|
|
498
|
-
hasPassword: !!configJson?.password,
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
// Outlook configurations
|
|
502
|
-
case 'email_api_outlook':
|
|
503
|
-
return {
|
|
504
|
-
email: configJson?.email,
|
|
505
|
-
authMethod: 'OAUTH2',
|
|
506
|
-
hasRefreshToken: !!configJson?.refreshToken,
|
|
507
|
-
tenantId: configJson?.tenantId,
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
case 'email_smtp_outlook':
|
|
511
|
-
return {
|
|
512
|
-
email: configJson?.email,
|
|
513
|
-
authMethod: 'SMTP',
|
|
514
|
-
hasPassword: !!configJson?.password,
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
// WhatsApp configurations
|
|
518
|
-
case 'wa_api_whatsapp':
|
|
519
|
-
return {
|
|
520
|
-
phoneNumberId: configJson?.phoneNumberId,
|
|
521
|
-
apiVersion: configJson?.apiVersion || 'v17.0',
|
|
522
|
-
hasAccessToken: !!configJson?.accessToken,
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
// SMS configurations
|
|
526
|
-
case 'sms_third_party_twilio':
|
|
527
|
-
return {
|
|
528
|
-
fromNumber: configJson?.fromNumber,
|
|
529
|
-
accountSid: configJson?.accountSid ? configJson.accountSid.substring(0, 8) + '...' : null,
|
|
530
|
-
hasAuthToken: !!configJson?.authToken,
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
case 'sms_third_party_knowlarity':
|
|
534
|
-
return {
|
|
535
|
-
callerNumber: configJson?.callerNumber,
|
|
536
|
-
callType: configJson?.callType || 'sms',
|
|
537
|
-
hasApiSecret: !!configJson?.apiSecret,
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
// Telephone configurations
|
|
541
|
-
case 'telephone_third_party_knowlarity':
|
|
542
|
-
return {
|
|
543
|
-
callerNumber: configJson?.callerNumber,
|
|
544
|
-
callType: configJson?.callType || 'voice',
|
|
545
|
-
language: configJson?.language || 'en',
|
|
546
|
-
hasApiSecret: !!configJson?.apiSecret,
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
// AWS SES configurations
|
|
550
|
-
case 'email_api_aws-ses':
|
|
551
|
-
case 'email_api_ses':
|
|
552
|
-
return {
|
|
553
|
-
fromEmail: configJson?.fromEmail,
|
|
554
|
-
region: configJson?.region,
|
|
555
|
-
hasCredentials: !!(configJson?.accessKeyId && configJson?.secretAccessKey),
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
// SendGrid configurations
|
|
559
|
-
case 'email_smtp_sendgrid':
|
|
560
|
-
return {
|
|
561
|
-
from: configJson?.from,
|
|
562
|
-
hasApiKey: !!configJson?.apiKey,
|
|
563
|
-
templateId: configJson?.templateId,
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
// Generic SMTP configurations
|
|
567
|
-
case 'email_smtp_custom':
|
|
568
|
-
case 'email_smtp_generic':
|
|
569
|
-
return {
|
|
570
|
-
host: configJson?.host,
|
|
571
|
-
port: configJson?.port || 587,
|
|
572
|
-
secure: configJson?.secure || false,
|
|
573
|
-
from: configJson?.from || configJson?.user,
|
|
574
|
-
hasCredentials: !!(configJson?.user && configJson?.password),
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
default:
|
|
578
|
-
// Generic details - return safe subset of config
|
|
579
|
-
const safeConfig: any = {};
|
|
580
|
-
|
|
581
|
-
// Include non-sensitive fields
|
|
582
|
-
const safeFields = [
|
|
583
|
-
'email', 'from', 'user', 'host', 'port', 'secure',
|
|
584
|
-
'phoneNumberId', 'fromNumber', 'callerNumber', 'region',
|
|
585
|
-
'apiVersion', 'callType', 'language', 'templateId'
|
|
586
|
-
];
|
|
587
|
-
|
|
588
|
-
safeFields.forEach(field => {
|
|
589
|
-
if (configJson?.[field]) {
|
|
590
|
-
safeConfig[field] = configJson[field];
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
// Include boolean indicators for sensitive fields
|
|
595
|
-
const sensitiveFields = [
|
|
596
|
-
'accessToken', 'refreshToken', 'password', 'authToken',
|
|
597
|
-
'apiKey', 'apiSecret', 'clientSecret', 'secretAccessKey'
|
|
598
|
-
];
|
|
599
|
-
|
|
600
|
-
sensitiveFields.forEach(field => {
|
|
601
|
-
if (configJson?.[field]) {
|
|
602
|
-
safeConfig[`has${field.charAt(0).toUpperCase() + field.slice(1)}`] = true;
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
return safeConfig;
|
|
607
|
-
}
|
|
608
|
-
} catch (error) {
|
|
609
|
-
return { error: 'Unable to extract configuration details' };
|
|
610
|
-
}
|
|
611
349
|
}
|
|
612
350
|
|
|
613
351
|
async updateConfigStatus(hubId: number, status: number): Promise<void> {
|
|
@@ -30,9 +30,10 @@ export class UserController {
|
|
|
30
30
|
@Post('check-email')
|
|
31
31
|
@HttpCode(HttpStatus.OK)
|
|
32
32
|
async checkEmail(@Body() body, @Res() res: Response) {
|
|
33
|
-
const {
|
|
33
|
+
const { email_id, subdomain } = body;
|
|
34
|
+
console.log(body, 'body-----------------------------body');
|
|
34
35
|
const result = await this.userService.checkEmailExists({
|
|
35
|
-
|
|
36
|
+
email_id,
|
|
36
37
|
subdomain,
|
|
37
38
|
});
|
|
38
39
|
return res.status(HttpStatus.OK).json(result);
|
|
@@ -302,14 +302,12 @@ export class UserService extends EntityServiceImpl {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
async checkEmailExists(data: {
|
|
305
|
-
|
|
305
|
+
email_id: string;
|
|
306
306
|
subdomain: string;
|
|
307
307
|
}): Promise<any> {
|
|
308
|
-
const {
|
|
308
|
+
const { email_id, subdomain } = data;
|
|
309
309
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (!email || !subdomain) {
|
|
310
|
+
if (!email_id || !subdomain) {
|
|
313
311
|
return { success: false, message: 'Email and Subdomain is required' };
|
|
314
312
|
}
|
|
315
313
|
|
|
@@ -326,10 +324,8 @@ export class UserService extends EntityServiceImpl {
|
|
|
326
324
|
}
|
|
327
325
|
}
|
|
328
326
|
|
|
329
|
-
console.log('Email and Subdomain 2nd', email, subdomain);
|
|
330
|
-
|
|
331
327
|
// 🔹 Step 2: Find the user by email + organization check
|
|
332
|
-
const user = await this.userRepository.findByEmailId(
|
|
328
|
+
const user = await this.userRepository.findByEmailId(email_id);
|
|
333
329
|
|
|
334
330
|
if (!user || (organization && user.organization_id !== organization.id)) {
|
|
335
331
|
throw new BadRequestException('User not found in organization.');
|