@punks/backend-entity-manager 0.0.504 → 0.0.506

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.
@@ -5,4 +5,5 @@ export declare class AwsSesEmailProvider implements IEmailProvider<AwsSesEmailTe
5
5
  constructor();
6
6
  sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<AwsSesEmailTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
7
7
  sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
8
+ private invokeEmailSend;
8
9
  }
@@ -6,5 +6,7 @@ export type AwsSesSettings = {
6
6
  defaultSender: string;
7
7
  defaultCc?: string[];
8
8
  defaultBcc?: string[];
9
+ sandboxMode?: boolean;
10
+ sandboxAddresses?: string[];
9
11
  };
10
12
  export declare const awsSesSettings: AppInMemorySettings<AwsSesSettings>;
package/dist/esm/index.js CHANGED
@@ -41300,28 +41300,55 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
41300
41300
  cc: input.cc ?? templateData.cc,
41301
41301
  from: input.from ?? templateData.from,
41302
41302
  attachments: input.attachments,
41303
- });
41303
+ }, options);
41304
41304
  }
41305
41305
  async sendHtmlEmail(input, options) {
41306
+ const from = input.from || awsSesSettings.value.defaultSender;
41307
+ if (!from) {
41308
+ throw new Error("No sender address provided");
41309
+ }
41310
+ if (awsSesSettings.value.sandboxMode || options?.sandboxMode) {
41311
+ if (awsSesSettings.value.sandboxAddresses?.length) {
41312
+ await this.invokeEmailSend({
41313
+ from,
41314
+ to: awsSesSettings.value.sandboxAddresses,
41315
+ subjectTemplate: input.subjectTemplate,
41316
+ bodyTemplate: input.bodyTemplate,
41317
+ payload: input.payload,
41318
+ });
41319
+ }
41320
+ return;
41321
+ }
41322
+ await this.invokeEmailSend({
41323
+ from,
41324
+ to: input.to ?? [],
41325
+ cc: input.cc ?? awsSesSettings.value.defaultCc ?? [],
41326
+ bcc: input.bcc ?? awsSesSettings.value.defaultBcc ?? [],
41327
+ subjectTemplate: input.subjectTemplate,
41328
+ bodyTemplate: input.bodyTemplate,
41329
+ payload: input.payload,
41330
+ });
41331
+ }
41332
+ async invokeEmailSend({ from, to, cc, bcc, subjectTemplate, bodyTemplate, payload, }) {
41306
41333
  await this.client.send(new SendEmailCommand({
41307
- Source: input.from ?? input.from ?? awsSesSettings.value.defaultSender,
41334
+ Source: from,
41308
41335
  Destination: {
41309
- ToAddresses: input.to ?? input.to ?? [],
41310
- CcAddresses: input.cc ?? awsSesSettings.value.defaultCc ?? [],
41311
- BccAddresses: input.bcc ?? awsSesSettings.value.defaultBcc ?? [],
41336
+ ToAddresses: to ?? [],
41337
+ CcAddresses: cc ?? [],
41338
+ BccAddresses: bcc ?? [],
41312
41339
  },
41313
41340
  Message: {
41314
41341
  Subject: {
41315
41342
  Data: renderHandlebarsTemplate({
41316
- template: input.subjectTemplate,
41317
- context: input.payload,
41343
+ template: subjectTemplate,
41344
+ context: payload,
41318
41345
  }),
41319
41346
  },
41320
41347
  Body: {
41321
41348
  Html: {
41322
41349
  Data: renderHandlebarsTemplate({
41323
- template: input.bodyTemplate,
41324
- context: input.payload,
41350
+ template: bodyTemplate,
41351
+ context: payload,
41325
41352
  }),
41326
41353
  },
41327
41354
  },