@drax/email-back 0.9.0 → 0.10.0
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/config/EmailLayoutConfig.js +20 -0
- package/dist/config/EmailTransportConfig.js +14 -0
- package/dist/factory/EmailLayoutServiceFactory.js +36 -0
- package/dist/factory/EmailServiceFactory.js +12 -12
- package/dist/factory/EmailTransportServiceFactory.js +46 -0
- package/dist/index.js +6 -3
- package/dist/services/EmailLayoutService.js +2 -2
- package/dist/services/EmailTransportService.js +58 -0
- package/package.json +2 -2
- package/src/config/EmailLayoutConfig.ts +27 -0
- package/src/config/{EmailConfig.ts → EmailTransportConfig.ts} +3 -3
- package/src/factory/EmailLayoutServiceFactory.ts +52 -0
- package/src/factory/EmailTransportServiceFactory.ts +56 -0
- package/src/index.ts +11 -4
- package/src/services/EmailLayoutService.ts +2 -2
- package/src/services/{EmailService.ts → EmailTransportService.ts} +3 -3
- package/test/Email.test.ts +4 -3
- package/test/EmailLayout.test.ts +3 -3
- package/tsconfig.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/types/config/EmailLayoutConfig.d.ts +20 -0
- package/types/config/EmailLayoutConfig.d.ts.map +1 -0
- package/types/config/EmailTransportConfig.d.ts +14 -0
- package/types/config/EmailTransportConfig.d.ts.map +1 -0
- package/types/factory/EmailLayoutServiceFactory.d.ts +10 -0
- package/types/factory/EmailLayoutServiceFactory.d.ts.map +1 -0
- package/types/factory/EmailServiceFactory.d.ts +1 -1
- package/types/factory/EmailTransportServiceFactory.d.ts +11 -0
- package/types/factory/EmailTransportServiceFactory.d.ts.map +1 -0
- package/types/index.d.ts +6 -3
- package/types/index.d.ts.map +1 -1
- package/types/services/EmailTransportService.d.ts +13 -0
- package/types/services/EmailTransportService.d.ts.map +1 -0
- package/src/factory/EmailServiceFactory.ts +0 -56
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare enum EmailLayoutConfig {
|
|
2
|
+
bodyStyle = "EMAIL_BODYSTYLE",
|
|
3
|
+
maxWidth = "EMAIL_MAXWIDTH",
|
|
4
|
+
headerCentered = "EMAIL_HEADER_CENTERED",
|
|
5
|
+
headerBgColor = "EMAIL_HEADER_BGCOLOR",
|
|
6
|
+
headerColor = "EMAIL_HEADER_COLOR",
|
|
7
|
+
headerImage = "EMAIL_HEADER_IMAGE",
|
|
8
|
+
headerImageStyle = "EMAIL_HEADER_IMAGE_STYLE",
|
|
9
|
+
headerTitle = "EMAIL_HEADER_TITLE",
|
|
10
|
+
headerTitleStyle = "EMAIL_HEADER_TITLE_STYLE",
|
|
11
|
+
headerLogo = "EMAIL_HEADER_LOGO",
|
|
12
|
+
headerLogoStyle = "EMAIL_HEADER_LOGO_STYLE",
|
|
13
|
+
footerBgColor = "EMAIL_FOOTER_BGCOLOR",
|
|
14
|
+
footerCopyright = "EMAIL_FOOTER_COPYRIGHT",
|
|
15
|
+
footerContent = "EMAIL_FOOTER_CONTENT",
|
|
16
|
+
footerUnsubscribe = "EMAIL_FOOTER_UNSUBSCRIBE"
|
|
17
|
+
}
|
|
18
|
+
export default EmailLayoutConfig;
|
|
19
|
+
export { EmailLayoutConfig };
|
|
20
|
+
//# sourceMappingURL=EmailLayoutConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailLayoutConfig.d.ts","sourceRoot":"","sources":["../../src/config/EmailLayoutConfig.ts"],"names":[],"mappings":"AAAA,aAAK,iBAAiB;IAClB,SAAS,oBAAoB;IAC7B,QAAQ,mBAAmB;IAE3B,cAAc,0BAA0B;IACxC,aAAa,yBAAyB;IACtC,WAAW,uBAAuB;IAElC,WAAW,uBAAuB;IAClC,gBAAgB,6BAA6B;IAE7C,WAAW,uBAAuB;IAClC,gBAAgB,6BAA6B;IAE7C,UAAU,sBAAsB;IAChC,eAAe,4BAA4B;IAE3C,aAAa,yBAAyB;IACtC,eAAe,2BAA2B;IAC1C,aAAa,yBAAyB;IACtC,iBAAiB,6BAA6B;CAGjD;AAED,eAAe,iBAAiB,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare enum EmailTransportConfig {
|
|
2
|
+
type = "EMAIL_TYPE",
|
|
3
|
+
service = "EMAIL_SERVICE",
|
|
4
|
+
smtpHost = "EMAIL_HOST",
|
|
5
|
+
smtpPort = "EMAIL_PORT",
|
|
6
|
+
authType = "EMAIL_AUTH_TYPE",
|
|
7
|
+
authUsername = "EMAIL_AUTH_USERNAME",
|
|
8
|
+
authPassword = "EMAIL_AUTH_PASSWORD",
|
|
9
|
+
secure = "EMAIL_SECURE",
|
|
10
|
+
ignoreTLS = "EMAIL_IGNORE_TLS"
|
|
11
|
+
}
|
|
12
|
+
export default EmailTransportConfig;
|
|
13
|
+
export { EmailTransportConfig };
|
|
14
|
+
//# sourceMappingURL=EmailTransportConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailTransportConfig.d.ts","sourceRoot":"","sources":["../../src/config/EmailTransportConfig.ts"],"names":[],"mappings":"AAAA,aAAK,oBAAoB;IACrB,IAAI,eAAe;IACnB,OAAO,kBAAkB;IACzB,QAAQ,eAAe;IACvB,QAAQ,eAAe;IACvB,QAAQ,oBAAoB;IAC5B,YAAY,wBAAwB;IACpC,YAAY,wBAAwB;IACpC,MAAM,iBAAiB;IACvB,SAAS,qBAAqB;CACjC;AAED,eAAe,oBAAoB,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EmailLayoutService } from '../services/EmailLayoutService.js';
|
|
2
|
+
import type { IEmailLayout } from "../interfaces/IEmailLayout";
|
|
3
|
+
declare class EmailLayoutServiceFactory {
|
|
4
|
+
private static service;
|
|
5
|
+
static get instance(): EmailLayoutService;
|
|
6
|
+
static get getOptions(): IEmailLayout;
|
|
7
|
+
}
|
|
8
|
+
export default EmailLayoutServiceFactory;
|
|
9
|
+
export { EmailLayoutServiceFactory };
|
|
10
|
+
//# sourceMappingURL=EmailLayoutServiceFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailLayoutServiceFactory.d.ts","sourceRoot":"","sources":["../../src/factory/EmailLayoutServiceFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAA;AAEpE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAE7D,cAAM,yBAAyB;IAC3B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAqB;IAE3C,WAAkB,QAAQ,IAAI,kBAAkB,CAO/C;IAED,WAAkB,UAAU,IAAI,YAAY,CA2B3C;CACJ;AAED,eAAe,yBAAyB,CAAA;AACxC,OAAO,EACH,yBAAyB,EAC5B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EmailTransportService } from '../services/EmailTransportService.js';
|
|
2
|
+
import type { TransportGmailConfig, TransportSmtpConfig } from "../interfaces/ITransportConfig";
|
|
3
|
+
declare class EmailTransportServiceFactory {
|
|
4
|
+
private static service;
|
|
5
|
+
static get instance(): EmailTransportService;
|
|
6
|
+
static get getType(): any;
|
|
7
|
+
static get getOptions(): TransportSmtpConfig | TransportGmailConfig;
|
|
8
|
+
}
|
|
9
|
+
export default EmailTransportServiceFactory;
|
|
10
|
+
export { EmailTransportServiceFactory };
|
|
11
|
+
//# sourceMappingURL=EmailTransportServiceFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailTransportServiceFactory.d.ts","sourceRoot":"","sources":["../../src/factory/EmailTransportServiceFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,sCAAsC,CAAA;AAE1E,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AAE9F,cAAM,4BAA4B;IAC9B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAwB;IAE9C,WAAkB,QAAQ,IAAI,qBAAqB,CAOlD;IAED,WAAkB,OAAO,QAExB;IAED,WAAkB,UAAU,+CA2B3B;CACJ;AAED,eAAe,4BAA4B,CAAA;AAC3C,OAAO,EACH,4BAA4B,EAC/B,CAAA"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import EmailTransportConfig from "./config/EmailTransportConfig.js";
|
|
2
|
+
import EmailLayoutConfig from "./config/EmailLayoutConfig.js";
|
|
3
|
+
import EmailTransportService from "./services/EmailTransportService.js";
|
|
3
4
|
import EmailLayoutService from "./services/EmailLayoutService.js";
|
|
5
|
+
import EmailTransportServiceFactory from "./factory/EmailTransportServiceFactory.js";
|
|
6
|
+
import EmailLayoutServiceFactory from "./factory/EmailLayoutServiceFactory.js";
|
|
4
7
|
import type { IEmailLayout } from "./interfaces/IEmailLayout";
|
|
5
8
|
import type { TransportGmailConfig, TransportSmtpConfig } from "./interfaces/ITransportConfig";
|
|
6
9
|
export type { IEmailLayout, TransportGmailConfig, TransportSmtpConfig, };
|
|
7
|
-
export {
|
|
10
|
+
export { EmailTransportConfig, EmailLayoutConfig, EmailTransportServiceFactory, EmailTransportService, EmailLayoutServiceFactory, EmailLayoutService, };
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,qBAAqB,MAAM,qCAAqC,CAAC;AACxE,OAAO,kBAAkB,MAAM,kCAAkC,CAAC;AAClE,OAAO,4BAA4B,MAAM,2CAA2C,CAAC;AACrF,OAAO,yBAAyB,MAAM,wCAAwC,CAAC;AAE/E,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AAE5F,YAAY,EACR,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACtB,CAAA;AAGD,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,GACrB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Transporter, SendMailOptions } from "nodemailer";
|
|
2
|
+
import type { TransportGmailConfig, TransportSmtpConfig } from "../interfaces/ITransportConfig";
|
|
3
|
+
declare class EmailTransportService {
|
|
4
|
+
transporter: Transporter;
|
|
5
|
+
transporterConfig: TransportGmailConfig | TransportSmtpConfig;
|
|
6
|
+
constructor(type: 'smtp' | 'gmail', config: TransportGmailConfig | TransportSmtpConfig);
|
|
7
|
+
prepareTransportGmail(config: TransportGmailConfig): any;
|
|
8
|
+
prepareTransportSmtp(config: TransportSmtpConfig): any;
|
|
9
|
+
sendEmail(options: SendMailOptions): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export default EmailTransportService;
|
|
12
|
+
export { EmailTransportService };
|
|
13
|
+
//# sourceMappingURL=EmailTransportService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailTransportService.d.ts","sourceRoot":"","sources":["../../src/services/EmailTransportService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,gCAAgC,CAAC;AAG9F,cAAM,qBAAqB;IAEvB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,EAAG,oBAAoB,GAAG,mBAAmB,CAAC;gBAEnD,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,MAAM,EAAE,oBAAoB,GAAG,mBAAmB;IAetF,qBAAqB,CAAC,MAAM,EAAE,oBAAoB,GAAG,GAAG;IAWxD,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,GAAG;IAetD,SAAS,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;CAyBpD;AAED,eAAe,qBAAqB,CAAA;AACpC,OAAO,EAAC,qBAAqB,EAAC,CAAA"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {DraxConfig} from "@drax/common-back";
|
|
2
|
-
import {EmailService} from '../services/EmailService.js'
|
|
3
|
-
import EmailConfig from "../config/EmailConfig";
|
|
4
|
-
import {TransportGmailConfig, TransportSmtpConfig} from "../interfaces/ITransportConfig";
|
|
5
|
-
|
|
6
|
-
class EmailServiceFactory {
|
|
7
|
-
private static service: EmailService;
|
|
8
|
-
|
|
9
|
-
public static get instance(): EmailService {
|
|
10
|
-
if (!EmailServiceFactory.service) {
|
|
11
|
-
const type = EmailServiceFactory.getType;
|
|
12
|
-
const options = EmailServiceFactory.getOptions;
|
|
13
|
-
EmailServiceFactory.service = new EmailService(type, options);
|
|
14
|
-
}
|
|
15
|
-
return EmailServiceFactory.service;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public static get getType() {
|
|
19
|
-
return DraxConfig.getOrLoad(EmailConfig.type)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public static get getOptions() {
|
|
23
|
-
let options: TransportSmtpConfig | TransportGmailConfig;
|
|
24
|
-
switch(DraxConfig.getOrLoad(EmailConfig.type)){
|
|
25
|
-
case 'smtp':
|
|
26
|
-
options = {
|
|
27
|
-
host: DraxConfig.getOrLoad(EmailConfig.smtpHost),
|
|
28
|
-
port: DraxConfig.getOrLoad(EmailConfig.smtpPort),
|
|
29
|
-
secure: DraxConfig.getOrLoad(EmailConfig.secure),
|
|
30
|
-
ignoreTLS: DraxConfig.getOrLoad(EmailConfig.ignoreTLS),
|
|
31
|
-
auth: {
|
|
32
|
-
user: DraxConfig.getOrLoad(EmailConfig.authUsername),
|
|
33
|
-
pass: DraxConfig.getOrLoad(EmailConfig.authPassword),
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
case 'gmail':
|
|
38
|
-
options = {
|
|
39
|
-
auth: {
|
|
40
|
-
user: DraxConfig.getOrLoad(EmailConfig.authUsername),
|
|
41
|
-
pass: DraxConfig.getOrLoad(EmailConfig.authPassword),
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
throw new Error(`Unsupported email service type: ${DraxConfig.getOrLoad(EmailConfig.type)}`)
|
|
47
|
-
}
|
|
48
|
-
return options;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default EmailServiceFactory
|
|
53
|
-
export {
|
|
54
|
-
EmailServiceFactory
|
|
55
|
-
}
|
|
56
|
-
|