@tstdl/base 0.90.26 → 0.90.27

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.
@@ -1,4 +1,5 @@
1
1
  import type { TypedOmit } from '../types.js';
2
+ import type { MailClientConfig } from './mail.client.js';
2
3
  import type { MailData, MailSendResult, MailTemplate } from './models/index.js';
3
4
  export declare class MailService {
4
5
  private readonly mailClient;
@@ -6,8 +7,8 @@ export declare class MailService {
6
7
  private readonly mailLogRepository;
7
8
  private readonly defaultData;
8
9
  private readonly logger;
9
- send(mailData: MailData): Promise<MailSendResult>;
10
+ send(mailData: MailData, clientConfig?: MailClientConfig): Promise<MailSendResult>;
10
11
  /** @deprecated internal */
11
- send(mailData: MailData, templateName?: string): Promise<MailSendResult>;
12
- sendTemplate<Context extends object>(keyOrTemplate: string | MailTemplate<Context>, mailData: TypedOmit<MailData, 'content' | 'subject'>, templateContext?: Context): Promise<MailSendResult>;
12
+ send(mailData: MailData, clientConfig?: MailClientConfig, templateName?: string): Promise<MailSendResult>;
13
+ sendTemplate<Context extends object>(keyOrTemplate: string | MailTemplate<Context>, mailData: TypedOmit<MailData, 'content' | 'subject'>, templateContext?: Context, clientConfig?: MailClientConfig): Promise<MailSendResult>;
13
14
  }
@@ -19,7 +19,9 @@ let MailService = class MailService {
19
19
  mailLogRepository = inject(MailLogRepository, undefined, { optional: true });
20
20
  defaultData = inject(MAIL_DEFAULT_DATA, undefined, { optional: true });
21
21
  logger = inject(Logger, 'MailService');
22
- async send(mailData, templateName) {
22
+ async send(mailData, clientConfigOrTemplateName, templateNameOrNothing) {
23
+ const clientConfig = (typeof clientConfigOrTemplateName == 'object') ? clientConfigOrTemplateName : undefined;
24
+ const templateName = (typeof clientConfigOrTemplateName == 'object') ? templateNameOrNothing : clientConfigOrTemplateName;
23
25
  const data = { ...this.defaultData, ...mailData };
24
26
  let mailLog;
25
27
  if (isDefined(this.mailLogRepository)) {
@@ -33,7 +35,7 @@ let MailService = class MailService {
33
35
  mailLog = await this.mailLogRepository.insert(log);
34
36
  }
35
37
  try {
36
- const result = await this.mailClient.send(data);
38
+ const result = await this.mailClient.send(data, clientConfig);
37
39
  if (isDefined(mailLog)) {
38
40
  await this.mailLogRepository.patch(mailLog, { sendResult: result });
39
41
  }
@@ -51,10 +53,10 @@ let MailService = class MailService {
51
53
  throw error;
52
54
  }
53
55
  }
54
- async sendTemplate(keyOrTemplate, mailData, templateContext) {
56
+ async sendTemplate(keyOrTemplate, mailData, templateContext, clientConfig) {
55
57
  const { name, fields: { subject, html, text } } = await this.templateService.render(keyOrTemplate, templateContext);
56
58
  const fullMailData = { ...mailData, subject, content: { html, text } };
57
- return this.send(fullMailData, name);
59
+ return this.send(fullMailData, clientConfig, name);
58
60
  }
59
61
  };
60
62
  MailService = __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.90.26",
3
+ "version": "0.90.27",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"