@solidstarters/solid-core 1.2.156 → 1.2.158

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 (153) hide show
  1. package/dist/config/cache.options.js +2 -7
  2. package/dist/config/cache.options.js.map +1 -1
  3. package/dist/config/common.config.d.ts +2 -0
  4. package/dist/config/common.config.d.ts.map +1 -1
  5. package/dist/config/common.config.js +1 -0
  6. package/dist/config/common.config.js.map +1 -1
  7. package/dist/constants/error-messages.js +1 -1
  8. package/dist/constants/error-messages.js.map +1 -1
  9. package/dist/controllers/authentication.controller.d.ts +0 -2
  10. package/dist/controllers/authentication.controller.d.ts.map +1 -1
  11. package/dist/controllers/authentication.controller.js +5 -5
  12. package/dist/controllers/authentication.controller.js.map +1 -1
  13. package/dist/decorators/whatsapp-provider.decorator.d.ts +3 -0
  14. package/dist/decorators/whatsapp-provider.decorator.d.ts.map +1 -0
  15. package/dist/decorators/whatsapp-provider.decorator.js +11 -0
  16. package/dist/decorators/whatsapp-provider.decorator.js.map +1 -0
  17. package/dist/factories/whatsapp.factory.d.ts +14 -0
  18. package/dist/factories/whatsapp.factory.d.ts.map +1 -0
  19. package/dist/factories/whatsapp.factory.js +53 -0
  20. package/dist/factories/whatsapp.factory.js.map +1 -0
  21. package/dist/helpers/environment.helper.d.ts +2 -0
  22. package/dist/helpers/environment.helper.d.ts.map +1 -1
  23. package/dist/helpers/environment.helper.js +7 -0
  24. package/dist/helpers/environment.helper.js.map +1 -1
  25. package/dist/helpers/solid-registry.d.ts +3 -0
  26. package/dist/helpers/solid-registry.d.ts.map +1 -1
  27. package/dist/helpers/solid-registry.js +7 -0
  28. package/dist/helpers/solid-registry.js.map +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +3 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/interfaces.d.ts +3 -0
  34. package/dist/interfaces.d.ts.map +1 -1
  35. package/dist/interfaces.js.map +1 -1
  36. package/dist/jobs/database/{whatsapp-publisher-database.service.d.ts → msg91-whatsapp-publisher-database.service.d.ts} +2 -2
  37. package/dist/jobs/database/msg91-whatsapp-publisher-database.service.d.ts.map +1 -0
  38. package/dist/jobs/database/{whatsapp-publisher-database.service.js → msg91-whatsapp-publisher-database.service.js} +8 -8
  39. package/dist/jobs/database/msg91-whatsapp-publisher-database.service.js.map +1 -0
  40. package/dist/jobs/database/{whatsapp-queue-options-database.d.ts → msg91-whatsapp-queue-options-database.d.ts} +1 -1
  41. package/dist/jobs/database/msg91-whatsapp-queue-options-database.d.ts.map +1 -0
  42. package/dist/jobs/database/{whatsapp-queue-options-database.js → msg91-whatsapp-queue-options-database.js} +2 -2
  43. package/dist/jobs/database/msg91-whatsapp-queue-options-database.js.map +1 -0
  44. package/dist/jobs/database/{whatsapp-subscriber-database.service.d.ts → msg91-whatsapp-subscriber-database.service.d.ts} +2 -2
  45. package/dist/jobs/database/msg91-whatsapp-subscriber-database.service.d.ts.map +1 -0
  46. package/dist/jobs/database/{whatsapp-subscriber-database.service.js → msg91-whatsapp-subscriber-database.service.js} +9 -9
  47. package/dist/jobs/database/msg91-whatsapp-subscriber-database.service.js.map +1 -0
  48. package/dist/jobs/database/three60-whatsapp-publisher-database.service.d.ts +11 -0
  49. package/dist/jobs/database/three60-whatsapp-publisher-database.service.d.ts.map +1 -0
  50. package/dist/jobs/database/three60-whatsapp-publisher-database.service.js +39 -0
  51. package/dist/jobs/database/three60-whatsapp-publisher-database.service.js.map +1 -0
  52. package/dist/jobs/database/three60-whatsapp-queue-options-database.d.ts +8 -0
  53. package/dist/jobs/database/three60-whatsapp-queue-options-database.d.ts.map +1 -0
  54. package/dist/jobs/database/three60-whatsapp-queue-options-database.js +10 -0
  55. package/dist/jobs/database/three60-whatsapp-queue-options-database.js.map +1 -0
  56. package/dist/jobs/database/three60-whatsapp-subscriber-database.service.d.ts +17 -0
  57. package/dist/jobs/database/three60-whatsapp-subscriber-database.service.d.ts.map +1 -0
  58. package/dist/jobs/database/three60-whatsapp-subscriber-database.service.js +48 -0
  59. package/dist/jobs/database/three60-whatsapp-subscriber-database.service.js.map +1 -0
  60. package/dist/jobs/{whatsapp-publisher.service.d.ts → msg91-whatsapp-publisher.service.d.ts} +2 -2
  61. package/dist/jobs/msg91-whatsapp-publisher.service.d.ts.map +1 -0
  62. package/dist/jobs/{whatsapp-publisher.service.js → msg91-whatsapp-publisher.service.js} +8 -8
  63. package/dist/jobs/msg91-whatsapp-publisher.service.js.map +1 -0
  64. package/dist/jobs/{whatsapp-queue-options.d.ts → msg91-whatsapp-queue-options.d.ts} +1 -1
  65. package/dist/jobs/msg91-whatsapp-queue-options.d.ts.map +1 -0
  66. package/dist/jobs/msg91-whatsapp-queue-options.js +10 -0
  67. package/dist/jobs/msg91-whatsapp-queue-options.js.map +1 -0
  68. package/dist/jobs/{whatsapp-subscriber.service.d.ts → msg91-whatsapp-subscriber.service.d.ts} +2 -2
  69. package/dist/jobs/msg91-whatsapp-subscriber.service.d.ts.map +1 -0
  70. package/dist/jobs/{whatsapp-subscriber.service.js → msg91-whatsapp-subscriber.service.js} +9 -9
  71. package/dist/jobs/msg91-whatsapp-subscriber.service.js.map +1 -0
  72. package/dist/jobs/three60-whatsapp-publisher.service.d.ts +11 -0
  73. package/dist/jobs/three60-whatsapp-publisher.service.d.ts.map +1 -0
  74. package/dist/jobs/three60-whatsapp-publisher.service.js +39 -0
  75. package/dist/jobs/three60-whatsapp-publisher.service.js.map +1 -0
  76. package/dist/jobs/three60-whatsapp-queue-options.d.ts +8 -0
  77. package/dist/jobs/three60-whatsapp-queue-options.d.ts.map +1 -0
  78. package/dist/jobs/{whatsapp-queue-options.js → three60-whatsapp-queue-options.js} +3 -3
  79. package/dist/jobs/three60-whatsapp-queue-options.js.map +1 -0
  80. package/dist/jobs/three60-whatsapp-subscriber.service.d.ts +15 -0
  81. package/dist/jobs/three60-whatsapp-subscriber.service.d.ts.map +1 -0
  82. package/dist/jobs/three60-whatsapp-subscriber.service.js +45 -0
  83. package/dist/jobs/three60-whatsapp-subscriber.service.js.map +1 -0
  84. package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
  85. package/dist/seeders/module-metadata-seeder.service.js +2 -0
  86. package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
  87. package/dist/services/authentication.service.d.ts +0 -2
  88. package/dist/services/authentication.service.d.ts.map +1 -1
  89. package/dist/services/authentication.service.js +15 -14
  90. package/dist/services/authentication.service.js.map +1 -1
  91. package/dist/services/chatter-message.service.d.ts.map +1 -1
  92. package/dist/services/chatter-message.service.js +6 -0
  93. package/dist/services/chatter-message.service.js.map +1 -1
  94. package/dist/services/list-of-values.service.js.map +1 -1
  95. package/dist/services/solid-introspect.service.d.ts +1 -0
  96. package/dist/services/solid-introspect.service.d.ts.map +1 -1
  97. package/dist/services/solid-introspect.service.js +14 -0
  98. package/dist/services/solid-introspect.service.js.map +1 -1
  99. package/dist/services/whatsapp/Msg91WhatsappService.d.ts +8 -6
  100. package/dist/services/whatsapp/Msg91WhatsappService.d.ts.map +1 -1
  101. package/dist/services/whatsapp/Msg91WhatsappService.js +24 -7
  102. package/dist/services/whatsapp/Msg91WhatsappService.js.map +1 -1
  103. package/dist/services/whatsapp/Three60WhatsappService.d.ts +18 -0
  104. package/dist/services/whatsapp/Three60WhatsappService.d.ts.map +1 -0
  105. package/dist/services/whatsapp/Three60WhatsappService.js +61 -0
  106. package/dist/services/whatsapp/Three60WhatsappService.js.map +1 -0
  107. package/dist/solid-core.module.d.ts.map +1 -1
  108. package/dist/solid-core.module.js +34 -15
  109. package/dist/solid-core.module.js.map +1 -1
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/package.json +2 -1
  112. package/src/config/cache.options.ts +1 -6
  113. package/src/config/common.config.ts +1 -0
  114. package/src/constants/error-messages.ts +1 -1
  115. package/src/controllers/authentication.controller.ts +5 -5
  116. package/src/decorators/whatsapp-provider.decorator.ts +7 -0
  117. package/src/factories/whatsapp.factory.ts +41 -0
  118. package/src/helpers/environment.helper.ts +9 -0
  119. package/src/helpers/solid-registry.ts +9 -0
  120. package/src/index.ts +3 -3
  121. package/src/interfaces.ts +12 -2
  122. package/src/jobs/database/{whatsapp-publisher-database.service.ts → msg91-whatsapp-publisher-database.service.ts} +2 -2
  123. package/src/jobs/database/{whatsapp-queue-options-database.ts → msg91-whatsapp-queue-options-database.ts} +1 -1
  124. package/src/jobs/database/{whatsapp-subscriber-database.service.ts → msg91-whatsapp-subscriber-database.service.ts} +3 -4
  125. package/src/jobs/database/three60-whatsapp-publisher-database.service.ts +23 -0
  126. package/src/jobs/database/three60-whatsapp-queue-options-database.ts +9 -0
  127. package/src/jobs/database/three60-whatsapp-subscriber-database.service.ts +32 -0
  128. package/src/jobs/{whatsapp-publisher.service.ts → msg91-whatsapp-publisher.service.ts} +2 -2
  129. package/src/jobs/msg91-whatsapp-queue-options.ts +12 -0
  130. package/src/jobs/{whatsapp-subscriber.service.ts → msg91-whatsapp-subscriber.service.ts} +3 -3
  131. package/src/jobs/three60-whatsapp-publisher.service.ts +23 -0
  132. package/src/jobs/{whatsapp-queue-options.ts → three60-whatsapp-queue-options.ts} +2 -2
  133. package/src/jobs/three60-whatsapp-subscriber.service.ts +30 -0
  134. package/src/seeders/module-metadata-seeder.service.ts +2 -0
  135. package/src/services/authentication.service.ts +20 -14
  136. package/src/services/chatter-message.service.ts +6 -0
  137. package/src/services/list-of-values.service.ts +1 -1
  138. package/src/services/solid-introspect.service.ts +22 -0
  139. package/src/services/whatsapp/Msg91WhatsappService.ts +34 -10
  140. package/src/services/whatsapp/Three60WhatsappService.ts +52 -0
  141. package/src/solid-core.module.ts +30 -11
  142. package/dist/jobs/database/whatsapp-publisher-database.service.d.ts.map +0 -1
  143. package/dist/jobs/database/whatsapp-publisher-database.service.js.map +0 -1
  144. package/dist/jobs/database/whatsapp-queue-options-database.d.ts.map +0 -1
  145. package/dist/jobs/database/whatsapp-queue-options-database.js.map +0 -1
  146. package/dist/jobs/database/whatsapp-subscriber-database.service.d.ts.map +0 -1
  147. package/dist/jobs/database/whatsapp-subscriber-database.service.js.map +0 -1
  148. package/dist/jobs/whatsapp-publisher.service.d.ts.map +0 -1
  149. package/dist/jobs/whatsapp-publisher.service.js.map +0 -1
  150. package/dist/jobs/whatsapp-queue-options.d.ts.map +0 -1
  151. package/dist/jobs/whatsapp-queue-options.js.map +0 -1
  152. package/dist/jobs/whatsapp-subscriber.service.d.ts.map +0 -1
  153. package/dist/jobs/whatsapp-subscriber.service.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.156",
