@punks/backend-entity-manager 0.0.509 → 0.0.510
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 +82 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +64 -21
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -1
package/dist/esm/index.js
CHANGED
|
@@ -18,7 +18,8 @@ import require$$1 from 'fs';
|
|
|
18
18
|
import { ApiProperty } from '@nestjs/swagger';
|
|
19
19
|
import { ListObjectsCommand, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, CopyObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
20
20
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
21
|
-
import { SendEmailCommand, SESClient } from '@aws-sdk/client-ses';
|
|
21
|
+
import { SendEmailCommand, SendRawEmailCommand, SESClient } from '@aws-sdk/client-ses';
|
|
22
|
+
import * as nodemailer from 'nodemailer';
|
|
22
23
|
import { MailService } from '@sendgrid/mail';
|
|
23
24
|
import { BatchClient, CancelJobCommand, ListJobsCommand, PlatformCapability, SubmitJobCommand, DeregisterJobDefinitionCommand, RegisterJobDefinitionCommand, JobDefinitionType, ResourceType, AssignPublicIp, DescribeJobDefinitionsCommand, CreateJobQueueCommand, UpdateJobQueueCommand, DescribeJobQueuesCommand, JobStatus as JobStatus$1 } from '@aws-sdk/client-batch';
|
|
24
25
|
import { CloudWatchLogsClient, DescribeLogGroupsCommand, CreateLogGroupCommand } from '@aws-sdk/client-cloudwatch-logs';
|
|
@@ -41316,6 +41317,7 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
|
|
|
41316
41317
|
subjectTemplate: input.subjectTemplate,
|
|
41317
41318
|
bodyTemplate: input.bodyTemplate,
|
|
41318
41319
|
payload: input.payload,
|
|
41320
|
+
attachments: input.attachments,
|
|
41319
41321
|
});
|
|
41320
41322
|
}
|
|
41321
41323
|
return;
|
|
@@ -41328,31 +41330,72 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
|
|
|
41328
41330
|
subjectTemplate: input.subjectTemplate,
|
|
41329
41331
|
bodyTemplate: input.bodyTemplate,
|
|
41330
41332
|
payload: input.payload,
|
|
41333
|
+
attachments: input.attachments,
|
|
41331
41334
|
});
|
|
41332
41335
|
}
|
|
41333
|
-
async invokeEmailSend({ from, to, cc, bcc, subjectTemplate, bodyTemplate, payload, }) {
|
|
41334
|
-
|
|
41335
|
-
|
|
41336
|
-
|
|
41337
|
-
|
|
41338
|
-
|
|
41339
|
-
|
|
41340
|
-
|
|
41341
|
-
|
|
41342
|
-
|
|
41343
|
-
|
|
41344
|
-
|
|
41345
|
-
|
|
41346
|
-
|
|
41336
|
+
async invokeEmailSend({ from, to, cc, bcc, subjectTemplate, bodyTemplate, payload, attachments, }) {
|
|
41337
|
+
const subject = renderHandlebarsTemplate({
|
|
41338
|
+
template: subjectTemplate,
|
|
41339
|
+
context: payload,
|
|
41340
|
+
});
|
|
41341
|
+
const htmlBody = renderHandlebarsTemplate({
|
|
41342
|
+
template: bodyTemplate,
|
|
41343
|
+
context: payload,
|
|
41344
|
+
});
|
|
41345
|
+
// If no attachments, use the simpler SendEmailCommand
|
|
41346
|
+
if (!attachments || attachments.length === 0) {
|
|
41347
|
+
await this.client.send(new SendEmailCommand({
|
|
41348
|
+
Source: from,
|
|
41349
|
+
Destination: {
|
|
41350
|
+
ToAddresses: to ?? [],
|
|
41351
|
+
CcAddresses: cc ?? [],
|
|
41352
|
+
BccAddresses: bcc ?? [],
|
|
41347
41353
|
},
|
|
41348
|
-
|
|
41349
|
-
|
|
41350
|
-
Data:
|
|
41351
|
-
|
|
41352
|
-
|
|
41353
|
-
|
|
41354
|
+
Message: {
|
|
41355
|
+
Subject: {
|
|
41356
|
+
Data: subject,
|
|
41357
|
+
},
|
|
41358
|
+
Body: {
|
|
41359
|
+
Html: {
|
|
41360
|
+
Data: htmlBody,
|
|
41361
|
+
},
|
|
41354
41362
|
},
|
|
41355
41363
|
},
|
|
41364
|
+
}));
|
|
41365
|
+
return;
|
|
41366
|
+
}
|
|
41367
|
+
// // With attachments, use SendRawEmailCommand
|
|
41368
|
+
// const rawMessage = this.buildRawEmailMessage({
|
|
41369
|
+
// from,
|
|
41370
|
+
// to: to ?? [],
|
|
41371
|
+
// cc: cc ?? [],
|
|
41372
|
+
// bcc: bcc ?? [],
|
|
41373
|
+
// subject,
|
|
41374
|
+
// htmlBody,
|
|
41375
|
+
// attachments,
|
|
41376
|
+
// })
|
|
41377
|
+
const message = {
|
|
41378
|
+
from: from,
|
|
41379
|
+
to: to ?? [],
|
|
41380
|
+
cc: cc ?? [],
|
|
41381
|
+
bcc: bcc ?? [],
|
|
41382
|
+
subject: subject,
|
|
41383
|
+
html: htmlBody,
|
|
41384
|
+
attachments: attachments.map((attachment) => ({
|
|
41385
|
+
filename: attachment.filename,
|
|
41386
|
+
content: attachment.content,
|
|
41387
|
+
contentType: attachment.type,
|
|
41388
|
+
})),
|
|
41389
|
+
};
|
|
41390
|
+
const transporter = nodemailer.createTransport({
|
|
41391
|
+
streamTransport: true,
|
|
41392
|
+
newline: "unix",
|
|
41393
|
+
buffer: true,
|
|
41394
|
+
});
|
|
41395
|
+
const rawEmail = await transporter.sendMail(message);
|
|
41396
|
+
await this.client.send(new SendRawEmailCommand({
|
|
41397
|
+
RawMessage: {
|
|
41398
|
+
Data: rawEmail.message,
|
|
41356
41399
|
},
|
|
41357
41400
|
}));
|
|
41358
41401
|
}
|