rez_core 2.2.262 → 2.3.1

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.
Files changed (21) hide show
  1. package/dist/module/integration/controller/integration.controller.d.ts +16 -0
  2. package/dist/module/integration/controller/integration.controller.js +64 -0
  3. package/dist/module/integration/controller/integration.controller.js.map +1 -1
  4. package/dist/module/integration/entity/integration-source.entity.js +1 -1
  5. package/dist/module/integration/entity/integration-source.entity.js.map +1 -1
  6. package/dist/module/integration/service/integration.service.d.ts +1 -0
  7. package/dist/module/integration/service/integration.service.js +14 -0
  8. package/dist/module/integration/service/integration.service.js.map +1 -1
  9. package/dist/module/notification/controller/notification.controller.d.ts +1 -0
  10. package/dist/module/notification/controller/notification.controller.js +1 -1
  11. package/dist/module/notification/controller/notification.controller.js.map +1 -1
  12. package/dist/module/notification/service/notification.service.d.ts +1 -1
  13. package/dist/module/notification/service/notification.service.js +11 -2
  14. package/dist/module/notification/service/notification.service.js.map +1 -1
  15. package/dist/tsconfig.build.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/src/module/integration/controller/integration.controller.ts +64 -0
  18. package/src/module/integration/entity/integration-source.entity.ts +1 -1
  19. package/src/module/integration/service/integration.service.ts +21 -0
  20. package/src/module/notification/controller/notification.controller.ts +8 -1
  21. package/src/module/notification/service/notification.service.ts +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.2.262",
3
+ "version": "2.3.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -429,4 +429,68 @@ export class IntegrationController {
429
429
 
430
430
  return allIntegrationData;
431
431
  }
432
+
433
+ @Get('provider-urls')
434
+ getProviderUrls(
435
+ @Query('integration_type')
436
+ integration_type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
437
+ @Query('integration_provider') integration_provider?: string,
438
+ ) {
439
+ if (integration_type === 'TELEPHONE' && integration_provider) {
440
+ if (integration_provider.toLowerCase() == 'ozonetel') {
441
+ return {
442
+ success: true,
443
+ data: {
444
+ baseUrl: 'https://in1-ccaas-api.ozonetel.com',
445
+ agentLoginUrl: 'https://agent.cloudagent.ozonetel.com/login',
446
+ },
447
+ };
448
+ } else if (integration_provider.toLowerCase() == 'tubelight') {
449
+ return {
450
+ success: true,
451
+ data: {
452
+ baseUrl: 'https://portal.tubelightcommunications.com',
453
+ agentLoginUrl: 'https://dashboard.hellotubelight.com/sign-in',
454
+ },
455
+ };
456
+ }
457
+ }
458
+ }
459
+
460
+ @Get('active-config')
461
+ async getActiveConfig(
462
+ @Query('level_id', ParseIntPipe) levelId: number,
463
+ @Query('level_type') levelType: string,
464
+ @Query('app_code') appCode: string,
465
+ @Query('integration_type') integrationType: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
466
+ ) {
467
+ try {
468
+ const config = await this.integrationService.getSingleActiveConfig(
469
+ levelId,
470
+ levelType,
471
+ appCode,
472
+ integrationType,
473
+ );
474
+
475
+ if (!config) {
476
+ return {
477
+ success: false,
478
+ message: 'No active configuration found',
479
+ data: null,
480
+ };
481
+ }
482
+
483
+ return {
484
+ success: true,
485
+ data: config,
486
+ };
487
+ } catch (error) {
488
+ throw new BadRequestException({
489
+ success: false,
490
+ error: 'GET_ACTIVE_CONFIG_ERROR',
491
+ message: error.message || 'Failed to fetch active configuration',
492
+ code: 'FETCH_ERROR',
493
+ });
494
+ }
495
+ }
432
496
  }
@@ -12,6 +12,6 @@ export class IntegrationSource extends BaseEntity {
12
12
  @Column({ name: 'integration_type', type: 'varchar', length: 20 })
13
13
  integration_type: string;
14
14
 
15
- @Column({ name: 'description', type: 'varchar', length: 20 })
15
+ @Column({ name: 'description', type: 'varchar', length: 500 })
16
16
  description: string;
17
17
  }
@@ -170,6 +170,27 @@ export class IntegrationService {
170
170
  return await queryBuilder.getMany();
171
171
  }
172
172
 
173
+ async getSingleActiveConfig(
174
+ levelId: number,
175
+ levelType: string,
176
+ app_code: string,
177
+ integration_type: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
178
+ ): Promise<IntegrationConfig | null> {
179
+ const configs = await this.configRepository
180
+ .createQueryBuilder('config')
181
+ .where('config.level_id = :levelId', { levelId })
182
+ .andWhere('config.level_type = :levelType', { levelType })
183
+ .andWhere('config.app_code = :app_code', { app_code })
184
+ .andWhere('config.integration_type = :integration_type', { integration_type })
185
+ .andWhere('config.status = 1')
186
+ .orderBy('config.is_default', 'DESC')
187
+ .addOrderBy('config.priority', 'ASC')
188
+ .addOrderBy('config.created_at', 'DESC')
189
+ .getMany();
190
+
191
+ return configs.length > 0 ? configs[0] : null;
192
+ }
193
+
173
194
  async getAllIntegrationData(
174
195
  loggedInUser,
175
196
  integration_type?: string,
@@ -23,12 +23,19 @@ export class NotificationsController {
23
23
 
24
24
  @Post('send')
25
25
  async sendNotification(
26
- @Body() body: { token: string; title: string; message: string },
26
+ @Body()
27
+ body: {
28
+ token: string;
29
+ title: string;
30
+ message: string;
31
+ data?: Record<string, any>;
32
+ },
27
33
  ) {
28
34
  return this.notificationsService.sendToDevice(
29
35
  body.token,
30
36
  body.title,
31
37
  body.message,
38
+ body.data,
32
39
  );
33
40
  }
34
41
 
@@ -20,13 +20,28 @@ export class NotificationsService {
20
20
  return { success: true, token };
21
21
  }
22
22
 
23
- async sendToDevice(token: string, title: string, body: string) {
24
- const message = {
23
+ async sendToDevice(
24
+ token: string,
25
+ title: string,
26
+ body: string,
27
+ data?: Record<string, any>,
28
+ ) {
29
+ const message: admin.messaging.Message = {
25
30
  token,
26
- notification: { title, body },
31
+ notification: { title, body }, // system notification
32
+ data: data
33
+ ? Object.fromEntries(
34
+ Object.entries(data).map(([k, v]) => [k, v.toString()]),
35
+ )
36
+ : undefined, // FCM requires all values to be strings
27
37
  };
28
38
 
29
- return this.firebaseAdmin.messaging().send(message);
39
+ try {
40
+ return await this.firebaseAdmin.messaging().send(message);
41
+ } catch (error) {
42
+ console.error(error);
43
+ throw error;
44
+ }
30
45
  }
31
46
 
32
47
  // Helper: send to a registered user by userId