@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
|
@@ -9,10 +9,12 @@ import { PdfService } from '../pdf.service';
|
|
|
9
9
|
import { FileService } from '../file.service';
|
|
10
10
|
import { IMail, MailAttachment, MailAttachmentWrapper } from "../../interfaces";
|
|
11
11
|
import { PublisherFactory } from '../queues/publisher-factory.service';
|
|
12
|
+
import { MailProvider } from 'src/decorators/mail-provider.decorator';
|
|
12
13
|
|
|
13
14
|
const ElasticEmail = require('@elasticemail/elasticemail-client');
|
|
14
15
|
|
|
15
16
|
@Injectable()
|
|
17
|
+
@MailProvider()
|
|
16
18
|
export class ElasticEmailService implements IMail {
|
|
17
19
|
private readonly logger = new Logger(ElasticEmailService.name);
|
|
18
20
|
private readonly emailsApi;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
import { ConfigType } from '@nestjs/config';
|
|
3
|
-
import
|
|
3
|
+
import Handlebars from "handlebars";
|
|
4
4
|
import commonConfig from 'src/config/common.config';
|
|
5
|
+
import { MailProvider } from 'src/decorators/mail-provider.decorator';
|
|
6
|
+
import { QueueMessage } from 'src/interfaces/mq';
|
|
7
|
+
import { IMail, MailAttachment, MailAttachmentWrapper } from "../../interfaces";
|
|
5
8
|
import { EmailTemplateService } from '../email-template.service';
|
|
6
|
-
import Handlebars from "handlebars";
|
|
7
|
-
import { IMail, MailAttachment } from "../../interfaces";
|
|
8
9
|
import { PublisherFactory } from '../queues/publisher-factory.service';
|
|
9
10
|
|
|
10
11
|
const nodemailer = require("nodemailer");
|
|
11
12
|
|
|
12
13
|
@Injectable()
|
|
14
|
+
@MailProvider()
|
|
13
15
|
export class SMTPEMailService implements IMail {
|
|
14
16
|
private readonly logger = new Logger(SMTPEMailService.name);
|
|
15
17
|
private readonly transporter: any;
|
|
@@ -33,8 +35,20 @@ export class SMTPEMailService implements IMail {
|
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
async sendEmailUsingTemplate(
|
|
37
|
-
|
|
38
|
+
async sendEmailUsingTemplate(
|
|
39
|
+
to: string,
|
|
40
|
+
templateName: string,
|
|
41
|
+
templateParams: any,
|
|
42
|
+
shouldQueueEmails = false,
|
|
43
|
+
wrapperAttachments?: MailAttachmentWrapper[],
|
|
44
|
+
attachments?: MailAttachment[],
|
|
45
|
+
parentEntity?: any,
|
|
46
|
+
parentEntityId?: any,
|
|
47
|
+
cc?: string[],
|
|
48
|
+
bcc?: string[],
|
|
49
|
+
from?: string
|
|
50
|
+
): Promise<void> {
|
|
51
|
+
// Load template and evaluate it.
|
|
38
52
|
const emailTemplate = await this.emailTemplateService.findOneByName(templateName);
|
|
39
53
|
if (!emailTemplate) {
|
|
40
54
|
throw new Error(`Invalid template name ${templateName}`);
|
|
@@ -49,18 +63,31 @@ export class SMTPEMailService implements IMail {
|
|
|
49
63
|
const subject = subjectTemplate(templateParams);
|
|
50
64
|
|
|
51
65
|
// Finally send the email.
|
|
52
|
-
await this.sendEmail(to, subject, body, shouldQueueEmails, parentEntity, parentEntityId,
|
|
66
|
+
await this.sendEmail(to, subject, body, shouldQueueEmails, wrapperAttachments, attachments, parentEntity, parentEntityId, cc, bcc, from);
|
|
53
67
|
}
|
|
54
68
|
|
|
55
|
-
async sendEmail(
|
|
69
|
+
async sendEmail(
|
|
70
|
+
to: string,
|
|
71
|
+
subject: string,
|
|
72
|
+
body: string,
|
|
73
|
+
shouldQueueEmails = false,
|
|
74
|
+
wrapperAttachments?: MailAttachmentWrapper[],
|
|
75
|
+
attachments?: MailAttachment[],
|
|
76
|
+
parentEntity?: any,
|
|
77
|
+
parentEntityId?: any,
|
|
78
|
+
cc?: string[],
|
|
79
|
+
bcc?: string[],
|
|
80
|
+
from?: string
|
|
81
|
+
): Promise<void> {
|
|
56
82
|
const message = {
|
|
57
83
|
payload: {
|
|
58
|
-
from: this.commonConfiguration.smtpMail.from,
|
|
84
|
+
from: from || this.commonConfiguration.smtpMail.from,
|
|
59
85
|
to: to,
|
|
60
86
|
subject: subject,
|
|
61
87
|
body: body,
|
|
62
88
|
attachments: attachments,
|
|
63
89
|
cc: cc,
|
|
90
|
+
bcc: bcc,
|
|
64
91
|
},
|
|
65
92
|
parentEntity: parentEntity,
|
|
66
93
|
parentEntityId: parentEntityId,
|
|
@@ -86,13 +113,13 @@ export class SMTPEMailService implements IMail {
|
|
|
86
113
|
// this.emailPublisher.publish(message);
|
|
87
114
|
// this.emailDbPublisher.publish(message);
|
|
88
115
|
|
|
89
|
-
this.publisherFactory.publish(message, '
|
|
116
|
+
this.publisherFactory.publish(message, 'SmtpEmailQueuePublisher');
|
|
90
117
|
|
|
91
118
|
this.logger.debug(`Queueing email to ${to} with subject ${subject} and body ${body}`);
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
async sendEmailSynchronously(message: QueueMessage<any>): Promise<void> {
|
|
95
|
-
const { from, to, subject, body, attachments, cc } = message.payload;
|
|
122
|
+
const { from, to, subject, body, attachments, cc, bcc } = message.payload;
|
|
96
123
|
|
|
97
124
|
const attachmentsList = attachments.map((attachment: MailAttachment) => {
|
|
98
125
|
const attachmentEntry = {
|
|
@@ -113,6 +140,7 @@ export class SMTPEMailService implements IMail {
|
|
|
113
140
|
from: from,
|
|
114
141
|
to: to,
|
|
115
142
|
cc: cc,
|
|
143
|
+
bcc: bcc,
|
|
116
144
|
subject: subject,
|
|
117
145
|
html: body,
|
|
118
146
|
attachments: attachmentsList,
|
|
@@ -10,6 +10,7 @@ import { CRUDService } from './crud.service';
|
|
|
10
10
|
import { IS_SCHEDULED_JOB_PROVIDER } from 'src/decorators/scheduled-job-provider.decorator';
|
|
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
|
+
import { IS_MAIL_PROVIDER } from 'src/decorators/mail-provider.decorator';
|
|
13
14
|
|
|
14
15
|
@Injectable()
|
|
15
16
|
export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
@@ -40,7 +41,6 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
40
41
|
.filter((provider) => this.isSelectionProvider(provider));
|
|
41
42
|
|
|
42
43
|
selectionProviders.forEach((selectionProvider) => {
|
|
43
|
-
// @ts-ignore
|
|
44
44
|
this.solidRegistry.registerSelectionProvider(selectionProvider);
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -50,7 +50,6 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
50
50
|
.filter((provider) => this.isDashboardVariableSelectionProvider(provider));
|
|
51
51
|
|
|
52
52
|
dashboardVariableSelectionProviders.forEach((dashboardSelectionProvider) => {
|
|
53
|
-
// @ts-ignore
|
|
54
53
|
this.solidRegistry.registerDashboardVariableSelectionProvider(dashboardSelectionProvider);
|
|
55
54
|
});
|
|
56
55
|
|
|
@@ -60,7 +59,6 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
60
59
|
.filter((provider) => this.isDashboardQuestionDataProvider(provider));
|
|
61
60
|
|
|
62
61
|
dashboardQuestionDataProviders.forEach((provider) => {
|
|
63
|
-
// @ts-ignore
|
|
64
62
|
this.solidRegistry.registerDashboardQuestionDataProvider(provider);
|
|
65
63
|
});
|
|
66
64
|
|
|
@@ -81,7 +79,6 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
81
79
|
.filter((provider) => this.isSolidDatabaseModule(provider));
|
|
82
80
|
|
|
83
81
|
solidDatabaseModules.forEach((solidDatabaseModule) => {
|
|
84
|
-
// @ts-ignore
|
|
85
82
|
this.solidRegistry.registerSolidDatabaseModule(solidDatabaseModule);
|
|
86
83
|
});
|
|
87
84
|
|
|
@@ -110,10 +107,17 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
110
107
|
.filter((provider) => this.isScheduledJobProvider(provider));
|
|
111
108
|
|
|
112
109
|
scheduledJobProviders.forEach((scheduledJobProvider) => {
|
|
113
|
-
// @ts-ignore
|
|
114
110
|
this.solidRegistry.registerScheduledJobProvider(scheduledJobProvider);
|
|
115
111
|
});
|
|
116
112
|
|
|
113
|
+
// Register all IMail implementations
|
|
114
|
+
const mailProviders = this.discoveryService
|
|
115
|
+
.getProviders()
|
|
116
|
+
.filter((provider) => this.isMailProvider(provider));
|
|
117
|
+
|
|
118
|
+
mailProviders.forEach((mailProvider) => {
|
|
119
|
+
this.solidRegistry.registerMailProvider(mailProvider);
|
|
120
|
+
});
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
isDashboardQuestionDataProvider(providerWrapper: InstanceWrapper<any>) {
|
|
@@ -196,6 +200,18 @@ export class SolidIntrospectService implements OnApplicationBootstrap {
|
|
|
196
200
|
return !!isSolidDatabaseModule;
|
|
197
201
|
}
|
|
198
202
|
|
|
203
|
+
private isMailProvider(provider: InstanceWrapper) {
|
|
204
|
+
const { instance } = provider;
|
|
205
|
+
if (!instance) return false;
|
|
206
|
+
|
|
207
|
+
const isMailProvider = this.reflector.get<boolean>(
|
|
208
|
+
IS_MAIL_PROVIDER,
|
|
209
|
+
instance.constructor,
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
return !!isMailProvider;
|
|
213
|
+
}
|
|
214
|
+
|
|
199
215
|
private isModule(provider: InstanceWrapper): boolean {
|
|
200
216
|
const metatype = provider.metatype;
|
|
201
217
|
// Check if it's a Static Module (Class-Based)
|
package/src/solid-core.module.ts
CHANGED
|
@@ -86,8 +86,8 @@ import { ApiEmailQueuePublisher } from './jobs/api-email-publisher.service';
|
|
|
86
86
|
import { ApiEmailQueueSubscriber } from './jobs/api-email-subscriber.service';
|
|
87
87
|
import { TestQueuePublisherDatabase } from './jobs/database/test-queue-publisher-database.service';
|
|
88
88
|
import { TestQueueSubscriberDatabase } from './jobs/database/test-queue-subscriber-database.service';
|
|
89
|
-
import {
|
|
90
|
-
import {
|
|
89
|
+
import { SmtpEmailQueuePublisherRabbitmq } from './jobs/smtp-email-publisher.service';
|
|
90
|
+
import { SmtpEmailQueueSubscriberRabbitmq } from './jobs/smtp-email-subscriber.service';
|
|
91
91
|
import { OTPQueuePublisher } from './jobs/otp-publisher.service';
|
|
92
92
|
import { OTPQueueSubscriber } from './jobs/otp-subscriber.service';
|
|
93
93
|
import { SmsQueuePublisher } from './jobs/sms-publisher.service';
|
|
@@ -108,8 +108,8 @@ import { UuidExternalIdComputedFieldProvider } from './services/computed-fields/
|
|
|
108
108
|
import { EmailTemplateService } from './services/email-template.service';
|
|
109
109
|
import { FileService } from './services/file.service';
|
|
110
110
|
import { HashingService } from './services/hashing.service';
|
|
111
|
-
import { ElasticEmailService } from './services/mail/
|
|
112
|
-
import { SMTPEMailService } from './services/mail/
|
|
111
|
+
import { ElasticEmailService } from './services/mail/elastic-email.service';
|
|
112
|
+
import { SMTPEMailService } from './services/mail/smtp-email.service';
|
|
113
113
|
import { MenuItemMetadataService } from './services/menu-item-metadata.service';
|
|
114
114
|
import { MqMessageQueueService } from './services/mq-message-queue.service';
|
|
115
115
|
import { MqMessageService } from './services/mq-message.service';
|
|
@@ -178,8 +178,8 @@ import { ApiEmailQueuePublisherDatabase } from './jobs/database/api-email-publis
|
|
|
178
178
|
import { ApiEmailQueueSubscriberDatabase } from './jobs/database/api-email-subscriber-database.service';
|
|
179
179
|
import { ComputedFieldEvaluationPublisher } from './jobs/database/computed-field-evaluation-publisher.service';
|
|
180
180
|
import { ComputedFieldEvaluationSubscriber } from './jobs/database/computed-field-evaluation-subscriber.service';
|
|
181
|
-
import {
|
|
182
|
-
import {
|
|
181
|
+
import { SmtpEmailQueuePublisherDatabase } from './jobs/database/smtp-email-publisher-database.service';
|
|
182
|
+
import { SmtpEmailQueueSubscriberDatabase } from './jobs/database/smtp-email-subscriber-database.service';
|
|
183
183
|
import { GenerateCodePublisherDatabase } from './jobs/database/generate-code-publisher-database.service';
|
|
184
184
|
import { GenerateCodeSubscriberDatabase } from './jobs/database/generate-code-subscriber-database.service';
|
|
185
185
|
import { OTPQueuePublisherDatabase } from './jobs/database/otp-publisher-database.service';
|
|
@@ -259,6 +259,7 @@ import { ViewMetadataRepository } from './repository/view-metadata.repository';
|
|
|
259
259
|
import { SolidCreateModelLayoutMcpToolResponseHandler } from './services/mcp-tool-response-handlers/solid-save-model-layout-mcp-tool-response-handler.service';
|
|
260
260
|
import { NoopsEntityComputedFieldProviderService } from './services/computed-fields/entity/noops-entity-computed-field-provider.service';
|
|
261
261
|
import { AlphaNumExternalIdComputationProvider } from './services/computed-fields/entity/alpha-num-external-id-computed-field-provider';
|
|
262
|
+
import { MailFactory } from './factories/mail.factory';
|
|
262
263
|
|
|
263
264
|
|
|
264
265
|
@Global()
|
|
@@ -436,10 +437,10 @@ import { AlphaNumExternalIdComputationProvider } from './services/computed-field
|
|
|
436
437
|
TriggerMcpClientPublisherDatabase,
|
|
437
438
|
TriggerMcpClientSubscriberDatabase,
|
|
438
439
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
SmtpEmailQueuePublisherRabbitmq,
|
|
441
|
+
SmtpEmailQueueSubscriberRabbitmq,
|
|
442
|
+
SmtpEmailQueuePublisherDatabase,
|
|
443
|
+
SmtpEmailQueueSubscriberDatabase,
|
|
443
444
|
ApiEmailQueuePublisher,
|
|
444
445
|
ApiEmailQueueSubscriber,
|
|
445
446
|
ApiEmailQueuePublisherDatabase,
|
|
@@ -548,6 +549,7 @@ import { AlphaNumExternalIdComputationProvider } from './services/computed-field
|
|
|
548
549
|
ViewMetadataRepository,
|
|
549
550
|
SolidCreateModelLayoutMcpToolResponseHandler,
|
|
550
551
|
AlphaNumExternalIdComputationProvider,
|
|
552
|
+
MailFactory,
|
|
551
553
|
],
|
|
552
554
|
exports: [
|
|
553
555
|
ModuleMetadataService,
|
|
@@ -586,7 +588,10 @@ import { AlphaNumExternalIdComputationProvider } from './services/computed-field
|
|
|
586
588
|
SolidIntrospectService,
|
|
587
589
|
ImportTransactionService,
|
|
588
590
|
HttpModule,
|
|
589
|
-
ListOfValuesService
|
|
591
|
+
ListOfValuesService,
|
|
592
|
+
ConfigModule,
|
|
593
|
+
PublisherFactory,
|
|
594
|
+
MailFactory,
|
|
590
595
|
],
|
|
591
596
|
})
|
|
592
597
|
export class SolidCoreModule { }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-publisher-database.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/database/email-publisher-database.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,qBACa,2BAA4B,SAAQ,iBAAiB,CAAC,GAAG,CAAC;IAE/D,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IACrD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;gBAD5C,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB;IAKnE,OAAO,IAAI,mBAAmB;CAKjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-publisher-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/email-publisher-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,kGAA8D;AAC9D,sFAA8E;AAC9E,0EAAmE;AAEnE,iGAAmF;AAG5E,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,8CAAsB;IACnE,YACuB,gBAAkC,EAClC,qBAA4C;QAE/D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAH5B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGnE,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,sCAAgB;SACtB,CAAA;IACL,CAAC;CACJ,CAAA;AAbY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAGgC,qCAAgB;QACX,gDAAqB;GAH1D,2BAA2B,CAavC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport mailQueueOptions from './email-queue-options-database';\nimport { MqMessageQueueService } from 'src/services/mq-message-queue.service';\nimport { MqMessageService } from 'src/services/mq-message.service';\nimport { QueuesModuleOptions } from 'src/interfaces';\nimport { DatabasePublisher } from 'src/services/queues/database-publisher.service';\n\n@Injectable()\nexport class EmailQueuePublisherDatabase extends DatabasePublisher<any> {\n constructor(\n protected readonly mqMessageService: MqMessageService,\n protected readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...mailQueueOptions\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-queue-options-database.d.ts","sourceRoot":"","sources":["../../../src/jobs/database/email-queue-options-database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;;;;;;AAK5C,wBAIE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-queue-options-database.js","sourceRoot":"","sources":["../../../src/jobs/database/email-queue-options-database.ts"],"names":[],"mappings":";;AAAA,iDAA4C;AAG5C,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAElD,kBAAe;IACX,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,uBAAU,CAAC,QAAQ;IACzB,SAAS,EAAE,eAAe;CAC7B,CAAC","sourcesContent":["import { BrokerType } from \"src/interfaces\";\n\n\nconst MAIL_QUEUE_NAME = 'solid_email_db_queue_v3';\n\nexport default {\n name: 'solidEmailInstance',\n type: BrokerType.Database,\n queueName: MAIL_QUEUE_NAME,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-subscriber-database.service.d.ts","sourceRoot":"","sources":["../../../src/jobs/database/email-subscriber-database.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,qBACa,4BAA6B,SAAQ,kBAAkB,CAAC,GAAG,CAAC;IAEjE,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;gBAFpC,YAAY,EAAE,gBAAgB,EACtC,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB;IAKzD,OAAO,IAAI,mBAAmB;IAM9B,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC;CAGvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-subscriber-database.service.js","sourceRoot":"","sources":["../../../src/jobs/database/email-subscriber-database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,kGAA8D;AAE9D,0EAAmE;AACnE,sFAA8E;AAC9E,mGAAqF;AACrF,2EAAsE;AAI/D,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,gDAAuB;IACrE,YACqB,YAA8B,EACtC,gBAAkC,EAClC,qBAA4C;QAErD,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAJ9B,iBAAY,GAAZ,YAAY,CAAkB;QACtC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGzD,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,sCAAgB;SACtB,CAAA;IACL,CAAC;IAED,SAAS,CAAC,OAA0B;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;CACJ,CAAA;AAlBY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,mBAAU,GAAE;qCAG0B,mCAAgB;QACpB,qCAAgB;QACX,gDAAqB;GAJhD,4BAA4B,CAkBxC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport mailQueueOptions from './email-queue-options-database';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { MqMessageService } from 'src/services/mq-message.service';\nimport { MqMessageQueueService } from 'src/services/mq-message-queue.service';\nimport { DatabaseSubscriber } from 'src/services/queues/database-subscriber.service';\nimport { SMTPEMailService } from 'src/services/mail/SMTPEmailService';\nimport { QueuesModuleOptions } from 'src/interfaces';\n\n@Injectable()\nexport class EmailQueueSubscriberDatabase extends DatabaseSubscriber<any> {\n constructor(\n private readonly emailService: SMTPEMailService,\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...mailQueueOptions\n }\n }\n\n subscribe(message: QueueMessage<any>) {\n return this.emailService.sendEmailSynchronously(message);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-publisher.service.d.ts","sourceRoot":"","sources":["../../src/jobs/email-publisher.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,qBACa,mBAAoB,SAAQ,iBAAiB,CAAC,GAAG,CAAC;IAEvD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IACrD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;gBAD5C,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB;IAKnE,OAAO,IAAI,mBAAmB;CAKjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-publisher.service.js","sourceRoot":"","sources":["../../src/jobs/email-publisher.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,8FAAmF;AACnF,gFAAqD;AACrD,mFAA8E;AAC9E,uEAAmE;AAI5D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,8CAAsB;IAC3D,YACuB,gBAAkC,EAClC,qBAA4C;QAE/D,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAH5B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGnE,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,6BAAgB;SACtB,CAAA;IACL,CAAC;CACJ,CAAA;AAbY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAGgC,qCAAgB;QACX,gDAAqB;GAH1D,mBAAmB,CAa/B","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport { RabbitMqPublisher } from 'src/services/queues/rabbitmq-publisher.service';\nimport mailQueueOptions from './email-queue-options';\nimport { MqMessageQueueService } from 'src/services/mq-message-queue.service';\nimport { MqMessageService } from 'src/services/mq-message.service';\nimport { QueuesModuleOptions } from \"../interfaces\";\n\n@Injectable()\nexport class EmailQueuePublisher extends RabbitMqPublisher<any> {\n constructor(\n protected readonly mqMessageService: MqMessageService,\n protected readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...mailQueueOptions\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-queue-options.d.ts","sourceRoot":"","sources":["../../src/jobs/email-queue-options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;;;;;AAI3C,wBAQE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-queue-options.js","sourceRoot":"","sources":["../../src/jobs/email-queue-options.ts"],"names":[],"mappings":";;AACA,8CAA2C;AAE3C,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,kBAAe;IACX,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,uBAAU,CAAC,QAAQ;IACzB,SAAS,EAAE,eAAe;CAK7B,CAAC","sourcesContent":["import { QueueMessage } from 'src/interfaces/mq';\nimport { BrokerType } from \"../interfaces\";\n\nconst MAIL_QUEUE_NAME = 'solid_email_queue_v3';\n\nexport default {\n name: 'solidEmailInstance',\n type: BrokerType.RabbitMQ,\n queueName: MAIL_QUEUE_NAME,\n // receive: async (message: QueueMessage<any>) => { // Default receive handler\n // console.log(`Received message: ${JSON.stringify(message)} from queue ${MAIL_QUEUE_NAME}`);\n // return 'Received';\n // },\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-subscriber.service.d.ts","sourceRoot":"","sources":["../../src/jobs/email-subscriber.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,qBACa,oBAAqB,SAAQ,kBAAkB,CAAC,GAAG,CAAC;IAEzD,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB;gBAFpC,YAAY,EAAE,gBAAgB,EACtC,gBAAgB,EAAE,gBAAgB,EAClC,qBAAqB,EAAE,qBAAqB;IAKzD,OAAO,IAAI,mBAAmB;IAM9B,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC;CAGvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-subscriber.service.js","sourceRoot":"","sources":["../../src/jobs/email-subscriber.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,gFAAqD;AACrD,gGAAqF;AAErF,wEAAqE;AACrE,uEAAmE;AACnE,mFAA8E;AAIvE,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,gDAAuB;IAC7D,YACqB,YAA8B,EACtC,gBAAkC,EAClC,qBAA4C;QAErD,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;QAJ9B,iBAAY,GAAZ,YAAY,CAAkB;QACtC,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAGzD,CAAC;IAED,OAAO;QACH,OAAO;YACH,GAAG,6BAAgB;SACtB,CAAA;IACL,CAAC;IAED,SAAS,CAAC,OAA0B;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;CACJ,CAAA;AAlBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAG0B,mCAAgB;QACpB,qCAAgB;QACX,gDAAqB;GAJhD,oBAAoB,CAkBhC","sourcesContent":["import { Injectable } from '@nestjs/common';\n\nimport mailQueueOptions from './email-queue-options';\nimport { RabbitMqSubscriber } from 'src/services/queues/rabbitmq-subscriber.service';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { SMTPEMailService } from '../services/mail/SMTPEmailService';\nimport { MqMessageService } from 'src/services/mq-message.service';\nimport { MqMessageQueueService } from 'src/services/mq-message-queue.service';\nimport { QueuesModuleOptions } from \"../interfaces\";\n\n@Injectable()\nexport class EmailQueueSubscriber extends RabbitMqSubscriber<any> {\n constructor(\n private readonly emailService: SMTPEMailService,\n readonly mqMessageService: MqMessageService,\n readonly mqMessageQueueService: MqMessageQueueService,\n ) {\n super(mqMessageService, mqMessageQueueService);\n }\n\n options(): QueuesModuleOptions {\n return {\n ...mailQueueOptions\n }\n }\n\n subscribe(message: QueueMessage<any>) {\n return this.emailService.sendEmailSynchronously(message);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ElasticEmailService.d.ts","sourceRoot":"","sources":["../../../src/services/mail/ElasticEmailService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAkB,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAIvE,qBACa,mBAAoB,YAAW,KAAK;IAMzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAEpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAVhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAIN,mBAAmB,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,EAEpD,gBAAgB,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,CAAC,QAAQ,CAAC;YACrD,MAAM,EAAE,UAAU,CAAC,QAAQ;SAC9B,CAAA;IACL,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,sBAA8B,EAAE,cAAmB;QAChF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAA;QACxE,MAAM,YAAY,GAAG,oBAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAnKY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,uBAAY,CAAC,GAAG,CAAC,CAAA;6CAGU,4CAAgB;QACZ,6CAAoB;QAC9B,wBAAU;QACT,0BAAW;GAXpC,mBAAmB,CAmK/B","sourcesContent":["import { Inject, Injectable, Logger } from '@nestjs/common';\nimport { ConfigType } from '@nestjs/config';\nimport Handlebars from \"handlebars\";\nimport commonConfig from 'src/config/common.config';\nimport { EmailAttachment } from 'src/entities/email-attachment.entity';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport { EmailTemplateService } from '../email-template.service';\nimport { PdfService } from '../pdf.service';\nimport { FileService } from '../file.service';\nimport { IMail, MailAttachment, MailAttachmentWrapper } from \"../../interfaces\";\nimport { PublisherFactory } from '../queues/publisher-factory.service';\n\nconst ElasticEmail = require('@elasticemail/elasticemail-client');\n\n@Injectable()\nexport class ElasticEmailService implements IMail {\n private readonly logger = new Logger(ElasticEmailService.name);\n private readonly emailsApi;\n\n constructor(\n @Inject(commonConfig.KEY)\n private readonly commonConfiguration: ConfigType<typeof commonConfig>,\n // private readonly emailPublisher: ApiEmailQueuePublisher,\n private readonly publisherFactory: PublisherFactory<any>,\n private readonly emailTemplateService: EmailTemplateService,\n private readonly pdfService: PdfService,\n private readonly fileService: FileService,\n ) {\n const client = ElasticEmail.ApiClient.instance;\n const apikey = client.authentications['apikey'];\n apikey.apiKey = commonConfiguration.apiMail.key;\n this.emailsApi = new ElasticEmail.EmailsApi();\n }\n\n async sendEmailUsingTemplate(to: string, templateName: string, templateParams: any, shouldQueueEmails = false, parentEntity = null, parentEntityId = null): Promise<void> {\n // Load template and evaluate it. \n const emailTemplate = await this.emailTemplateService.findOneByName(templateName, { attachments: true });\n if (!emailTemplate) {\n throw new Error(`Invalid template name ${templateName}`);\n }\n\n // Evaluate the body template.\n const bodyTemplate = Handlebars.compile(emailTemplate.body);\n const body = bodyTemplate(templateParams);\n\n // Evaluate the subject template \n const subjectTemplate = Handlebars.compile(emailTemplate.subject);\n const subject = subjectTemplate(templateParams);\n\n // Populate the email with the template.\n const emailTemplateAttachments = emailTemplate.attachments;\n const attachmentWrappers: MailAttachmentWrapper[] = [];\n for (const attachment of emailTemplateAttachments) {\n const attachmentWrapper = await this.toAttachmentWrapper(attachment, templateParams);\n attachmentWrappers.push(attachmentWrapper);\n }\n\n // Finally send the email.\n await this.sendEmail(to, subject, body, shouldQueueEmails, parentEntity, parentEntityId, attachmentWrappers);\n }\n\n async sendEmail(to: string, subject: string, body: string, shouldQueueEmails = false, parentEntity = null, parentEntityId = null, wrapperAttachments: MailAttachmentWrapper[] = []): Promise<void> {\n const message = {\n payload: {\n from: this.commonConfiguration.smtpMail.from,\n to: to,\n subject: subject,\n body: body,\n wrapperAttachments: wrapperAttachments,\n },\n parentEntity: parentEntity,\n parentEntityId: parentEntityId,\n };\n\n // Send using queue if the developer has explicitly invoked with true.\n if (shouldQueueEmails === true) {\n this.sendEmailAsynchronously(message);\n }\n // If developer has not, however system config mandates that we send using queue, still we send.\n else if (shouldQueueEmails == false && this.commonConfiguration.shouldQueueEmails === true) {\n this.sendEmailAsynchronously(message);\n }\n // Else we send synch\n else {\n await this.sendEmailSynchronously(message);\n }\n }\n\n async sendEmailAsynchronously(message: QueueMessage<any>) {\n const { to, subject, body } = message.payload;\n // this.notificationPublisherService.publish(message);\n // this.emailPublisher.publish(message);\n this.publisherFactory.publish(message, 'ApiEmailQueuePublisher');\n this.logger.debug(`Queueing email to ${to} with subject ${subject} and body ${body}`);\n }\n\n async sendEmailSynchronously(message: QueueMessage<any>): Promise<void> {\n const { from, to, subject, body, wrapperAttachments }: { from: string, to: string, subject: string, body: string, wrapperAttachments: MailAttachmentWrapper[] } = message.payload;\n const emailData = {\n Recipients: {\n To: [to]\n },\n Content: {\n Body: [\n {\n ContentType: \"HTML\", //ContentType Text version is handled by elastic email automatically through a config setting\n Charset: \"utf-8\",\n Content: body\n }\n ],\n From: from,\n Subject: subject\n }\n };\n\n // Handle relative attachments i.e attachments that are uploaded to the email service.\n const relativeAttachments = wrapperAttachments.filter(wrapperAttachment => wrapperAttachment.relativePath);\n if (relativeAttachments.length > 0) {\n emailData.Content['AttachFiles'] = relativeAttachments.map(attachment => attachment.relativePath);\n }\n\n const binaryAttachments = wrapperAttachments.filter(wrapperAttachment => wrapperAttachment.attachment);\n if (binaryAttachments.length > 0) {\n //FIXME Replace this with actual attachment.\n // const dummyAttachmentBuffer = await this.dummyAttachment();\n // emailData.Content['Attachments'] = [{\n // \"BinaryContent\": dummyAttachmentBuffer.toString('base64'),\n // \"Name\": \"Invoice.pdf\", \n // }];\n const attachments = [];\n for (const wrapperAttachment of binaryAttachments) {\n const attachment = await this.toMessageAttachment(wrapperAttachment.attachment, wrapperAttachment.attachment.templateParams);\n attachments.push(attachment);\n }\n emailData.Content['Attachments'] = attachments;\n }\n\n const callback = (error, _data, _response) => {\n if (error) {\n this.logger.debug(`Error while sending email to ${to} with subject ${subject}`, error);\n } else {\n this.logger.debug(`Sending email to ${to} with subject ${subject}`);\n }\n };\n\n this.emailsApi.emailsTransactionalPost(emailData, callback);\n }\n\n private async toAttachmentWrapper(attachment: EmailAttachment, templateParams: any): Promise<MailAttachmentWrapper> {\n const attachmentWrapper: MailAttachmentWrapper = {}\n if (attachment.template) {\n attachmentWrapper.attachment = {\n filename: attachment.displayName,\n templatePath: attachment.template,\n templateParams: templateParams,\n }\n } else {\n attachmentWrapper.relativePath = attachment.relativePath\n }\n return attachmentWrapper;\n }\n\n private async toMessageAttachment(attachment: MailAttachment, templateParams: any): Promise<any> {\n const attachmentContent = await this.getAttachmentAsPDF(attachment.templatePath, templateParams);\n return {\n \"BinaryContent\": attachmentContent.toString('base64'),\n \"Name\": attachment.filename,\n }\n }\n\n private async getAttachmentAsPDF(attachmentTemplatePath: string, templateParams: any): Promise<Buffer> {\n const template = await this.fileService.readFile(attachmentTemplatePath)\n const bodyTemplate = Handlebars.compile(template);\n const html = bodyTemplate(templateParams);\n const pdfBuffer = await this.pdfService.generatePdf(html);\n const buffer = Buffer.from(pdfBuffer);\n return buffer;\n }\n}"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SMTPEmailService.d.ts","sourceRoot":"","sources":["../../../src/services/mail/SMTPEmailService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAIvE,qBACa,gBAAiB,YAAW,KAAK;IAMtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAGpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IATzC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able, Logger } from '@nestjs/common';\nimport { ConfigType } from '@nestjs/config';\nimport { QueueMessage } from 'src/interfaces/mq';\nimport commonConfig from 'src/config/common.config';\nimport { EmailTemplateService } from '../email-template.service';\nimport Handlebars from \"handlebars\";\nimport { IMail, MailAttachment } from \"../../interfaces\";\nimport { PublisherFactory } from '../queues/publisher-factory.service';\n\nconst nodemailer = require(\"nodemailer\");\n\n@Injectable()\nexport class SMTPEMailService implements IMail {\n private readonly logger = new Logger(SMTPEMailService.name);\n private readonly transporter: any;\n\n constructor(\n @Inject(commonConfig.KEY)\n private readonly commonConfiguration: ConfigType<typeof commonConfig>,\n // private readonly emailPublisher: EmailQueuePublisher,\n // private readonly emailDbPublisher: EmailQueueDbPublisher,\n private readonly publisherFactory: PublisherFactory<any>,\n private readonly emailTemplateService: EmailTemplateService,\n ) {\n this.transporter = nodemailer.createTransport({\n host: this.commonConfiguration.smtpMail.host,\n port: this.commonConfiguration.smtpMail.port,\n secure: this.commonConfiguration.smtpMail.port === 465,\n auth: {\n user: this.commonConfiguration.smtpMail.username,\n pass: this.commonConfiguration.smtpMail.password\n }\n });\n }\n\n async sendEmailUsingTemplate(to: string, templateName: string, templateParams: any, shouldQueueEmails = false, parentEntity = null, parentEntityId = null, attachments: MailAttachment[] = [], cc: string[] = []): Promise<void> {\n // Load template and evaluate it. \n const emailTemplate = await this.emailTemplateService.findOneByName(templateName);\n if (!emailTemplate) {\n throw new Error(`Invalid template name ${templateName}`);\n }\n\n // Evaluate the body template.\n const bodyTemplate = Handlebars.compile(emailTemplate.body);\n const body = bodyTemplate(templateParams);\n\n // Evaluate the subject template \n const subjectTemplate = Handlebars.compile(emailTemplate.subject);\n const subject = subjectTemplate(templateParams);\n\n // Finally send the email.\n await this.sendEmail(to, subject, body, shouldQueueEmails, parentEntity, parentEntityId, attachments);\n }\n\n async sendEmail(to: string, subject: string, body: string, shouldQueueEmails = false, parentEntity = null, parentEntityId = null, attachments: MailAttachment[] = [], cc: string[] = []): Promise<void> {\n const message = {\n payload: {\n from: this.commonConfiguration.smtpMail.from,\n to: to,\n subject: subject,\n body: body,\n attachments: attachments,\n cc: cc,\n },\n parentEntity: parentEntity,\n parentEntityId: parentEntityId,\n };\n\n // Send using queue if the developer has explicitly invoked with true.\n if (shouldQueueEmails === true) {\n this.sendEmailAsynchronously(message);\n }\n // If developer has not, however system config mandates that we send using queue, still we send.\n else if (shouldQueueEmails == false && this.commonConfiguration.shouldQueueEmails === true) {\n this.sendEmailAsynchronously(message);\n }\n // Else we send synch\n else {\n await this.sendEmailSynchronously(message);\n }\n }\n\n async sendEmailAsynchronously(message) {\n const { to, subject, body } = message.payload;\n // this.notificationPublisherService.publish(message);\n // this.emailPublisher.publish(message);\n // this.emailDbPublisher.publish(message);\n\n this.publisherFactory.publish(message, 'EmailQueuePublisher');\n\n this.logger.debug(`Queueing email to ${to} with subject ${subject} and body ${body}`);\n }\n\n async sendEmailSynchronously(message: QueueMessage<any>): Promise<void> {\n const { from, to, subject, body, attachments, cc } = message.payload;\n\n const attachmentsList = attachments.map((attachment: MailAttachment) => {\n const attachmentEntry = {\n filename: attachment.filename,\n contentType: attachment.contentType,\n }\n if (attachment.path) {\n attachmentEntry['path'] = attachment.path;\n }\n if (attachment.content) {\n attachmentEntry['content'] = attachment.content;\n }\n return attachmentEntry;\n });\n\n // throw new Error('Random error....');\n const r = await this.transporter.sendMail({\n from: from,\n to: to,\n cc: cc,\n subject: subject,\n html: body,\n attachments: attachmentsList,\n });\n // this.logger.debug(`Sending email to ${to} with subject ${subject} and body ${body}`);\n this.logger.debug(`Sending email to ${to} with subject ${subject}`);\n\n return r;\n }\n}"]}
|
/package/src/jobs/database/{email-queue-options-database.ts → smtp-email-queue-options-database.ts}
RENAMED
|
File without changes
|
|
File without changes
|