@webiny/api-mailer 0.0.0-unstable.3bc8100a7f → 0.0.0-unstable.3fddf667ea

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.
Files changed (181) hide show
  1. package/MailerFeature.d.ts +4 -0
  2. package/MailerFeature.js +27 -0
  3. package/MailerFeature.js.map +1 -0
  4. package/README.md +10 -13
  5. package/constants.d.ts +4 -0
  6. package/constants.js +7 -0
  7. package/constants.js.map +1 -0
  8. package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
  9. package/domain/CodeMailerSettings/abstractions.js +5 -0
  10. package/domain/CodeMailerSettings/abstractions.js.map +1 -0
  11. package/domain/MailTransport/abstractions.d.ts +36 -0
  12. package/domain/MailTransport/abstractions.js +7 -0
  13. package/domain/MailTransport/abstractions.js.map +1 -0
  14. package/domain/MailerService/abstractions.d.ts +19 -0
  15. package/domain/MailerService/abstractions.js +5 -0
  16. package/domain/MailerService/abstractions.js.map +1 -0
  17. package/domain/MailerService/errors.d.ts +20 -0
  18. package/domain/MailerService/errors.js +35 -0
  19. package/domain/MailerService/errors.js.map +1 -0
  20. package/domain/errors.d.ts +36 -0
  21. package/domain/errors.js +62 -0
  22. package/domain/errors.js.map +1 -0
  23. package/exports/api/mailer.d.ts +4 -0
  24. package/exports/api/mailer.js +4 -0
  25. package/features/CodeMailerSettings/CodeMailerSettings.d.ts +12 -0
  26. package/features/CodeMailerSettings/CodeMailerSettings.js +23 -0
  27. package/features/CodeMailerSettings/CodeMailerSettings.js.map +1 -0
  28. package/features/CodeMailerSettings/feature.d.ts +4 -0
  29. package/features/CodeMailerSettings/feature.js +11 -0
  30. package/features/CodeMailerSettings/feature.js.map +1 -0
  31. package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
  32. package/features/DummyTransport/DummyMailTransport.js +15 -0
  33. package/features/DummyTransport/DummyMailTransport.js.map +1 -0
  34. package/features/DummyTransport/DummyMailTransportFactory.d.ts +10 -0
  35. package/features/DummyTransport/DummyMailTransportFactory.js +21 -0
  36. package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
  37. package/features/DummyTransport/feature.d.ts +4 -0
  38. package/features/DummyTransport/feature.js +11 -0
  39. package/features/DummyTransport/feature.js.map +1 -0
  40. package/features/GetSettings/GetSettingsRepository.d.ts +16 -0
  41. package/features/GetSettings/GetSettingsRepository.js +56 -0
  42. package/features/GetSettings/GetSettingsRepository.js.map +1 -0
  43. package/features/GetSettings/GetSettingsUseCase.d.ts +11 -0
  44. package/features/GetSettings/GetSettingsUseCase.js +18 -0
  45. package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
  46. package/features/GetSettings/abstractions.d.ts +22 -0
  47. package/features/GetSettings/abstractions.js +6 -0
  48. package/features/GetSettings/abstractions.js.map +1 -0
  49. package/features/GetSettings/feature.d.ts +4 -0
  50. package/features/GetSettings/feature.js +13 -0
  51. package/features/GetSettings/feature.js.map +1 -0
  52. package/features/GetSettings/index.d.ts +1 -0
  53. package/features/GetSettings/index.js +1 -0
  54. package/features/MailerService/MailTransportResolver.d.ts +13 -0
  55. package/features/MailerService/MailTransportResolver.js +37 -0
  56. package/features/MailerService/MailTransportResolver.js.map +1 -0
  57. package/features/MailerService/MailerService.d.ts +13 -0
  58. package/features/MailerService/MailerService.js +38 -0
  59. package/features/MailerService/MailerService.js.map +1 -0
  60. package/features/MailerService/feature.d.ts +4 -0
  61. package/features/MailerService/feature.js +13 -0
  62. package/features/MailerService/feature.js.map +1 -0
  63. package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
  64. package/features/SaveSettings/SaveSettingsRepository.js +45 -0
  65. package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
  66. package/features/SaveSettings/SaveSettingsUseCase.d.ts +18 -0
  67. package/features/SaveSettings/SaveSettingsUseCase.js +57 -0
  68. package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
  69. package/features/SaveSettings/abstractions.d.ts +62 -0
  70. package/features/SaveSettings/abstractions.js +8 -0
  71. package/features/SaveSettings/abstractions.js.map +1 -0
  72. package/features/SaveSettings/events.d.ts +10 -0
  73. package/features/SaveSettings/events.js +21 -0
  74. package/features/SaveSettings/events.js.map +1 -0
  75. package/features/SaveSettings/feature.d.ts +4 -0
  76. package/features/SaveSettings/feature.js +13 -0
  77. package/features/SaveSettings/feature.js.map +1 -0
  78. package/features/SaveSettings/index.d.ts +1 -0
  79. package/features/SaveSettings/index.js +1 -0
  80. package/features/SaveSettings/validation.d.ts +10 -0
  81. package/features/SaveSettings/validation.js +21 -0
  82. package/features/SaveSettings/validation.js.map +1 -0
  83. package/features/SendMail/SendMailUseCase.d.ts +16 -0
  84. package/features/SendMail/SendMailUseCase.js +58 -0
  85. package/features/SendMail/SendMailUseCase.js.map +1 -0
  86. package/features/SendMail/abstractions.d.ts +45 -0
  87. package/features/SendMail/abstractions.js +8 -0
  88. package/features/SendMail/abstractions.js.map +1 -0
  89. package/features/SendMail/events.d.ts +14 -0
  90. package/features/SendMail/events.js +29 -0
  91. package/features/SendMail/events.js.map +1 -0
  92. package/features/SendMail/feature.d.ts +4 -0
  93. package/features/SendMail/feature.js +11 -0
  94. package/features/SendMail/feature.js.map +1 -0
  95. package/features/SendMail/index.d.ts +1 -0
  96. package/features/SendMail/index.js +1 -0
  97. package/features/SendTestMail/SendTestMailUseCase.d.ts +15 -0
  98. package/features/SendTestMail/SendTestMailUseCase.js +43 -0
  99. package/features/SendTestMail/SendTestMailUseCase.js.map +1 -0
  100. package/features/SendTestMail/abstractions.d.ts +32 -0
  101. package/features/SendTestMail/abstractions.js +5 -0
  102. package/features/SendTestMail/abstractions.js.map +1 -0
  103. package/features/SendTestMail/feature.d.ts +4 -0
  104. package/features/SendTestMail/feature.js +11 -0
  105. package/features/SendTestMail/feature.js.map +1 -0
  106. package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
  107. package/features/SmtpTransport/SmtpConfig.js +26 -0
  108. package/features/SmtpTransport/SmtpConfig.js.map +1 -0
  109. package/features/SmtpTransport/SmtpMailTransport.d.ts +77 -0
  110. package/features/SmtpTransport/SmtpMailTransport.js +60 -0
  111. package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
  112. package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +11 -0
  113. package/features/SmtpTransport/SmtpMailTransportFactory.js +22 -0
  114. package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
  115. package/features/SmtpTransport/feature.d.ts +4 -0
  116. package/features/SmtpTransport/feature.js +11 -0
  117. package/features/SmtpTransport/feature.js.map +1 -0
  118. package/graphql/MailerSchemaFactory.d.ts +10 -0
  119. package/graphql/MailerSchemaFactory.js +148 -0
  120. package/graphql/MailerSchemaFactory.js.map +1 -0
  121. package/index.d.ts +3 -5
  122. package/index.js +2 -83
  123. package/package.json +29 -34
  124. package/types.d.ts +1 -107
  125. package/types.js +0 -7
  126. package/utils/isMailboxAddress.d.ts +6 -0
  127. package/utils/isMailboxAddress.js +5 -0
  128. package/utils/isMailboxAddress.js.map +1 -0
  129. package/context.d.ts +0 -3
  130. package/context.js +0 -20
  131. package/context.js.map +0 -1
  132. package/crud/settings/hooks.d.ts +0 -5
  133. package/crud/settings/hooks.js +0 -42
  134. package/crud/settings/hooks.js.map +0 -1
  135. package/crud/settings/model.d.ts +0 -2
  136. package/crud/settings/model.js +0 -72
  137. package/crud/settings/model.js.map +0 -1
  138. package/crud/settings/password.d.ts +0 -7
  139. package/crud/settings/password.js +0 -55
  140. package/crud/settings/password.js.map +0 -1
  141. package/crud/settings/secret.d.ts +0 -1
  142. package/crud/settings/secret.js +0 -19
  143. package/crud/settings/secret.js.map +0 -1
  144. package/crud/settings/transform.d.ts +0 -13
  145. package/crud/settings/transform.js +0 -46
  146. package/crud/settings/transform.js.map +0 -1
  147. package/crud/settings/validation.d.ts +0 -45
  148. package/crud/settings/validation.js +0 -28
  149. package/crud/settings/validation.js.map +0 -1
  150. package/crud/settings.crud.d.ts +0 -5
  151. package/crud/settings.crud.js +0 -269
  152. package/crud/settings.crud.js.map +0 -1
  153. package/crud/transport/onTransportBeforeSend.d.ts +0 -7
  154. package/crud/transport/onTransportBeforeSend.js +0 -62
  155. package/crud/transport/onTransportBeforeSend.js.map +0 -1
  156. package/crud/transporter.crud.d.ts +0 -2
  157. package/crud/transporter.crud.js +0 -158
  158. package/crud/transporter.crud.js.map +0 -1
  159. package/graphql/index.d.ts +0 -1
  160. package/graphql/index.js +0 -13
  161. package/graphql/index.js.map +0 -1
  162. package/graphql/settings.d.ts +0 -3
  163. package/graphql/settings.js +0 -103
  164. package/graphql/settings.js.map +0 -1
  165. package/index.js.map +0 -1
  166. package/plugins/CreateTransportPlugin.d.ts +0 -17
  167. package/plugins/CreateTransportPlugin.js +0 -24
  168. package/plugins/CreateTransportPlugin.js.map +0 -1
  169. package/plugins/index.d.ts +0 -1
  170. package/plugins/index.js +0 -18
  171. package/plugins/index.js.map +0 -1
  172. package/transports/createDummyTransport.d.ts +0 -5
  173. package/transports/createDummyTransport.js +0 -25
  174. package/transports/createDummyTransport.js.map +0 -1
  175. package/transports/createSmtpTransport.d.ts +0 -13
  176. package/transports/createSmtpTransport.js +0 -94
  177. package/transports/createSmtpTransport.js.map +0 -1
  178. package/transports/index.d.ts +0 -2
  179. package/transports/index.js +0 -29
  180. package/transports/index.js.map +0 -1
  181. package/types.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ export declare const MailerFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,27 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CodeMailerSettingsFeature } from "./features/CodeMailerSettings/feature.js";
