@punks/backend-entity-manager 0.0.41 → 0.0.42

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.
@@ -2,6 +2,7 @@ import { HtmlEmailInput, IEmailProvider, IEmailTemplate, TemplatedEmailInput } f
2
2
  import { SendgridEmailTemplateData } from "../../abstractions";
3
3
  export declare class SendgridEmailProvider implements IEmailProvider<SendgridEmailTemplateData> {
4
4
  private readonly client;
5
+ private readonly logger;
5
6
  constructor();
6
7
  sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<SendgridEmailTemplateData, TPayload, TAugmentedPayload>): Promise<void>;
7
8
  sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>): Promise<void>;
@@ -5,5 +5,6 @@ export type SendgridSettings = {
5
5
  defaultReplyTo?: string;
6
6
  defaultCc?: string[];
7
7
  defaultBcc?: string[];
8
+ loggingEnabled?: boolean;
8
9
  };
9
10
  export declare const sendgridSettings: AppInMemorySettings<SendgridSettings>;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { applyDecorators, Injectable, SetMetadata, Global, Module, Scope, Logger, HttpStatus, HttpException } from '@nestjs/common';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
  import { hash } from 'bcrypt';
4
- import { Log, toDict, newUuid as newUuid$1 } from '@punks/backend-core';
4
+ import { Log, toDict, newUuid as newUuid$1, removeUndefinedProps } from '@punks/backend-core';
5
5
  import { PATH_METADATA } from '@nestjs/common/constants';
6
6
  import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
7
7
  import { MetadataScanner } from '@nestjs/core/metadata-scanner';
@@ -25009,6 +25009,7 @@ const sendgridSettings = new AppInMemorySettings();
25009
25009
 
25010
25010
  let SendgridEmailProvider = class SendgridEmailProvider {
25011
25011
  constructor() {
25012
+ this.logger = Log.getLogger("Sendgrid");
25012
25013
  this.client = new MailService();
25013
25014
  this.client.setApiKey(sendgridSettings.value.apiKey);
25014
25015
  }
@@ -25035,7 +25036,7 @@ let SendgridEmailProvider = class SendgridEmailProvider {
25035
25036
  });
25036
25037
  return;
25037
25038
  }
25038
- await this.client.send({
25039
+ const request = removeUndefinedProps({
25039
25040
  from: input.from ?? templateData.from ?? sendgridSettings.value.defaultSender,
25040
25041
  cc: [
25041
25042
  ...(input.cc ?? templateData.cc ?? []),
@@ -25057,9 +25058,16 @@ let SendgridEmailProvider = class SendgridEmailProvider {
25057
25058
  },
25058
25059
  templateId: templateData.sendgridTemplateId,
25059
25060
  });
25061
+ if (sendgridSettings.value.loggingEnabled) {
25062
+ this.logger.info("Sending templated email", request);
25063
+ }
25064
+ await this.client.send(request);
25065
+ if (sendgridSettings.value.loggingEnabled) {
25066
+ this.logger.info("Templated email sent", request);
25067
+ }
25060
25068
  }
25061
25069
  async sendHtmlEmail(input) {
25062
- await this.client.send({
25070
+ const request = removeUndefinedProps({
25063
25071
  from: input.from ?? sendgridSettings.value.defaultSender,
25064
25072
  cc: input.cc,
25065
25073
  bcc: [...(input.bcc ?? []), ...(sendgridSettings.value.defaultBcc ?? [])],
@@ -25073,6 +25081,13 @@ let SendgridEmailProvider = class SendgridEmailProvider {
25073
25081
  }),
25074
25082
  replyTo: input.replyTo ?? sendgridSettings.value.defaultReplyTo,
25075
25083
  });
25084
+ if (sendgridSettings.value.loggingEnabled) {
25085
+ this.logger.info("Sending html email", request);
25086
+ }
25087
+ await this.client.send(request);
25088
+ if (sendgridSettings.value.loggingEnabled) {
25089
+ this.logger.info("Html email sent", request);
25090
+ }
25076
25091
  }
25077
25092
  };
25078
25093
  SendgridEmailProvider = __decorate([