@solidstarters/solid-core 1.2.144 → 1.2.146
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/config/common.config.d.ts +2 -0
- package/dist/config/common.config.d.ts.map +1 -1
- package/dist/config/common.config.js +4 -3
- package/dist/config/common.config.js.map +1 -1
- package/dist/decorators/mail-provider.decorator.d.ts +3 -0
- package/dist/decorators/mail-provider.decorator.d.ts.map +1 -0
- package/dist/decorators/mail-provider.decorator.js +11 -0
- package/dist/decorators/mail-provider.decorator.js.map +1 -0
- package/dist/factories/mail.factory.d.ts +14 -0
- package/dist/factories/mail.factory.d.ts.map +1 -0
- package/dist/factories/mail.factory.js +50 -0
- package/dist/factories/mail.factory.js.map +1 -0
- package/dist/helpers/solid-registry.d.ts +3 -0
- package/dist/helpers/solid-registry.d.ts.map +1 -1
- package/dist/helpers/solid-registry.js +7 -0
- package/dist/helpers/solid-registry.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +2 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/jobs/api-email-subscriber.service.d.ts +1 -1
- package/dist/jobs/api-email-subscriber.service.d.ts.map +1 -1
- package/dist/jobs/api-email-subscriber.service.js +2 -2
- package/dist/jobs/api-email-subscriber.service.js.map +1 -1
- package/dist/jobs/database/api-email-subscriber-database.service.d.ts +1 -1
- package/dist/jobs/database/api-email-subscriber-database.service.d.ts.map +1 -1
- package/dist/jobs/database/api-email-subscriber-database.service.js +2 -2
- package/dist/jobs/database/api-email-subscriber-database.service.js.map +1 -1
- package/dist/jobs/database/{email-publisher-database.service.d.ts → smtp-email-publisher-database.service.d.ts} +2 -2
- package/dist/jobs/database/smtp-email-publisher-database.service.d.ts.map +1 -0
- package/dist/jobs/database/{email-publisher-database.service.js → smtp-email-publisher-database.service.js} +8 -8
- package/dist/jobs/database/smtp-email-publisher-database.service.js.map +1 -0
- package/dist/jobs/database/{email-queue-options-database.d.ts → smtp-email-queue-options-database.d.ts} +1 -1
- package/dist/jobs/database/smtp-email-queue-options-database.d.ts.map +1 -0
- package/dist/jobs/database/{email-queue-options-database.js → smtp-email-queue-options-database.js} +1 -1
- package/dist/jobs/database/smtp-email-queue-options-database.js.map +1 -0
- package/dist/jobs/database/{email-subscriber-database.service.d.ts → smtp-email-subscriber-database.service.d.ts} +3 -3
- package/dist/jobs/database/smtp-email-subscriber-database.service.d.ts.map +1 -0
- package/dist/jobs/database/{email-subscriber-database.service.js → smtp-email-subscriber-database.service.js} +10 -10
- package/dist/jobs/database/smtp-email-subscriber-database.service.js.map +1 -0
- package/dist/jobs/{email-publisher.service.d.ts → smtp-email-publisher.service.d.ts} +2 -2
- package/dist/jobs/smtp-email-publisher.service.d.ts.map +1 -0
- package/dist/jobs/{email-publisher.service.js → smtp-email-publisher.service.js} +8 -8
- package/dist/jobs/smtp-email-publisher.service.js.map +1 -0
- package/dist/jobs/{email-queue-options.d.ts → smtp-email-queue-options.d.ts} +1 -1
- package/dist/jobs/smtp-email-queue-options.d.ts.map +1 -0
- package/dist/jobs/{email-queue-options.js → smtp-email-queue-options.js} +1 -1
- package/dist/jobs/smtp-email-queue-options.js.map +1 -0
- package/dist/jobs/{email-subscriber.service.d.ts → smtp-email-subscriber.service.d.ts} +3 -3
- package/dist/jobs/smtp-email-subscriber.service.d.ts.map +1 -0
- package/dist/jobs/{email-subscriber.service.js → smtp-email-subscriber.service.js} +10 -10
- package/dist/jobs/smtp-email-subscriber.service.js.map +1 -0
- package/dist/seeders/module-metadata-seeder.service.js +27 -27
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +12 -12
- package/dist/services/authentication.service.d.ts +3 -3
- package/dist/services/authentication.service.d.ts.map +1 -1
- package/dist/services/authentication.service.js +16 -12
- package/dist/services/authentication.service.js.map +1 -1
- package/dist/services/import-transaction.service.d.ts.map +1 -1
- package/dist/services/import-transaction.service.js +1 -0
- package/dist/services/import-transaction.service.js.map +1 -1
- package/dist/services/mail/{ElasticEmailService.d.ts → elastic-email.service.d.ts} +1 -1
- package/dist/services/mail/elastic-email.service.d.ts.map +1 -0
- package/dist/services/mail/{ElasticEmailService.js → elastic-email.service.js} +3 -1
- package/dist/services/mail/elastic-email.service.js.map +1 -0
- package/dist/services/mail/{SMTPEmailService.d.ts → smtp-email.service.d.ts} +5 -5
- package/dist/services/mail/smtp-email.service.d.ts.map +1 -0
- package/dist/services/mail/{SMTPEmailService.js → smtp-email.service.js} +12 -8
- package/dist/services/mail/smtp-email.service.js.map +1 -0
- package/dist/services/model-metadata.service.js +1 -1
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/solid-introspect.service.d.ts +1 -0
- package/dist/services/solid-introspect.service.d.ts.map +1 -1
- package/dist/services/solid-introspect.service.js +14 -0
- package/dist/services/solid-introspect.service.js.map +1 -1
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +20 -15
- package/dist/solid-core.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/common.config.ts +4 -3
- package/src/decorators/mail-provider.decorator.ts +7 -0
- package/src/factories/mail.factory.ts +38 -0
- package/src/helpers/solid-registry.ts +9 -0
- package/src/index.ts +15 -6
- package/src/interfaces.ts +9 -3
- package/src/jobs/api-email-subscriber.service.ts +1 -1
- package/src/jobs/database/api-email-subscriber-database.service.ts +1 -1
- package/src/jobs/database/{email-publisher-database.service.ts → smtp-email-publisher-database.service.ts} +2 -2
- package/src/jobs/database/{email-subscriber-database.service.ts → smtp-email-subscriber-database.service.ts} +3 -3
- package/src/jobs/{email-publisher.service.ts → smtp-email-publisher.service.ts} +2 -2
- package/src/jobs/{email-subscriber.service.ts → smtp-email-subscriber.service.ts} +3 -3
- package/src/seeders/module-metadata-seeder.service.ts +27 -27
- package/src/seeders/seed-data/solid-core-metadata.json +12 -12
- package/src/services/authentication.service.ts +25 -10
- package/src/services/import-transaction.service.ts +1 -0
- package/src/services/mail/{ElasticEmailService.ts → elastic-email.service.ts} +2 -0
- package/src/services/mail/{SMTPEmailService.ts → smtp-email.service.ts} +38 -10
- package/src/services/model-metadata.service.ts +1 -1
- package/src/services/solid-introspect.service.ts +21 -5
- package/src/solid-core.module.ts +16 -11
- package/dist/jobs/database/email-publisher-database.service.d.ts.map +0 -1
- package/dist/jobs/database/email-publisher-database.service.js.map +0 -1
- package/dist/jobs/database/email-queue-options-database.d.ts.map +0 -1
- package/dist/jobs/database/email-queue-options-database.js.map +0 -1
- package/dist/jobs/database/email-subscriber-database.service.d.ts.map +0 -1
- package/dist/jobs/database/email-subscriber-database.service.js.map +0 -1
- package/dist/jobs/email-publisher.service.d.ts.map +0 -1
- package/dist/jobs/email-publisher.service.js.map +0 -1
- package/dist/jobs/email-queue-options.d.ts.map +0 -1
- package/dist/jobs/email-queue-options.js.map +0 -1
- package/dist/jobs/email-subscriber.service.d.ts.map +0 -1
- package/dist/jobs/email-subscriber.service.js.map +0 -1
- package/dist/services/mail/ElasticEmailService.d.ts.map +0 -1
- package/dist/services/mail/ElasticEmailService.js.map +0 -1
- package/dist/services/mail/SMTPEmailService.d.ts.map +0 -1
- package/dist/services/mail/SMTPEmailService.js.map +0 -1
- /package/src/jobs/database/{email-queue-options-database.ts → smtp-email-queue-options-database.ts} +0 -0
- /package/src/jobs/{email-queue-options.ts → smtp-email-queue-options.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.146",
|
|
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",
|
|
@@ -2,7 +2,7 @@ import { registerAs } from '@nestjs/config';
|
|
|
2
2
|
|
|
3
3
|
export default registerAs('common', () => {
|
|
4
4
|
return {
|
|
5
|
-
emailProvider: process.env.COMMON_EMAIL_PROVIDER,
|
|
5
|
+
emailProvider: process.env.COMMON_EMAIL_PROVIDER ?? "SMTPEMailService",
|
|
6
6
|
emailTemplateSeederFiles: process.env.COMMON_EMAIL_TEMPLATE_SEEDER_FILES,
|
|
7
7
|
smsProvider: process.env.COMMON_SMS_PROVIDER,
|
|
8
8
|
smsTemplateSeederFiles: process.env.COMMON_SMS_TEMPLATE_SEEDER_FILES,
|
|
@@ -13,10 +13,11 @@ export default registerAs('common', () => {
|
|
|
13
13
|
port: +(process.env.COMMON_SMTP_EMAIL_SMTP_PORT ?? 587),
|
|
14
14
|
username: process.env.COMMON_SMTP_EMAIL_USERNAME,
|
|
15
15
|
password: process.env.COMMON_SMTP_EMAIL_PASSWORD,
|
|
16
|
-
from: process.env.COMMON_SMTP_EMAIL_FROM,
|
|
16
|
+
from: process.env.COMMON_SMTP_EMAIL_FROM ?? process.env.COMMON_EMAIL_FROM,
|
|
17
17
|
},
|
|
18
18
|
apiMail: {
|
|
19
|
-
key: process.env.COMMON_API_EMAIL_KEY
|
|
19
|
+
key: process.env.COMMON_API_EMAIL_KEY,
|
|
20
|
+
from: process.env.COMMON_EMAIL_FROM
|
|
20
21
|
},
|
|
21
22
|
msg91Sms: {
|
|
22
23
|
url: process.env.COMMON_MSG91_SMS_URL,
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { IMail } 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 MailFactory {
|
|
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
|
+
|
|
24
|
+
getMailService(): IMail {
|
|
25
|
+
const mailServiceName = this.commonConfiguration.emailProvider;
|
|
26
|
+
const mailProviders = this.solidRegistry.getMailProviders();
|
|
27
|
+
// Return the instance which matches the mailServiceName
|
|
28
|
+
if (!mailProviders.length) {
|
|
29
|
+
// throw new Error("No mail providers are registered.");
|
|
30
|
+
this.logger.error("No mail providers are registered.");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const mailServiceProvider = mailProviders.find(provider => provider.name === mailServiceName);
|
|
34
|
+
|
|
35
|
+
return mailServiceProvider.instance as IMail;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -65,6 +65,11 @@ export class SolidRegistry {
|
|
|
65
65
|
private computedFieldMetadata: ComputedFieldMetadata[] = [];
|
|
66
66
|
private dashboardVariableSelectionProviders: Set<InstanceWrapper> = new Set();
|
|
67
67
|
private dashboardQuestionDataProviders: Set<InstanceWrapper> = new Set();
|
|
68
|
+
private mailProviders: Set<InstanceWrapper> = new Set();
|
|
69
|
+
|
|
70
|
+
registerMailProvider(mailProvider: InstanceWrapper): void {
|
|
71
|
+
this.mailProviders.add(mailProvider);
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
registerController(name: string, methodNames: string[]): void {
|
|
70
75
|
this.controllers.add({ name: name, methods: methodNames });
|
|
@@ -106,6 +111,10 @@ export class SolidRegistry {
|
|
|
106
111
|
this.modules = new Set(modules);
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
getMailProviders(): Array<InstanceWrapper> {
|
|
115
|
+
return Array.from(this.mailProviders);
|
|
116
|
+
}
|
|
117
|
+
|
|
109
118
|
getSeeders(): Array<InstanceWrapper> {
|
|
110
119
|
return Array.from(this.seeders);
|
|
111
120
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './commands/remove-fields.command'
|
|
|
5
5
|
export * from './commands/seed.command'
|
|
6
6
|
|
|
7
7
|
export * from './config/app-builder.config'
|
|
8
|
-
export
|
|
8
|
+
export {default as commonConfig} from './config/common.config'
|
|
9
9
|
export * from './config/iam.config'
|
|
10
10
|
export * from './config/cache.options'
|
|
11
11
|
|
|
@@ -21,6 +21,8 @@ export * from './decorators/roles.decorator'
|
|
|
21
21
|
export * from './decorators/selection-provider.decorator'
|
|
22
22
|
export * from './decorators/solid-database-module.decorator'
|
|
23
23
|
export * from './decorators/solid-service.decorator'
|
|
24
|
+
export * from './decorators/mail-provider.decorator'
|
|
25
|
+
|
|
24
26
|
export * from './dtos/basic-filters.dto'
|
|
25
27
|
export * from './dtos/solid-request-context.dto'
|
|
26
28
|
export * from './dtos/change-password.dto'
|
|
@@ -177,9 +179,9 @@ export * from './services/scheduled-jobs/scheduler.service';
|
|
|
177
179
|
export * from './jobs/api-email-publisher.service'
|
|
178
180
|
export * from './jobs/api-email-queue-options'
|
|
179
181
|
export * from './jobs/api-email-subscriber.service'
|
|
180
|
-
export
|
|
181
|
-
export * from './jobs/email-queue-options'
|
|
182
|
-
export
|
|
182
|
+
export { SmtpEmailQueuePublisherRabbitmq, SmtpEmailQueuePublisherRabbitmq as EmailQueuePublisher } from './jobs/smtp-email-publisher.service' // alias for backward compatibility
|
|
183
|
+
export * from './jobs/smtp-email-queue-options'
|
|
184
|
+
export { SmtpEmailQueueSubscriberRabbitmq, SmtpEmailQueueSubscriberRabbitmq as EmailQueueSubscriber } from './jobs/smtp-email-subscriber.service' // alias for backward compatibility
|
|
183
185
|
export * from './jobs/otp-publisher.service'
|
|
184
186
|
export * from './jobs/otp-queue-options'
|
|
185
187
|
export * from './jobs/otp-subscriber.service'
|
|
@@ -216,8 +218,8 @@ export * from './services/field-metadata.service'
|
|
|
216
218
|
export * from './services/file.service'
|
|
217
219
|
export * from './services/hashing.service'
|
|
218
220
|
export * from './services/list-of-values.service'
|
|
219
|
-
export * from './services/mail/
|
|
220
|
-
export * from './services/mail/
|
|
221
|
+
export * from './services/mail/elastic-email.service'
|
|
222
|
+
export * from './services/mail/smtp-email.service'
|
|
221
223
|
export * from './services/media-storage-provider-metadata-seeder.service'
|
|
222
224
|
export * from './services/media-storage-provider-metadata.service'
|
|
223
225
|
export * from './services/media.service'
|
|
@@ -257,6 +259,13 @@ export * from './services/import-transaction.service'
|
|
|
257
259
|
export * from './services/import-transaction-error-log.service'
|
|
258
260
|
export * from './services/excel.service'
|
|
259
261
|
export * from './services/csv.service'
|
|
262
|
+
export * from './services/queues/publisher-factory.service'
|
|
263
|
+
export * from './services/queues/database-publisher.service'
|
|
264
|
+
export * from './services/queues/database-subscriber.service'
|
|
265
|
+
|
|
266
|
+
// Factories
|
|
267
|
+
export * from './factories/mail.factory'
|
|
268
|
+
|
|
260
269
|
// Repositories
|
|
261
270
|
export * from './repository/solid-base.repository'
|
|
262
271
|
export * from './repository/security-rule.repository'
|
package/src/interfaces.ts
CHANGED
|
@@ -169,6 +169,9 @@ export interface IMail {
|
|
|
169
169
|
attachments?: MailAttachment[],
|
|
170
170
|
parentEntity?: any,
|
|
171
171
|
parentEntityId?: any,
|
|
172
|
+
cc?: string[],
|
|
173
|
+
bcc?: string[],
|
|
174
|
+
from?: string,
|
|
172
175
|
): Promise<void>;
|
|
173
176
|
|
|
174
177
|
sendEmailUsingTemplate(
|
|
@@ -180,6 +183,9 @@ export interface IMail {
|
|
|
180
183
|
attachments?: MailAttachment[],
|
|
181
184
|
parentEntity?: any,
|
|
182
185
|
parentEntityId?: any,
|
|
186
|
+
cc?: string[],
|
|
187
|
+
bcc?: string[],
|
|
188
|
+
from?: string,
|
|
183
189
|
): Promise<void>;
|
|
184
190
|
}
|
|
185
191
|
|
|
@@ -201,11 +207,11 @@ export interface MailAttachmentWrapper {
|
|
|
201
207
|
|
|
202
208
|
export interface MailAttachment {
|
|
203
209
|
filename: string;
|
|
204
|
-
templatePath?: string;
|
|
205
|
-
templateParams?: any;
|
|
210
|
+
templatePath?: string; // deprecated
|
|
211
|
+
templateParams?: any; // deprecated
|
|
206
212
|
content?: string | Buffer;
|
|
207
213
|
contentType?: string;
|
|
208
|
-
path?: string;
|
|
214
|
+
path?: string; //Filesystem absolute path or URL.
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
export enum BrokerType {
|
|
@@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
|
|
3
3
|
import mailQueueOptions from './api-email-queue-options';
|
|
4
4
|
import { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';
|
|
5
5
|
import { QueueMessage } from 'src/interfaces/mq';
|
|
6
|
-
import { ElasticEmailService } from '../services/mail/
|
|
6
|
+
import { ElasticEmailService } from '../services/mail/elastic-email.service';
|
|
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";
|
|
@@ -4,7 +4,7 @@ import mailQueueOptions from './api-email-queue-options-database';
|
|
|
4
4
|
import { QueueMessage } from 'src/interfaces/mq';
|
|
5
5
|
import { MqMessageService } from 'src/services/mq-message.service';
|
|
6
6
|
import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
|
|
7
|
-
import { ElasticEmailService } from 'src/services/mail/
|
|
7
|
+
import { ElasticEmailService } from 'src/services/mail/elastic-email.service';
|
|
8
8
|
import { QueuesModuleOptions } from 'src/interfaces';
|
|
9
9
|
import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';
|
|
10
10
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
-
import mailQueueOptions from './email-queue-options-database';
|
|
3
|
+
import mailQueueOptions from './smtp-email-queue-options-database';
|
|
4
4
|
import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
|
|
5
5
|
import { MqMessageService } from 'src/services/mq-message.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
|
|
10
|
+
export class SmtpEmailQueuePublisherDatabase extends DatabasePublisher<any> {
|
|
11
11
|
constructor(
|
|
12
12
|
protected readonly mqMessageService: MqMessageService,
|
|
13
13
|
protected readonly mqMessageQueueService: MqMessageQueueService,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
-
import mailQueueOptions from './email-queue-options-database';
|
|
3
|
+
import mailQueueOptions from './smtp-email-queue-options-database';
|
|
4
4
|
import { QueueMessage } from 'src/interfaces/mq';
|
|
5
5
|
import { MqMessageService } from 'src/services/mq-message.service';
|
|
6
6
|
import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
|
|
7
7
|
import { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';
|
|
8
|
-
import { SMTPEMailService } from 'src/services/mail/
|
|
8
|
+
import { SMTPEMailService } from 'src/services/mail/smtp-email.service';
|
|
9
9
|
import { QueuesModuleOptions } from 'src/interfaces';
|
|
10
10
|
|
|
11
11
|
@Injectable()
|
|
12
|
-
export class
|
|
12
|
+
export class SmtpEmailQueueSubscriberDatabase extends DatabaseSubscriber<any> {
|
|
13
13
|
constructor(
|
|
14
14
|
private readonly emailService: SMTPEMailService,
|
|
15
15
|
readonly mqMessageService: MqMessageService,
|
|
@@ -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 mailQueueOptions from './email-queue-options';
|
|
4
|
+
import mailQueueOptions from './smtp-email-queue-options';
|
|
5
5
|
import { MqMessageQueueService } from 'src/services/mq-message-queue.service';
|
|
6
6
|
import { MqMessageService } from 'src/services/mq-message.service';
|
|
7
7
|
import { QueuesModuleOptions } from "../interfaces";
|
|
8
8
|
|
|
9
9
|
@Injectable()
|
|
10
|
-
export class
|
|
10
|
+
export class SmtpEmailQueuePublisherRabbitmq extends RabbitMqPublisher<any> {
|
|
11
11
|
constructor(
|
|
12
12
|
protected readonly mqMessageService: MqMessageService,
|
|
13
13
|
protected readonly mqMessageQueueService: MqMessageQueueService,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
|
|
3
|
-
import mailQueueOptions from './email-queue-options';
|
|
3
|
+
import mailQueueOptions from './smtp-email-queue-options';
|
|
4
4
|
import { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';
|
|
5
5
|
import { QueueMessage } from 'src/interfaces/mq';
|
|
6
|
-
import { SMTPEMailService } from '../services/mail/
|
|
6
|
+
import { SMTPEMailService } from '../services/mail/smtp-email.service';
|
|
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
|
|
12
|
+
export class SmtpEmailQueueSubscriberRabbitmq extends RabbitMqSubscriber<any> {
|
|
13
13
|
constructor(
|
|
14
14
|
private readonly emailService: SMTPEMailService,
|
|
15
15
|
readonly mqMessageService: MqMessageService,
|
|
@@ -134,18 +134,18 @@ export class ModuleMetadataSeederService {
|
|
|
134
134
|
|
|
135
135
|
// Process module metadata first.
|
|
136
136
|
const moduleMetadata: CreateModuleMetadataDto = overallMetadata.moduleMetadata;
|
|
137
|
-
this.logger.
|
|
137
|
+
this.logger.log(`[Start] Processing module metadata for ${moduleMetadata.name}`)
|
|
138
138
|
await this.seedModuleModelFields(moduleMetadata);
|
|
139
|
-
this.logger.
|
|
139
|
+
this.logger.log(`[End] Processing module metadata for ${moduleMetadata.name}`)
|
|
140
140
|
|
|
141
141
|
// Media Storage provider templates
|
|
142
|
-
this.logger.
|
|
142
|
+
this.logger.log(`[Start] Processing Media Storage Provider for ${moduleMetadata.name}`);
|
|
143
143
|
const mediaStorageProviders = overallMetadata.mediaStorageProviders;
|
|
144
144
|
await this.seedMediaStorageProviders(mediaStorageProviders);
|
|
145
|
-
this.logger.
|
|
145
|
+
this.logger.log(`[End] Processing Media Storage Provider for ${moduleMetadata.name}`);
|
|
146
146
|
|
|
147
147
|
// Custom role handling
|
|
148
|
-
this.logger.
|
|
148
|
+
this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)
|
|
149
149
|
const roles = overallMetadata.roles;
|
|
150
150
|
|
|
151
151
|
// Every role configuration in the seeder json can optionally have a permissions attribute.
|
|
@@ -159,67 +159,67 @@ export class ModuleMetadataSeederService {
|
|
|
159
159
|
await this.roleService.addPermissionsToRole(role.name, role.permissions)
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
this.logger.
|
|
162
|
+
this.logger.log(`[End] Processing roles for ${moduleMetadata.name}`)
|
|
163
163
|
|
|
164
164
|
// Custom user handling
|
|
165
|
-
this.logger.
|
|
165
|
+
this.logger.log(`[Start] Processing users for ${moduleMetadata.name}`);
|
|
166
166
|
const users = overallMetadata.users;
|
|
167
167
|
usersDetail = users;
|
|
168
168
|
await this.seedUsers(users);
|
|
169
|
-
this.logger.
|
|
169
|
+
this.logger.log(`[End] Processing users for ${moduleMetadata.name}`)
|
|
170
170
|
|
|
171
171
|
// Application Module View handling
|
|
172
|
-
this.logger.
|
|
172
|
+
this.logger.log(`[Start] Processing views for ${moduleMetadata.name}`);
|
|
173
173
|
const views = overallMetadata.views;
|
|
174
174
|
await this.seedViews(views);
|
|
175
|
-
this.logger.
|
|
175
|
+
this.logger.log(`[End] Processing views for ${moduleMetadata.name}`)
|
|
176
176
|
|
|
177
177
|
// Application Module Action handling
|
|
178
|
-
this.logger.
|
|
178
|
+
this.logger.log(`[Start] Processing actions for ${moduleMetadata.name}`);
|
|
179
179
|
const actions = overallMetadata.actions;
|
|
180
180
|
await this.seedActions(actions);
|
|
181
|
-
this.logger.
|
|
181
|
+
this.logger.log(`[End] Processing actions for ${moduleMetadata.name}`)
|
|
182
182
|
|
|
183
183
|
// Application Module Menu handling
|
|
184
|
-
this.logger.
|
|
184
|
+
this.logger.log(`[Start] Processing menus for ${moduleMetadata.name}`);
|
|
185
185
|
const menus = overallMetadata.menus;
|
|
186
186
|
await this.seedMenus(menus);
|
|
187
|
-
this.logger.
|
|
187
|
+
this.logger.log(`[End] Processing menus for ${moduleMetadata.name}`)
|
|
188
188
|
|
|
189
189
|
// Email templates
|
|
190
|
-
this.logger.
|
|
190
|
+
this.logger.log(`[Start] Processing email templates for ${moduleMetadata.name}`);
|
|
191
191
|
const emailTemplates: CreateEmailTemplateDto[] = overallMetadata.emailTemplates;
|
|
192
192
|
await this.seedEmailTemplates(emailTemplates, moduleMetadata);
|
|
193
|
-
this.logger.
|
|
193
|
+
this.logger.log(`[End] Processing email templates for ${moduleMetadata.name}`);
|
|
194
194
|
|
|
195
195
|
// Sms templates
|
|
196
|
-
this.logger.
|
|
196
|
+
this.logger.log(`[Start] Processing sms templates for ${moduleMetadata.name}`);
|
|
197
197
|
const smsTemplates: CreateSmsTemplateDto[] = overallMetadata.smsTemplates;
|
|
198
198
|
await this.seedSmsTemplates(smsTemplates);
|
|
199
|
-
this.logger.
|
|
199
|
+
this.logger.log(`[End] Processing sms templates for ${moduleMetadata.name}`);
|
|
200
200
|
|
|
201
201
|
// Settings
|
|
202
|
-
this.logger.
|
|
202
|
+
this.logger.log(`[Start] Processing settings for ${moduleMetadata.name}`);
|
|
203
203
|
await this.seetingService.seedDefaultSettings();
|
|
204
|
-
this.logger.
|
|
204
|
+
this.logger.log(`[End] Processing settings for ${moduleMetadata.name}`);
|
|
205
205
|
|
|
206
206
|
// Security rules
|
|
207
|
-
this.logger.
|
|
207
|
+
this.logger.log(`[Start] Processing security rules for ${moduleMetadata.name}`);
|
|
208
208
|
const securityRules: CreateSecurityRuleDto[] = overallMetadata.securityRules;
|
|
209
209
|
await this.seedSecurityRules(securityRules);
|
|
210
|
-
this.logger.
|
|
210
|
+
this.logger.log(`[End] Processing security rules for ${moduleMetadata.name}`);
|
|
211
211
|
|
|
212
212
|
// List Of Values
|
|
213
|
-
this.logger.
|
|
213
|
+
this.logger.log(`[Start] Processing List Of Values for ${moduleMetadata.name}`);
|
|
214
214
|
const listOfValues: CreateListOfValuesDto[] = overallMetadata.listOfValues;
|
|
215
215
|
await this.seedListOfValues(listOfValues);
|
|
216
|
-
this.logger.
|
|
216
|
+
this.logger.log(`[End] Processing List Of Values for ${moduleMetadata.name}`);
|
|
217
217
|
|
|
218
218
|
// Dashboards
|
|
219
|
-
this.logger.
|
|
219
|
+
this.logger.log(`[Start] Processing dashboards for ${moduleMetadata.name}`);
|
|
220
220
|
const dashboards: CreateDashboardDto[] = overallMetadata.dashboards;
|
|
221
221
|
await this.seedDashboards(dashboards);
|
|
222
|
-
this.logger.
|
|
222
|
+
this.logger.log(`[End] Processing dashboards for ${moduleMetadata.name}`);
|
|
223
223
|
|
|
224
224
|
|
|
225
225
|
this.logger.debug(`[End] module seed data: ${overallMetadata}`);
|
|
@@ -229,7 +229,7 @@ export class ModuleMetadataSeederService {
|
|
|
229
229
|
// Post seed data file processing.
|
|
230
230
|
|
|
231
231
|
// 1. Give all permissions to the Admin role.
|
|
232
|
-
this.logger.
|
|
232
|
+
this.logger.log(`About to add all permissions to the Admin role`);
|
|
233
233
|
await this.roleService.addAllPermissionsToRole("Admin");
|
|
234
234
|
// 2. Give wrapSettings permissions to the Public role.
|
|
235
235
|
const internalRolePermission = [
|
|
@@ -5387,27 +5387,27 @@
|
|
|
5387
5387
|
},
|
|
5388
5388
|
{
|
|
5389
5389
|
"displayName": "Email list action",
|
|
5390
|
-
"name": "
|
|
5390
|
+
"name": "emailTemplate-list-action",
|
|
5391
5391
|
"type": "solid",
|
|
5392
5392
|
"domain": "",
|
|
5393
5393
|
"context": "",
|
|
5394
5394
|
"customComponent": "",
|
|
5395
5395
|
"customIsModal": true,
|
|
5396
5396
|
"serverEndpoint": "",
|
|
5397
|
-
"viewUserKey": "
|
|
5397
|
+
"viewUserKey": "emailTemplate-list-view",
|
|
5398
5398
|
"moduleUserKey": "solid-core",
|
|
5399
5399
|
"modelUserKey": "emailTemplate"
|
|
5400
5400
|
},
|
|
5401
5401
|
{
|
|
5402
5402
|
"displayName": "SMS list action",
|
|
5403
|
-
"name": "
|
|
5403
|
+
"name": "smsTemplate-list-action",
|
|
5404
5404
|
"type": "solid",
|
|
5405
5405
|
"domain": "",
|
|
5406
5406
|
"context": "",
|
|
5407
5407
|
"customComponent": "",
|
|
5408
5408
|
"customIsModal": true,
|
|
5409
5409
|
"serverEndpoint": "",
|
|
5410
|
-
"viewUserKey": "
|
|
5410
|
+
"viewUserKey": "smsTemplate-list-view",
|
|
5411
5411
|
"moduleUserKey": "solid-core",
|
|
5412
5412
|
"modelUserKey": "smsTemplate"
|
|
5413
5413
|
},
|
|
@@ -5755,17 +5755,17 @@
|
|
|
5755
5755
|
},
|
|
5756
5756
|
{
|
|
5757
5757
|
"displayName": "Email",
|
|
5758
|
-
"name": "
|
|
5758
|
+
"name": "emailTemplate-menu-item",
|
|
5759
5759
|
"sequenceNumber": 1,
|
|
5760
|
-
"actionUserKey": "
|
|
5760
|
+
"actionUserKey": "emailTemplate-list-action",
|
|
5761
5761
|
"moduleUserKey": "solid-core",
|
|
5762
5762
|
"parentMenuItemUserKey": "notification-menu-item"
|
|
5763
5763
|
},
|
|
5764
5764
|
{
|
|
5765
5765
|
"displayName": "SMS",
|
|
5766
|
-
"name": "
|
|
5766
|
+
"name": "smsTemplate-menu-item",
|
|
5767
5767
|
"sequenceNumber": 1,
|
|
5768
|
-
"actionUserKey": "
|
|
5768
|
+
"actionUserKey": "smsTemplate-list-action",
|
|
5769
5769
|
"moduleUserKey": "solid-core",
|
|
5770
5770
|
"parentMenuItemUserKey": "notification-menu-item"
|
|
5771
5771
|
},
|
|
@@ -10672,7 +10672,7 @@
|
|
|
10672
10672
|
}
|
|
10673
10673
|
},
|
|
10674
10674
|
{
|
|
10675
|
-
"name": "
|
|
10675
|
+
"name": "emailTemplate-list-view",
|
|
10676
10676
|
"displayName": "Email",
|
|
10677
10677
|
"type": "list",
|
|
10678
10678
|
"context": "{}",
|
|
@@ -10706,7 +10706,7 @@
|
|
|
10706
10706
|
}
|
|
10707
10707
|
},
|
|
10708
10708
|
{
|
|
10709
|
-
"name": "
|
|
10709
|
+
"name": "emailTemplate-form-view",
|
|
10710
10710
|
"displayName": "Email",
|
|
10711
10711
|
"type": "form",
|
|
10712
10712
|
"context": "{}",
|
|
@@ -10805,7 +10805,7 @@
|
|
|
10805
10805
|
}
|
|
10806
10806
|
},
|
|
10807
10807
|
{
|
|
10808
|
-
"name": "
|
|
10808
|
+
"name": "smsTemplate-list-view",
|
|
10809
10809
|
"displayName": "SMS Template",
|
|
10810
10810
|
"type": "list",
|
|
10811
10811
|
"context": "{}",
|
|
@@ -10839,7 +10839,7 @@
|
|
|
10839
10839
|
}
|
|
10840
10840
|
},
|
|
10841
10841
|
{
|
|
10842
|
-
"name": "
|
|
10842
|
+
"name": "smsTemplate-form-view",
|
|
10843
10843
|
"displayName": "SMS Template",
|
|
10844
10844
|
"type": "form",
|
|
10845
10845
|
"context": "{}",
|
|
@@ -15,7 +15,7 @@ import { JwtService } from '@nestjs/jwt';
|
|
|
15
15
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
16
16
|
import { isEmpty, isNotEmpty } from 'class-validator';
|
|
17
17
|
import { randomInt, randomUUID } from 'crypto';
|
|
18
|
-
import { SMTPEMailService } from 'src/services/mail/
|
|
18
|
+
import { SMTPEMailService } from 'src/services/mail/smtp-email.service';
|
|
19
19
|
import { Msg91OTPService } from 'src/services/sms/Msg91OTPService';
|
|
20
20
|
import { Repository } from 'typeorm';
|
|
21
21
|
import { iamConfig, jwtConfig } from '../config/iam.config';
|
|
@@ -34,7 +34,7 @@ import { ActiveUserData } from '../interfaces/active-user-data.interface';
|
|
|
34
34
|
import { HashingService } from './hashing.service';
|
|
35
35
|
import { InvalidatedRefreshTokenError, RefreshTokenIdsStorageService } from './refresh-token-ids-storage.service';
|
|
36
36
|
import { UserService } from './user.service';
|
|
37
|
-
import { EventDetails, EventType } from "../interfaces";
|
|
37
|
+
import { EventDetails, EventType, IMail } from "../interfaces";
|
|
38
38
|
import {
|
|
39
39
|
ForgotPasswordSendVerificationTokenOn,
|
|
40
40
|
RegistrationValidationSource,
|
|
@@ -48,6 +48,7 @@ import { UserActivityHistoryService } from './user-activity-history.service';
|
|
|
48
48
|
import { RequestContextService } from './request-context.service';
|
|
49
49
|
import { ERROR_MESSAGES } from 'src/constants/error-messages';
|
|
50
50
|
import { SUCCESS_MESSAGES } from 'src/constants/success-messages';
|
|
51
|
+
import { MailFactory } from 'src/factories/mail.factory';
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
enum LoginProvider {
|
|
@@ -64,7 +65,7 @@ interface otp {
|
|
|
64
65
|
@Injectable()
|
|
65
66
|
export class AuthenticationService {
|
|
66
67
|
private readonly logger = new Logger(AuthenticationService.name);
|
|
67
|
-
|
|
68
|
+
// private readonly mailService: IMail;
|
|
68
69
|
constructor(
|
|
69
70
|
private readonly userService: UserService,
|
|
70
71
|
@InjectRepository(User) private readonly userRepository: Repository<User>,
|
|
@@ -77,7 +78,8 @@ export class AuthenticationService {
|
|
|
77
78
|
private readonly iamConfiguration: ConfigType<typeof iamConfig>,
|
|
78
79
|
private readonly refreshTokenIdsStorage: RefreshTokenIdsStorageService,
|
|
79
80
|
private readonly httpService: HttpService,
|
|
80
|
-
private readonly mailService: SMTPEMailService,
|
|
81
|
+
// private readonly mailService: SMTPEMailService,
|
|
82
|
+
private readonly mailServiceFactory: MailFactory,
|
|
81
83
|
private readonly smsService: Msg91OTPService,
|
|
82
84
|
private readonly eventEmitter: EventEmitter2,
|
|
83
85
|
private readonly settingService: SettingService,
|
|
@@ -86,7 +88,9 @@ export class AuthenticationService {
|
|
|
86
88
|
private readonly commonConfiguration: ConfigType<typeof commonConfig>,
|
|
87
89
|
private readonly userActivityHistoryService: UserActivityHistoryService,
|
|
88
90
|
private readonly requestContextService: RequestContextService,
|
|
89
|
-
) {
|
|
91
|
+
) {
|
|
92
|
+
// this.mailService = this.mailServiceFactory.getMailService();
|
|
93
|
+
}
|
|
90
94
|
|
|
91
95
|
private async getConfig(key: string): Promise<any> {
|
|
92
96
|
return this.settingService.getConfigValue(key);
|
|
@@ -253,8 +257,8 @@ export class AuthenticationService {
|
|
|
253
257
|
|
|
254
258
|
private async notifyUserOnForcePasswordChange(user: User, autoGeneratedPwd: string) {
|
|
255
259
|
const companyLogo = await this.getCompanyLogo();
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
const mailService = this.mailServiceFactory.getMailService();
|
|
261
|
+
mailService.sendEmailUsingTemplate(
|
|
258
262
|
user.email,
|
|
259
263
|
'on-force-password-change',
|
|
260
264
|
{
|
|
@@ -268,6 +272,8 @@ export class AuthenticationService {
|
|
|
268
272
|
companyLogoUrl: companyLogo
|
|
269
273
|
},
|
|
270
274
|
this.commonConfiguration.shouldQueueEmails,
|
|
275
|
+
null,
|
|
276
|
+
null,
|
|
271
277
|
'user',
|
|
272
278
|
user.id
|
|
273
279
|
);
|
|
@@ -375,7 +381,8 @@ export class AuthenticationService {
|
|
|
375
381
|
if (this.iamConfiguration.dummyOtp)
|
|
376
382
|
return; // Do nothing if dummy otp is configured.
|
|
377
383
|
if (registrationValidationSources.includes(RegistrationValidationSource.EMAIL)) {
|
|
378
|
-
this.
|
|
384
|
+
const mailService = this.mailServiceFactory.getMailService();
|
|
385
|
+
mailService.sendEmailUsingTemplate(
|
|
379
386
|
user.email,
|
|
380
387
|
'otp-on-register',
|
|
381
388
|
{
|
|
@@ -387,6 +394,8 @@ export class AuthenticationService {
|
|
|
387
394
|
companyLogoUrl: companyLogo
|
|
388
395
|
},
|
|
389
396
|
this.commonConfiguration.shouldQueueEmails,
|
|
397
|
+
null,
|
|
398
|
+
null,
|
|
390
399
|
'user',
|
|
391
400
|
user.id
|
|
392
401
|
);
|
|
@@ -563,7 +572,8 @@ export class AuthenticationService {
|
|
|
563
572
|
if (this.iamConfiguration.dummyOtp)
|
|
564
573
|
return; // Do nothing if dummy otp is configured.
|
|
565
574
|
if (loginType === RegistrationValidationSource.EMAIL) {
|
|
566
|
-
this.
|
|
575
|
+
const mailService = this.mailServiceFactory.getMailService();
|
|
576
|
+
mailService.sendEmailUsingTemplate(
|
|
567
577
|
user.email,
|
|
568
578
|
'otp-on-login',
|
|
569
579
|
{
|
|
@@ -575,6 +585,8 @@ export class AuthenticationService {
|
|
|
575
585
|
companyLogoUrl: companyLogo
|
|
576
586
|
},
|
|
577
587
|
this.commonConfiguration.shouldQueueEmails,
|
|
588
|
+
null,
|
|
589
|
+
null,
|
|
578
590
|
'user',
|
|
579
591
|
user.id
|
|
580
592
|
);
|
|
@@ -767,7 +779,8 @@ export class AuthenticationService {
|
|
|
767
779
|
const forgotPasswordSendVerificationTokenOn = this.iamConfiguration.forgotPasswordSendVerificationTokenOn;
|
|
768
780
|
|
|
769
781
|
if (forgotPasswordSendVerificationTokenOn == ForgotPasswordSendVerificationTokenOn.EMAIL) {
|
|
770
|
-
this.
|
|
782
|
+
const mailService = this.mailServiceFactory.getMailService();
|
|
783
|
+
mailService.sendEmailUsingTemplate(
|
|
771
784
|
user.email,
|
|
772
785
|
'forgot-password',
|
|
773
786
|
{
|
|
@@ -780,6 +793,8 @@ export class AuthenticationService {
|
|
|
780
793
|
companyLogoUrl: companyLogo
|
|
781
794
|
},
|
|
782
795
|
this.commonConfiguration.shouldQueueEmails,
|
|
796
|
+
null,
|
|
797
|
+
null,
|
|
783
798
|
'user',
|
|
784
799
|
user.id
|
|
785
800
|
);
|
|
@@ -385,6 +385,7 @@ export class ImportTransactionService extends CRUDService<ImportTransaction> {
|
|
|
385
385
|
field.type !== SolidFieldType.password &&
|
|
386
386
|
field.type !== SolidFieldType.richText &&
|
|
387
387
|
field.type !== SolidFieldType.uuid &&
|
|
388
|
+
field.relationType !== RelationType.oneToMany &&
|
|
388
389
|
field.isSystem !== true // Exclude system fields
|
|
389
390
|
);
|
|
390
391
|
}
|