@punks/backend-entity-manager 0.0.464 → 0.0.465
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/cjs/index.js +33 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/email.d.ts +6 -2
- package/dist/cjs/types/platforms/nest/plugins/email/aws-ses/provider/email/index.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/plugins/email/sendgrid/provider/email/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/plugins/email/testing/mock.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/services/email/index.d.ts +3 -3
- package/dist/esm/index.js +33 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/email.d.ts +6 -2
- package/dist/esm/types/platforms/nest/plugins/email/aws-ses/provider/email/index.d.ts +3 -3
- package/dist/esm/types/platforms/nest/plugins/email/sendgrid/provider/email/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/plugins/email/testing/mock.d.ts +2 -2
- package/dist/esm/types/platforms/nest/services/email/index.d.ts +3 -3
- package/dist/index.d.ts +10 -6
- package/package.json +1 -1
|
@@ -40,9 +40,13 @@ export interface HtmlEmailInput<TPayload> {
|
|
|
40
40
|
payload: TPayload;
|
|
41
41
|
attachments?: EmailAttachmentData[];
|
|
42
42
|
}
|
|
43
|
+
export type EmailSendOptions = {
|
|
44
|
+
sandboxMode?: boolean;
|
|
45
|
+
forceDelivery?: boolean;
|
|
46
|
+
};
|
|
43
47
|
export interface IEmailProvider<TTemplateData> {
|
|
44
|
-
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<TTemplateData, TPayload, TAugmentedPayload
|
|
45
|
-
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload
|
|
48
|
+
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<TTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
|
|
49
|
+
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
|
|
46
50
|
}
|
|
47
51
|
export interface IEmailLogger {
|
|
48
52
|
logTemplatedEmail<TPayload>(input: TemplatedEmailInput<TPayload>): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../../../abstractions";
|
|
1
|
+
import { EmailSendOptions, HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../../../abstractions";
|
|
2
2
|
import { AwsSesEmailTemplateData } from "../../abstractions";
|
|
3
3
|
export declare class AwsSesEmailProvider implements IEmailProvider<AwsSesEmailTemplateData> {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor();
|
|
6
|
-
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<AwsSesEmailTemplateData, TPayload, TAugmentedPayload
|
|
7
|
-
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload
|
|
6
|
+
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<AwsSesEmailTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
|
|
7
|
+
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../../../abstractions";
|
|
1
|
+
import { EmailSendOptions, HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../../../abstractions";
|
|
2
2
|
import { SendgridEmailTemplateData } from "../../abstractions";
|
|
3
3
|
import { EventsService } from "../../../../../services";
|
|
4
4
|
export declare class SendgridEmailProvider implements IEmailProvider<SendgridEmailTemplateData> {
|
|
@@ -6,6 +6,6 @@ export declare class SendgridEmailProvider implements IEmailProvider<SendgridEma
|
|
|
6
6
|
private readonly client;
|
|
7
7
|
private readonly logger;
|
|
8
8
|
constructor(eventsService: EventsService);
|
|
9
|
-
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<SendgridEmailTemplateData, TPayload, TAugmentedPayload
|
|
9
|
+
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<SendgridEmailTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
|
|
10
10
|
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>): Promise<void>;
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../abstractions";
|
|
1
|
+
import { EmailSendOptions, HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } from "../../../../../abstractions";
|
|
2
2
|
type SentEmail = {
|
|
3
3
|
input: TemplatedEmailInput<unknown>;
|
|
4
4
|
template: IEmailTemplate<void, unknown, unknown>;
|
|
@@ -9,7 +9,7 @@ type SentEmail = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare class InMemoryEmailProvider implements IEmailProvider<void> {
|
|
11
11
|
private readonly sentEmails;
|
|
12
|
-
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<void, TPayload, TAugmentedPayload
|
|
12
|
+
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<void, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
|
|
13
13
|
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>): Promise<void>;
|
|
14
14
|
getSentEmails(): SentEmail[];
|
|
15
15
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EntityManagerRegistry } from "../../ioc";
|
|
2
|
-
import { HtmlEmailInput, TemplatedEmailInput } from "../../../../abstractions";
|
|
2
|
+
import { EmailSendOptions, HtmlEmailInput, TemplatedEmailInput } from "../../../../abstractions";
|
|
3
3
|
export declare class EmailService {
|
|
4
4
|
private readonly registry;
|
|
5
5
|
constructor(registry: EntityManagerRegistry);
|
|
6
|
-
sendTemplatedEmail<TPayload>(input: TemplatedEmailInput<TPayload
|
|
7
|
-
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload
|
|
6
|
+
sendTemplatedEmail<TPayload>(input: TemplatedEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
|
|
7
|
+
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
|
|
8
8
|
private getTemplate;
|
|
9
9
|
private get templateMiddleware();
|
|
10
10
|
private get templates();
|
package/dist/esm/index.js
CHANGED
|
@@ -22778,7 +22778,7 @@ let EmailService = class EmailService {
|
|
|
22778
22778
|
constructor(registry) {
|
|
22779
22779
|
this.registry = registry;
|
|
22780
22780
|
}
|
|
22781
|
-
async sendTemplatedEmail(input) {
|
|
22781
|
+
async sendTemplatedEmail(input, options) {
|
|
22782
22782
|
const template = this.getTemplate(input.templateId);
|
|
22783
22783
|
const transformedPayload = (await this.templateMiddleware?.processPayload(input.payload)) ??
|
|
22784
22784
|
input.payload;
|
|
@@ -22791,11 +22791,11 @@ let EmailService = class EmailService {
|
|
|
22791
22791
|
...transformedInput,
|
|
22792
22792
|
...normalizeAddresses(transformedInput),
|
|
22793
22793
|
};
|
|
22794
|
-
await this.provider.sendTemplatedEmail(normalizedInput, template);
|
|
22794
|
+
await this.provider.sendTemplatedEmail(normalizedInput, template, options);
|
|
22795
22795
|
await this.logger.logTemplatedEmail(normalizedInput);
|
|
22796
22796
|
}
|
|
22797
|
-
async sendHtmlEmail(input) {
|
|
22798
|
-
await this.provider.sendHtmlEmail(input);
|
|
22797
|
+
async sendHtmlEmail(input, options) {
|
|
22798
|
+
await this.provider.sendHtmlEmail(input, options);
|
|
22799
22799
|
await this.logger.logHtmlEmail(input);
|
|
22800
22800
|
}
|
|
22801
22801
|
getTemplate(templateId) {
|
|
@@ -41139,7 +41139,7 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
|
|
|
41139
41139
|
constructor() {
|
|
41140
41140
|
this.client = createClient$2(awsSesSettings.value);
|
|
41141
41141
|
}
|
|
41142
|
-
async sendTemplatedEmail(input, template) {
|
|
41142
|
+
async sendTemplatedEmail(input, template, options) {
|
|
41143
41143
|
const processedPayload = await template.processPayload(input.payload);
|
|
41144
41144
|
const templateData = await template.getTemplateData(processedPayload);
|
|
41145
41145
|
await this.sendHtmlEmail({
|
|
@@ -41153,7 +41153,7 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
|
|
|
41153
41153
|
attachments: input.attachments,
|
|
41154
41154
|
});
|
|
41155
41155
|
}
|
|
41156
|
-
async sendHtmlEmail(input) {
|
|
41156
|
+
async sendHtmlEmail(input, options) {
|
|
41157
41157
|
await this.client.send(new SendEmailCommand({
|
|
41158
41158
|
Source: input.from ?? input.from ?? awsSesSettings.value.defaultSender,
|
|
41159
41159
|
Destination: {
|
|
@@ -41238,7 +41238,7 @@ let SendgridEmailProvider = class SendgridEmailProvider {
|
|
|
41238
41238
|
this.client = new MailService();
|
|
41239
41239
|
this.client.setApiKey(sendgridSettings.value.apiKey);
|
|
41240
41240
|
}
|
|
41241
|
-
async sendTemplatedEmail(input, template) {
|
|
41241
|
+
async sendTemplatedEmail(input, template, options) {
|
|
41242
41242
|
if (!input.to?.length && !input.cc?.length && !input.bcc?.length) {
|
|
41243
41243
|
throw new Error(`No recipient specified for email ${input.templateId}`);
|
|
41244
41244
|
}
|
|
@@ -41293,6 +41293,31 @@ let SendgridEmailProvider = class SendgridEmailProvider {
|
|
|
41293
41293
|
? attachment.content.toString("base64")
|
|
41294
41294
|
: attachment.content,
|
|
41295
41295
|
})),
|
|
41296
|
+
mailSettings: {
|
|
41297
|
+
...(options?.sandboxMode
|
|
41298
|
+
? {
|
|
41299
|
+
sandboxMode: {
|
|
41300
|
+
enable: options.sandboxMode,
|
|
41301
|
+
},
|
|
41302
|
+
}
|
|
41303
|
+
: {}),
|
|
41304
|
+
...(options?.forceDelivery
|
|
41305
|
+
? {
|
|
41306
|
+
bypassListManagement: {
|
|
41307
|
+
enable: options.forceDelivery,
|
|
41308
|
+
},
|
|
41309
|
+
bypassBounceManagement: {
|
|
41310
|
+
enable: options.forceDelivery,
|
|
41311
|
+
},
|
|
41312
|
+
bypassUnsubscribeManagement: {
|
|
41313
|
+
enable: options.forceDelivery,
|
|
41314
|
+
},
|
|
41315
|
+
bypassSpamManagement: {
|
|
41316
|
+
enable: options.forceDelivery,
|
|
41317
|
+
},
|
|
41318
|
+
}
|
|
41319
|
+
: {}),
|
|
41320
|
+
},
|
|
41296
41321
|
});
|
|
41297
41322
|
if (sendgridSettings.value.loggingEnabled) {
|
|
41298
41323
|
this.logger.info("Sending templated email", {
|
|
@@ -41404,7 +41429,7 @@ let InMemoryEmailProvider = class InMemoryEmailProvider {
|
|
|
41404
41429
|
constructor() {
|
|
41405
41430
|
this.sentEmails = [];
|
|
41406
41431
|
}
|
|
41407
|
-
async sendTemplatedEmail(input, template) {
|
|
41432
|
+
async sendTemplatedEmail(input, template, options) {
|
|
41408
41433
|
this.sentEmails.push({
|
|
41409
41434
|
input,
|
|
41410
41435
|
template,
|