@punks/backend-entity-manager 0.0.464 → 0.0.466
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 +60 -10
- 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 +3 -3
- package/dist/cjs/types/platforms/nest/plugins/email/sendgrid/settings/index.d.ts +2 -0
- 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 +60 -10
- 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 +3 -3
- package/dist/esm/types/platforms/nest/plugins/email/sendgrid/settings/index.d.ts +2 -0
- 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 +12 -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
|
|
10
|
-
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload
|
|
9
|
+
sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<SendgridEmailTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
|
|
10
|
+
sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): 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
|
}
|
|
@@ -41262,7 +41262,7 @@ let SendgridEmailProvider = class SendgridEmailProvider {
|
|
|
41262
41262
|
from: input.from ?? templateData.from,
|
|
41263
41263
|
to: input.to ?? templateData.to,
|
|
41264
41264
|
attachments: input.attachments,
|
|
41265
|
-
});
|
|
41265
|
+
}, options);
|
|
41266
41266
|
return;
|
|
41267
41267
|
}
|
|
41268
41268
|
const request = removeUndefinedProps({
|
|
@@ -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 || sendgridSettings.value.sandboxMode
|
|
41298
|
+
? {
|
|
41299
|
+
sandboxMode: {
|
|
41300
|
+
enable: true,
|
|
41301
|
+
},
|
|
41302
|
+
}
|
|
41303
|
+
: {}),
|
|
41304
|
+
...(options?.forceDelivery || sendgridSettings.value.forceDelivery
|
|
41305
|
+
? {
|
|
41306
|
+
bypassListManagement: {
|
|
41307
|
+
enable: true,
|
|
41308
|
+
},
|
|
41309
|
+
bypassBounceManagement: {
|
|
41310
|
+
enable: true,
|
|
41311
|
+
},
|
|
41312
|
+
bypassUnsubscribeManagement: {
|
|
41313
|
+
enable: true,
|
|
41314
|
+
},
|
|
41315
|
+
bypassSpamManagement: {
|
|
41316
|
+
enable: true,
|
|
41317
|
+
},
|
|
41318
|
+
}
|
|
41319
|
+
: {}),
|
|
41320
|
+
},
|
|
41296
41321
|
});
|
|
41297
41322
|
if (sendgridSettings.value.loggingEnabled) {
|
|
41298
41323
|
this.logger.info("Sending templated email", {
|
|
@@ -41318,7 +41343,7 @@ let SendgridEmailProvider = class SendgridEmailProvider {
|
|
|
41318
41343
|
});
|
|
41319
41344
|
}
|
|
41320
41345
|
}
|
|
41321
|
-
async sendHtmlEmail(input) {
|
|
41346
|
+
async sendHtmlEmail(input, options) {
|
|
41322
41347
|
const request = removeUndefinedProps({
|
|
41323
41348
|
from: input.from ?? sendgridSettings.value.defaultSender,
|
|
41324
41349
|
to: sanitizeArray(input.to),
|
|
@@ -41342,6 +41367,31 @@ let SendgridEmailProvider = class SendgridEmailProvider {
|
|
|
41342
41367
|
? attachment.content.toString("base64")
|
|
41343
41368
|
: attachment.content,
|
|
41344
41369
|
})),
|
|
41370
|
+
mailSettings: {
|
|
41371
|
+
...(options?.sandboxMode || sendgridSettings.value.sandboxMode
|
|
41372
|
+
? {
|
|
41373
|
+
sandboxMode: {
|
|
41374
|
+
enable: true,
|
|
41375
|
+
},
|
|
41376
|
+
}
|
|
41377
|
+
: {}),
|
|
41378
|
+
...(options?.forceDelivery || sendgridSettings.value.forceDelivery
|
|
41379
|
+
? {
|
|
41380
|
+
bypassListManagement: {
|
|
41381
|
+
enable: true,
|
|
41382
|
+
},
|
|
41383
|
+
bypassBounceManagement: {
|
|
41384
|
+
enable: true,
|
|
41385
|
+
},
|
|
41386
|
+
bypassUnsubscribeManagement: {
|
|
41387
|
+
enable: true,
|
|
41388
|
+
},
|
|
41389
|
+
bypassSpamManagement: {
|
|
41390
|
+
enable: true,
|
|
41391
|
+
},
|
|
41392
|
+
}
|
|
41393
|
+
: {}),
|
|
41394
|
+
},
|
|
41345
41395
|
});
|
|
41346
41396
|
if (sendgridSettings.value.loggingEnabled) {
|
|
41347
41397
|
this.logger.info("Sending html email", {
|
|
@@ -41404,7 +41454,7 @@ let InMemoryEmailProvider = class InMemoryEmailProvider {
|
|
|
41404
41454
|
constructor() {
|
|
41405
41455
|
this.sentEmails = [];
|
|
41406
41456
|
}
|
|
41407
|
-
async sendTemplatedEmail(input, template) {
|
|
41457
|
+
async sendTemplatedEmail(input, template, options) {
|
|
41408
41458
|
this.sentEmails.push({
|
|
41409
41459
|
input,
|
|
41410
41460
|
template,
|