3
+ import { DummyTransportFeature } from "./features/DummyTransport/feature.js";
4
+ import { SmtpTransportFeature } from "./features/SmtpTransport/feature.js";
5
+ import { GetSettingsFeature } from "./features/GetSettings/feature.js";
6
+ import { SaveSettingsFeature } from "./features/SaveSettings/feature.js";
7
+ import { MailerServiceFeature } from "./features/MailerService/feature.js";
8
+ import { SendMailFeature } from "./features/SendMail/feature.js";
9
+ import { SendTestMailFeature } from "./features/SendTestMail/feature.js";
10
+ import { MailerSchemaFactory } from "./graphql/MailerSchemaFactory.js";
11
+ const MailerFeature = createFeature({
12
+ name: "Mailer",
13
+ register (container) {
14
+ CodeMailerSettingsFeature.register(container);
15
+ DummyTransportFeature.register(container);
16
+ SmtpTransportFeature.register(container);
17
+ GetSettingsFeature.register(container);
18
+ SaveSettingsFeature.register(container);
19
+ MailerServiceFeature.register(container);
20
+ SendMailFeature.register(container);
21
+ SendTestMailFeature.register(container);
22
+ container.register(MailerSchemaFactory);
23
+ }
24
+ });
25
+ export { MailerFeature };
26
+
27
+ //# sourceMappingURL=MailerFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MailerFeature.js","sources":["../src/MailerFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettingsFeature } from \"~/features/CodeMailerSettings/feature.js\";\nimport { DummyTransportFeature } from \"~/features/DummyTransport/feature.js\";\nimport { SmtpTransportFeature } from \"~/features/SmtpTransport/feature.js\";\nimport { GetSettingsFeature } from \"~/features/GetSettings/feature.js\";\nimport { SaveSettingsFeature } from \"~/features/SaveSettings/feature.js\";\nimport { MailerServiceFeature } from \"~/features/MailerService/feature.js\";\nimport { SendMailFeature } from \"~/features/SendMail/feature.js\";\nimport { SendTestMailFeature } from \"~/features/SendTestMail/feature.js\";\nimport { MailerSchemaFactory } from \"~/graphql/MailerSchemaFactory.js\";\n\nexport const MailerFeature = createFeature({\n name: \"Mailer\",\n register(container) {\n CodeMailerSettingsFeature.register(container);\n DummyTransportFeature.register(container);\n SmtpTransportFeature.register(container);\n GetSettingsFeature.register(container);\n SaveSettingsFeature.register(container);\n MailerServiceFeature.register(container);\n SendMailFeature.register(container);\n SendTestMailFeature.register(container);\n container.register(MailerSchemaFactory);\n }\n});\n"],"names":["MailerFeature","createFeature","container","CodeMailerSettingsFeature","DummyTransportFeature","SmtpTransportFeature","GetSettingsFeature","SaveSettingsFeature","MailerServiceFeature","SendMailFeature","SendTestMailFeature","MailerSchemaFactory"],"mappings":";;;;;;;;;;AAWO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdC,0BAA0B,QAAQ,CAACD;QACnCE,sBAAsB,QAAQ,CAACF;QAC/BG,qBAAqB,QAAQ,CAACH;QAC9BI,mBAAmB,QAAQ,CAACJ;QAC5BK,oBAAoB,QAAQ,CAACL;QAC7BM,qBAAqB,QAAQ,CAACN;QAC9BO,gBAAgB,QAAQ,CAACP;QACzBQ,oBAAoB,QAAQ,CAACR;QAC7BA,UAAU,QAAQ,CAACS;IACvB;AACJ"}
package/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  # @webiny/api-mailer
2
- [![](https://img.shields.io/npm/dw/@webiny/api-mailer.svg)](https://www.npmjs.com/package/@webiny/api-mailer)
3
- [![](https://img.shields.io/npm/v/@webiny/api-mailer.svg)](https://www.npmjs.com/package/@webiny/api-mailer)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
-
7
-
8
- ## Install
9
- ```
10
- yarn add @webiny/api-mailer
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,4 @@
1
+ export declare const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
2
+ export declare const MAILER_SETTINGS_PERMISSION = "mailer.settings";
3
+ export declare const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
4
+ export declare const DUMMY_TRANSPORT_NAME = "Mailer/DummyTransport";
package/constants.js ADDED
@@ -0,0 +1,7 @@
1
+ const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
2
+ const MAILER_SETTINGS_PERMISSION = "mailer.settings";
3
+ const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
4
+ const DUMMY_TRANSPORT_NAME = "Mailer/DummyTransport";
5
+ export { DUMMY_TRANSPORT_NAME, MAILER_SETTINGS_PERMISSION, MAILER_TRANSPORT_SETTINGS, SMTP_TRANSPORT_NAME };
6
+
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\nexport const MAILER_SETTINGS_PERMISSION = \"mailer.settings\";\nexport const SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nexport const DUMMY_TRANSPORT_NAME = \"Mailer/DummyTransport\";\n"],"names":["MAILER_TRANSPORT_SETTINGS","MAILER_SETTINGS_PERMISSION","SMTP_TRANSPORT_NAME","DUMMY_TRANSPORT_NAME"],"mappings":"AAAO,MAAMA,4BAA4B;AAClC,MAAMC,6BAA6B;AACnC,MAAMC,sBAAsB;AAC5B,MAAMC,uBAAuB"}
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const CodeMailerSettings = createAbstraction("CodeMailerSettings");
3
+ export { CodeMailerSettings };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,36 @@
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
+ canUse(settings: TransportSettings | null): boolean;
14
+ createTransport(settings: TransportSettings): Promise<IMailTransport>;
15
+ }
16
+ export declare const MailTransportFactory: import("@webiny/di").Abstraction<IMailTransportFactory>;
17
+ export declare namespace MailTransportFactory {
18
+ type Interface = IMailTransportFactory;
19
+ type Return = Promise<IMailTransport>;
20
+ }
21
+ export interface IResolvedMailTransport {
22
+ factory: IMailTransportFactory;
23
+ settings: TransportSettings | null;
24
+ }
25
+ export interface IMailTransportResolver {
26
+ /**
27
+ * The factory mail goes out through right now: the last registered one whose settings it can
28
+ * use. Null when none can.
29
+ */
30
+ resolve(): Promise<IResolvedMailTransport | null>;
31
+ }
32
+ export declare const MailTransportResolver: import("@webiny/di").Abstraction<IMailTransportResolver>;
33
+ export declare namespace MailTransportResolver {
34
+ type Interface = IMailTransportResolver;
35
+ type Resolved = IResolvedMailTransport;
36
+ }
@@ -0,0 +1,7 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const MailTransport = createAbstraction("MailTransport");
3
+ const MailTransportFactory = createAbstraction("MailTransportFactory");
4
+ const MailTransportResolver = createAbstraction("MailTransportResolver");
5
+ export { MailTransport, MailTransportFactory, MailTransportResolver };
6
+
7
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
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 canUse(settings: TransportSettings | null): boolean;\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 IResolvedMailTransport {\n factory: IMailTransportFactory;\n settings: TransportSettings | null;\n}\n\nexport interface IMailTransportResolver {\n /**\n * The factory mail goes out through right now: the last registered one whose settings it can\n * use. Null when none can.\n */\n resolve(): Promise<IResolvedMailTransport | null>;\n}\n\nexport const MailTransportResolver =\n createAbstraction<IMailTransportResolver>(\"MailTransportResolver\");\n\nexport namespace MailTransportResolver {\n export type Interface = IMailTransportResolver;\n export type Resolved = IResolvedMailTransport;\n}\n"],"names":["MailTransport","createAbstraction","MailTransportFactory","MailTransportResolver"],"mappings":";AAQO,MAAMA,gBAAgBC,kBAAkC;AAaxD,MAAMC,uBACTD,kBAAyC;AAoBtC,MAAME,wBACTF,kBAA0C"}
@@ -0,0 +1,19 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import type { TransportSendData, TransportSendResponse } from "../../types.js";
3
+ import { NoTransportAvailableError, TransportCreateError, TransportSendError } from "./errors.js";
4
+ export interface IMailerServiceErrors {
5
+ noTransport: NoTransportAvailableError;
6
+ transportCreate: TransportCreateError;
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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const MailerService = createAbstraction("MailerService");
3
+ export { MailerService };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
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 { NoTransportAvailableError, TransportCreateError, TransportSendError } from \"./errors.js\";\n\nexport interface IMailerServiceErrors {\n noTransport: NoTransportAvailableError;\n transportCreate: TransportCreateError;\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":";AAmBO,MAAMA,gBAAgBC,kBAAkC"}
@@ -0,0 +1,20 @@
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 TransportCreateError extends BaseError {
12
+ readonly code: "Mailer/MailerService/TransportCreateError";
13
+ constructor(error: unknown);
14
+ }
15
+ export declare class TransportSendError extends BaseError<{
16
+ error: TransportSendResponse["error"];
17
+ }> {
18
+ readonly code: "Mailer/MailerService/TransportSendError";
19
+ constructor(error: NonNullable<TransportSendResponse["error"]>);
20
+ }
@@ -0,0 +1,35 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ class NoTransportAvailableError extends BaseError {
3
+ constructor(){
4
+ super({
5
+ message: "There is no transport available."
6
+ }), this.code = "Mailer/MailerService/NoTransportAvailable";
7
+ }
8
+ }
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
+ }
15
+ }
16
+ class TransportCreateError extends BaseError {
17
+ constructor(error){
18
+ super({
19
+ message: error instanceof Error ? error.message : String(error)
20
+ }), this.code = "Mailer/MailerService/TransportCreateError";
21
+ }
22
+ }
23
+ class TransportSendError extends BaseError {
24
+ constructor(error){
25
+ super({
26
+ message: error.message,
27
+ data: {
28
+ error
29
+ }
30
+ }), this.code = "Mailer/MailerService/TransportSendError";
31
+ }
32
+ }
33
+ export { NoSettingsConfiguredError, NoTransportAvailableError, TransportCreateError, TransportSendError };
34
+
35
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
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 TransportCreateError extends BaseError {\n override readonly code = \"Mailer/MailerService/TransportCreateError\" as const;\n\n constructor(error: unknown) {\n super({\n message: error instanceof Error ? error.message : String(error)\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","TransportCreateError","error","Error","String","TransportSendError"],"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,6BAA6BF;IAGtC,YAAYG,KAAc,CAAE;QACxB,KAAK,CAAC;YACF,SAASA,iBAAiBC,QAAQD,MAAM,OAAO,GAAGE,OAAOF;QAC7D,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMG,2BAA2BN;IAGpC,YAAYG,KAAkD,CAAE;QAC5D,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;YACtB,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ"}
@@ -0,0 +1,36 @@
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 TestMailNotAuthorized extends BaseError {
26
+ readonly code: "Mailer/SendTestMail/NotAuthorized";
27
+ constructor();
28
+ }
29
+ export declare class TestMailNotConfigured extends BaseError {
30
+ readonly code: "Mailer/SendTestMail/NotConfigured";
31
+ constructor();
32
+ }
33
+ export declare class SettingsLockedByCode extends BaseError {
34
+ readonly code: "Mailer/Settings/LockedByCode";
35
+ constructor();
36
+ }
@@ -0,0 +1,62 @@
1
+ import { BaseError } from "@webiny/feature/api";
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
+ }
11
+ }
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
+ }
21
+ }
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
+ }
28
+ }
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
+ }
38
+ }
39
+ class TestMailNotAuthorized extends BaseError {
40
+ constructor(){
41
+ super({
42
+ message: "Not allowed to send a test email."
43
+ }), this.code = "Mailer/SendTestMail/NotAuthorized";
44
+ }
45
+ }
46
+ class TestMailNotConfigured extends BaseError {
47
+ constructor(){
48
+ super({
49
+ message: "No mail transport is configured, so there is nothing to test."
50
+ }), this.code = "Mailer/SendTestMail/NotConfigured";
51
+ }
52
+ }
53
+ class SettingsLockedByCode extends BaseError {
54
+ constructor(){
55
+ super({
56
+ message: "Mailer settings are managed by code and cannot be saved via the API."
57
+ }), this.code = "Mailer/Settings/LockedByCode";
58
+ }
59
+ }
60
+ export { MailValidationError, SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError, TestMailNotAuthorized, TestMailNotConfigured };
61
+
62
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
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 TestMailNotAuthorized extends BaseError {\n override readonly code = \"Mailer/SendTestMail/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not allowed to send a test email.\" });\n }\n}\n\nexport class TestMailNotConfigured extends BaseError {\n override readonly code = \"Mailer/SendTestMail/NotConfigured\" as const;\n\n constructor() {\n super({\n message: \"No mail transport is configured, so there is nothing to test.\"\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","TestMailNotAuthorized","TestMailNotConfigured","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,8BAA8BN;IAGvC,aAAc;QACV,KAAK,CAAC;YAAE,SAAS;QAAoC,SAHvC,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMO,8BAA8BP;IAGvC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMQ,6BAA6BR;IAGtC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ"}
@@ -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,4 @@
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
+ export { MailerService } from "../../domain/MailerService/abstractions.js";
@@ -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,23 @@
1
+ import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
2
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
3
+ import { SMTP_TRANSPORT_NAME } from "../../constants.js";
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) return null;
11
+ const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
12
+ return value ?? null;
13
+ }
14
+ }
15
+ const CodeMailerSettings_CodeMailerSettings = CodeMailerSettings.createImplementation({
16
+ implementation: CodeMailerSettingsImpl,
17
+ dependencies: [
18
+ BuildParams
19
+ ]
20
+ });
21
+ export { CodeMailerSettings_CodeMailerSettings as CodeMailerSettings };
22
+
23
+ //# sourceMappingURL=CodeMailerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CodeMailerSettings/CodeMailerSettings.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettings.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\";\nimport { SMTP_TRANSPORT_NAME } from \"~/constants.js\";\n\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_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","SMTP_TRANSPORT_NAME","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;;AAKA,MAAMA,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBC,qBAClB,OAAO;QAEX,MAAMC,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBL;QACtD,OAAOK,SAAS;IACpB;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBN;IAChB,cAAc;QAACO;KAAY;AAC/B"}
@@ -0,0 +1,4 @@
1
+ export declare const CodeMailerSettingsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CodeMailerSettings } from "./CodeMailerSettings.js";
3
+ const CodeMailerSettingsFeature = createFeature({
4
+ name: "Mailer/CodeMailerSettings",
5
+ register (container) {
6
+ container.register(CodeMailerSettings).inSingletonScope();
7
+ }
8
+ });
9
+ export { CodeMailerSettingsFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./CodeMailerSettings.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"}
@@ -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,15 @@
1
+ import { DUMMY_TRANSPORT_NAME } from "../../constants.js";
2
+ class DummyMailTransport {
3
+ constructor(){
4
+ this.name = DUMMY_TRANSPORT_NAME;
5
+ }
6
+ async send() {
7
+ return {
8
+ result: true,
9
+ error: null
10
+ };
11
+ }
12
+ }
13
+ export { DummyMailTransport };
14
+
15
+ //# sourceMappingURL=DummyMailTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/DummyTransport/DummyMailTransport.js","sources":["../../../src/features/DummyTransport/DummyMailTransport.ts"],"sourcesContent":["import { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\nimport { DUMMY_TRANSPORT_NAME } from \"~/constants.js\";\n\nexport class DummyMailTransport implements MailTransport.Interface {\n public readonly name = DUMMY_TRANSPORT_NAME;\n\n constructor() {}\n\n async send() {\n return {\n result: true,\n error: null\n };\n }\n}\n"],"names":["DummyMailTransport","DUMMY_TRANSPORT_NAME"],"mappings":";AAGO,MAAMA;IAGT,aAAc;aAFE,IAAI,GAAGC;IAER;IAEf,MAAM,OAAO;QACT,OAAO;YACH,QAAQ;YACR,OAAO;QACX;IACJ;AACJ"}
@@ -0,0 +1,10 @@
1
+ import { type IMailTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ declare class DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {
3
+ readonly name = "Mailer/DummyTransport";
4
+ canUse(): boolean;
5
+ createTransport(): Promise<IMailTransport>;
6
+ }
7
+ export declare const DummyMailTransportFactory: typeof DummyMailTransportFactoryImpl & {
8
+ __abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IMailTransportFactory>;
9
+ };
10
+ export {};
@@ -0,0 +1,21 @@
1
+ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ import { DummyMailTransport } from "./DummyMailTransport.js";
3
+ import { DUMMY_TRANSPORT_NAME } from "../../constants.js";
4
+ class DummyMailTransportFactoryImpl {
5
+ canUse() {
6
+ return true;
7
+ }
8
+ async createTransport() {
9
+ return new DummyMailTransport();
10
+ }
11
+ constructor(){
12
+ this.name = DUMMY_TRANSPORT_NAME;
13
+ }
14
+ }
15
+ const DummyMailTransportFactory = MailTransportFactory.createImplementation({
16
+ implementation: DummyMailTransportFactoryImpl,
17
+ dependencies: []
18
+ });
19
+ export { DummyMailTransportFactory };
20
+
21
+ //# sourceMappingURL=DummyMailTransportFactory.js.map
@@ -0,0 +1 @@
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\";\nimport { DUMMY_TRANSPORT_NAME } from \"~/constants.js\";\n\nclass DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = DUMMY_TRANSPORT_NAME;\n\n canUse(): boolean {\n return true;\n }\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","DUMMY_TRANSPORT_NAME","DummyMailTransportFactory","MailTransportFactory"],"mappings":";;;AAIA,MAAMA;IAGF,SAAkB;QACd,OAAO;IACX;IAEA,MAAM,kBAA2C;QAC7C,OAAO,IAAIC;IACf;;aARgB,IAAI,GAAGC;;AAS3B;AAEO,MAAMC,4BAA4BC,qBAAqB,oBAAoB,CAAC;IAC/E,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,4 @@
1
+ export declare const DummyTransportFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { DummyMailTransportFactory } from "./DummyMailTransportFactory.js";
3
+ const DummyTransportFeature = createFeature({
4
+ name: "Mailer/DummyTransport",
5
+ register (container) {
6
+ container.register(DummyMailTransportFactory).inSingletonScope();
7
+ }
8
+ });
9
+ export { DummyTransportFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
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"}
@@ -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,56 @@
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
+ 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 ? await this.encryption.decrypt(String(settings.password)) : "";
30
+ const port = Number(settings.port || 587);
31
+ const transportSettings = {
32
+ host: String(settings.host || ""),
33
+ port,
34
+ secure: settings.secure ?? 465 === port,
35
+ user: String(settings.user || ""),
36
+ password,
37
+ from: String(settings.from || ""),
38
+ replyTo: settings.replyTo ? String(settings.replyTo) : void 0
39
+ };
40
+ return Result.ok({
41
+ settings: transportSettings,
42
+ source: "storage"
43
+ });
44
+ }
45
+ }
46
+ const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
47
+ implementation: GetSettingsRepositoryImpl,
48
+ dependencies: [
49
+ KeyValueStore,
50
+ Encryption,
51
+ CodeMailerSettings
52
+ ]
53
+ });
54
+ export { GetSettingsRepositoryImplementation };
55
+
56
+ //# sourceMappingURL=GetSettingsRepository.js.map