@webiny/api-mailer 6.3.0 → 6.4.0-beta.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/constants.js +2 -1
- package/constants.js.map +1 -1
- package/domain/CodeMailerSettings/abstractions.js +2 -1
- package/domain/CodeMailerSettings/abstractions.js.map +1 -1
- package/domain/MailTransport/abstractions.js +4 -3
- 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.js +40 -44
- package/domain/errors.js.map +1 -1
- package/exports/api/mailer.js +3 -5
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +14 -13
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -1
- package/features/CodeMailerSettings/feature.js +6 -5
- package/features/CodeMailerSettings/feature.js.map +1 -1
- package/features/DummyTransport/DummyMailTransport.js +11 -9
- package/features/DummyTransport/DummyMailTransport.js.map +1 -1
- package/features/DummyTransport/DummyMailTransportFactory.js +10 -7
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -1
- package/features/DummyTransport/feature.js +6 -5
- package/features/DummyTransport/feature.js.map +1 -1
- package/features/GetSettings/GetSettingsRepository.js +41 -45
- package/features/GetSettings/GetSettingsRepository.js.map +1 -1
- package/features/GetSettings/GetSettingsUseCase.js +13 -10
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/GetSettings/abstractions.js +3 -2
- package/features/GetSettings/abstractions.js.map +1 -1
- package/features/GetSettings/feature.js +7 -6
- package/features/GetSettings/feature.js.map +1 -1
- package/features/GetSettings/index.js +1 -3
- package/features/MailerService/ActiveTransport.js +18 -14
- package/features/MailerService/ActiveTransport.js.map +1 -1
- package/features/MailerService/MailerService.js +38 -42
- package/features/MailerService/MailerService.js.map +1 -1
- package/features/MailerService/feature.js +7 -6
- package/features/MailerService/feature.js.map +1 -1
- package/features/SaveSettings/SaveSettingsRepository.js +29 -45
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
- package/features/SaveSettings/SaveSettingsUseCase.js +38 -56
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
- package/features/SaveSettings/abstractions.js +5 -17
- package/features/SaveSettings/abstractions.js.map +1 -1
- package/features/SaveSettings/events.js +16 -11
- package/features/SaveSettings/events.js.map +1 -1
- package/features/SaveSettings/feature.js +7 -6
- package/features/SaveSettings/feature.js.map +1 -1
- package/features/SaveSettings/index.js +1 -3
- package/features/SaveSettings/validation.d.ts +1 -1
- package/features/SaveSettings/validation.js +11 -14
- package/features/SaveSettings/validation.js.map +1 -1
- package/features/SendMail/SendMailUseCase.js +40 -47
- package/features/SendMail/SendMailUseCase.js.map +1 -1
- package/features/SendMail/abstractions.js +5 -8
- package/features/SendMail/abstractions.js.map +1 -1
- package/features/SendMail/events.js +23 -16
- package/features/SendMail/events.js.map +1 -1
- package/features/SendMail/feature.js +6 -5
- package/features/SendMail/feature.js.map +1 -1
- package/features/SendMail/index.js +1 -3
- package/features/SmtpTransport/SmtpConfig.js +20 -24
- package/features/SmtpTransport/SmtpConfig.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransport.js +47 -61
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -1
- package/features/SmtpTransport/SmtpMailTransportFactory.js +10 -7
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -1
- package/features/SmtpTransport/feature.js +6 -5
- package/features/SmtpTransport/feature.js.map +1 -1
- package/graphql/settings.js +54 -74
- package/graphql/settings.js.map +1 -1
- package/index.js +11 -15
- package/index.js.map +1 -1
- package/package.json +17 -17
- package/types.js +0 -3
- package/utils/isMailboxAddress.js +3 -10
- package/utils/isMailboxAddress.js.map +1 -1
- package/exports/api/mailer.js.map +0 -1
- package/features/GetSettings/index.js.map +0 -1
- package/features/SaveSettings/index.js.map +0 -1
- package/features/SendMail/index.js.map +0 -1
- package/types.js.map +0 -1
package/constants.js
CHANGED
package/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\n"],"names":["MAILER_TRANSPORT_SETTINGS"],"mappings":"AAAO,MAAMA,4BAA4B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
2
|
+
const CodeMailerSettings = createAbstraction("CodeMailerSettings");
|
|
3
|
+
export { CodeMailerSettings };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/CodeMailerSettings/abstractions.js","sources":["../../../src/domain/CodeMailerSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport interface ICodeMailerSettings {\n get(transportName: string): TransportSettings | null;\n}\n\nexport const CodeMailerSettings = createAbstraction<ICodeMailerSettings>(\"CodeMailerSettings\");\n\nexport namespace CodeMailerSettings {\n export type Interface = ICodeMailerSettings;\n}\n"],"names":["CodeMailerSettings","createAbstraction"],"mappings":";AAOO,MAAMA,qBAAqBC,kBAAuC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const MailTransport = createAbstraction("MailTransport");
|
|
3
|
+
const MailTransportFactory = createAbstraction("MailTransportFactory");
|
|
4
|
+
const ActiveTransport = createAbstraction("ActiveTransport");
|
|
5
|
+
export { ActiveTransport, MailTransport, MailTransportFactory };
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/MailTransport/abstractions.js","sources":["../../../src/domain/MailTransport/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse, TransportSettings } from \"~/types.js\";\n\nexport interface IMailTransport {\n name: string;\n send(params: TransportSendData): Promise<TransportSendResponse>;\n}\n\nexport const MailTransport = createAbstraction<IMailTransport>(\"MailTransport\");\n\nexport namespace MailTransport {\n export type Interface = IMailTransport;\n export type SendParams = TransportSendData;\n}\n\nexport interface IMailTransportFactory {\n name: string;\n createTransport(settings: TransportSettings): Promise<IMailTransport>;\n}\n\nexport const MailTransportFactory =\n createAbstraction<IMailTransportFactory>(\"MailTransportFactory\");\n\nexport namespace MailTransportFactory {\n export type Interface = IMailTransportFactory;\n export type Return = Promise<IMailTransport>;\n}\n\nexport interface IActiveTransport {\n name(): string | null;\n}\n\nexport const ActiveTransport = createAbstraction<IActiveTransport>(\"ActiveTransport\");\n\nexport namespace ActiveTransport {\n export type Interface = IActiveTransport;\n}\n"],"names":["MailTransport","createAbstraction","MailTransportFactory","ActiveTransport"],"mappings":";AAQO,MAAMA,gBAAgBC,kBAAkC;AAYxD,MAAMC,uBACTD,kBAAyC;AAWtC,MAAME,kBAAkBF,kBAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/MailerService/abstractions.js","sources":["../../../src/domain/MailerService/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse } from \"~/types.js\";\nimport {\n NoTransportAvailableError,\n NoSettingsConfiguredError,\n TransportSendError\n} from \"./errors.js\";\n\nexport interface IMailerServiceErrors {\n noTransport: NoTransportAvailableError;\n noSettings: NoSettingsConfiguredError;\n transportSend: TransportSendError;\n}\n\ntype MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];\n\nexport interface IMailerService {\n sendMail<T = any>(\n data: TransportSendData\n ): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n}\n\nexport const MailerService = createAbstraction<IMailerService>(\"MailerService\");\n\nexport namespace MailerService {\n export type Interface = IMailerService;\n export type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n export type Error = MailerServiceError;\n}\n"],"names":["MailerService","createAbstraction"],"mappings":";AAuBO,MAAMA,gBAAgBC,kBAAkC"}
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import { BaseError } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
2
|
+
class NoTransportAvailableError extends BaseError {
|
|
3
|
+
constructor(){
|
|
4
|
+
super({
|
|
5
|
+
message: "There is no transport available."
|
|
6
|
+
}), this.code = "Mailer/MailerService/NoTransportAvailable";
|
|
7
|
+
}
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
9
|
+
class NoSettingsConfiguredError extends BaseError {
|
|
10
|
+
constructor(){
|
|
11
|
+
super({
|
|
12
|
+
message: "No mailer settings are configured and no environment variables are set."
|
|
13
|
+
}), this.code = "Mailer/MailerService/NoSettingsConfigured";
|
|
14
|
+
}
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
16
|
+
class TransportSendError extends BaseError {
|
|
17
|
+
constructor(error){
|
|
18
|
+
super({
|
|
19
|
+
message: error.message,
|
|
20
|
+
data: {
|
|
21
|
+
error
|
|
22
|
+
}
|
|
23
|
+
}), this.code = "Mailer/MailerService/TransportSendError";
|
|
24
|
+
}
|
|
28
25
|
}
|
|
26
|
+
export { NoSettingsConfiguredError, NoTransportAvailableError, TransportSendError };
|
|
29
27
|
|
|
30
28
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/MailerService/errors.js","sources":["../../../src/domain/MailerService/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { TransportSendResponse } from \"~/types.js\";\n\nexport class NoTransportAvailableError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoTransportAvailable\" as const;\n\n constructor() {\n super({\n message: \"There is no transport available.\"\n });\n }\n}\n\nexport class NoSettingsConfiguredError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoSettingsConfigured\" as const;\n\n constructor() {\n super({\n message: \"No mailer settings are configured and no environment variables are set.\"\n });\n }\n}\n\nexport class TransportSendError extends BaseError<{ error: TransportSendResponse[\"error\"] }> {\n override readonly code = \"Mailer/MailerService/TransportSendError\" as const;\n\n constructor(error: NonNullable<TransportSendResponse[\"error\"]>) {\n super({\n message: error.message,\n data: {\n error\n }\n });\n }\n}\n"],"names":["NoTransportAvailableError","BaseError","NoSettingsConfiguredError","TransportSendError","error"],"mappings":";AAGO,MAAMA,kCAAkCC;IAG3C,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,kCAAkCD;IAG3C,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAME,2BAA2BF;IAGpC,YAAYG,KAAkD,CAAE;QAC5D,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;YACtB,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ"}
|
package/domain/errors.js
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
import { BaseError } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
}
|
|
2
|
+
class MailValidationError extends BaseError {
|
|
3
|
+
constructor(errors){
|
|
4
|
+
super({
|
|
5
|
+
message: "Email params are invalid.",
|
|
6
|
+
data: {
|
|
7
|
+
errors
|
|
8
|
+
}
|
|
9
|
+
}), this.code = "Mailer/SendMail/Validation";
|
|
10
|
+
}
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
12
|
+
class SettingsValidationError extends BaseError {
|
|
13
|
+
constructor(errors){
|
|
14
|
+
super({
|
|
15
|
+
message: "Settings validation failed.",
|
|
16
|
+
data: {
|
|
17
|
+
errors
|
|
18
|
+
}
|
|
19
|
+
}), this.code = "Mailer/Settings/Validation";
|
|
20
|
+
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
22
|
+
class SettingsNotAuthorized extends BaseError {
|
|
23
|
+
constructor(){
|
|
24
|
+
super({
|
|
25
|
+
message: "Not allowed to update the mailer settings."
|
|
26
|
+
}), this.code = "Mailer/Settings/NotAuthorized";
|
|
27
|
+
}
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
29
|
+
class SettingsPersistenceError extends BaseError {
|
|
30
|
+
constructor(error){
|
|
31
|
+
super({
|
|
32
|
+
message: "Failed to persist settings.",
|
|
33
|
+
data: {
|
|
34
|
+
error
|
|
35
|
+
}
|
|
36
|
+
}), this.code = "Mailer/Settings/Persistence";
|
|
37
|
+
}
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
39
|
+
class SettingsLockedByCode extends BaseError {
|
|
40
|
+
constructor(){
|
|
41
|
+
super({
|
|
42
|
+
message: "Mailer settings are managed by code and cannot be saved via the API."
|
|
43
|
+
}), this.code = "Mailer/Settings/LockedByCode";
|
|
44
|
+
}
|
|
50
45
|
}
|
|
46
|
+
export { MailValidationError, SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError };
|
|
51
47
|
|
|
52
48
|
//# sourceMappingURL=errors.js.map
|
package/domain/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"domain/errors.js","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not allowed to update the mailer settings.\" });\n }\n}\n\nexport class SettingsPersistenceError extends BaseError<{ error: Error }> {\n override readonly code = \"Mailer/Settings/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: \"Failed to persist settings.\",\n data: {\n error\n }\n });\n }\n}\n\nexport class SettingsLockedByCode extends BaseError {\n override readonly code = \"Mailer/Settings/LockedByCode\" as const;\n\n constructor() {\n super({\n message: \"Mailer settings are managed by code and cannot be saved via the API.\"\n });\n }\n}\n"],"names":["MailValidationError","BaseError","errors","SettingsValidationError","SettingsNotAuthorized","SettingsPersistenceError","error","SettingsLockedByCode"],"mappings":";AAGO,MAAMA,4BAA4BC;IAGrC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,gCAAgCF;IAGzC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAME,8BAA8BH;IAGvC,aAAc;QACV,KAAK,CAAC;YAAE,SAAS;QAA6C,SAHhD,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMI,iCAAiCJ;IAG1C,YAAYK,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,6BAA6BN;IAGtC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ"}
|
package/exports/api/mailer.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler, SendMailUseCase } from "../../features/SendMail/index.js";
|
|
2
|
+
export { GetSettingsRepository, GetSettingsUseCase } from "../../features/GetSettings/index.js";
|
|
3
|
+
export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase } from "../../features/SaveSettings/index.js";
|
|
4
4
|
export { MailerService } from "../../domain/MailerService/abstractions.js";
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=mailer.js.map
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
-
import { CodeMailerSettings
|
|
2
|
+
import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
3
|
const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
|
|
4
4
|
const SMTP_BUILD_PARAM_KEY = "Mailer.SmtpSettings";
|
|
5
5
|
class CodeMailerSettingsImpl {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
constructor(buildParams){
|
|
7
|
+
this.buildParams = buildParams;
|
|
8
|
+
}
|
|
9
|
+
get(transportName) {
|
|
10
|
+
if (transportName !== SMTP_TRANSPORT_NAME) return null;
|
|
11
|
+
const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
|
|
12
|
+
return value ?? null;
|
|
12
13
|
}
|
|
13
|
-
const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
|
|
14
|
-
return value ?? null;
|
|
15
|
-
}
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const CodeMailerSettingsImpl_CodeMailerSettings = CodeMailerSettings.createImplementation({
|
|
16
|
+
implementation: CodeMailerSettingsImpl,
|
|
17
|
+
dependencies: [
|
|
18
|
+
BuildParams
|
|
19
|
+
]
|
|
20
20
|
});
|
|
21
|
+
export { CodeMailerSettingsImpl_CodeMailerSettings as CodeMailerSettings };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=CodeMailerSettingsImpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CodeMailerSettings/CodeMailerSettingsImpl.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettingsImpl.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"names":["SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;AAIA,MAAMA,sBAAsB;AAC5B,MAAMC,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBJ,qBAClB,OAAO;QAEX,MAAMK,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBJ;QACtD,OAAOI,SAAS;IACpB;AACJ;AAEO,MAAMC,4CAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { CodeMailerSettings } from "./CodeMailerSettingsImpl.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const CodeMailerSettingsFeature = createFeature({
|
|
4
|
+
name: "Mailer/CodeMailerSettings",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(CodeMailerSettings).inSingletonScope();
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { CodeMailerSettingsFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./CodeMailerSettingsImpl.js\";\n\nexport const CodeMailerSettingsFeature = createFeature({\n name: \"Mailer/CodeMailerSettings\",\n register(container) {\n container.register(CodeMailerSettings).inSingletonScope();\n }\n});\n"],"names":["CodeMailerSettingsFeature","createFeature","container","CodeMailerSettings"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;IAC3D;AACJ"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
class DummyMailTransport {
|
|
2
|
+
constructor(){
|
|
3
|
+
this.name = "Mailer/DummyTransport";
|
|
4
|
+
}
|
|
5
|
+
async send() {
|
|
6
|
+
return {
|
|
7
|
+
result: true,
|
|
8
|
+
error: null
|
|
9
|
+
};
|
|
10
|
+
}
|
|
10
11
|
}
|
|
12
|
+
export { DummyMailTransport };
|
|
11
13
|
|
|
12
14
|
//# sourceMappingURL=DummyMailTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/DummyTransport/DummyMailTransport.js","sources":["../../../src/features/DummyTransport/DummyMailTransport.ts"],"sourcesContent":["import { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class DummyMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n constructor() {}\n\n async send() {\n return {\n result: true,\n error: null\n };\n }\n}\n"],"names":["DummyMailTransport"],"mappings":"AAEO,MAAMA;IAGT,aAAc;aAFE,IAAI,GAAG;IAER;IAEf,MAAM,OAAO;QACT,OAAO;YACH,QAAQ;YACR,OAAO;QACX;IACJ;AACJ"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
2
|
import { DummyMailTransport } from "./DummyMailTransport.js";
|
|
3
3
|
class DummyMailTransportFactoryImpl {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
async createTransport() {
|
|
5
|
+
return new DummyMailTransport();
|
|
6
|
+
}
|
|
7
|
+
constructor(){
|
|
8
|
+
this.name = "Mailer/DummyTransport";
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const DummyMailTransportFactory = MailTransportFactory.createImplementation({
|
|
12
|
+
implementation: DummyMailTransportFactoryImpl,
|
|
13
|
+
dependencies: []
|
|
12
14
|
});
|
|
15
|
+
export { DummyMailTransportFactory };
|
|
13
16
|
|
|
14
17
|
//# sourceMappingURL=DummyMailTransportFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/DummyTransport/DummyMailTransportFactory.js","sources":["../../../src/features/DummyTransport/DummyMailTransportFactory.ts"],"sourcesContent":["import { type IMailTransport, MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { DummyMailTransport } from \"./DummyMailTransport.js\";\n\nclass DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n async createTransport(): Promise<IMailTransport> {\n return new DummyMailTransport();\n }\n}\n\nexport const DummyMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: DummyMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["DummyMailTransportFactoryImpl","DummyMailTransport","DummyMailTransportFactory","MailTransportFactory"],"mappings":";;AAGA,MAAMA;IAGF,MAAM,kBAA2C;QAC7C,OAAO,IAAIC;IACf;;aAJgB,IAAI,GAAG;;AAK3B;AAEO,MAAMC,4BAA4BC,qBAAqB,oBAAoB,CAAC;IAC/E,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { DummyMailTransportFactory } from "./DummyMailTransportFactory.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const DummyTransportFeature = createFeature({
|
|
4
|
+
name: "Mailer/DummyTransport",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(DummyMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { DummyTransportFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/DummyTransport/feature.js","sources":["../../../src/features/DummyTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DummyMailTransportFactory } from \"./DummyMailTransportFactory.js\";\n\nexport const DummyTransportFeature = createFeature({\n name: \"Mailer/DummyTransport\",\n register(container) {\n container.register(DummyMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["DummyTransportFeature","createFeature","container","DummyMailTransportFactory"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,2BAA2B,gBAAgB;IAClE;AACJ"}
|
|
@@ -5,54 +5,50 @@ import { GetSettingsRepository } from "./abstractions.js";
|
|
|
5
5
|
import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
6
6
|
import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
|
|
7
7
|
class GetSettingsRepositoryImpl {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
async get(transportName) {
|
|
14
|
-
// Code-defined settings win over the KV store.
|
|
15
|
-
const codeSettingsValue = this.codeSettings.get(transportName);
|
|
16
|
-
if (codeSettingsValue !== null) {
|
|
17
|
-
return Result.ok({
|
|
18
|
-
settings: codeSettingsValue,
|
|
19
|
-
source: "code"
|
|
20
|
-
});
|
|
8
|
+
constructor(keyValueStore, encryption, codeSettings){
|
|
9
|
+
this.keyValueStore = keyValueStore;
|
|
10
|
+
this.encryption = encryption;
|
|
11
|
+
this.codeSettings = codeSettings;
|
|
21
12
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
async get(transportName) {
|
|
14
|
+
const codeSettingsValue = this.codeSettings.get(transportName);
|
|
15
|
+
if (null !== codeSettingsValue) return Result.ok({
|
|
16
|
+
settings: codeSettingsValue,
|
|
17
|
+
source: "code"
|
|
18
|
+
});
|
|
19
|
+
const result = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
|
|
20
|
+
if (result.isFail()) return Result.ok({
|
|
21
|
+
settings: null,
|
|
22
|
+
source: null
|
|
23
|
+
});
|
|
24
|
+
const settings = result.value;
|
|
25
|
+
if (!settings) return Result.ok({
|
|
26
|
+
settings: null,
|
|
27
|
+
source: null
|
|
28
|
+
});
|
|
29
|
+
const password = settings.password ? this.encryption.decrypt(String(settings.password)) : "";
|
|
30
|
+
const transportSettings = {
|
|
31
|
+
host: String(settings.host || ""),
|
|
32
|
+
port: Number(settings.port || 25),
|
|
33
|
+
user: String(settings.user || ""),
|
|
34
|
+
password,
|
|
35
|
+
from: String(settings.from || ""),
|
|
36
|
+
replyTo: settings.replyTo ? String(settings.replyTo) : void 0
|
|
37
|
+
};
|
|
38
|
+
return Result.ok({
|
|
39
|
+
settings: transportSettings,
|
|
40
|
+
source: "storage"
|
|
41
|
+
});
|
|
28
42
|
}
|
|
29
|
-
const settings = result.value;
|
|
30
|
-
if (!settings) {
|
|
31
|
-
return Result.ok({
|
|
32
|
-
settings: null,
|
|
33
|
-
source: null
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Decrypt password if present.
|
|
38
|
-
const password = settings.password ? this.encryption.decrypt(String(settings.password)) : "";
|
|
39
|
-
const transportSettings = {
|
|
40
|
-
host: String(settings.host || ""),
|
|
41
|
-
port: Number(settings.port || 25),
|
|
42
|
-
user: String(settings.user || ""),
|
|
43
|
-
password,
|
|
44
|
-
from: String(settings.from || ""),
|
|
45
|
-
replyTo: settings.replyTo ? String(settings.replyTo) : undefined
|
|
46
|
-
};
|
|
47
|
-
return Result.ok({
|
|
48
|
-
settings: transportSettings,
|
|
49
|
-
source: "storage"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
|
|
45
|
+
implementation: GetSettingsRepositoryImpl,
|
|
46
|
+
dependencies: [
|
|
47
|
+
KeyValueStore,
|
|
48
|
+
Encryption,
|
|
49
|
+
CodeMailerSettings
|
|
50
|
+
]
|
|
56
51
|
});
|
|
52
|
+
export { GetSettingsRepositoryImplementation };
|
|
57
53
|
|
|
58
54
|
//# sourceMappingURL=GetSettingsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/GetSettings/GetSettingsRepository.js","sources":["../../../src/features/GetSettings/GetSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { GetSettingsRepository, type ISettingsWithSource } from \"./abstractions.js\";\nimport { CodeMailerSettings } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { MAILER_TRANSPORT_SETTINGS } from \"~/constants.js\";\n\nclass GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface,\n private codeSettings: CodeMailerSettings.Interface\n ) {}\n\n async get(transportName: string): Promise<Result<ISettingsWithSource>> {\n // Code-defined settings win over the KV store.\n const codeSettingsValue = this.codeSettings.get(transportName);\n if (codeSettingsValue !== null) {\n return Result.ok({\n settings: codeSettingsValue,\n source: \"code\"\n });\n }\n\n const result = await this.keyValueStore.get<TransportSettings>(MAILER_TRANSPORT_SETTINGS);\n\n if (result.isFail()) {\n return Result.ok({ settings: null, source: null });\n }\n\n const settings = result.value;\n if (!settings) {\n return Result.ok({ settings: null, source: null });\n }\n\n // Decrypt password if present.\n const password = settings.password\n ? this.encryption.decrypt(String(settings.password))\n : \"\";\n\n const transportSettings: TransportSettings = {\n host: String(settings.host || \"\"),\n port: Number(settings.port || 25),\n user: String(settings.user || \"\"),\n password,\n from: String(settings.from || \"\"),\n replyTo: settings.replyTo ? String(settings.replyTo) : undefined\n };\n\n return Result.ok({ settings: transportSettings, source: \"storage\" });\n }\n}\n\nexport const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption, CodeMailerSettings]\n});\n"],"names":["GetSettingsRepositoryImpl","keyValueStore","encryption","codeSettings","transportName","codeSettingsValue","Result","result","MAILER_TRANSPORT_SETTINGS","settings","password","String","transportSettings","Number","undefined","GetSettingsRepositoryImplementation","GetSettingsRepository","KeyValueStore","Encryption","CodeMailerSettings"],"mappings":";;;;;;AAQA,MAAMA;IACF,YACYC,aAAsC,EACtCC,UAAgC,EAChCC,YAA0C,CACpD;aAHUF,aAAa,GAAbA;aACAC,UAAU,GAAVA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,IAAIC,aAAqB,EAAwC;QAEnE,MAAMC,oBAAoB,IAAI,CAAC,YAAY,CAAC,GAAG,CAACD;QAChD,IAAIC,AAAsB,SAAtBA,mBACA,OAAOC,OAAO,EAAE,CAAC;YACb,UAAUD;YACV,QAAQ;QACZ;QAGJ,MAAME,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAoBC;QAE/D,IAAID,OAAO,MAAM,IACb,OAAOD,OAAO,EAAE,CAAC;YAAE,UAAU;YAAM,QAAQ;QAAK;QAGpD,MAAMG,WAAWF,OAAO,KAAK;QAC7B,IAAI,CAACE,UACD,OAAOH,OAAO,EAAE,CAAC;YAAE,UAAU;YAAM,QAAQ;QAAK;QAIpD,MAAMI,WAAWD,SAAS,QAAQ,GAC5B,IAAI,CAAC,UAAU,CAAC,OAAO,CAACE,OAAOF,SAAS,QAAQ,KAChD;QAEN,MAAMG,oBAAuC;YACzC,MAAMD,OAAOF,SAAS,IAAI,IAAI;YAC9B,MAAMI,OAAOJ,SAAS,IAAI,IAAI;YAC9B,MAAME,OAAOF,SAAS,IAAI,IAAI;YAC9BC;YACA,MAAMC,OAAOF,SAAS,IAAI,IAAI;YAC9B,SAASA,SAAS,OAAO,GAAGE,OAAOF,SAAS,OAAO,IAAIK;QAC3D;QAEA,OAAOR,OAAO,EAAE,CAAC;YAAE,UAAUM;YAAmB,QAAQ;QAAU;IACtE;AACJ;AAEO,MAAMG,sCAAsCC,sBAAsB,oBAAoB,CAAC;IAC1F,gBAAgBhB;IAChB,cAAc;QAACiB;QAAeC;QAAYC;KAAmB;AACjE"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetSettingsRepository, GetSettingsUseCase } from "./abstractions.js";
|
|
2
2
|
class GetSettingsUseCaseImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
constructor(repository){
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
execute(transportName) {
|
|
7
|
+
return this.repository.get(transportName);
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
|
|
11
|
+
implementation: GetSettingsUseCaseImpl,
|
|
12
|
+
dependencies: [
|
|
13
|
+
GetSettingsRepository
|
|
14
|
+
]
|
|
13
15
|
});
|
|
16
|
+
export { GetSettingsUseCaseImplementation };
|
|
14
17
|
|
|
15
18
|
//# sourceMappingURL=GetSettingsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/GetSettings/GetSettingsUseCase.js","sources":["../../../src/features/GetSettings/GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetSettingsUseCase,\n GetSettingsRepository,\n type ISettingsWithSource\n} from \"./abstractions.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute(transportName: string): Promise<Result<ISettingsWithSource>> {\n return this.repository.get(transportName);\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"names":["GetSettingsUseCaseImpl","repository","transportName","GetSettingsUseCaseImplementation","GetSettingsUseCase","GetSettingsRepository"],"mappings":";AAOA,MAAMA;IACF,YAAoBC,UAA2C,CAAE;aAA7CA,UAAU,GAAVA;IAA8C;IAElE,QAAQC,aAAqB,EAAwC;QACjE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA;IAC/B;AACJ;AAEO,MAAMC,mCAAmCC,mBAAmB,oBAAoB,CAAC;IACpF,gBAAgBJ;IAChB,cAAc;QAACK;KAAsB;AACzC"}
|