3
+ "version": "1.2.158",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "@aws-sdk/s3-request-presigner": "^3.828.0",
39
39
  "@elasticemail/elasticemail-client": "^4.0.23",
40
40
  "@hapi/joi": "^17.1.1",
41
+ "@nest-lab/throttler-storage-redis": "^1.1.0",
41
42
  "@nestjs/schedule": "^6.0.0",
42
43
  "@nestjs/throttler": "^6.4.0",
43
44
  "amqplib": "^0.10.4",
@@ -1,7 +1,7 @@
1
1
  import { CacheModuleAsyncOptions } from '@nestjs/cache-manager';
2
2
  import { ConfigModule, ConfigService } from '@nestjs/config';
3
3
  import { redisStore } from 'cache-manager-redis-store';
4
- import { isNumber } from 'class-validator';
4
+ import { isRedisConfigured } from 'src/helpers/environment.helper';
5
5
 
6
6
  export const RedisOptions: CacheModuleAsyncOptions = {
7
7
  isGlobal: true,
@@ -29,8 +29,3 @@ async function createRedisStore(configService: ConfigService<Record<string, unkn
29
29
  });
30
30
  }
31
31
 
32
- function isRedisConfigured(configService: ConfigService): boolean {
33
- const host = configService.get<string>('REDIS_HOST');
34
- const port = configService.get<string>('REDIS_PORT');
35
- return host && port && isNumber(parseInt(port));
36
- }
@@ -3,6 +3,7 @@ import { registerAs } from '@nestjs/config';
3
3
  export default registerAs('common', () => {
4
4
  return {
5
5
  emailProvider: process.env.COMMON_EMAIL_PROVIDER ?? "SMTPEMailService",
6
+ whatsappProvider: process.env.COMMON_WHATSAPP_PROVIDER,
6
7
  emailTemplateSeederFiles: process.env.COMMON_EMAIL_TEMPLATE_SEEDER_FILES,
7
8
  smsProvider: process.env.COMMON_SMS_PROVIDER,
8
9
  smsTemplateSeederFiles: process.env.COMMON_SMS_TEMPLATE_SEEDER_FILES,
@@ -28,7 +28,7 @@ export const ERROR_MESSAGES = {
28
28
  GOOGLE_OAUTH_PROFILE_FETCH_FAILED: 'Failed to fetch user profile from Google OAuth service',
29
29
  LOGOUT_FAILED: 'Logout failed due to an unexpected error.',
30
30
 
31
- INVALID_CREDENTIALS: 'Invalid username or password specified.',
31
+ INVALID_CREDENTIALS: 'Invalid credentials',
32
32
  LOGIN_FAILED: 'Login Failed',
33
33
  OLD_PASSWORD_INCORRECT: 'You have specified an incorrect old password.',
34
34
  INVALID_NEW_PASSWORD: 'Invalid new password.',
@@ -25,7 +25,7 @@ export class AuthenticationController {
25
25
  constructor(private readonly authService: AuthenticationService) { }
26
26
 
27
27
  @Public()
28
- @SkipThrottle({ login: false }) //Enable the login throttle only
28
+ @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
29
29
  @Post('register')
30
30
  signUp(@Body() signUpDto: SignUpDto) {
31
31
  return this.authService.signUp(signUpDto);
@@ -39,7 +39,7 @@ export class AuthenticationController {
39
39
 
40
40
  @Public()
41
41
  // @UseGuards(LocalAuthGuard)
42
- @SkipThrottle({ login: false }) //Enable the login throttle only
42
+ @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
43
43
  @HttpCode(HttpStatus.OK) // by default @Post does 201, we wanted 200 - hence using @HttpCode(HttpStatus.OK)
44
44
  @Post('authenticate')
45
45
  async signIn(
@@ -62,7 +62,7 @@ export class AuthenticationController {
62
62
  }
63
63
 
64
64
  @Public()
65
- @SkipThrottle({ login: false }) //Enable the login throttle only
65
+ @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
66
66
  @HttpCode(HttpStatus.OK) // changed since the default is 201
67
67
  @Post('refresh-tokens')
68
68
  refreshTokens(@Body() refreshTokenDto: RefreshTokenDto) {
@@ -70,14 +70,14 @@ export class AuthenticationController {
70
70
  }
71
71
 
72
72
  @Public()
73
- @SkipThrottle({ login: false }) //Enable the login throttle only
73
+ @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
74
74
  @Post('initiate/forgot-password')
75
75
  initiateForgotPassword(@Body() initiateForgotPasswordDto: InitiateForgotPasswordDto) {
76
76
  return this.authService.initiateForgotPassword(initiateForgotPasswordDto);
77
77
  }
78
78
 
79
79
  @Public()
80
- @SkipThrottle({ login: false }) //Enable the login throttle only
80
+ @SkipThrottle({ login: false, short: true, burst: true, sustained: true }) //Enable the login throttle only
81
81
  @Post('confirm/forgot-password')
82
82
  confirmForgotPassword(@Body() confirmForgotPasswordDto: ConfirmForgotPasswordDto) {
83
83
  return this.authService.confirmForgotPassword(confirmForgotPasswordDto);
@@ -0,0 +1,7 @@
1
+ export const IS_WA_PROVIDER = 'IS_WA_PROVIDER';
2
+
3
+ export const WhatsAppProvider = () => {
4
+ return (target: Function) => {
5
+ Reflect.defineMetadata(IS_WA_PROVIDER, true, target);
6
+ };
7
+ };
@@ -0,0 +1,41 @@
1
+ import { Inject, Injectable, Logger } from "@nestjs/common";
2
+ import { ConfigType } from "@nestjs/config";
3
+ import { ModuleRef } from "@nestjs/core";
4
+ import commonConfig from "src/config/common.config";
5
+ import { SolidRegistry } from "src/helpers/solid-registry";
6
+ import { IWhatsAppTransport } from "src/interfaces";
7
+
8
+ function norm(s?: string) {
9
+ return s?.trim().toLowerCase();
10
+ }
11
+
12
+ // This factory will be use to return a mail service instance, using the configured environment variables
13
+ @Injectable()
14
+ export class WhatsAppFactory {
15
+ private readonly logger = new Logger(this.constructor.name);
16
+ constructor(
17
+ private readonly moduleRef: ModuleRef, // Use the module ref to dynamically resolve the mail service
18
+ private readonly solidRegistry: SolidRegistry,
19
+ @Inject(commonConfig.KEY)
20
+ private readonly commonConfiguration: ConfigType<typeof commonConfig>,
21
+ ) { }
22
+
23
+ getWhatsappService(name: string = null): IWhatsAppTransport {
24
+ // This is the default provider
25
+ const whatsappServiceName = this.commonConfiguration.whatsappProvider || name;
26
+ if (!whatsappServiceName) {
27
+ throw new Error("Unable to resolve whatsapp provider")
28
+ }
29
+ const whatsappProviders = this.solidRegistry.getWhatsappProviders();
30
+ // Return the instance which matches the whatsappServiceName
31
+ if (!whatsappProviders.length) {
32
+ // throw new Error("No mail providers are registered.");
33
+ this.logger.error("No whatsapp providers are registered.");
34
+ }
35
+
36
+ const whatsappServiceProvider = whatsappProviders.find(provider => provider.name === whatsappServiceName);
37
+
38
+ return whatsappServiceProvider.instance as IWhatsAppTransport;
39
+ }
40
+
41
+ }
@@ -1,7 +1,16 @@
1
+ import { ConfigService } from "@nestjs/config";
2
+ import { isNumber } from 'class-validator';
3
+
1
4
  export function parseBooleanEnv(key: string, defaultValue: boolean = false): boolean {
2
5
  const value = process.env[key];
3
6
  if (value === undefined) {
4
7
  return defaultValue;
5
8
  }
6
9
  return value.toLowerCase() === 'true';
10
+ }
11
+
12
+ export function isRedisConfigured(configService: ConfigService): boolean {
13
+ const host = configService.get<string>('REDIS_HOST');
14
+ const port = configService.get<string>('REDIS_PORT');
15
+ return host && port && isNumber(parseInt(port));
7
16
  }
@@ -66,6 +66,11 @@ export class SolidRegistry {
66
66
  private dashboardVariableSelectionProviders: Set<InstanceWrapper> = new Set();
67
67
  private dashboardQuestionDataProviders: Set<InstanceWrapper> = new Set();
68
68
  private mailProviders: Set<InstanceWrapper> = new Set();
69
+ private whatsappProviders: Set<InstanceWrapper> = new Set();
70
+
71
+ registerWhatsappProvider(whatsappProvider: InstanceWrapper): void {
72
+ this.whatsappProviders.add(whatsappProvider);
73
+ }
69
74
 
70
75
  registerMailProvider(mailProvider: InstanceWrapper): void {
71
76
  this.mailProviders.add(mailProvider);
@@ -115,6 +120,10 @@ export class SolidRegistry {
115
120
  return Array.from(this.mailProviders);
116
121
  }
117
122
 
123
+ getWhatsappProviders(): Array<InstanceWrapper> {
124
+ return Array.from(this.whatsappProviders);
125
+ }
126
+
118
127
  getSeeders(): Array<InstanceWrapper> {
119
128
  return Array.from(this.seeders);
120
129
  }
package/src/index.ts CHANGED
@@ -193,9 +193,9 @@ export * from './jobs/otp-subscriber.service'
193
193
  export * from './jobs/sms-publisher.service'
194
194
  export * from './jobs/sms-queue-options'
195
195
  export * from './jobs/sms-subscriber.service'
196
- export * from './jobs/whatsapp-publisher.service'
197
- export * from './jobs/whatsapp-queue-options'
198
- export * from './jobs/whatsapp-subscriber.service'
196
+ export * from './jobs/msg91-whatsapp-publisher.service'
197
+ export * from './jobs/msg91-whatsapp-queue-options'
198
+ export * from './jobs/msg91-whatsapp-subscriber.service'
199
199
 
200
200
  export * from './listeners/user-registration.listener'
201
201
 
package/src/interfaces.ts CHANGED
@@ -134,7 +134,7 @@ export interface IEntityComputedFieldProvider {
134
134
  name(): string;
135
135
  }
136
136
 
137
- export interface IEntityPreComputeFieldProvider<TTriggerEntity, TContext, TValue=void> extends IEntityComputedFieldProvider {
137
+ export interface IEntityPreComputeFieldProvider<TTriggerEntity, TContext, TValue = void> extends IEntityComputedFieldProvider {
138
138
  preComputeValue(triggerEntity: TTriggerEntity, computedFieldMetadata: ComputedFieldMetadata<TContext>): Promise<TValue>;
139
139
  }
140
140
 
@@ -159,7 +159,7 @@ export class EventDetails<T> {
159
159
  ) { }
160
160
  }
161
161
 
162
- export interface IMail<TResponse=unknown> {
162
+ export interface IMail<TResponse = unknown> {
163
163
  sendEmail(
164
164
  to: string,
165
165
  subject: string,
@@ -200,6 +200,16 @@ export interface ISMS {
200
200
  ): Promise<any>;
201
201
  }
202
202
 
203
+ export interface IWhatsAppTransport {
204
+ sendWhatsAppMessage(
205
+ to: string,
206
+ templateId: string,
207
+ parameters: any,
208
+ parentEntity?: any,
209
+ parentEntityId?: any
210
+ ): Promise<any>;
211
+ }
212
+
203
213
  export interface MailAttachmentWrapper {
204
214
  relativePath?: string;
205
215
  attachment?: MailAttachment;
@@ -1,13 +1,13 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
 
3
- import whatsappQueueOptions from './whatsapp-queue-options-database';
3
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options-database';
4
4
  import { MqMessageService } from 'src/services/mq-message.service';
5
5
  import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
6
6
  import { QueuesModuleOptions } from 'src/interfaces';
7
7
  import { DatabasePublisher } from 'src/services/queues/database-publisher.service';
8
8
 
9
9
  @Injectable()
10
- export class WhatsappQueuePublisherDatabase extends DatabasePublisher<any> {
10
+ export class Msg91WhatsappQueuePublisherDatabase extends DatabasePublisher<any> {
11
11
  constructor(
12
12
  protected readonly mqMessageService: MqMessageService,
13
13
  protected readonly mqMessageQueueService: MqMessageQueueService,
@@ -1,6 +1,6 @@
1
1
  import { BrokerType } from "src/interfaces";
2
2
 
3
- const WHATSAPP_QUEUE_NAME = 'whatsapp_queue_database';
3
+ const WHATSAPP_QUEUE_NAME = 'msg91_whatsapp_queue_database';
4
4
 
5
5
  export default {
6
6
  name: 'whatsappInstance',
@@ -1,8 +1,7 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
 
3
- import { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';
4
3
  import { QueueMessage } from 'src/interfaces/mq';
5
- import whatsappQueueOptions from './whatsapp-queue-options-database';
4
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options-database';
6
5
  import { MqMessageService } from 'src/services/mq-message.service';
7
6
  import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
8
7
  import { Msg91WhatsappService } from 'src/services/whatsapp/Msg91WhatsappService';
@@ -11,7 +10,7 @@ import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.serv
11
10
  import { PollerService } from 'src/services/poller.service';
12
11
 
13
12
  @Injectable()
14
- export class WhatsappQueueSubscriberDatabase extends DatabaseSubscriber<any> {
13
+ export class Msg91WhatsappQueueSubscriberDatabase extends DatabaseSubscriber<any> {
15
14
  constructor(
16
15
  private readonly whatsappService: Msg91WhatsappService,
17
16
  readonly mqMessageService: MqMessageService,
@@ -28,6 +27,6 @@ export class WhatsappQueueSubscriberDatabase extends DatabaseSubscriber<any> {
28
27
  }
29
28
 
30
29
  subscribe(message: QueueMessage<any>) {
31
- this.whatsappService.sendSMSSynchronously(message);
30
+ this.whatsappService.sendWhatsAppMessageSynchronously(message);
32
31
  }
33
32
  }
@@ -0,0 +1,23 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options-database';
4
+ import { MqMessageService } from 'src/services/mq-message.service';
5
+ import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
6
+ import { QueuesModuleOptions } from 'src/interfaces';
7
+ import { DatabasePublisher } from 'src/services/queues/database-publisher.service';
8
+
9
+ @Injectable()
10
+ export class Three60WhatsappQueuePublisherDatabase extends DatabasePublisher<any> {
11
+ constructor(
12
+ protected readonly mqMessageService: MqMessageService,
13
+ protected readonly mqMessageQueueService: MqMessageQueueService,
14
+ ) {
15
+ super(mqMessageService, mqMessageQueueService);
16
+ }
17
+
18
+ options(): QueuesModuleOptions {
19
+ return {
20
+ ...whatsappQueueOptions
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,9 @@
1
+ import { BrokerType } from "src/interfaces";
2
+
3
+ const WHATSAPP_QUEUE_NAME = 'three60_whatsapp_queue_database';
4
+
5
+ export default {
6
+ name: 'whatsappInstance',
7
+ type: BrokerType.Database,
8
+ queueName: WHATSAPP_QUEUE_NAME,
9
+ };
@@ -0,0 +1,32 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ import { QueueMessage } from 'src/interfaces/mq';
4
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options-database';
5
+ import { MqMessageService } from 'src/services/mq-message.service';
6
+ import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
7
+ import { QueuesModuleOptions } from 'src/interfaces';
8
+ import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';
9
+ import { PollerService } from 'src/services/poller.service';
10
+ import { Three60WhatsappService } from 'src/services/whatsapp/Three60WhatsappService';
11
+
12
+ @Injectable()
13
+ export class Three60WhatsappQueueSubscriberDatabase extends DatabaseSubscriber<any> {
14
+ constructor(
15
+ private readonly whatsappService: Three60WhatsappService,
16
+ readonly mqMessageService: MqMessageService,
17
+ readonly mqMessageQueueService: MqMessageQueueService,
18
+ readonly poller: PollerService,
19
+ ) {
20
+ super(mqMessageService, mqMessageQueueService, poller);
21
+ }
22
+
23
+ options(): QueuesModuleOptions {
24
+ return {
25
+ ...whatsappQueueOptions
26
+ }
27
+ }
28
+
29
+ subscribe(message: QueueMessage<any>) {
30
+ this.whatsappService.sendWhatsAppMessageSynchronously(message);
31
+ }
32
+ }
@@ -1,13 +1,13 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
 
3
3
  import { RabbitMqPublisher } from 'src/services/queues/rabbitmq-publisher.service';
4
- import whatsappQueueOptions from './whatsapp-queue-options';
4
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options';
5
5
  import { MqMessageService } from 'src/services/mq-message.service';
6
6
  import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
7
7
  import { QueuesModuleOptions } from "../interfaces";
8
8
 
9
9
  @Injectable()
10
- export class WhatsappQueuePublisher extends RabbitMqPublisher<any> {
10
+ export class Msg91WhatsappQueuePublisher extends RabbitMqPublisher<any> {
11
11
  constructor(
12
12
  protected readonly mqMessageService: MqMessageService,
13
13
  protected readonly mqMessageQueueService: MqMessageQueueService,
@@ -0,0 +1,12 @@
1
+ import { BrokerType } from "../interfaces";
2
+
3
+ const MSG91_WHATSAPP_QUEUE_NAME = 'mag_91_whatsapp_queue';
4
+ export default {
5
+ name: 'whatsappInstance',
6
+ type: BrokerType.RabbitMQ,
7
+ queueName: MSG91_WHATSAPP_QUEUE_NAME,
8
+ // receive: async (message: QueueMessage<any>) => { // Default receive handler
9
+ // console.log(`Received message: ${JSON.stringify(message)} from queue ${SMS_QUEUE_NAME}`);
10
+ // return 'Received';
11
+ // },
12
+ };
@@ -2,14 +2,14 @@ import { Injectable } from '@nestjs/common';
2
2
 
3
3
  import { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';
4
4
  import { QueueMessage } from 'src/interfaces/mq';
5
- import whatsappQueueOptions from './whatsapp-queue-options';
5
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options';
6
6
  import { Msg91WhatsappService } from '../services/whatsapp/Msg91WhatsappService';
7
7
  import { MqMessageService } from 'src/services/mq-message.service';
8
8
  import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
9
9
  import { QueuesModuleOptions } from "../interfaces";
10
10
 
11
11
  @Injectable()
12
- export class WhatsappQueueSubscriber extends RabbitMqSubscriber<any> {
12
+ export class Msg91WhatsappQueueSubscriber extends RabbitMqSubscriber<any> {
13
13
  constructor(
14
14
  private readonly whatsappService: Msg91WhatsappService,
15
15
  readonly mqMessageService: MqMessageService,
@@ -25,6 +25,6 @@ export class WhatsappQueueSubscriber extends RabbitMqSubscriber<any> {
25
25
  }
26
26
 
27
27
  subscribe(message: QueueMessage<any>) {
28
- this.whatsappService.sendSMSSynchronously(message);
28
+ this.whatsappService.sendWhatsAppMessageSynchronously(message);
29
29
  }
30
30
  }
@@ -0,0 +1,23 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ import { RabbitMqPublisher } from 'src/services/queues/rabbitmq-publisher.service';
4
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options';
5
+ import { MqMessageService } from 'src/services/mq-message.service';
6
+ import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
7
+ import { QueuesModuleOptions } from "../interfaces";
8
+
9
+ @Injectable()
10
+ export class Three60WhatsappQueuePublisher extends RabbitMqPublisher<any> {
11
+ constructor(
12
+ protected readonly mqMessageService: MqMessageService,
13
+ protected readonly mqMessageQueueService: MqMessageQueueService,
14
+ ) {
15
+ super(mqMessageService, mqMessageQueueService);
16
+ }
17
+
18
+ options(): QueuesModuleOptions {
19
+ return {
20
+ ...whatsappQueueOptions
21
+ }
22
+ }
23
+ }
@@ -1,10 +1,10 @@
1
1
  import { BrokerType } from "../interfaces";
2
2
 
3
- const WHATSAPP_QUEUE_NAME = 'whatsapp_queue';
3
+ const _WHATSAPP_QUEUE_NAME = 'three60_whatsapp_queue';
4
4
  export default {
5
5
  name: 'whatsappInstance',
6
6
  type: BrokerType.RabbitMQ,
7
- queueName: WHATSAPP_QUEUE_NAME,
7
+ queueName: _WHATSAPP_QUEUE_NAME,
8
8
  // receive: async (message: QueueMessage<any>) => { // Default receive handler
9
9
  // console.log(`Received message: ${JSON.stringify(message)} from queue ${SMS_QUEUE_NAME}`);
10
10
  // return 'Received';
@@ -0,0 +1,30 @@
1
+ import { Injectable } from '@nestjs/common';
2
+
3
+ import { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';
4
+ import { QueueMessage } from 'src/interfaces/mq';
5
+ import whatsappQueueOptions from './msg91-whatsapp-queue-options';
6
+ import { MqMessageService } from 'src/services/mq-message.service';
7
+ import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
8
+ import { QueuesModuleOptions } from "../interfaces";
9
+ import { Three60WhatsappService } from 'src/services/whatsapp/Three60WhatsappService';
10
+
11
+ @Injectable()
12
+ export class Three60WhatsappQueueSubscriber extends RabbitMqSubscriber<any> {
13
+ constructor(
14
+ private readonly whatsappService: Three60WhatsappService,
15
+ readonly mqMessageService: MqMessageService,
16
+ readonly mqMessageQueueService: MqMessageQueueService,
17
+ ) {
18
+ super(mqMessageService, mqMessageQueueService);
19
+ }
20
+
21
+ options(): QueuesModuleOptions {
22
+ return {
23
+ ...whatsappQueueOptions
24
+ }
25
+ }
26
+
27
+ subscribe(message: QueueMessage<any>) {
28
+ this.whatsappService.sendWhatsAppMessageSynchronously(message);
29
+ }
30
+ }
@@ -584,6 +584,8 @@ export class ModuleMetadataSeederService {
584
584
  return;
585
585
  }
586
586
  for (let j = 0; j < listOfValuesDto.length; j++) {
587
+ const listOfValueDto = listOfValuesDto[j];
588
+ listOfValueDto['module'] = await this.moduleMetadataService.findOneByUserKey(listOfValueDto.moduleUserKey);
587
589
  await this.listOfValuesService.upsert(listOfValuesDto[j]);
588
590
  }
589
591
  }
@@ -126,7 +126,7 @@ export class AuthenticationService {
126
126
  const user = await this.resolveUser(signInDto.username, signInDto.email);
127
127
 
128
128
  if (!user) {
129
- throw new UnauthorizedException(ERROR_MESSAGES.USER_NOT_FOUND);
129
+ throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
130
130
  }
131
131
  if (!user.active) {
132
132
  throw new UnauthorizedException(ERROR_MESSAGES.USER_NOT_ACTIVE);
@@ -136,7 +136,7 @@ export class AuthenticationService {
136
136
  user.password,
137
137
  );
138
138
  if (!isEqual) {
139
- throw new UnauthorizedException(ERROR_MESSAGES.PASSWORD_INCORRECT);
139
+ throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
140
140
  }
141
141
 
142
142
  return user;
@@ -759,25 +759,31 @@ export class AuthenticationService {
759
759
  // });
760
760
  const user = await this.resolveUser(initiateForgotPasswordDto.username, initiateForgotPasswordDto.email);
761
761
 
762
+ let isValidUser = true // Instead of throwing exceptions we will simply return success message, this is to avoid user enumeration attacks.
762
763
  if (!user) {
763
- throw new NotFoundException(ERROR_MESSAGES.INVALID_CREDENTIALS);
764
+ isValidUser = false
765
+ // throw new NotFoundException(ERROR_MESSAGES.INVALID_CREDENTIALS);
764
766
  }
765
767
  if (!user.active) {
766
- throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
768
+ isValidUser = false
769
+ // throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
767
770
  }
768
771
 
769
772
  // 2. Validate if user has used a provider which is "local", only then it makes sense for us to initiate the forgot password routine.
770
773
  if (user.lastLoginProvider !== 'local') {
771
- throw new BadRequestException(ERROR_MESSAGES.INVALID_CREDENTIALS);
774
+ isValidUser = false
775
+ // throw new BadRequestException(ERROR_MESSAGES.INVALID_CREDENTIALS);
772
776
  }
773
777
 
774
778
  // 3. Generate a 6 digit validation token, we send this token to the user over their email & mobile number (controlled using configuration).
775
779
  // 4. Save this validation token in new fields on the user record.
776
- const { token, expiresAt } = this.generateForgotPasswordToken();
777
- user.verificationTokenOnForgotPassword = token;
778
- user.verificationTokenOnForgotPasswordExpiresAt = expiresAt;
779
- await this.userRepository.save(user);
780
- this.notifyUserOnForgotPassword(user);
780
+ if (isValidUser) {
781
+ const { token, expiresAt } = this.generateForgotPasswordToken();
782
+ user.verificationTokenOnForgotPassword = token;
783
+ user.verificationTokenOnForgotPasswordExpiresAt = expiresAt;
784
+ await this.userRepository.save(user);
785
+ this.notifyUserOnForgotPassword(user);
786
+ }
781
787
 
782
788
  // 5. Return.
783
789
  return {
@@ -788,8 +794,8 @@ export class AuthenticationService {
788
794
  data: {
789
795
  user: {
790
796
  email: user.email,
791
- mobile: user.mobile,
792
- username: user.username,
797
+ // mobile: user.mobile,
798
+ // username: user.username,
793
799
  },
794
800
  }
795
801
  }
@@ -841,8 +847,8 @@ export class AuthenticationService {
841
847
  return this.dataSource.transaction(async (m) => {
842
848
  // Resolve the user id first (by username/email), but DON'T check the token in JS.
843
849
  const user = await this.resolveUserByVerificationToken(confirmForgotPasswordDto.verificationToken);
844
- if (!user) throw new NotFoundException(ERROR_MESSAGES.INVALID_CREDENTIALS);
845
- if (user.lastLoginProvider !== 'local') throw new BadRequestException(ERROR_MESSAGES.INVALID_CREDENTIALS);
850
+ if (!user) throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
851
+ if (user.lastLoginProvider !== 'local') throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
846
852
  if (!user.active) throw new UnauthorizedException(ERROR_MESSAGES.INVALID_CREDENTIALS);
847
853
 
848
854
  // 1) Atomically consume the token (only one request can succeed)
@@ -86,6 +86,9 @@ export class ChatterMessageService extends CRUDService<ChatterMessage>{
86
86
  }
87
87
 
88
88
  async postAuditMessageOnInsert(entity: any, metadata: EntityMetadata, messageQueue: boolean = false) {
89
+ if(!entity){
90
+ return;
91
+ }
89
92
  const model = await this.modelMetadataRepo.findOne({
90
93
  where: {
91
94
  displayName: metadata.name
@@ -140,6 +143,9 @@ export class ChatterMessageService extends CRUDService<ChatterMessage>{
140
143
  }
141
144
 
142
145
  async postAuditMessageOnUpdate(entity: any, metadata: EntityMetadata, databaseEntity: any, messageQueue: boolean = false) {
146
+ if(!databaseEntity || !entity){
147
+ return;
148
+ }
143
149
  const model = await this.modelMetadataRepo.findOne({
144
150
  where: {
145
151
  displayName: metadata.name
@@ -43,7 +43,7 @@ export class ListOfValuesService extends CRUDService<ListOfValues> {
43
43
  async findAll(): Promise<ListOfValues[]> {
44
44
  return await this.repo.find();
45
45
  }
46
-
46
+
47
47
  async upsert(updateListOfValuesDto: any) {
48
48
  // First check if module already exists using name
49
49
  const existingListOfValue = await this.repo.findOne({
@@ -11,6 +11,7 @@ import { IS_SCHEDULED_JOB_PROVIDER } from 'src/decorators/scheduled-job-provider
11
11
  import { IS_DASHBOARD_VARIABLE_SELECTION_PROVIDER } from 'src/decorators/dashboard-selection-provider.decorator';
12
12
  import { IS_DASHBOARD_QUESTION_DATA_PROVIDER } from 'src/decorators/dashboard-question-data-provider.decorator';
13
13
  import { IS_MAIL_PROVIDER } from 'src/decorators/mail-provider.decorator';
14
+ import { IS_WA_PROVIDER } from 'src/decorators/whatsapp-provider.decorator';
14
15
 
15
16
  @Injectable()
16
17
  export class SolidIntrospectService implements OnApplicationBootstrap {
@@ -118,6 +119,15 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
118
119
  mailProviders.forEach((mailProvider) => {
119
120
  this.solidRegistry.registerMailProvider(mailProvider);
120
121
  });
122
+
123
+ // Register all IMail implementations
124
+ const whatsappProviders = this.discoveryService
125
+ .getProviders()
126
+ .filter((provider) => this.isWhatsappProvider(provider));
127
+
128
+ whatsappProviders.forEach((whatsappProvider) => {
129
+ this.solidRegistry.registerWhatsappProvider(whatsappProvider);
130
+ });
121
131
  }
122
132
 
123
133
  isDashboardQuestionDataProvider(providerWrapper: InstanceWrapper<any>) {
@@ -212,6 +222,18 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
212
222
  return !!isMailProvider;
213
223
  }
214
224
 
225
+ private isWhatsappProvider(provider: InstanceWrapper) {
226
+ const { instance } = provider;
227
+ if (!instance) return false;
228
+
229
+ const isWhatsappProvider = this.reflector.get<boolean>(
230
+ IS_WA_PROVIDER,
231
+ instance.constructor,
232
+ );
233
+
234
+ return !!isWhatsappProvider;
235
+ }
236
+
215
237
  private isModule(provider: InstanceWrapper): boolean {
216
238
  const metatype = provider.metatype;
217
239
  // Check if it's a Static Module (Class-Based)