@webiny/api-mailer 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7
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/README.md +10 -13
- package/constants.d.ts +1 -0
- package/constants.js +3 -0
- package/constants.js.map +1 -0
- package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
- package/domain/CodeMailerSettings/abstractions.js +4 -0
- package/domain/CodeMailerSettings/abstractions.js.map +1 -0
- package/domain/MailTransport/abstractions.d.ts +26 -0
- package/domain/MailTransport/abstractions.js +6 -0
- package/domain/MailTransport/abstractions.js.map +1 -0
- package/domain/MailerService/abstractions.d.ts +19 -0
- package/domain/MailerService/abstractions.js +4 -0
- package/domain/MailerService/abstractions.js.map +1 -0
- package/domain/MailerService/errors.d.ts +16 -0
- package/domain/MailerService/errors.js +30 -0
- package/domain/MailerService/errors.js.map +1 -0
- package/domain/errors.d.ts +28 -0
- package/domain/errors.js +52 -0
- package/domain/errors.js.map +1 -0
- package/exports/api/mailer.d.ts +4 -0
- package/exports/api/mailer.js +6 -0
- package/exports/api/mailer.js.map +1 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.d.ts +12 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +22 -0
- package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -0
- package/features/CodeMailerSettings/feature.d.ts +4 -0
- package/features/CodeMailerSettings/feature.js +10 -0
- package/features/CodeMailerSettings/feature.js.map +1 -0
- package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransport.js +12 -0
- package/features/DummyTransport/DummyMailTransport.js.map +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +14 -0
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
- package/features/DummyTransport/feature.d.ts +4 -0
- package/features/DummyTransport/feature.js +10 -0
- package/features/DummyTransport/feature.js.map +1 -0
- package/features/GetSettings/GetSettingsRepository.d.ts +16 -0
- package/features/GetSettings/GetSettingsRepository.js +58 -0
- package/features/GetSettings/GetSettingsRepository.js.map +1 -0
- package/features/GetSettings/GetSettingsUseCase.d.ts +11 -0
- package/features/GetSettings/GetSettingsUseCase.js +15 -0
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/GetSettings/abstractions.d.ts +22 -0
- package/features/GetSettings/abstractions.js +5 -0
- package/features/GetSettings/abstractions.js.map +1 -0
- package/features/GetSettings/feature.d.ts +4 -0
- package/features/GetSettings/feature.js +12 -0
- package/features/GetSettings/feature.js.map +1 -0
- package/features/GetSettings/index.d.ts +1 -0
- package/features/GetSettings/index.js +3 -0
- package/features/GetSettings/index.js.map +1 -0
- package/features/MailerService/ActiveTransport.d.ts +10 -0
- package/features/MailerService/ActiveTransport.js +20 -0
- package/features/MailerService/ActiveTransport.js.map +1 -0
- package/features/MailerService/MailerService.d.ts +16 -0
- package/features/MailerService/MailerService.js +53 -0
- package/features/MailerService/MailerService.js.map +1 -0
- package/features/MailerService/feature.d.ts +4 -0
- package/features/MailerService/feature.js +12 -0
- package/features/MailerService/feature.js.map +1 -0
- package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
- package/features/SaveSettings/SaveSettingsRepository.js +59 -0
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +18 -0
- package/features/SaveSettings/SaveSettingsUseCase.js +69 -0
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
- package/features/SaveSettings/abstractions.d.ts +61 -0
- package/features/SaveSettings/abstractions.js +20 -0
- package/features/SaveSettings/abstractions.js.map +1 -0
- package/features/SaveSettings/events.d.ts +10 -0
- package/features/SaveSettings/events.js +16 -0
- package/features/SaveSettings/events.js.map +1 -0
- package/features/SaveSettings/feature.d.ts +4 -0
- package/features/SaveSettings/feature.js +12 -0
- package/features/SaveSettings/feature.js.map +1 -0
- package/features/SaveSettings/index.d.ts +1 -0
- package/features/SaveSettings/index.js +3 -0
- package/features/SaveSettings/index.js.map +1 -0
- package/features/SaveSettings/validation.d.ts +9 -0
- package/features/SaveSettings/validation.js +23 -0
- package/features/SaveSettings/validation.js.map +1 -0
- package/features/SendMail/SendMailUseCase.d.ts +16 -0
- package/features/SendMail/SendMailUseCase.js +65 -0
- package/features/SendMail/SendMailUseCase.js.map +1 -0
- package/features/SendMail/abstractions.d.ts +45 -0
- package/features/SendMail/abstractions.js +11 -0
- package/features/SendMail/abstractions.js.map +1 -0
- package/features/SendMail/events.d.ts +14 -0
- package/features/SendMail/events.js +22 -0
- package/features/SendMail/events.js.map +1 -0
- package/features/SendMail/feature.d.ts +4 -0
- package/features/SendMail/feature.js +10 -0
- package/features/SendMail/feature.js.map +1 -0
- package/features/SendMail/index.d.ts +1 -0
- package/features/SendMail/index.js +3 -0
- package/features/SendMail/index.js.map +1 -0
- package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
- package/features/SmtpTransport/SmtpConfig.js +29 -0
- package/features/SmtpTransport/SmtpConfig.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransport.d.ts +68 -0
- package/features/SmtpTransport/SmtpMailTransport.js +67 -0
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +10 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +15 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
- package/features/SmtpTransport/feature.d.ts +4 -0
- package/features/SmtpTransport/feature.js +10 -0
- package/features/SmtpTransport/feature.js.map +1 -0
- package/graphql/settings.d.ts +2 -2
- package/graphql/settings.js +60 -36
- package/graphql/settings.js.map +1 -1
- package/index.d.ts +4 -5
- package/index.js +22 -78
- package/index.js.map +1 -1
- package/package.json +27 -31
- package/types.d.ts +0 -107
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/utils/isMailboxAddress.d.ts +6 -0
- package/utils/isMailboxAddress.js +12 -0
- package/utils/isMailboxAddress.js.map +1 -0
- package/context.d.ts +0 -3
- package/context.js +0 -20
- package/context.js.map +0 -1
- package/crud/settings/hooks.d.ts +0 -5
- package/crud/settings/hooks.js +0 -42
- package/crud/settings/hooks.js.map +0 -1
- package/crud/settings/model.d.ts +0 -2
- package/crud/settings/model.js +0 -72
- package/crud/settings/model.js.map +0 -1
- package/crud/settings/password.d.ts +0 -7
- package/crud/settings/password.js +0 -55
- package/crud/settings/password.js.map +0 -1
- package/crud/settings/secret.d.ts +0 -1
- package/crud/settings/secret.js +0 -19
- package/crud/settings/secret.js.map +0 -1
- package/crud/settings/transform.d.ts +0 -13
- package/crud/settings/transform.js +0 -46
- package/crud/settings/transform.js.map +0 -1
- package/crud/settings/validation.d.ts +0 -45
- package/crud/settings/validation.js +0 -28
- package/crud/settings/validation.js.map +0 -1
- package/crud/settings.crud.d.ts +0 -5
- package/crud/settings.crud.js +0 -269
- package/crud/settings.crud.js.map +0 -1
- package/crud/transport/onTransportBeforeSend.d.ts +0 -7
- package/crud/transport/onTransportBeforeSend.js +0 -62
- package/crud/transport/onTransportBeforeSend.js.map +0 -1
- package/crud/transporter.crud.d.ts +0 -2
- package/crud/transporter.crud.js +0 -158
- package/crud/transporter.crud.js.map +0 -1
- package/graphql/index.d.ts +0 -1
- package/graphql/index.js +0 -13
- package/graphql/index.js.map +0 -1
- package/plugins/CreateTransportPlugin.d.ts +0 -17
- package/plugins/CreateTransportPlugin.js +0 -24
- package/plugins/CreateTransportPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -18
- package/plugins/index.js.map +0 -1
- package/transports/createDummyTransport.d.ts +0 -5
- package/transports/createDummyTransport.js +0 -25
- package/transports/createDummyTransport.js.map +0 -1
- package/transports/createSmtpTransport.d.ts +0 -13
- package/transports/createSmtpTransport.js +0 -94
- package/transports/createSmtpTransport.js.map +0 -1
- package/transports/index.d.ts +0 -2
- package/transports/index.js +0 -29
- package/transports/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# @webiny/api-mailer
|
|
2
|
-
|
|
3
|
-
[!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Documentation
|
|
14
|
-
[Webiny Documentation > Overview > Features > Mailer](https://www.webiny.com/docs/overview/features/mailer)
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
|
package/constants.js
ADDED
package/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAILER_TRANSPORT_SETTINGS"],"sources":["constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\n"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG,2BAA2B","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TransportSettings } from "../../types.js";
|
|
2
|
+
export interface ICodeMailerSettings {
|
|
3
|
+
get(transportName: string): TransportSettings | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const CodeMailerSettings: import("@webiny/di").Abstraction<ICodeMailerSettings>;
|
|
6
|
+
export declare namespace CodeMailerSettings {
|
|
7
|
+
type Interface = ICodeMailerSettings;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","CodeMailerSettings"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,kBAAkB,GAAGD,iBAAiB,CAAsB,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TransportSendData, TransportSendResponse, TransportSettings } from "../../types.js";
|
|
2
|
+
export interface IMailTransport {
|
|
3
|
+
name: string;
|
|
4
|
+
send(params: TransportSendData): Promise<TransportSendResponse>;
|
|
5
|
+
}
|
|
6
|
+
export declare const MailTransport: import("@webiny/di").Abstraction<IMailTransport>;
|
|
7
|
+
export declare namespace MailTransport {
|
|
8
|
+
type Interface = IMailTransport;
|
|
9
|
+
type SendParams = TransportSendData;
|
|
10
|
+
}
|
|
11
|
+
export interface IMailTransportFactory {
|
|
12
|
+
name: string;
|
|
13
|
+
createTransport(settings: TransportSettings): Promise<IMailTransport>;
|
|
14
|
+
}
|
|
15
|
+
export declare const MailTransportFactory: import("@webiny/di").Abstraction<IMailTransportFactory>;
|
|
16
|
+
export declare namespace MailTransportFactory {
|
|
17
|
+
type Interface = IMailTransportFactory;
|
|
18
|
+
type Return = Promise<IMailTransport>;
|
|
19
|
+
}
|
|
20
|
+
export interface IActiveTransport {
|
|
21
|
+
name(): string | null;
|
|
22
|
+
}
|
|
23
|
+
export declare const ActiveTransport: import("@webiny/di").Abstraction<IActiveTransport>;
|
|
24
|
+
export declare namespace ActiveTransport {
|
|
25
|
+
type Interface = IActiveTransport;
|
|
26
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
export const MailTransport = createAbstraction("MailTransport");
|
|
3
|
+
export const MailTransportFactory = createAbstraction("MailTransportFactory");
|
|
4
|
+
export const ActiveTransport = createAbstraction("ActiveTransport");
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","MailTransport","MailTransportFactory","ActiveTransport"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC;AAY/E,OAAO,MAAME,oBAAoB,GAC7BF,iBAAiB,CAAwB,sBAAsB,CAAC;AAWpE,OAAO,MAAMG,eAAe,GAAGH,iBAAiB,CAAmB,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSendData, TransportSendResponse } from "../../types.js";
|
|
3
|
+
import { NoTransportAvailableError, NoSettingsConfiguredError, TransportSendError } from "./errors.js";
|
|
4
|
+
export interface IMailerServiceErrors {
|
|
5
|
+
noTransport: NoTransportAvailableError;
|
|
6
|
+
noSettings: NoSettingsConfiguredError;
|
|
7
|
+
transportSend: TransportSendError;
|
|
8
|
+
}
|
|
9
|
+
type MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];
|
|
10
|
+
export interface IMailerService {
|
|
11
|
+
sendMail<T = any>(data: TransportSendData): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const MailerService: import("@webiny/di").Abstraction<IMailerService>;
|
|
14
|
+
export declare namespace MailerService {
|
|
15
|
+
type Interface = IMailerService;
|
|
16
|
+
type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;
|
|
17
|
+
type Error = MailerServiceError;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","MailerService"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAuBvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSendResponse } from "../../types.js";
|
|
3
|
+
export declare class NoTransportAvailableError extends BaseError {
|
|
4
|
+
readonly code: "Mailer/MailerService/NoTransportAvailable";
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class NoSettingsConfiguredError extends BaseError {
|
|
8
|
+
readonly code: "Mailer/MailerService/NoSettingsConfigured";
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare class TransportSendError extends BaseError<{
|
|
12
|
+
error: TransportSendResponse["error"];
|
|
13
|
+
}> {
|
|
14
|
+
readonly code: "Mailer/MailerService/TransportSendError";
|
|
15
|
+
constructor(error: NonNullable<TransportSendResponse["error"]>);
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
export class NoTransportAvailableError extends BaseError {
|
|
3
|
+
code = "Mailer/MailerService/NoTransportAvailable";
|
|
4
|
+
constructor() {
|
|
5
|
+
super({
|
|
6
|
+
message: "There is no transport available."
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class NoSettingsConfiguredError extends BaseError {
|
|
11
|
+
code = "Mailer/MailerService/NoSettingsConfigured";
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
message: "No mailer settings are configured and no environment variables are set."
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class TransportSendError extends BaseError {
|
|
19
|
+
code = "Mailer/MailerService/TransportSendError";
|
|
20
|
+
constructor(error) {
|
|
21
|
+
super({
|
|
22
|
+
message: error.message,
|
|
23
|
+
data: {
|
|
24
|
+
error
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BaseError","NoTransportAvailableError","code","constructor","message","NoSettingsConfiguredError","TransportSendError","error","data"],"sources":["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"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,yBAAyB,SAASD,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMC,yBAAyB,SAASL,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAME,kBAAkB,SAASN,SAAS,CAA4C;EACvEE,IAAI,GAAG,yCAAyC;EAElEC,WAAWA,CAACI,KAAkD,EAAE;IAC5D,KAAK,CAAC;MACFH,OAAO,EAAEG,KAAK,CAACH,OAAO;MACtBI,IAAI,EAAE;QACFD;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
import type { ZodError } from "zod";
|
|
3
|
+
export declare class MailValidationError extends BaseError<{
|
|
4
|
+
errors: ZodError["issues"];
|
|
5
|
+
}> {
|
|
6
|
+
readonly code: "Mailer/SendMail/Validation";
|
|
7
|
+
constructor(errors: ZodError["issues"]);
|
|
8
|
+
}
|
|
9
|
+
export declare class SettingsValidationError extends BaseError<{
|
|
10
|
+
errors: ZodError["issues"];
|
|
11
|
+
}> {
|
|
12
|
+
readonly code: "Mailer/Settings/Validation";
|
|
13
|
+
constructor(errors: ZodError["issues"]);
|
|
14
|
+
}
|
|
15
|
+
export declare class SettingsNotAuthorized extends BaseError {
|
|
16
|
+
readonly code: "Mailer/Settings/NotAuthorized";
|
|
17
|
+
constructor();
|
|
18
|
+
}
|
|
19
|
+
export declare class SettingsPersistenceError extends BaseError<{
|
|
20
|
+
error: Error;
|
|
21
|
+
}> {
|
|
22
|
+
readonly code: "Mailer/Settings/Persistence";
|
|
23
|
+
constructor(error: Error);
|
|
24
|
+
}
|
|
25
|
+
export declare class SettingsLockedByCode extends BaseError {
|
|
26
|
+
readonly code: "Mailer/Settings/LockedByCode";
|
|
27
|
+
constructor();
|
|
28
|
+
}
|
package/domain/errors.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
export class MailValidationError extends BaseError {
|
|
3
|
+
code = "Mailer/SendMail/Validation";
|
|
4
|
+
constructor(errors) {
|
|
5
|
+
super({
|
|
6
|
+
message: "Email params are invalid.",
|
|
7
|
+
data: {
|
|
8
|
+
errors
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class SettingsValidationError extends BaseError {
|
|
14
|
+
code = "Mailer/Settings/Validation";
|
|
15
|
+
constructor(errors) {
|
|
16
|
+
super({
|
|
17
|
+
message: "Settings validation failed.",
|
|
18
|
+
data: {
|
|
19
|
+
errors
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class SettingsNotAuthorized extends BaseError {
|
|
25
|
+
code = "Mailer/Settings/NotAuthorized";
|
|
26
|
+
constructor() {
|
|
27
|
+
super({
|
|
28
|
+
message: "Not allowed to update the mailer settings."
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class SettingsPersistenceError extends BaseError {
|
|
33
|
+
code = "Mailer/Settings/Persistence";
|
|
34
|
+
constructor(error) {
|
|
35
|
+
super({
|
|
36
|
+
message: "Failed to persist settings.",
|
|
37
|
+
data: {
|
|
38
|
+
error
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class SettingsLockedByCode extends BaseError {
|
|
44
|
+
code = "Mailer/Settings/LockedByCode";
|
|
45
|
+
constructor() {
|
|
46
|
+
super({
|
|
47
|
+
message: "Mailer settings are managed by code and cannot be saved via the API."
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BaseError","MailValidationError","code","constructor","errors","message","data","SettingsValidationError","SettingsNotAuthorized","SettingsPersistenceError","error","SettingsLockedByCode"],"sources":["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"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAiC;EAC7DE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,2BAA2B;MACpCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMG,uBAAuB,SAASP,SAAS,CAAiC;EACjEE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMI,qBAAqB,SAASR,SAAS,CAAC;EAC/BE,IAAI,GAAG,+BAA+B;EAExDC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MAAEE,OAAO,EAAE;IAA6C,CAAC,CAAC;EACpE;AACJ;AAEA,OAAO,MAAMI,wBAAwB,SAAST,SAAS,CAAmB;EACpDE,IAAI,GAAG,6BAA6B;EAEtDC,WAAWA,CAACO,KAAY,EAAE;IACtB,KAAK,CAAC;MACFL,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFI;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMC,oBAAoB,SAASX,SAAS,CAAC;EAC9BE,IAAI,GAAG,8BAA8B;EAEvDC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFE,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SendMailUseCase, MailSendErrorEventHandler, MailBeforeSendEventHandler, MailAfterSendEventHandler } from "../../features/SendMail/index.js";
|
|
2
|
+
export { GetSettingsUseCase, GetSettingsRepository } from "../../features/GetSettings/index.js";
|
|
3
|
+
export { SaveSettingsUseCase, SaveSettingsRepository, MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "../../features/SaveSettings/index.js";
|
|
4
|
+
export { MailerService } from "../../domain/MailerService/abstractions.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { SendMailUseCase, MailSendErrorEventHandler, MailBeforeSendEventHandler, MailAfterSendEventHandler } from "../../features/SendMail/index.js";
|
|
2
|
+
export { GetSettingsUseCase, GetSettingsRepository } from "../../features/GetSettings/index.js";
|
|
3
|
+
export { SaveSettingsUseCase, SaveSettingsRepository, MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "../../features/SaveSettings/index.js";
|
|
4
|
+
export { MailerService } from "../../domain/MailerService/abstractions.js";
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=mailer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SendMailUseCase","MailSendErrorEventHandler","MailBeforeSendEventHandler","MailAfterSendEventHandler","GetSettingsUseCase","GetSettingsRepository","SaveSettingsUseCase","SaveSettingsRepository","MailerSettingsAfterSaveEventHandler","MailerSettingsBeforeSaveEventHandler","MailerService"],"sources":["mailer.ts"],"sourcesContent":["export {\n SendMailUseCase,\n MailSendErrorEventHandler,\n MailBeforeSendEventHandler,\n MailAfterSendEventHandler\n} from \"~/features/SendMail/index.js\";\nexport { GetSettingsUseCase, GetSettingsRepository } from \"~/features/GetSettings/index.js\";\nexport {\n SaveSettingsUseCase,\n SaveSettingsRepository,\n MailerSettingsAfterSaveEventHandler,\n MailerSettingsBeforeSaveEventHandler\n} from \"~/features/SaveSettings/index.js\";\nexport { MailerService } from \"~/domain/MailerService/abstractions.js\";\n"],"mappings":"AAAA,SACIA,eAAe,EACfC,yBAAyB,EACzBC,0BAA0B,EAC1BC,yBAAyB;AAE7B,SAASC,kBAAkB,EAAEC,qBAAqB;AAClD,SACIC,mBAAmB,EACnBC,sBAAsB,EACtBC,mCAAmC,EACnCC,oCAAoC;AAExC,SAASC,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
+
import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
|
+
import type { TransportSettings } from "../../types.js";
|
|
4
|
+
declare class CodeMailerSettingsImpl implements Abstraction.Interface {
|
|
5
|
+
private buildParams;
|
|
6
|
+
constructor(buildParams: BuildParams.Interface);
|
|
7
|
+
get(transportName: string): TransportSettings | null;
|
|
8
|
+
}
|
|
9
|
+
export declare const CodeMailerSettings: typeof CodeMailerSettingsImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/domain/CodeMailerSettings/abstractions.js").ICodeMailerSettings>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
|
|
2
|
+
import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
3
|
+
const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
|
|
4
|
+
const SMTP_BUILD_PARAM_KEY = "Mailer.SmtpSettings";
|
|
5
|
+
class CodeMailerSettingsImpl {
|
|
6
|
+
constructor(buildParams) {
|
|
7
|
+
this.buildParams = buildParams;
|
|
8
|
+
}
|
|
9
|
+
get(transportName) {
|
|
10
|
+
if (transportName !== SMTP_TRANSPORT_NAME) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
|
|
14
|
+
return value ?? null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const CodeMailerSettings = Abstraction.createImplementation({
|
|
18
|
+
implementation: CodeMailerSettingsImpl,
|
|
19
|
+
dependencies: [BuildParams]
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=CodeMailerSettingsImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BuildParams","CodeMailerSettings","Abstraction","SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","constructor","buildParams","get","transportName","value","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gDAAgD;AAC5E,SAASC,kBAAkB,IAAIC,WAAW;AAG1C,MAAMC,mBAAmB,GAAG,sBAAsB;AAClD,MAAMC,oBAAoB,GAAG,qBAAqB;AAElD,MAAMC,sBAAsB,CAAkC;EAC1DC,WAAWA,CAASC,WAAkC,EAAE;IAAA,KAApCA,WAAkC,GAAlCA,WAAkC;EAAG;EAEzDC,GAAGA,CAACC,aAAqB,EAA4B;IACjD,IAAIA,aAAa,KAAKN,mBAAmB,EAAE;MACvC,OAAO,IAAI;IACf;IACA,MAAMO,KAAK,GAAG,IAAI,CAACH,WAAW,CAACC,GAAG,CAAoBJ,oBAAoB,CAAC;IAC3E,OAAOM,KAAK,IAAI,IAAI;EACxB;AACJ;AAEA,OAAO,MAAMT,kBAAkB,GAAGC,WAAW,CAACS,oBAAoB,CAAC;EAC/DC,cAAc,EAAEP,sBAAsB;EACtCQ,YAAY,EAAE,CAACb,WAAW;AAC9B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { CodeMailerSettings } from "./CodeMailerSettingsImpl.js";
|
|
3
|
+
export const CodeMailerSettingsFeature = createFeature({
|
|
4
|
+
name: "Mailer/CodeMailerSettings",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(CodeMailerSettings).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","CodeMailerSettings","CodeMailerSettingsFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,yBAAyB,GAAGF,aAAa,CAAC;EACnDG,IAAI,EAAE,2BAA2B;EACjCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,kBAAkB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EAC7D;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MailTransport } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
export declare class DummyMailTransport implements MailTransport.Interface {
|
|
3
|
+
readonly name = "Mailer/DummyTransport";
|
|
4
|
+
constructor();
|
|
5
|
+
send(): Promise<{
|
|
6
|
+
result: boolean;
|
|
7
|
+
error: null;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DummyMailTransport","name","constructor","send","result","error"],"sources":["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"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAAoC;EAC/CC,IAAI,GAAG,uBAAuB;EAE9CC,WAAWA,CAAA,EAAG,CAAC;EAEf,MAAMC,IAAIA,CAAA,EAAG;IACT,OAAO;MACHC,MAAM,EAAE,IAAI;MACZC,KAAK,EAAE;IACX,CAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IMailTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
declare class DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {
|
|
3
|
+
readonly name = "Mailer/DummyTransport";
|
|
4
|
+
createTransport(): Promise<IMailTransport>;
|
|
5
|
+
}
|
|
6
|
+
export declare const DummyMailTransportFactory: typeof DummyMailTransportFactoryImpl & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IMailTransportFactory>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
import { DummyMailTransport } from "./DummyMailTransport.js";
|
|
3
|
+
class DummyMailTransportFactoryImpl {
|
|
4
|
+
name = "Mailer/DummyTransport";
|
|
5
|
+
async createTransport() {
|
|
6
|
+
return new DummyMailTransport();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export const DummyMailTransportFactory = MailTransportFactory.createImplementation({
|
|
10
|
+
implementation: DummyMailTransportFactoryImpl,
|
|
11
|
+
dependencies: []
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=DummyMailTransportFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MailTransportFactory","DummyMailTransport","DummyMailTransportFactoryImpl","name","createTransport","DummyMailTransportFactory","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAA8BA,oBAAoB;AAClD,SAASC,kBAAkB;AAE3B,MAAMC,6BAA6B,CAA2C;EAC1DC,IAAI,GAAG,uBAAuB;EAE9C,MAAMC,eAAeA,CAAA,EAA4B;IAC7C,OAAO,IAAIH,kBAAkB,CAAC,CAAC;EACnC;AACJ;AAEA,OAAO,MAAMI,yBAAyB,GAAGL,oBAAoB,CAACM,oBAAoB,CAAC;EAC/EC,cAAc,EAAEL,6BAA6B;EAC7CM,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { DummyMailTransportFactory } from "./DummyMailTransportFactory.js";
|
|
3
|
+
export const DummyTransportFeature = createFeature({
|
|
4
|
+
name: "Mailer/DummyTransport",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(DummyMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","DummyMailTransportFactory","DummyTransportFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;AAElC,OAAO,MAAMC,qBAAqB,GAAGF,aAAa,CAAC;EAC/CG,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yBAAyB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EACpE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
3
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
4
|
+
import { GetSettingsRepository, type ISettingsWithSource } from "./abstractions.js";
|
|
5
|
+
import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
6
|
+
declare class GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {
|
|
7
|
+
private keyValueStore;
|
|
8
|
+
private encryption;
|
|
9
|
+
private codeSettings;
|
|
10
|
+
constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface, codeSettings: CodeMailerSettings.Interface);
|
|
11
|
+
get(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const GetSettingsRepositoryImplementation: typeof GetSettingsRepositoryImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsRepository>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { Encryption } from "@webiny/api-core/features/encryption/index.js";
|
|
3
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
4
|
+
import { GetSettingsRepository } from "./abstractions.js";
|
|
5
|
+
import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
|
|
6
|
+
import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
|
|
7
|
+
class GetSettingsRepositoryImpl {
|
|
8
|
+
constructor(keyValueStore, encryption, codeSettings) {
|
|
9
|
+
this.keyValueStore = keyValueStore;
|
|
10
|
+
this.encryption = encryption;
|
|
11
|
+
this.codeSettings = codeSettings;
|
|
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
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const result = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
|
|
23
|
+
if (result.isFail()) {
|
|
24
|
+
return Result.ok({
|
|
25
|
+
settings: null,
|
|
26
|
+
source: null
|
|
27
|
+
});
|
|
28
|
+
}
|
|
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
|
+
}
|
|
53
|
+
export const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
|
|
54
|
+
implementation: GetSettingsRepositoryImpl,
|
|
55
|
+
dependencies: [KeyValueStore, Encryption, CodeMailerSettings]
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=GetSettingsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","Encryption","KeyValueStore","GetSettingsRepository","CodeMailerSettings","MAILER_TRANSPORT_SETTINGS","GetSettingsRepositoryImpl","constructor","keyValueStore","encryption","codeSettings","get","transportName","codeSettingsValue","ok","settings","source","result","isFail","value","password","decrypt","String","transportSettings","host","port","Number","user","from","replyTo","undefined","GetSettingsRepositoryImplementation","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,UAAU,QAAQ,+CAA+C;AAC1E,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAE3B,SAASC,yBAAyB;AAElC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,aAAsC,EACtCC,UAAgC,EAChCC,YAA0C,EACpD;IAAA,KAHUF,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,YAA0C,GAA1CA,YAA0C;EACnD;EAEH,MAAMC,GAAGA,CAACC,aAAqB,EAAwC;IACnE;IACA,MAAMC,iBAAiB,GAAG,IAAI,CAACH,YAAY,CAACC,GAAG,CAACC,aAAa,CAAC;IAC9D,IAAIC,iBAAiB,KAAK,IAAI,EAAE;MAC5B,OAAOb,MAAM,CAACc,EAAE,CAAC;QACbC,QAAQ,EAAEF,iBAAiB;QAC3BG,MAAM,EAAE;MACZ,CAAC,CAAC;IACN;IAEA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACT,aAAa,CAACG,GAAG,CAAoBN,yBAAyB,CAAC;IAEzF,IAAIY,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOlB,MAAM,CAACc,EAAE,CAAC;QAAEC,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;MAAK,CAAC,CAAC;IACtD;IAEA,MAAMD,QAAQ,GAAGE,MAAM,CAACE,KAAK;IAC7B,IAAI,CAACJ,QAAQ,EAAE;MACX,OAAOf,MAAM,CAACc,EAAE,CAAC;QAAEC,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;MAAK,CAAC,CAAC;IACtD;;IAEA;IACA,MAAMI,QAAQ,GAAGL,QAAQ,CAACK,QAAQ,GAC5B,IAAI,CAACX,UAAU,CAACY,OAAO,CAACC,MAAM,CAACP,QAAQ,CAACK,QAAQ,CAAC,CAAC,GAClD,EAAE;IAER,MAAMG,iBAAoC,GAAG;MACzCC,IAAI,EAAEF,MAAM,CAACP,QAAQ,CAACS,IAAI,IAAI,EAAE,CAAC;MACjCC,IAAI,EAAEC,MAAM,CAACX,QAAQ,CAACU,IAAI,IAAI,EAAE,CAAC;MACjCE,IAAI,EAAEL,MAAM,CAACP,QAAQ,CAACY,IAAI,IAAI,EAAE,CAAC;MACjCP,QAAQ;MACRQ,IAAI,EAAEN,MAAM,CAACP,QAAQ,CAACa,IAAI,IAAI,EAAE,CAAC;MACjCC,OAAO,EAAEd,QAAQ,CAACc,OAAO,GAAGP,MAAM,CAACP,QAAQ,CAACc,OAAO,CAAC,GAAGC;IAC3D,CAAC;IAED,OAAO9B,MAAM,CAACc,EAAE,CAAC;MAAEC,QAAQ,EAAEQ,iBAAiB;MAAEP,MAAM,EAAE;IAAU,CAAC,CAAC;EACxE;AACJ;AAEA,OAAO,MAAMe,mCAAmC,GAAG5B,qBAAqB,CAAC6B,oBAAoB,CAAC;EAC1FC,cAAc,EAAE3B,yBAAyB;EACzC4B,YAAY,EAAE,CAAChC,aAAa,EAAED,UAAU,EAAEG,kBAAkB;AAChE,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetSettingsUseCase, GetSettingsRepository, type ISettingsWithSource } from "./abstractions.js";
|
|
3
|
+
declare class GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {
|
|
4
|
+
private repository;
|
|
5
|
+
constructor(repository: GetSettingsRepository.Interface);
|
|
6
|
+
execute(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const GetSettingsUseCaseImplementation: typeof GetSettingsUseCaseImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsUseCase>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
|
|
2
|
+
class GetSettingsUseCaseImpl {
|
|
3
|
+
constructor(repository) {
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
execute(transportName) {
|
|
7
|
+
return this.repository.get(transportName);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
|
|
11
|
+
implementation: GetSettingsUseCaseImpl,
|
|
12
|
+
dependencies: [GetSettingsRepository]
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=GetSettingsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GetSettingsUseCase","GetSettingsRepository","GetSettingsUseCaseImpl","constructor","repository","execute","transportName","get","GetSettingsUseCaseImplementation","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AACA,SACIA,kBAAkB,EAClBC,qBAAqB;AAIzB,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CAASC,UAA2C,EAAE;IAAA,KAA7CA,UAA2C,GAA3CA,UAA2C;EAAG;EAElEC,OAAOA,CAACC,aAAqB,EAAwC;IACjE,OAAO,IAAI,CAACF,UAAU,CAACG,GAAG,CAACD,aAAa,CAAC;EAC7C;AACJ;AAEA,OAAO,MAAME,gCAAgC,GAAGR,kBAAkB,CAACS,oBAAoB,CAAC;EACpFC,cAAc,EAAER,sBAAsB;EACtCS,YAAY,EAAE,CAACV,qBAAqB;AACxC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSettings } from "../../types.js";
|
|
3
|
+
export type MailerSettingsSource = "code" | "storage" | null;
|
|
4
|
+
export interface ISettingsWithSource {
|
|
5
|
+
settings: TransportSettings | null;
|
|
6
|
+
source: MailerSettingsSource;
|
|
7
|
+
}
|
|
8
|
+
export interface IGetSettingsRepository {
|
|
9
|
+
get(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const GetSettingsRepository: import("@webiny/di").Abstraction<IGetSettingsRepository>;
|
|
12
|
+
export declare namespace GetSettingsRepository {
|
|
13
|
+
type Interface = IGetSettingsRepository;
|
|
14
|
+
type Return = Promise<Result<ISettingsWithSource>>;
|
|
15
|
+
}
|
|
16
|
+
export interface IGetSettingsUseCase {
|
|
17
|
+
execute(transportName: string): Promise<Result<ISettingsWithSource>>;
|
|
18
|
+
}
|
|
19
|
+
export declare const GetSettingsUseCase: import("@webiny/di").Abstraction<IGetSettingsUseCase>;
|
|
20
|
+
export declare namespace GetSettingsUseCase {
|
|
21
|
+
type Interface = IGetSettingsUseCase;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GetSettingsRepository","GetSettingsUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\nexport interface ISettingsWithSource {\n settings: TransportSettings | null;\n source: MailerSettingsSource;\n}\n\nexport interface IGetSettingsRepository {\n get(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n export type Return = Promise<Result<ISettingsWithSource>>;\n}\n\nexport interface IGetSettingsUseCase {\n execute(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAevD,OAAO,MAAMC,qBAAqB,GAC9BD,iBAAiB,CAAyB,uBAAuB,CAAC;AAWtE,OAAO,MAAME,kBAAkB,GAAGF,iBAAiB,CAAsB,oBAAoB,CAAC","ignoreList":[]}
|