@webiny/api-mailer 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9
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/constants.js +2 -1
- package/constants.js.map +1 -1
- package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
- package/domain/CodeMailerSettings/abstractions.js +5 -0
- package/domain/CodeMailerSettings/abstractions.js.map +1 -0
- package/domain/MailTransport/abstractions.d.ts +8 -0
- package/domain/MailTransport/abstractions.js +4 -2
- package/domain/MailTransport/abstractions.js.map +1 -1
- package/domain/MailerService/abstractions.js +2 -1
- package/domain/MailerService/abstractions.js.map +1 -1
- package/domain/MailerService/errors.js +22 -24
- package/domain/MailerService/errors.js.map +1 -1
- package/domain/errors.d.ts +8 -4
- package/domain/errors.js +41 -37
- package/domain/errors.js.map +1 -1
- package/exports/api/mailer.d.ts +4 -0
- package/exports/api/mailer.js +4 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.d.ts +12 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +23 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -0
- package/features/CodeMailerSettings/feature.d.ts +4 -0
- package/features/CodeMailerSettings/feature.js +11 -0
- package/features/CodeMailerSettings/feature.js.map +1 -0
- package/features/DummyTransport/DummyMailTransport.js +11 -9
- package/features/DummyTransport/DummyMailTransport.js.map +1 -1
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +10 -6
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -1
- package/features/DummyTransport/feature.d.ts +4 -1
- package/features/DummyTransport/feature.js +6 -5
- package/features/DummyTransport/feature.js.map +1 -1
- package/features/GetSettings/GetSettingsRepository.d.ts +6 -5
- package/features/GetSettings/GetSettingsRepository.js +44 -29
- package/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.d.ts +3 -4
- package/features/GetSettings/GetSettingsUseCase.js +13 -10
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.d.ts +11 -5
- package/features/GetSettings/abstractions.js +3 -2
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/GetSettings/feature.d.ts +4 -1
- package/features/GetSettings/feature.js +7 -6
- package/features/GetSettings/feature.js.map +1 -1
- package/features/GetSettings/index.d.ts +1 -1
- package/features/GetSettings/index.js +1 -3
- package/features/MailerService/ActiveTransport.d.ts +10 -0
- package/features/MailerService/ActiveTransport.js +24 -0
- package/features/MailerService/ActiveTransport.js.map +1 -0
- package/features/MailerService/MailerService.d.ts +3 -2
- package/features/MailerService/MailerService.js +39 -42
- package/features/MailerService/MailerService.js.map +1 -1
- package/features/MailerService/feature.d.ts +4 -1
- package/features/MailerService/feature.js +8 -5
- package/features/MailerService/feature.js.map +1 -1
- package/features/SaveSettings/SaveSettingsRepository.d.ts +1 -1
- package/features/SaveSettings/SaveSettingsRepository.js +30 -44
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +6 -2
- package/features/SaveSettings/SaveSettingsUseCase.js +41 -41
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
- package/features/SaveSettings/abstractions.d.ts +20 -12
- package/features/SaveSettings/abstractions.js +5 -8
- package/features/SaveSettings/abstractions.js.map +1 -1
- package/features/SaveSettings/events.d.ts +3 -3
- package/features/SaveSettings/events.js +17 -12
- package/features/SaveSettings/events.js.map +1 -1
- package/features/SaveSettings/feature.d.ts +4 -1
- package/features/SaveSettings/feature.js +7 -6
- package/features/SaveSettings/feature.js.map +1 -1
- package/features/SaveSettings/index.d.ts +1 -1
- package/features/SaveSettings/index.js +1 -3
- package/features/SaveSettings/validation.d.ts +3 -17
- package/features/SaveSettings/validation.js +14 -13
- package/features/SaveSettings/validation.js.map +1 -1
- package/features/SendMail/SendMailUseCase.d.ts +1 -1
- package/features/SendMail/SendMailUseCase.js +44 -48
- package/features/SendMail/SendMailUseCase.js.map +1 -1
- package/features/SendMail/abstractions.d.ts +7 -7
- package/features/SendMail/abstractions.js +5 -8
- package/features/SendMail/abstractions.js.map +1 -1
- package/features/SendMail/events.d.ts +4 -4
- package/features/SendMail/events.js +24 -17
- package/features/SendMail/events.js.map +1 -1
- package/features/SendMail/feature.d.ts +4 -1
- package/features/SendMail/feature.js +6 -5
- package/features/SendMail/feature.js.map +1 -1
- package/features/SendMail/index.d.ts +1 -0
- package/features/SendMail/index.js +1 -0
- package/features/SmtpTransport/SmtpConfig.js +20 -24
- package/features/SmtpTransport/SmtpConfig.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransport.d.ts +51 -1
- package/features/SmtpTransport/SmtpMailTransport.js +47 -55
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +10 -6
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -1
- package/features/SmtpTransport/feature.d.ts +4 -1
- package/features/SmtpTransport/feature.js +6 -5
- package/features/SmtpTransport/feature.js.map +1 -1
- package/graphql/settings.js +58 -66
- package/graphql/settings.js.map +1 -1
- package/index.js +12 -16
- package/index.js.map +1 -1
- package/package.json +29 -32
- package/types.js +0 -3
- package/utils/isMailboxAddress.d.ts +6 -0
- package/utils/isMailboxAddress.js +5 -0
- package/utils/isMailboxAddress.js.map +1 -0
- package/domain/Encryption/abstractions.d.ts +0 -8
- package/domain/Encryption/abstractions.js +0 -4
- package/domain/Encryption/abstractions.js.map +0 -1
- package/features/Encryption/PasswordEncryption.d.ts +0 -9
- package/features/Encryption/PasswordEncryption.js +0 -23
- package/features/Encryption/PasswordEncryption.js.map +0 -1
- package/features/Encryption/feature.d.ts +0 -1
- package/features/Encryption/feature.js +0 -10
- package/features/Encryption/feature.js.map +0 -1
- package/features/Encryption/utils/password.d.ts +0 -7
- package/features/Encryption/utils/password.js +0 -56
- package/features/Encryption/utils/password.js.map +0 -1
- package/features/Encryption/utils/secret.d.ts +0 -1
- package/features/Encryption/utils/secret.js +0 -11
- package/features/Encryption/utils/secret.js.map +0 -1
- package/features/GetSettings/index.js.map +0 -1
- package/features/MailerService/TransportFactory.d.ts +0 -2
- package/features/MailerService/TransportFactory.js +0 -31
- package/features/MailerService/TransportFactory.js.map +0 -1
- package/features/SaveSettings/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import type { DomainEvent, IEventHandler } from "@webiny/api-core/features/
|
|
2
|
+
import type { DomainEvent, IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { TransportSendData, TransportSendResponse } from "../../types.js";
|
|
4
4
|
import type { MailerService } from "../../domain/MailerService/abstractions.js";
|
|
5
5
|
import { MailValidationError } from "../../domain/errors.js";
|
|
@@ -27,18 +27,18 @@ export interface MailSendErrorPayload {
|
|
|
27
27
|
data: TransportSendData;
|
|
28
28
|
error: Error;
|
|
29
29
|
}
|
|
30
|
-
export declare const
|
|
31
|
-
export declare namespace
|
|
30
|
+
export declare const MailBeforeSendEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailBeforeSendPayload>>>;
|
|
31
|
+
export declare namespace MailBeforeSendEventHandler {
|
|
32
32
|
type Interface = IEventHandler<DomainEvent<MailBeforeSendPayload>>;
|
|
33
33
|
type Event = DomainEvent<MailBeforeSendPayload>;
|
|
34
34
|
}
|
|
35
|
-
export declare const
|
|
36
|
-
export declare namespace
|
|
35
|
+
export declare const MailAfterSendEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailAfterSendPayload>>>;
|
|
36
|
+
export declare namespace MailAfterSendEventHandler {
|
|
37
37
|
type Interface = IEventHandler<DomainEvent<MailAfterSendPayload>>;
|
|
38
38
|
type Event = DomainEvent<MailAfterSendPayload>;
|
|
39
39
|
}
|
|
40
|
-
export declare const
|
|
41
|
-
export declare namespace
|
|
40
|
+
export declare const MailSendErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailSendErrorPayload>>>;
|
|
41
|
+
export declare namespace MailSendErrorEventHandler {
|
|
42
42
|
type Interface = IEventHandler<DomainEvent<MailSendErrorPayload>>;
|
|
43
43
|
type Event = DomainEvent<MailSendErrorPayload>;
|
|
44
44
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const MailBeforeSendHandler = createAbstraction("MailBeforeSendHandler");
|
|
8
|
-
export const MailAfterSendHandler = createAbstraction("MailAfterSendHandler");
|
|
9
|
-
export const MailSendErrorHandler = createAbstraction("MailSendErrorHandler");
|
|
2
|
+
const SendMailUseCase = createAbstraction("SendMail");
|
|
3
|
+
const MailBeforeSendEventHandler = createAbstraction("MailBeforeSendEventHandler");
|
|
4
|
+
const MailAfterSendEventHandler = createAbstraction("MailAfterSendEventHandler");
|
|
5
|
+
const MailSendErrorEventHandler = createAbstraction("MailSendErrorEventHandler");
|
|
6
|
+
export { MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler, SendMailUseCase };
|
|
10
7
|
|
|
11
8
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SendMail/abstractions.js","sources":["../../../src/features/SendMail/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { DomainEvent, IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { TransportSendData, TransportSendResponse } from \"~/types.js\";\nimport type { MailerService } from \"~/domain/MailerService/abstractions.js\";\nimport { MailValidationError } from \"~/domain/errors.js\";\n\nexport interface ISendMailErrors {\n validation: MailValidationError;\n mailService: MailerService.Error;\n}\n\ntype SendMailErrors = ISendMailErrors[keyof ISendMailErrors];\n\nexport interface ISendMailUseCase {\n execute(data: TransportSendData): Promise<Result<TransportSendResponse, SendMailErrors>>;\n}\n\nexport const SendMailUseCase = createAbstraction<ISendMailUseCase>(\"SendMail\");\n\nexport namespace SendMailUseCase {\n export type Interface = ISendMailUseCase;\n export type Error = SendMailErrors;\n}\n\n// Domain Events\nexport interface MailBeforeSendPayload {\n data: TransportSendData;\n}\n\nexport interface MailAfterSendPayload {\n data: TransportSendData;\n response: TransportSendResponse;\n}\n\nexport interface MailSendErrorPayload {\n data: TransportSendData;\n error: Error;\n}\n\n// Event Handler Abstractions\nexport const MailBeforeSendEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailBeforeSendPayload>>\n>(\"MailBeforeSendEventHandler\");\n\nexport namespace MailBeforeSendEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailBeforeSendPayload>>;\n export type Event = DomainEvent<MailBeforeSendPayload>;\n}\n\nexport const MailAfterSendEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailAfterSendPayload>>\n>(\"MailAfterSendEventHandler\");\n\nexport namespace MailAfterSendEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailAfterSendPayload>>;\n export type Event = DomainEvent<MailAfterSendPayload>;\n}\n\nexport const MailSendErrorEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailSendErrorPayload>>\n>(\"MailSendErrorEventHandler\");\n\nexport namespace MailSendErrorEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailSendErrorPayload>>;\n export type Event = DomainEvent<MailSendErrorPayload>;\n}\n"],"names":["SendMailUseCase","createAbstraction","MailBeforeSendEventHandler","MailAfterSendEventHandler","MailSendErrorEventHandler"],"mappings":";AAkBO,MAAMA,kBAAkBC,kBAAoC;AAuB5D,MAAMC,6BAA6BD,kBAExC;AAOK,MAAME,4BAA4BF,kBAEvC;AAOK,MAAMG,4BAA4BH,kBAEvC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
2
|
import type { MailBeforeSendPayload, MailAfterSendPayload, MailSendErrorPayload } from "./abstractions.js";
|
|
3
3
|
export declare class MailBeforeSendEvent extends DomainEvent<MailBeforeSendPayload> {
|
|
4
4
|
eventType: "mailer.mail.beforeSend";
|
|
5
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
5
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailBeforeSendPayload>>>;
|
|
6
6
|
}
|
|
7
7
|
export declare class MailAfterSendEvent extends DomainEvent<MailAfterSendPayload> {
|
|
8
8
|
eventType: "mailer.mail.afterSend";
|
|
9
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
9
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailAfterSendPayload>>>;
|
|
10
10
|
}
|
|
11
11
|
export declare class MailSendErrorEvent extends DomainEvent<MailSendErrorPayload> {
|
|
12
12
|
eventType: "mailer.mail.sendError";
|
|
13
|
-
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/
|
|
13
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailSendErrorPayload>>>;
|
|
14
14
|
}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import { MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler } from "./abstractions.js";
|
|
3
|
+
class MailBeforeSendEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return MailBeforeSendEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "mailer.mail.beforeSend";
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
class MailAfterSendEvent extends DomainEvent {
|
|
12
|
+
getHandlerAbstraction() {
|
|
13
|
+
return MailAfterSendEventHandler;
|
|
14
|
+
}
|
|
15
|
+
constructor(...args){
|
|
16
|
+
super(...args), this.eventType = "mailer.mail.afterSend";
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
class MailSendErrorEvent extends DomainEvent {
|
|
20
|
+
getHandlerAbstraction() {
|
|
21
|
+
return MailSendErrorEventHandler;
|
|
22
|
+
}
|
|
23
|
+
constructor(...args){
|
|
24
|
+
super(...args), this.eventType = "mailer.mail.sendError";
|
|
25
|
+
}
|
|
20
26
|
}
|
|
27
|
+
export { MailAfterSendEvent, MailBeforeSendEvent, MailSendErrorEvent };
|
|
21
28
|
|
|
22
29
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SendMail/events.js","sources":["../../../src/features/SendMail/events.ts"],"sourcesContent":["import { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n MailBeforeSendEventHandler,\n MailAfterSendEventHandler,\n MailSendErrorEventHandler\n} from \"./abstractions.js\";\nimport type {\n MailBeforeSendPayload,\n MailAfterSendPayload,\n MailSendErrorPayload\n} from \"./abstractions.js\";\n\nexport class MailBeforeSendEvent extends DomainEvent<MailBeforeSendPayload> {\n eventType = \"mailer.mail.beforeSend\" as const;\n\n getHandlerAbstraction() {\n return MailBeforeSendEventHandler;\n }\n}\n\nexport class MailAfterSendEvent extends DomainEvent<MailAfterSendPayload> {\n eventType = \"mailer.mail.afterSend\" as const;\n\n getHandlerAbstraction() {\n return MailAfterSendEventHandler;\n }\n}\n\nexport class MailSendErrorEvent extends DomainEvent<MailSendErrorPayload> {\n eventType = \"mailer.mail.sendError\" as const;\n\n getHandlerAbstraction() {\n return MailSendErrorEventHandler;\n }\n}\n"],"names":["MailBeforeSendEvent","DomainEvent","MailBeforeSendEventHandler","MailAfterSendEvent","MailAfterSendEventHandler","MailSendErrorEvent","MailSendErrorEventHandler"],"mappings":";;AAYO,MAAMA,4BAA4BC;IAGrC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMC,2BAA2BF;IAGpC,wBAAwB;QACpB,OAAOG;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMC,2BAA2BJ;IAGpC,wBAAwB;QACpB,OAAOK;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { SendMailUseCaseImplementation } from "./SendMailUseCase.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const SendMailFeature = createFeature({
|
|
4
|
+
name: "SendMail",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SendMailUseCaseImplementation);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { SendMailFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SendMail/feature.js","sources":["../../../src/features/SendMail/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SendMailUseCaseImplementation } from \"./SendMailUseCase.js\";\n\nexport const SendMailFeature = createFeature({\n name: \"SendMail\",\n register(container) {\n container.register(SendMailUseCaseImplementation);\n }\n});\n"],"names":["SendMailFeature","createFeature","container","SendMailUseCaseImplementation"],"mappings":";;AAGO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SendMailUseCase, MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler } from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler, SendMailUseCase } from "./abstractions.js";
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
const configDefaults = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
socketTimeout: 15000,
|
|
3
|
+
connectionTimeout: 15000,
|
|
4
|
+
greetingTimeout: 15000
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
config[configKey] = configDefaults[configKey];
|
|
23
|
-
}
|
|
24
|
-
return config;
|
|
25
|
-
}, baseConfig);
|
|
26
|
-
}
|
|
6
|
+
class SmtpConfig {
|
|
7
|
+
static fromTransportSettings(settings) {
|
|
8
|
+
const baseConfig = {
|
|
9
|
+
host: settings.host,
|
|
10
|
+
port: settings.port,
|
|
11
|
+
auth: {
|
|
12
|
+
user: settings.user,
|
|
13
|
+
pass: settings.password
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return Object.keys(configDefaults).reduce((config, key)=>{
|
|
17
|
+
const configKey = key;
|
|
18
|
+
if (void 0 === config[configKey] || null === config[configKey]) config[configKey] = configDefaults[configKey];
|
|
19
|
+
return config;
|
|
20
|
+
}, baseConfig);
|
|
21
|
+
}
|
|
27
22
|
}
|
|
23
|
+
export { SmtpConfig };
|
|
28
24
|
|
|
29
25
|
//# sourceMappingURL=SmtpConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpConfig.js","sources":["../../../src/features/SmtpTransport/SmtpConfig.ts"],"sourcesContent":["import type { TransportSettings } from \"~/types.js\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\n\nexport type SmtpTransportConfig = SMTPTransport.Options;\n\nconst configDefaults: Partial<SmtpTransportConfig> = {\n socketTimeout: 15000,\n connectionTimeout: 15000,\n greetingTimeout: 15000\n};\n\nexport class SmtpConfig {\n static fromTransportSettings(settings: TransportSettings): SmtpTransportConfig {\n const baseConfig: SmtpTransportConfig = {\n host: settings.host,\n port: settings.port,\n auth: {\n user: settings.user,\n pass: settings.password\n }\n };\n\n // Apply defaults\n return Object.keys(configDefaults).reduce<SmtpTransportConfig>((config, key) => {\n const configKey = key as keyof SmtpTransportConfig;\n if (config[configKey] === undefined || config[configKey] === null) {\n // @ts-expect-error\n config[configKey] = configDefaults[configKey];\n }\n return config;\n }, baseConfig);\n }\n}\n"],"names":["configDefaults","SmtpConfig","settings","baseConfig","Object","config","key","configKey","undefined"],"mappings":"AAKA,MAAMA,iBAA+C;IACjD,eAAe;IACf,mBAAmB;IACnB,iBAAiB;AACrB;AAEO,MAAMC;IACT,OAAO,sBAAsBC,QAA2B,EAAuB;QAC3E,MAAMC,aAAkC;YACpC,MAAMD,SAAS,IAAI;YACnB,MAAMA,SAAS,IAAI;YACnB,MAAM;gBACF,MAAMA,SAAS,IAAI;gBACnB,MAAMA,SAAS,QAAQ;YAC3B;QACJ;QAGA,OAAOE,OAAO,IAAI,CAACJ,gBAAgB,MAAM,CAAsB,CAACK,QAAQC;YACpE,MAAMC,YAAYD;YAClB,IAAID,AAAsBG,WAAtBH,MAAM,CAACE,UAAU,IAAkBF,AAAsB,SAAtBA,MAAM,CAACE,UAAU,EAEpDF,MAAM,CAACE,UAAU,GAAGP,cAAc,CAACO,UAAU;YAEjD,OAAOF;QACX,GAAGF;IACP;AACJ"}
|
|
@@ -7,12 +7,62 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
|
|
|
7
7
|
send(params: MailTransport.SendParams): Promise<{
|
|
8
8
|
result: string;
|
|
9
9
|
error: null;
|
|
10
|
+
} | {
|
|
11
|
+
result: null;
|
|
12
|
+
error: {
|
|
13
|
+
message: string;
|
|
14
|
+
code: string;
|
|
15
|
+
data: {
|
|
16
|
+
envelope: import("nodemailer/lib/mime-node").Envelope;
|
|
17
|
+
messageId: string;
|
|
18
|
+
accepted: Array<string | import("nodemailer/lib/mailer").Address>;
|
|
19
|
+
rejected: Array<string | import("nodemailer/lib/mailer").Address>;
|
|
20
|
+
pending: Array<string | import("nodemailer/lib/mailer").Address>;
|
|
21
|
+
response: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
10
24
|
} | {
|
|
11
25
|
result: null;
|
|
12
26
|
error: {
|
|
13
27
|
message: any;
|
|
14
28
|
code: any;
|
|
15
|
-
data:
|
|
29
|
+
data: {
|
|
30
|
+
command: any;
|
|
31
|
+
response: any;
|
|
32
|
+
responseCode: any;
|
|
33
|
+
to: string[];
|
|
34
|
+
cc?: string[];
|
|
35
|
+
bcc?: string[];
|
|
36
|
+
from?: string;
|
|
37
|
+
subject: string;
|
|
38
|
+
text?: string;
|
|
39
|
+
html?: string;
|
|
40
|
+
replyTo?: string;
|
|
41
|
+
} | {
|
|
42
|
+
command: any;
|
|
43
|
+
response: any;
|
|
44
|
+
responseCode: any;
|
|
45
|
+
to?: string[];
|
|
46
|
+
cc: string[];
|
|
47
|
+
bcc?: string[];
|
|
48
|
+
from?: string;
|
|
49
|
+
subject: string;
|
|
50
|
+
text?: string;
|
|
51
|
+
html?: string;
|
|
52
|
+
replyTo?: string;
|
|
53
|
+
} | {
|
|
54
|
+
command: any;
|
|
55
|
+
response: any;
|
|
56
|
+
responseCode: any;
|
|
57
|
+
to?: string[];
|
|
58
|
+
cc?: string[];
|
|
59
|
+
bcc: string[];
|
|
60
|
+
from?: string;
|
|
61
|
+
subject: string;
|
|
62
|
+
text?: string;
|
|
63
|
+
html?: string;
|
|
64
|
+
replyTo?: string;
|
|
65
|
+
};
|
|
16
66
|
};
|
|
17
67
|
}>;
|
|
18
68
|
}
|
|
@@ -1,61 +1,53 @@
|
|
|
1
1
|
import nodemailer from "nodemailer";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
error: {
|
|
49
|
-
message: ex.message,
|
|
50
|
-
code: ex.code,
|
|
51
|
-
data: {
|
|
52
|
-
...params,
|
|
53
|
-
...ex.data
|
|
54
|
-
}
|
|
2
|
+
class SmtpMailTransport {
|
|
3
|
+
constructor(config){
|
|
4
|
+
this.name = "Mailer/SmtpTransport";
|
|
5
|
+
this.transporter = nodemailer.createTransport(config);
|
|
6
|
+
}
|
|
7
|
+
async send(params) {
|
|
8
|
+
const { replyTo, text, html, to, bcc, cc, from, subject } = params;
|
|
9
|
+
try {
|
|
10
|
+
const result = await this.transporter.sendMail({
|
|
11
|
+
replyTo,
|
|
12
|
+
bcc,
|
|
13
|
+
cc,
|
|
14
|
+
from,
|
|
15
|
+
text,
|
|
16
|
+
html,
|
|
17
|
+
to,
|
|
18
|
+
subject
|
|
19
|
+
});
|
|
20
|
+
if (result.messageId) return {
|
|
21
|
+
result: result.response,
|
|
22
|
+
error: null
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
result: null,
|
|
26
|
+
error: {
|
|
27
|
+
message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
|
|
28
|
+
code: "MAILER_ERROR",
|
|
29
|
+
data: {
|
|
30
|
+
...result
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
} catch (ex) {
|
|
35
|
+
return {
|
|
36
|
+
result: null,
|
|
37
|
+
error: {
|
|
38
|
+
message: ex.message,
|
|
39
|
+
code: ex.code,
|
|
40
|
+
data: {
|
|
41
|
+
...params,
|
|
42
|
+
command: ex.command,
|
|
43
|
+
response: ex.response,
|
|
44
|
+
responseCode: ex.responseCode
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
55
48
|
}
|
|
56
|
-
};
|
|
57
49
|
}
|
|
58
|
-
}
|
|
59
50
|
}
|
|
51
|
+
export { SmtpMailTransport };
|
|
60
52
|
|
|
61
53
|
//# sourceMappingURL=SmtpMailTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpMailTransport.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransport.ts"],"sourcesContent":["import type { Transporter } from \"nodemailer\";\nimport nodemailer from \"nodemailer\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\nimport { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class SmtpMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n private readonly transporter: Transporter<SMTPTransport.SentMessageInfo>;\n\n constructor(config: SMTPTransport.Options) {\n this.transporter = nodemailer.createTransport(config);\n }\n\n async send(params: MailTransport.SendParams) {\n const { replyTo, text, html, to, bcc, cc, from, subject } = params;\n\n try {\n const result = await this.transporter.sendMail({\n replyTo,\n bcc,\n cc,\n from,\n text,\n html,\n to,\n subject\n });\n\n if (result.messageId) {\n return {\n result: result.response,\n error: null\n };\n }\n\n return {\n result: null,\n error: {\n message:\n \"nodemailer.sendMail does not have a messageId in the result. Something went wrong...\",\n code: \"MAILER_ERROR\",\n data: {\n ...result\n }\n }\n };\n } catch (ex: any) {\n // Allow-list specific nodemailer/SMTP error fields. Spreading `ex`\n // or `ex.data` blindly would risk surfacing the transporter's auth\n // config (or anything else a future nodemailer version stamps onto\n // its errors) in error responses.\n return {\n result: null,\n error: {\n message: ex.message,\n code: ex.code,\n data: {\n ...params,\n command: ex.command,\n response: ex.response,\n responseCode: ex.responseCode\n }\n }\n };\n }\n }\n}\n"],"names":["SmtpMailTransport","config","nodemailer","params","replyTo","text","html","to","bcc","cc","from","subject","result","ex"],"mappings":";AAKO,MAAMA;IAIT,YAAYC,MAA6B,CAAE;aAH3B,IAAI,GAAG;QAInB,IAAI,CAAC,WAAW,GAAGC,WAAW,eAAe,CAACD;IAClD;IAEA,MAAM,KAAKE,MAAgC,EAAE;QACzC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,EAAE,EAAEC,GAAG,EAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGR;QAE5D,IAAI;YACA,MAAMS,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAC3CR;gBACAI;gBACAC;gBACAC;gBACAL;gBACAC;gBACAC;gBACAI;YACJ;YAEA,IAAIC,OAAO,SAAS,EAChB,OAAO;gBACH,QAAQA,OAAO,QAAQ;gBACvB,OAAO;YACX;YAGJ,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SACI;oBACJ,MAAM;oBACN,MAAM;wBACF,GAAGA,MAAM;oBACb;gBACJ;YACJ;QACJ,EAAE,OAAOC,IAAS;YAKd,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SAASA,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI;oBACb,MAAM;wBACF,GAAGV,MAAM;wBACT,SAASU,GAAG,OAAO;wBACnB,UAAUA,GAAG,QAAQ;wBACrB,cAAcA,GAAG,YAAY;oBACjC;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
2
|
import type { TransportSettings } from "../../types.js";
|
|
3
3
|
declare class SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {
|
|
4
|
+
readonly name = "Mailer/SmtpTransport";
|
|
4
5
|
createTransport(settings: TransportSettings): MailTransportFactory.Return;
|
|
5
6
|
}
|
|
6
7
|
export declare const SmtpMailTransportFactory: typeof SmtpMailTransportFactoryImpl & {
|
|
@@ -2,13 +2,17 @@ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js
|
|
|
2
2
|
import { SmtpMailTransport } from "./SmtpMailTransport.js";
|
|
3
3
|
import { SmtpConfig } from "./SmtpConfig.js";
|
|
4
4
|
class SmtpMailTransportFactoryImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
async createTransport(settings) {
|
|
6
|
+
return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));
|
|
7
|
+
}
|
|
8
|
+
constructor(){
|
|
9
|
+
this.name = "Mailer/SmtpTransport";
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
|
|
13
|
+
implementation: SmtpMailTransportFactoryImpl,
|
|
14
|
+
dependencies: []
|
|
12
15
|
});
|
|
16
|
+
export { SmtpMailTransportFactory };
|
|
13
17
|
|
|
14
18
|
//# sourceMappingURL=SmtpMailTransportFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/SmtpMailTransportFactory.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n\n async createTransport(settings: TransportSettings): MailTransportFactory.Return {\n return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["SmtpMailTransportFactoryImpl","settings","SmtpMailTransport","SmtpConfig","SmtpMailTransportFactory","MailTransportFactory"],"mappings":";;;AAKA,MAAMA;IAGF,MAAM,gBAAgBC,QAA2B,EAA+B;QAC5E,OAAO,IAAIC,kBAAkBC,WAAW,qBAAqB,CAACF;IAClE;;aAJgB,IAAI,GAAG;;AAK3B;AAEO,MAAMG,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { SmtpMailTransportFactory } from "./SmtpMailTransportFactory.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const SmtpTransportFeature = createFeature({
|
|
4
|
+
name: "SmtpTransport",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(SmtpMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { SmtpTransportFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/SmtpTransport/feature.js","sources":["../../../src/features/SmtpTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SmtpMailTransportFactory } from \"./SmtpMailTransportFactory.js\";\n\nexport const SmtpTransportFeature = createFeature({\n name: \"SmtpTransport\",\n register(container) {\n container.register(SmtpMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["SmtpTransportFeature","createFeature","container","SmtpMailTransportFactory"],"mappings":";;AAGO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
|