@moreapp/common-nodejs 0.13.3 → 0.13.5

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.
@@ -12,14 +12,16 @@ export interface Attachment {
12
12
  type MailSendResponse = {
13
13
  id: string;
14
14
  };
15
+ type LanguageCode = "nl" | "en" | "es" | "de" | "pt" | "fr" | "ca";
15
16
  export declare class MailService {
16
17
  readonly service: string;
17
18
  readonly baseUrl: string;
18
19
  readonly username: string;
19
20
  readonly password: string;
20
21
  constructor(service: string, baseUrl: string, username: string, password: string);
21
- sendTemplatedMail(emailAddress: string, template: string, language: string, customerId?: number, variables?: Record<string, unknown>): Promise<MailSendResponse | undefined>;
22
+ sendTemplatedMail(emailAddress: string, template: string, language: LanguageCode, customerId?: number, variables?: Record<string, unknown>): Promise<MailSendResponse | undefined>;
22
23
  sendRawMail(customerId: number, recipients: Recipient[], subject: string, body: string, attachments: Attachment[], fromName?: string, replyTo?: string, meta?: Record<string, unknown>): Promise<MailSendResponse | undefined>;
24
+ private toNotificationServiceLanguageCode;
23
25
  private sendMail;
24
26
  }
25
27
  export {};
@@ -31,10 +31,10 @@ class MailService {
31
31
  recipients: [recipient],
32
32
  customerId,
33
33
  content: {
34
- type: "TEMPLATE",
34
+ type: "template",
35
35
  template,
36
36
  variables: variables ?? {},
37
- language,
37
+ language: this.toNotificationServiceLanguageCode(language),
38
38
  attachments: [],
39
39
  },
40
40
  });
@@ -44,7 +44,7 @@ class MailService {
44
44
  recipients,
45
45
  customerId,
46
46
  content: {
47
- type: "HTML",
47
+ type: "html",
48
48
  subject,
49
49
  html: body,
50
50
  attachments,
@@ -54,6 +54,24 @@ class MailService {
54
54
  meta,
55
55
  });
56
56
  }
57
+ toNotificationServiceLanguageCode(languageCode) {
58
+ switch (languageCode) {
59
+ case "nl":
60
+ return "nl-NL";
61
+ case "en":
62
+ return "en-GB";
63
+ case "es":
64
+ return "es-ES";
65
+ case "de":
66
+ return "de-DE";
67
+ case "pt":
68
+ return "pt-PT";
69
+ case "fr":
70
+ return "fr-FR";
71
+ case "ca":
72
+ return "ca";
73
+ }
74
+ }
57
75
  async sendMail(mailRequest) {
58
76
  if ((0, lodash_1.isEmpty)(mailRequest.recipients)) {
59
77
  logger_1.logger.info("No recipients, not sending mail");
@@ -79,7 +79,7 @@ const newService = () => new MailService_1.MailService("some-service-name", base
79
79
  replyTo: "reply@example.com",
80
80
  recipients,
81
81
  content: {
82
- type: "HTML",
82
+ type: "html",
83
83
  html: "<p>Body</p>",
84
84
  subject: "Hello",
85
85
  attachments,
@@ -108,9 +108,9 @@ const newService = () => new MailService_1.MailService("some-service-name", base
108
108
  customerId: 42,
109
109
  recipients: [{ type: "to", email: "someone@example.com" }],
110
110
  content: {
111
- type: "TEMPLATE",
111
+ type: "template",
112
112
  template: "welcome",
113
- language: "en",
113
+ language: "en-GB",
114
114
  variables: { firstName: "Someone" },
115
115
  attachments: [],
116
116
  },
@@ -132,9 +132,9 @@ const newService = () => new MailService_1.MailService("some-service-name", base
132
132
  (0, vitest_1.expect)(result).toEqual({ id: "mail-000" });
133
133
  (0, vitest_1.expect)(requestBody).toMatchObject({
134
134
  content: {
135
- type: "TEMPLATE",
135
+ type: "template",
136
136
  template: "welcome",
137
- language: "en",
137
+ language: "en-GB",
138
138
  variables: {},
139
139
  attachments: [],
140
140
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moreapp/common-nodejs",
3
- "version": "0.13.3",
3
+ "version": "0.13.5",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,8 +57,8 @@
57
57
  "@types/node": "24.13.3",
58
58
  "@typescript-eslint/eslint-plugin": "8.67.0",
59
59
  "@typescript-eslint/parser": "8.67.0",
60
- "@vitest/coverage-v8": "4.1.10",
61
- "@vitest/ui": "4.1.10",
60
+ "@vitest/coverage-v8": "4.1.11",
61
+ "@vitest/ui": "4.1.11",
62
62
  "eslint": "9.39.5",
63
63
  "eslint-config-prettier": "10.1.8",
64
64
  "eslint-plugin-prettier": "5.5.6",
@@ -69,7 +69,7 @@
69
69
  "ts-node": "10.9.2",
70
70
  "typescript": "6.0.3",
71
71
  "typescript-eslint": "8.67.0",
72
- "vitest": "4.1.10",
72
+ "vitest": "4.1.11",
73
73
  "vitest-mock-extended": "5.1.1"
74
74
  },
75
75
  "prettier": {