@webiny/api-mailer 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/README.md +10 -13
  2. package/constants.d.ts +1 -0
  3. package/constants.js +4 -0
  4. package/constants.js.map +1 -0
  5. package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
  6. package/domain/CodeMailerSettings/abstractions.js +5 -0
  7. package/domain/CodeMailerSettings/abstractions.js.map +1 -0
  8. package/domain/MailTransport/abstractions.d.ts +26 -0
  9. package/domain/MailTransport/abstractions.js +7 -0
  10. package/domain/MailTransport/abstractions.js.map +1 -0
  11. package/domain/MailerService/abstractions.d.ts +19 -0
  12. package/domain/MailerService/abstractions.js +5 -0
  13. package/domain/MailerService/abstractions.js.map +1 -0
  14. package/domain/MailerService/errors.d.ts +16 -0
  15. package/domain/MailerService/errors.js +28 -0
  16. package/domain/MailerService/errors.js.map +1 -0
  17. package/domain/errors.d.ts +28 -0
  18. package/domain/errors.js +48 -0
  19. package/domain/errors.js.map +1 -0
  20. package/exports/api/mailer.d.ts +4 -0
  21. package/exports/api/mailer.js +4 -0
  22. package/features/CodeMailerSettings/CodeMailerSettingsImpl.d.ts +12 -0
  23. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +23 -0
  24. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -0
  25. package/features/CodeMailerSettings/feature.d.ts +4 -0
  26. package/features/CodeMailerSettings/feature.js +11 -0
  27. package/features/CodeMailerSettings/feature.js.map +1 -0
  28. package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
  29. package/features/DummyTransport/DummyMailTransport.js +14 -0
  30. package/features/DummyTransport/DummyMailTransport.js.map +1 -0
  31. package/features/DummyTransport/DummyMailTransportFactory.d.ts +9 -0
  32. package/features/DummyTransport/DummyMailTransportFactory.js +17 -0
  33. package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
  34. package/features/DummyTransport/feature.d.ts +4 -0
  35. package/features/DummyTransport/feature.js +11 -0
  36. package/features/DummyTransport/feature.js.map +1 -0
  37. package/features/GetSettings/GetSettingsRepository.d.ts +16 -0
  38. package/features/GetSettings/GetSettingsRepository.js +54 -0
  39. package/features/GetSettings/GetSettingsRepository.js.map +1 -0
  40. package/features/GetSettings/GetSettingsUseCase.d.ts +11 -0
  41. package/features/GetSettings/GetSettingsUseCase.js +18 -0
  42. package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
  43. package/features/GetSettings/abstractions.d.ts +22 -0
  44. package/features/GetSettings/abstractions.js +6 -0
  45. package/features/GetSettings/abstractions.js.map +1 -0
  46. package/features/GetSettings/feature.d.ts +4 -0
  47. package/features/GetSettings/feature.js +13 -0
  48. package/features/GetSettings/feature.js.map +1 -0
  49. package/features/GetSettings/index.d.ts +1 -0
  50. package/features/GetSettings/index.js +1 -0
  51. package/features/MailerService/ActiveTransport.d.ts +10 -0
  52. package/features/MailerService/ActiveTransport.js +24 -0
  53. package/features/MailerService/ActiveTransport.js.map +1 -0
  54. package/features/MailerService/MailerService.d.ts +16 -0
  55. package/features/MailerService/MailerService.js +49 -0
  56. package/features/MailerService/MailerService.js.map +1 -0
  57. package/features/MailerService/feature.d.ts +4 -0
  58. package/features/MailerService/feature.js +13 -0
  59. package/features/MailerService/feature.js.map +1 -0
  60. package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
  61. package/features/SaveSettings/SaveSettingsRepository.js +43 -0
  62. package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
  63. package/features/SaveSettings/SaveSettingsUseCase.d.ts +18 -0
  64. package/features/SaveSettings/SaveSettingsUseCase.js +51 -0
  65. package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
  66. package/features/SaveSettings/abstractions.d.ts +61 -0
  67. package/features/SaveSettings/abstractions.js +8 -0
  68. package/features/SaveSettings/abstractions.js.map +1 -0
  69. package/features/SaveSettings/events.d.ts +10 -0
  70. package/features/SaveSettings/events.js +21 -0
  71. package/features/SaveSettings/events.js.map +1 -0
  72. package/features/SaveSettings/feature.d.ts +4 -0
  73. package/features/SaveSettings/feature.js +13 -0
  74. package/features/SaveSettings/feature.js.map +1 -0
  75. package/features/SaveSettings/index.d.ts +1 -0
  76. package/features/SaveSettings/index.js +1 -0
  77. package/features/SaveSettings/validation.d.ts +9 -0
  78. package/features/SaveSettings/validation.js +20 -0
  79. package/features/SaveSettings/validation.js.map +1 -0
  80. package/features/SendMail/SendMailUseCase.d.ts +16 -0
  81. package/features/SendMail/SendMailUseCase.js +58 -0
  82. package/features/SendMail/SendMailUseCase.js.map +1 -0
  83. package/features/SendMail/abstractions.d.ts +45 -0
  84. package/features/SendMail/abstractions.js +8 -0
  85. package/features/SendMail/abstractions.js.map +1 -0
  86. package/features/SendMail/events.d.ts +14 -0
  87. package/features/SendMail/events.js +29 -0
  88. package/features/SendMail/events.js.map +1 -0
  89. package/features/SendMail/feature.d.ts +4 -0
  90. package/features/SendMail/feature.js +11 -0
  91. package/features/SendMail/feature.js.map +1 -0
  92. package/features/SendMail/index.d.ts +1 -0
  93. package/features/SendMail/index.js +1 -0
  94. package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
  95. package/features/SmtpTransport/SmtpConfig.js +25 -0
  96. package/features/SmtpTransport/SmtpConfig.js.map +1 -0
  97. package/features/SmtpTransport/SmtpMailTransport.d.ts +68 -0
  98. package/features/SmtpTransport/SmtpMailTransport.js +53 -0
  99. package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
  100. package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +10 -0
  101. package/features/SmtpTransport/SmtpMailTransportFactory.js +18 -0
  102. package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
  103. package/features/SmtpTransport/feature.d.ts +4 -0
  104. package/features/SmtpTransport/feature.js +11 -0
  105. package/features/SmtpTransport/feature.js.map +1 -0
  106. package/graphql/settings.d.ts +2 -2
  107. package/graphql/settings.js +71 -73
  108. package/graphql/settings.js.map +1 -1
  109. package/index.d.ts +4 -8
  110. package/index.js +23 -89
  111. package/index.js.map +1 -1
  112. package/package.json +32 -45
  113. package/types.d.ts +2 -109
  114. package/types.js +0 -5
  115. package/utils/isMailboxAddress.d.ts +6 -0
  116. package/utils/isMailboxAddress.js +5 -0
  117. package/utils/isMailboxAddress.js.map +1 -0
  118. package/context.d.ts +0 -3
  119. package/context.js +0 -24
  120. package/context.js.map +0 -1
  121. package/crud/group.d.ts +0 -2
  122. package/crud/group.js +0 -21
  123. package/crud/group.js.map +0 -1
  124. package/crud/mailer/onBeforeSend.d.ts +0 -7
  125. package/crud/mailer/onBeforeSend.js +0 -69
  126. package/crud/mailer/onBeforeSend.js.map +0 -1
  127. package/crud/mailer.crud.d.ts +0 -2
  128. package/crud/mailer.crud.js +0 -123
  129. package/crud/mailer.crud.js.map +0 -1
  130. package/crud/settings/hooks.d.ts +0 -5
  131. package/crud/settings/hooks.js +0 -55
  132. package/crud/settings/hooks.js.map +0 -1
  133. package/crud/settings/model.d.ts +0 -3
  134. package/crud/settings/model.js +0 -90
  135. package/crud/settings/model.js.map +0 -1
  136. package/crud/settings/password.d.ts +0 -7
  137. package/crud/settings/password.js +0 -71
  138. package/crud/settings/password.js.map +0 -1
  139. package/crud/settings/secret.d.ts +0 -1
  140. package/crud/settings/secret.js +0 -23
  141. package/crud/settings/secret.js.map +0 -1
  142. package/crud/settings/transform.d.ts +0 -13
  143. package/crud/settings/transform.js +0 -56
  144. package/crud/settings/transform.js.map +0 -1
  145. package/crud/settings/validation.d.ts +0 -4
  146. package/crud/settings/validation.js +0 -38
  147. package/crud/settings/validation.js.map +0 -1
  148. package/crud/settings.crud.d.ts +0 -5
  149. package/crud/settings.crud.js +0 -331
  150. package/crud/settings.crud.js.map +0 -1
  151. package/crud/transport/onTransportBeforeSend.d.ts +0 -7
  152. package/crud/transport/onTransportBeforeSend.js +0 -69
  153. package/crud/transport/onTransportBeforeSend.js.map +0 -1
  154. package/crud/transporter.crud.d.ts +0 -2
  155. package/crud/transporter.crud.js +0 -193
  156. package/crud/transporter.crud.js.map +0 -1
  157. package/graphql/index.d.ts +0 -1
  158. package/graphql/index.js +0 -14
  159. package/graphql/index.js.map +0 -1
  160. package/mailers/createDummyMailer.d.ts +0 -5
  161. package/mailers/createDummyMailer.js +0 -24
  162. package/mailers/createDummyMailer.js.map +0 -1
  163. package/mailers/createSmtpMailer.d.ts +0 -13
  164. package/mailers/createSmtpMailer.js +0 -106
  165. package/mailers/createSmtpMailer.js.map +0 -1
  166. package/plugins/CreateTransportPlugin.d.ts +0 -17
  167. package/plugins/CreateTransportPlugin.js +0 -34
  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 -12
  176. package/transports/createSmtpTransport.js +0 -101
  177. package/transports/createSmtpTransport.js.map +0 -1
  178. package/types.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { GetSettingsRepositoryImplementation } from "./GetSettingsRepository.js";
3
+ import { GetSettingsUseCaseImplementation } from "./GetSettingsUseCase.js";
4
+ const GetSettingsFeature = createFeature({
5
+ name: "GetSettings",
6
+ register (container) {
7
+ container.register(GetSettingsRepositoryImplementation).inSingletonScope();
8
+ container.register(GetSettingsUseCaseImplementation);
9
+ }
10
+ });
11
+ export { GetSettingsFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/GetSettings/feature.js","sources":["../../../src/features/GetSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GetSettingsRepositoryImplementation } from \"./GetSettingsRepository.js\";\nimport { GetSettingsUseCaseImplementation } from \"./GetSettingsUseCase.js\";\n\nexport const GetSettingsFeature = createFeature({\n name: \"GetSettings\",\n register(container) {\n container.register(GetSettingsRepositoryImplementation).inSingletonScope();\n container.register(GetSettingsUseCaseImplementation);\n }\n});\n"],"names":["GetSettingsFeature","createFeature","container","GetSettingsRepositoryImplementation","GetSettingsUseCaseImplementation"],"mappings":";;;AAIO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,qCAAqC,gBAAgB;QACxED,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -0,0 +1 @@
1
+ export { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
@@ -0,0 +1 @@
1
+ export { GetSettingsRepository, GetSettingsUseCase } from "./abstractions.js";
@@ -0,0 +1,10 @@
1
+ import { ActiveTransport as ActiveTransportAbstraction, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ declare class ActiveTransportImpl implements ActiveTransportAbstraction.Interface {
3
+ private transportFactories;
4
+ constructor(transportFactories: MailTransportFactory.Interface[]);
5
+ name(): string | null;
6
+ }
7
+ export declare const ActiveTransport: typeof ActiveTransportImpl & {
8
+ __abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IActiveTransport>;
9
+ };
10
+ export {};
@@ -0,0 +1,24 @@
1
+ import { ActiveTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ class ActiveTransportImpl {
3
+ constructor(transportFactories){
4
+ this.transportFactories = transportFactories;
5
+ }
6
+ name() {
7
+ if (0 === this.transportFactories.length) return null;
8
+ return this.transportFactories[this.transportFactories.length - 1].name;
9
+ }
10
+ }
11
+ const ActiveTransport_ActiveTransport = ActiveTransport.createImplementation({
12
+ implementation: ActiveTransportImpl,
13
+ dependencies: [
14
+ [
15
+ MailTransportFactory,
16
+ {
17
+ multiple: true
18
+ }
19
+ ]
20
+ ]
21
+ });
22
+ export { ActiveTransport_ActiveTransport as ActiveTransport };
23
+
24
+ //# sourceMappingURL=ActiveTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/MailerService/ActiveTransport.js","sources":["../../../src/features/MailerService/ActiveTransport.ts"],"sourcesContent":["import {\n ActiveTransport as ActiveTransportAbstraction,\n MailTransportFactory\n} from \"~/domain/MailTransport/abstractions.js\";\n\nclass ActiveTransportImpl implements ActiveTransportAbstraction.Interface {\n constructor(private transportFactories: MailTransportFactory.Interface[]) {}\n\n name(): string | null {\n if (this.transportFactories.length === 0) {\n return null;\n }\n return this.transportFactories[this.transportFactories.length - 1].name;\n }\n}\n\nexport const ActiveTransport = ActiveTransportAbstraction.createImplementation({\n implementation: ActiveTransportImpl,\n dependencies: [[MailTransportFactory, { multiple: true }]]\n});\n"],"names":["ActiveTransportImpl","transportFactories","ActiveTransport","ActiveTransportAbstraction","MailTransportFactory"],"mappings":";AAKA,MAAMA;IACF,YAAoBC,kBAAoD,CAAE;aAAtDA,kBAAkB,GAAlBA;IAAuD;IAE3E,OAAsB;QAClB,IAAI,AAAmC,MAAnC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAC9B,OAAO;QAEX,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,EAAE,CAAC,IAAI;IAC3E;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAA+C,CAAC;IAC3E,gBAAgBH;IAChB,cAAc;QAAC;YAACI;YAAsB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC9D"}
@@ -0,0 +1,16 @@
1
+ import { MailerService as Abstraction } from "../../domain/MailerService/abstractions.js";
2
+ import { ActiveTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
3
+ import { GetSettingsRepository } from "../GetSettings/abstractions.js";
4
+ import type { TransportSendData } from "../../types.js";
5
+ declare class MailerServiceImpl implements Abstraction.Interface {
6
+ private getSettingsRepository;
7
+ private activeTransport;
8
+ private transportFactories;
9
+ constructor(getSettingsRepository: GetSettingsRepository.Interface, activeTransport: ActiveTransport.Interface, transportFactories: MailTransportFactory.Interface[]);
10
+ sendMail<T = any>(data: TransportSendData): Abstraction.Return<T>;
11
+ private getTransport;
12
+ }
13
+ export declare const MailerService: typeof MailerServiceImpl & {
14
+ __abstraction: import("@webiny/di").Abstraction<import("~/domain/MailerService/abstractions.js").IMailerService>;
15
+ };
16
+ export {};
@@ -0,0 +1,49 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { MailerService } from "../../domain/MailerService/abstractions.js";
3
+ import { NoSettingsConfiguredError, NoTransportAvailableError, TransportSendError } from "../../domain/MailerService/errors.js";
4
+ import { ActiveTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
5
+ import { GetSettingsRepository } from "../GetSettings/abstractions.js";
6
+ class MailerServiceImpl {
7
+ constructor(getSettingsRepository, activeTransport, transportFactories){
8
+ this.getSettingsRepository = getSettingsRepository;
9
+ this.activeTransport = activeTransport;
10
+ this.transportFactories = transportFactories;
11
+ }
12
+ async sendMail(data) {
13
+ const transportName = this.activeTransport.name();
14
+ if (!transportName) return Result.fail(new NoTransportAvailableError());
15
+ const result = await this.getSettingsRepository.get(transportName);
16
+ const { settings } = result.value;
17
+ if (!settings) return Result.fail(new NoSettingsConfiguredError());
18
+ const transport = await this.getTransport(transportName, settings);
19
+ if (!transport) return Result.fail(new NoTransportAvailableError());
20
+ try {
21
+ const response = await transport.send(data);
22
+ if (response.error) return Result.fail(new TransportSendError(response.error));
23
+ return Result.ok(response);
24
+ } catch (error) {
25
+ return Result.fail(new TransportSendError(error));
26
+ }
27
+ }
28
+ async getTransport(transportName, settings) {
29
+ const factory = this.transportFactories.find((f)=>f.name === transportName);
30
+ if (!factory) return null;
31
+ return factory.createTransport(settings);
32
+ }
33
+ }
34
+ const MailerService_MailerService = MailerService.createImplementation({
35
+ implementation: MailerServiceImpl,
36
+ dependencies: [
37
+ GetSettingsRepository,
38
+ ActiveTransport,
39
+ [
40
+ MailTransportFactory,
41
+ {
42
+ multiple: true
43
+ }
44
+ ]
45
+ ]
46
+ });
47
+ export { MailerService_MailerService as MailerService };
48
+
49
+ //# sourceMappingURL=MailerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/MailerService/MailerService.js","sources":["../../../src/features/MailerService/MailerService.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { MailerService as Abstraction } from \"~/domain/MailerService/abstractions.js\";\nimport {\n NoTransportAvailableError,\n NoSettingsConfiguredError,\n TransportSendError\n} from \"~/domain/MailerService/errors.js\";\nimport {\n ActiveTransport,\n MailTransport,\n MailTransportFactory\n} from \"~/domain/MailTransport/abstractions.js\";\nimport { GetSettingsRepository } from \"../GetSettings/abstractions.js\";\nimport type { TransportSettings, TransportSendData } from \"~/types.js\";\n\nclass MailerServiceImpl implements Abstraction.Interface {\n constructor(\n private getSettingsRepository: GetSettingsRepository.Interface,\n private activeTransport: ActiveTransport.Interface,\n private transportFactories: MailTransportFactory.Interface[]\n ) {}\n\n async sendMail<T = any>(data: TransportSendData): Abstraction.Return<T> {\n const transportName = this.activeTransport.name();\n\n if (!transportName) {\n return Result.fail(new NoTransportAvailableError());\n }\n\n const result = await this.getSettingsRepository.get(transportName);\n const { settings } = result.value;\n\n if (!settings) {\n return Result.fail(new NoSettingsConfiguredError());\n }\n\n const transport = await this.getTransport(transportName, settings);\n\n if (!transport) {\n return Result.fail(new NoTransportAvailableError());\n }\n\n try {\n const response = await transport.send(data);\n\n if (response.error) {\n return Result.fail(new TransportSendError(response.error));\n }\n\n return Result.ok(response);\n } catch (error) {\n return Result.fail(new TransportSendError(error));\n }\n }\n\n private async getTransport(\n transportName: string,\n settings: TransportSettings\n ): Promise<MailTransport.Interface | null> {\n const factory = this.transportFactories.find(f => f.name === transportName);\n if (!factory) {\n return null;\n }\n return factory.createTransport(settings);\n }\n}\n\nexport const MailerService = Abstraction.createImplementation({\n implementation: MailerServiceImpl,\n dependencies: [\n GetSettingsRepository,\n ActiveTransport,\n [MailTransportFactory, { multiple: true }]\n ]\n});\n"],"names":["MailerServiceImpl","getSettingsRepository","activeTransport","transportFactories","data","transportName","Result","NoTransportAvailableError","result","settings","NoSettingsConfiguredError","transport","response","TransportSendError","error","factory","f","MailerService","Abstraction","GetSettingsRepository","ActiveTransport","MailTransportFactory"],"mappings":";;;;;AAeA,MAAMA;IACF,YACYC,qBAAsD,EACtDC,eAA0C,EAC1CC,kBAAoD,CAC9D;aAHUF,qBAAqB,GAArBA;aACAC,eAAe,GAAfA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,SAAkBC,IAAuB,EAAyB;QACpE,MAAMC,gBAAgB,IAAI,CAAC,eAAe,CAAC,IAAI;QAE/C,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,SAAS,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAACH;QACpD,MAAM,EAAEI,QAAQ,EAAE,GAAGD,OAAO,KAAK;QAEjC,IAAI,CAACC,UACD,OAAOH,OAAO,IAAI,CAAC,IAAII;QAG3B,MAAMC,YAAY,MAAM,IAAI,CAAC,YAAY,CAACN,eAAeI;QAEzD,IAAI,CAACE,WACD,OAAOL,OAAO,IAAI,CAAC,IAAIC;QAG3B,IAAI;YACA,MAAMK,WAAW,MAAMD,UAAU,IAAI,CAACP;YAEtC,IAAIQ,SAAS,KAAK,EACd,OAAON,OAAO,IAAI,CAAC,IAAIO,mBAAmBD,SAAS,KAAK;YAG5D,OAAON,OAAO,EAAE,CAACM;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOR,OAAO,IAAI,CAAC,IAAIO,mBAAmBC;QAC9C;IACJ;IAEA,MAAc,aACVT,aAAqB,EACrBI,QAA2B,EACY;QACvC,MAAMM,UAAU,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAACC,CAAAA,IAAKA,EAAE,IAAI,KAAKX;QAC7D,IAAI,CAACU,SACD,OAAO;QAEX,OAAOA,QAAQ,eAAe,CAACN;IACnC;AACJ;AAEO,MAAMQ,8BAAgBC,cAAAA,oBAAgC,CAAC;IAC1D,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACA;YAACC;YAAsB;gBAAE,UAAU;YAAK;SAAE;KAC7C;AACL"}
@@ -0,0 +1,4 @@
1
+ export declare const MailerServiceFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { MailerService } from "./MailerService.js";
3
+ import { ActiveTransport } from "./ActiveTransport.js";
4
+ const MailerServiceFeature = createFeature({
5
+ name: "Mailer/MailerService",
6
+ register (container) {
7
+ container.register(ActiveTransport).inSingletonScope();
8
+ container.register(MailerService).inSingletonScope();
9
+ }
10
+ });
11
+ export { MailerServiceFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/MailerService/feature.js","sources":["../../../src/features/MailerService/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { MailerService } from \"./MailerService.js\";\nimport { ActiveTransport } from \"./ActiveTransport.js\";\n\nexport const MailerServiceFeature = createFeature({\n name: \"Mailer/MailerService\",\n register(container) {\n container.register(ActiveTransport).inSingletonScope();\n container.register(MailerService).inSingletonScope();\n }\n});\n"],"names":["MailerServiceFeature","createFeature","container","ActiveTransport","MailerService"],"mappings":";;;AAIO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,iBAAiB,gBAAgB;QACpDD,UAAU,QAAQ,CAACE,eAAe,gBAAgB;IACtD;AACJ"}
@@ -0,0 +1,13 @@
1
+ import { Encryption } from "@webiny/api-core/features/encryption/index.js";
2
+ import { SaveSettingsRepository, type SaveSettingsInput } from "./abstractions.js";
3
+ import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
4
+ declare class SaveSettingsRepositoryImpl implements SaveSettingsRepository.Interface {
5
+ private keyValueStore;
6
+ private encryption;
7
+ constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface);
8
+ execute(input: SaveSettingsInput): SaveSettingsRepository.Return;
9
+ }
10
+ export declare const SaveSettingsRepositoryImplementation: typeof SaveSettingsRepositoryImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISaveSettingsRepository>;
12
+ };
13
+ export {};
@@ -0,0 +1,43 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { Encryption } from "@webiny/api-core/features/encryption/index.js";
3
+ import { SaveSettingsRepository } from "./abstractions.js";
4
+ import { SettingsPersistenceError } from "../../domain/errors.js";
5
+ import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
6
+ import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
7
+ const DEFAULT_PORT = 25;
8
+ class SaveSettingsRepositoryImpl {
9
+ constructor(keyValueStore, encryption){
10
+ this.keyValueStore = keyValueStore;
11
+ this.encryption = encryption;
12
+ }
13
+ async execute(input) {
14
+ const existingResult = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
15
+ const existingSettings = existingResult.isOk() ? existingResult.value : null;
16
+ const transportSettings = existingSettings ?? {};
17
+ let passwordToStore = input.password || "";
18
+ if (!input.password && existingSettings) passwordToStore = await this.encryption.decrypt(transportSettings.password || "");
19
+ const encryptedPassword = await this.encryption.encrypt(passwordToStore);
20
+ const data = {
21
+ host: input.host ?? transportSettings.host,
22
+ port: input.port ?? transportSettings.port ?? DEFAULT_PORT,
23
+ user: input.user ?? transportSettings.user,
24
+ password: encryptedPassword,
25
+ from: input.from ?? transportSettings.from,
26
+ replyTo: input.replyTo ?? transportSettings.replyTo
27
+ };
28
+ const result = await this.keyValueStore.set(MAILER_TRANSPORT_SETTINGS, data);
29
+ if (result.isFail()) return Result.fail(new SettingsPersistenceError(result.error));
30
+ const { password: _password, ...savedSettings } = data;
31
+ return Result.ok(savedSettings);
32
+ }
33
+ }
34
+ const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({
35
+ implementation: SaveSettingsRepositoryImpl,
36
+ dependencies: [
37
+ KeyValueStore,
38
+ Encryption
39
+ ]
40
+ });
41
+ export { SaveSettingsRepositoryImplementation };
42
+
43
+ //# sourceMappingURL=SaveSettingsRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/SaveSettingsRepository.js","sources":["../../../src/features/SaveSettings/SaveSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { SaveSettingsRepository, type SaveSettingsInput } from \"./abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SettingsPersistenceError } from \"~/domain/errors.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { MAILER_TRANSPORT_SETTINGS } from \"~/constants.js\";\n\nconst DEFAULT_PORT = 25;\n\nclass SaveSettingsRepositoryImpl implements SaveSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface\n ) {}\n\n async execute(input: SaveSettingsInput): SaveSettingsRepository.Return {\n // Check if settings exist\n const existingResult =\n await this.keyValueStore.get<TransportSettings>(MAILER_TRANSPORT_SETTINGS);\n const existingSettings = existingResult.isOk() ? existingResult.value : null;\n const transportSettings: Partial<TransportSettings> = existingSettings ?? {};\n\n // If updating and no password provided, keep the existing password\n let passwordToStore = input.password || \"\";\n if (!input.password && existingSettings) {\n passwordToStore = await this.encryption.decrypt(transportSettings.password || \"\");\n }\n\n // Encrypt password\n const encryptedPassword = await this.encryption.encrypt(passwordToStore);\n\n // Prepare data\n const data = {\n host: input.host ?? transportSettings.host,\n port: input.port ?? transportSettings.port ?? DEFAULT_PORT,\n user: input.user ?? transportSettings.user,\n password: encryptedPassword,\n from: input.from ?? transportSettings.from,\n replyTo: input.replyTo ?? transportSettings.replyTo\n };\n\n // Save settings.\n const result = await this.keyValueStore.set(MAILER_TRANSPORT_SETTINGS, data);\n\n if (result.isFail()) {\n return Result.fail(new SettingsPersistenceError(result.error));\n }\n\n // Return the stored state without the password. Callers that need the\n // plaintext password go through GetSettingsRepository.get(transportName).\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _password, ...savedSettings } = data as TransportSettings;\n return Result.ok(savedSettings);\n }\n}\n\nexport const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({\n implementation: SaveSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption]\n});\n"],"names":["DEFAULT_PORT","SaveSettingsRepositoryImpl","keyValueStore","encryption","input","existingResult","MAILER_TRANSPORT_SETTINGS","existingSettings","transportSettings","passwordToStore","encryptedPassword","data","result","Result","SettingsPersistenceError","_password","savedSettings","SaveSettingsRepositoryImplementation","SaveSettingsRepository","KeyValueStore","Encryption"],"mappings":";;;;;;AAQA,MAAMA,eAAe;AAErB,MAAMC;IACF,YACYC,aAAsC,EACtCC,UAAgC,CAC1C;aAFUD,aAAa,GAAbA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAwB,EAAiC;QAEnE,MAAMC,iBACF,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAoBC;QACpD,MAAMC,mBAAmBF,eAAe,IAAI,KAAKA,eAAe,KAAK,GAAG;QACxE,MAAMG,oBAAgDD,oBAAoB,CAAC;QAG3E,IAAIE,kBAAkBL,MAAM,QAAQ,IAAI;QACxC,IAAI,CAACA,MAAM,QAAQ,IAAIG,kBACnBE,kBAAkB,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD,kBAAkB,QAAQ,IAAI;QAIlF,MAAME,oBAAoB,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD;QAGxD,MAAME,OAAO;YACT,MAAMP,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1C,MAAMJ,MAAM,IAAI,IAAII,kBAAkB,IAAI,IAAIR;YAC9C,MAAMI,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1C,UAAUE;YACV,MAAMN,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1C,SAASJ,MAAM,OAAO,IAAII,kBAAkB,OAAO;QACvD;QAGA,MAAMI,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACN,2BAA2BK;QAEvE,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,yBAAyBF,OAAO,KAAK;QAMhE,MAAM,EAAE,UAAUG,SAAS,EAAE,GAAGC,eAAe,GAAGL;QAClD,OAAOE,OAAO,EAAE,CAACG;IACrB;AACJ;AAEO,MAAMC,uCAAuCC,uBAAuB,oBAAoB,CAAC;IAC5F,gBAAgBjB;IAChB,cAAc;QAACkB;QAAeC;KAAW;AAC7C"}
@@ -0,0 +1,18 @@
1
+ import { EventPublisher as EventPublisherAbstraction } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { SaveSettingsUseCase, SaveSettingsRepository, type SaveSettingsInput } from "./abstractions.js";
3
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
4
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
5
+ import { ActiveTransport } from "../../domain/MailTransport/abstractions.js";
6
+ declare class SaveSettingsUseCaseImpl implements SaveSettingsUseCase.Interface {
7
+ private identityContext;
8
+ private eventPublisher;
9
+ private repository;
10
+ private codeSettings;
11
+ private activeTransport;
12
+ constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisherAbstraction.Interface, repository: SaveSettingsRepository.Interface, codeSettings: CodeMailerSettings.Interface, activeTransport: ActiveTransport.Interface);
13
+ execute(input: SaveSettingsInput): SaveSettingsUseCase.Return;
14
+ }
15
+ export declare const SaveSettingsUseCaseImplementation: typeof SaveSettingsUseCaseImpl & {
16
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISaveSettings>;
17
+ };
18
+ export {};
@@ -0,0 +1,51 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { SaveSettingsRepository, SaveSettingsUseCase } from "./abstractions.js";
4
+ import { MailerSettingsAfterSaveEvent, MailerSettingsBeforeSaveEvent } from "./events.js";
5
+ import { saveValidation } from "./validation.js";
6
+ import { SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError } from "../../domain/errors.js";
7
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
8
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
9
+ import { ActiveTransport } from "../../domain/MailTransport/abstractions.js";
10
+ class SaveSettingsUseCaseImpl {
11
+ constructor(identityContext, eventPublisher, repository, codeSettings, activeTransport){
12
+ this.identityContext = identityContext;
13
+ this.eventPublisher = eventPublisher;
14
+ this.repository = repository;
15
+ this.codeSettings = codeSettings;
16
+ this.activeTransport = activeTransport;
17
+ }
18
+ async execute(input) {
19
+ const permission = await this.identityContext.getPermission("mailer.settings");
20
+ if (!permission) return Result.fail(new SettingsNotAuthorized());
21
+ const validationResult = saveValidation.safeParse(input);
22
+ if (!validationResult.success) return Result.fail(new SettingsValidationError(validationResult.error.issues));
23
+ const transportName = this.activeTransport.name();
24
+ if (transportName && null !== this.codeSettings.get(transportName)) return Result.fail(new SettingsLockedByCode());
25
+ const { password: _beforePassword, ...inputForEvent } = input;
26
+ const beforeSaveEvent = new MailerSettingsBeforeSaveEvent({
27
+ input: inputForEvent
28
+ });
29
+ await this.eventPublisher.publish(beforeSaveEvent);
30
+ const result = await this.repository.execute(input);
31
+ if (result.isFail()) return Result.fail(new SettingsPersistenceError(result.error));
32
+ const afterSaveEvent = new MailerSettingsAfterSaveEvent({
33
+ settings: result.value
34
+ });
35
+ await this.eventPublisher.publish(afterSaveEvent);
36
+ return result;
37
+ }
38
+ }
39
+ const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({
40
+ implementation: SaveSettingsUseCaseImpl,
41
+ dependencies: [
42
+ IdentityContext,
43
+ EventPublisher,
44
+ SaveSettingsRepository,
45
+ CodeMailerSettings,
46
+ ActiveTransport
47
+ ]
48
+ });
49
+ export { SaveSettingsUseCaseImplementation };
50
+
51
+ //# sourceMappingURL=SaveSettingsUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/SaveSettingsUseCase.js","sources":["../../../src/features/SaveSettings/SaveSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n EventPublisher,\n EventPublisher as EventPublisherAbstraction\n} from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n SaveSettingsUseCase,\n SaveSettingsRepository,\n type SaveSettingsInput\n} from \"./abstractions.js\";\nimport { MailerSettingsBeforeSaveEvent, MailerSettingsAfterSaveEvent } from \"./events.js\";\nimport { saveValidation } from \"./validation.js\";\nimport {\n SettingsValidationError,\n SettingsPersistenceError,\n SettingsNotAuthorized,\n SettingsLockedByCode\n} from \"~/domain/errors.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { CodeMailerSettings } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport { ActiveTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nclass SaveSettingsUseCaseImpl implements SaveSettingsUseCase.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisherAbstraction.Interface,\n private repository: SaveSettingsRepository.Interface,\n private codeSettings: CodeMailerSettings.Interface,\n private activeTransport: ActiveTransport.Interface\n ) {}\n\n async execute(input: SaveSettingsInput): SaveSettingsUseCase.Return {\n const permission = await this.identityContext.getPermission(\"mailer.settings\");\n\n if (!permission) {\n return Result.fail(new SettingsNotAuthorized());\n }\n\n // Validate input.\n const validationResult = saveValidation.safeParse(input);\n if (!validationResult.success) {\n return Result.fail(new SettingsValidationError(validationResult.error.issues));\n }\n\n // Refuse when settings are defined via code.\n const transportName = this.activeTransport.name();\n if (transportName && this.codeSettings.get(transportName) !== null) {\n return Result.fail(new SettingsLockedByCode());\n }\n\n // Publish before save event. Strip the password — subscribers (audit\n // logs, telemetry) must never see the plaintext value from the input.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _beforePassword, ...inputForEvent } = input;\n const beforeSaveEvent = new MailerSettingsBeforeSaveEvent({ input: inputForEvent });\n await this.eventPublisher.publish(beforeSaveEvent);\n\n // Save settings.\n const result = await this.repository.execute(input);\n\n if (result.isFail()) {\n return Result.fail(new SettingsPersistenceError(result.error));\n }\n\n // Publish after save event. The repository return is already password-free\n // (its type is Omit<TransportSettings, \"password\">), so no runtime strip\n // is needed here.\n const afterSaveEvent = new MailerSettingsAfterSaveEvent({ settings: result.value });\n await this.eventPublisher.publish(afterSaveEvent);\n\n return result;\n }\n}\n\nexport const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({\n implementation: SaveSettingsUseCaseImpl,\n dependencies: [\n IdentityContext,\n EventPublisher,\n SaveSettingsRepository,\n CodeMailerSettings,\n ActiveTransport\n ]\n});\n"],"names":["SaveSettingsUseCaseImpl","identityContext","eventPublisher","repository","codeSettings","activeTransport","input","permission","Result","SettingsNotAuthorized","validationResult","saveValidation","SettingsValidationError","transportName","SettingsLockedByCode","_beforePassword","inputForEvent","beforeSaveEvent","MailerSettingsBeforeSaveEvent","result","SettingsPersistenceError","afterSaveEvent","MailerSettingsAfterSaveEvent","SaveSettingsUseCaseImplementation","SaveSettingsUseCase","IdentityContext","EventPublisher","SaveSettingsRepository","CodeMailerSettings","ActiveTransport"],"mappings":";;;;;;;;;AAsBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAmD,EACnDC,UAA4C,EAC5CC,YAA0C,EAC1CC,eAA0C,CACpD;aALUJ,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,YAAY,GAAZA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QAAQC,KAAwB,EAA8B;QAChE,MAAMC,aAAa,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAE5D,IAAI,CAACA,YACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,mBAAmBC,eAAe,SAAS,CAACL;QAClD,IAAI,CAACI,iBAAiB,OAAO,EACzB,OAAOF,OAAO,IAAI,CAAC,IAAII,wBAAwBF,iBAAiB,KAAK,CAAC,MAAM;QAIhF,MAAMG,gBAAgB,IAAI,CAAC,eAAe,CAAC,IAAI;QAC/C,IAAIA,iBAAiB,AAAyC,SAAzC,IAAI,CAAC,YAAY,CAAC,GAAG,CAACA,gBACvC,OAAOL,OAAO,IAAI,CAAC,IAAIM;QAM3B,MAAM,EAAE,UAAUC,eAAe,EAAE,GAAGC,eAAe,GAAGV;QACxD,MAAMW,kBAAkB,IAAIC,8BAA8B;YAAE,OAAOF;QAAc;QACjF,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACC;QAGlC,MAAME,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACb;QAE7C,IAAIa,OAAO,MAAM,IACb,OAAOX,OAAO,IAAI,CAAC,IAAIY,yBAAyBD,OAAO,KAAK;QAMhE,MAAME,iBAAiB,IAAIC,6BAA6B;YAAE,UAAUH,OAAO,KAAK;QAAC;QACjF,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAACE;QAElC,OAAOF;IACX;AACJ;AAEO,MAAMI,oCAAoCC,oBAAoB,oBAAoB,CAAC;IACtF,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -0,0 +1,61 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import type { DomainEvent, IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import type { TransportSettings } from "../../types.js";
4
+ import { SettingsValidationError, SettingsPersistenceError, SettingsNotAuthorized, SettingsLockedByCode } from "../../domain/errors.js";
5
+ export interface SaveSettingsInput {
6
+ host: string;
7
+ port?: number;
8
+ user: string;
9
+ password?: string;
10
+ from: string;
11
+ replyTo?: string;
12
+ }
13
+ export interface ISaveSettingsErrors {
14
+ validation: SettingsValidationError;
15
+ persistence: SettingsPersistenceError;
16
+ notAuthorized: SettingsNotAuthorized;
17
+ lockedByCode: SettingsLockedByCode;
18
+ }
19
+ type SaveSettingsError = ISaveSettingsErrors[keyof ISaveSettingsErrors];
20
+ /**
21
+ * Save-side returns are password-free. The only path that exposes the password
22
+ * to in-process callers is GetSettingsRepository.get / GetSettingsUseCase.execute
23
+ * (used by MailerService to authenticate SMTP). Everything else — events,
24
+ * GraphQL responses, logs, audit trails — must use this Omit shape.
25
+ */
26
+ export type SavedTransportSettings = Omit<TransportSettings, "password">;
27
+ export interface ISaveSettingsRepository {
28
+ execute(input: SaveSettingsInput): Promise<Result<SavedTransportSettings, SaveSettingsError>>;
29
+ }
30
+ export declare const SaveSettingsRepository: import("@webiny/di").Abstraction<ISaveSettingsRepository>;
31
+ export declare namespace SaveSettingsRepository {
32
+ type Interface = ISaveSettingsRepository;
33
+ type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;
34
+ type Error = SaveSettingsError;
35
+ }
36
+ export interface ISaveSettings {
37
+ execute(input: SaveSettingsInput): Promise<Result<SavedTransportSettings, SaveSettingsError>>;
38
+ }
39
+ export declare const SaveSettingsUseCase: import("@webiny/di").Abstraction<ISaveSettings>;
40
+ export declare namespace SaveSettingsUseCase {
41
+ type Interface = ISaveSettings;
42
+ type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;
43
+ type Error = SaveSettingsError;
44
+ }
45
+ export interface MailerSettingsBeforeSavePayload {
46
+ input: Omit<SaveSettingsInput, "password">;
47
+ }
48
+ export interface MailerSettingsAfterSavePayload {
49
+ settings: Omit<TransportSettings, "password">;
50
+ }
51
+ export declare const MailerSettingsBeforeSaveEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>>;
52
+ export declare namespace MailerSettingsBeforeSaveEventHandler {
53
+ type Interface = IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>;
54
+ type Event = DomainEvent<MailerSettingsBeforeSavePayload>;
55
+ }
56
+ export declare const MailerSettingsAfterSaveEventHandler: import("@webiny/di").Abstraction<IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>>;
57
+ export declare namespace MailerSettingsAfterSaveEventHandler {
58
+ type Interface = IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>;
59
+ type Event = DomainEvent<MailerSettingsAfterSavePayload>;
60
+ }
61
+ export {};
@@ -0,0 +1,8 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const SaveSettingsRepository = createAbstraction("SaveSettingsRepository");
3
+ const SaveSettingsUseCase = createAbstraction("SaveSettingsUseCase");
4
+ const MailerSettingsBeforeSaveEventHandler = createAbstraction("MailerSettingsBeforeSaveEventHandler");
5
+ const MailerSettingsAfterSaveEventHandler = createAbstraction("MailerSettingsAfterSaveEventHandler");
6
+ export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase };
7
+
8
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/abstractions.js","sources":["../../../src/features/SaveSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { DomainEvent, IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport {\n SettingsValidationError,\n SettingsPersistenceError,\n SettingsNotAuthorized,\n SettingsLockedByCode\n} from \"~/domain/errors.js\";\n\nexport interface SaveSettingsInput {\n host: string;\n port?: number;\n user: string;\n password?: string;\n from: string;\n replyTo?: string;\n}\n\nexport interface ISaveSettingsErrors {\n validation: SettingsValidationError;\n persistence: SettingsPersistenceError;\n notAuthorized: SettingsNotAuthorized;\n lockedByCode: SettingsLockedByCode;\n}\n\ntype SaveSettingsError = ISaveSettingsErrors[keyof ISaveSettingsErrors];\n\n/**\n * Save-side returns are password-free. The only path that exposes the password\n * to in-process callers is GetSettingsRepository.get / GetSettingsUseCase.execute\n * (used by MailerService to authenticate SMTP). Everything else — events,\n * GraphQL responses, logs, audit trails — must use this Omit shape.\n */\nexport type SavedTransportSettings = Omit<TransportSettings, \"password\">;\n\nexport interface ISaveSettingsRepository {\n execute(input: SaveSettingsInput): Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n}\n\nexport const SaveSettingsRepository =\n createAbstraction<ISaveSettingsRepository>(\"SaveSettingsRepository\");\n\nexport namespace SaveSettingsRepository {\n export type Interface = ISaveSettingsRepository;\n export type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n export type Error = SaveSettingsError;\n}\n\nexport interface ISaveSettings {\n execute(input: SaveSettingsInput): Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n}\n\nexport const SaveSettingsUseCase = createAbstraction<ISaveSettings>(\"SaveSettingsUseCase\");\n\nexport namespace SaveSettingsUseCase {\n export type Interface = ISaveSettings;\n export type Return = Promise<Result<SavedTransportSettings, SaveSettingsError>>;\n export type Error = SaveSettingsError;\n}\n\n// Domain Events. Both payloads exclude `password` so subscribers (audit logs,\n// telemetry, etc.) cannot accidentally persist plaintext or ciphertext secrets.\nexport interface MailerSettingsBeforeSavePayload {\n input: Omit<SaveSettingsInput, \"password\">;\n}\n\nexport interface MailerSettingsAfterSavePayload {\n settings: Omit<TransportSettings, \"password\">;\n}\n\n// Event Handler Abstractions\nexport const MailerSettingsBeforeSaveEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>\n>(\"MailerSettingsBeforeSaveEventHandler\");\n\nexport namespace MailerSettingsBeforeSaveEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>;\n export type Event = DomainEvent<MailerSettingsBeforeSavePayload>;\n}\n\nexport const MailerSettingsAfterSaveEventHandler = createAbstraction<\n IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>\n>(\"MailerSettingsAfterSaveEventHandler\");\n\nexport namespace MailerSettingsAfterSaveEventHandler {\n export type Interface = IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>;\n export type Event = DomainEvent<MailerSettingsAfterSavePayload>;\n}\n"],"names":["SaveSettingsRepository","createAbstraction","SaveSettingsUseCase","MailerSettingsBeforeSaveEventHandler","MailerSettingsAfterSaveEventHandler"],"mappings":";AAyCO,MAAMA,yBACTC,kBAA2C;AAYxC,MAAMC,sBAAsBD,kBAAiC;AAmB7D,MAAME,uCAAuCF,kBAElD;AAOK,MAAMG,sCAAsCH,kBAEjD"}
@@ -0,0 +1,10 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import type { MailerSettingsBeforeSavePayload, MailerSettingsAfterSavePayload } from "./abstractions.js";
3
+ export declare class MailerSettingsBeforeSaveEvent extends DomainEvent<MailerSettingsBeforeSavePayload> {
4
+ eventType: "mailer.settings.beforeSave";
5
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailerSettingsBeforeSavePayload>>>;
6
+ }
7
+ export declare class MailerSettingsAfterSaveEvent extends DomainEvent<MailerSettingsAfterSavePayload> {
8
+ eventType: "mailer.settings.afterSave";
9
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher/abstractions.js").IEventHandler<DomainEvent<MailerSettingsAfterSavePayload>>>;
10
+ }
@@ -0,0 +1,21 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "./abstractions.js";
3
+ class MailerSettingsBeforeSaveEvent extends DomainEvent {
4
+ getHandlerAbstraction() {
5
+ return MailerSettingsBeforeSaveEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "mailer.settings.beforeSave";
9
+ }
10
+ }
11
+ class MailerSettingsAfterSaveEvent extends DomainEvent {
12
+ getHandlerAbstraction() {
13
+ return MailerSettingsAfterSaveEventHandler;
14
+ }
15
+ constructor(...args){
16
+ super(...args), this.eventType = "mailer.settings.afterSave";
17
+ }
18
+ }
19
+ export { MailerSettingsAfterSaveEvent, MailerSettingsBeforeSaveEvent };
20
+
21
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/events.js","sources":["../../../src/features/SaveSettings/events.ts"],"sourcesContent":["import { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport {\n MailerSettingsBeforeSaveEventHandler,\n MailerSettingsAfterSaveEventHandler\n} from \"./abstractions.js\";\nimport type {\n MailerSettingsBeforeSavePayload,\n MailerSettingsAfterSavePayload\n} from \"./abstractions.js\";\n\nexport class MailerSettingsBeforeSaveEvent extends DomainEvent<MailerSettingsBeforeSavePayload> {\n eventType = \"mailer.settings.beforeSave\" as const;\n\n getHandlerAbstraction() {\n return MailerSettingsBeforeSaveEventHandler;\n }\n}\n\nexport class MailerSettingsAfterSaveEvent extends DomainEvent<MailerSettingsAfterSavePayload> {\n eventType = \"mailer.settings.afterSave\" as const;\n\n getHandlerAbstraction() {\n return MailerSettingsAfterSaveEventHandler;\n }\n}\n"],"names":["MailerSettingsBeforeSaveEvent","DomainEvent","MailerSettingsBeforeSaveEventHandler","MailerSettingsAfterSaveEvent","MailerSettingsAfterSaveEventHandler"],"mappings":";;AAUO,MAAMA,sCAAsCC;IAG/C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMC,qCAAqCF;IAG9C,wBAAwB;QACpB,OAAOG;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB"}
@@ -0,0 +1,4 @@
1
+ export declare const SaveSettingsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { SaveSettingsRepositoryImplementation } from "./SaveSettingsRepository.js";
3
+ import { SaveSettingsUseCaseImplementation } from "./SaveSettingsUseCase.js";
4
+ const SaveSettingsFeature = createFeature({
5
+ name: "SaveSettings",
6
+ register (container) {
7
+ container.register(SaveSettingsRepositoryImplementation).inSingletonScope();
8
+ container.register(SaveSettingsUseCaseImplementation);
9
+ }
10
+ });
11
+ export { SaveSettingsFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/feature.js","sources":["../../../src/features/SaveSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SaveSettingsRepositoryImplementation } from \"./SaveSettingsRepository.js\";\nimport { SaveSettingsUseCaseImplementation } from \"./SaveSettingsUseCase.js\";\n\nexport const SaveSettingsFeature = createFeature({\n name: \"SaveSettings\",\n register(container) {\n container.register(SaveSettingsRepositoryImplementation).inSingletonScope();\n container.register(SaveSettingsUseCaseImplementation);\n }\n});\n"],"names":["SaveSettingsFeature","createFeature","container","SaveSettingsRepositoryImplementation","SaveSettingsUseCaseImplementation"],"mappings":";;;AAIO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,sCAAsC,gBAAgB;QACzED,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -0,0 +1 @@
1
+ export { SaveSettingsUseCase, SaveSettingsRepository, MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "./abstractions.js";
@@ -0,0 +1 @@
1
+ export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase } from "./abstractions.js";
@@ -0,0 +1,9 @@
1
+ import zod from "zod";
2
+ export declare const saveValidation: zod.ZodObject<{
3
+ password: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodString>>>, zod.ZodTransform<string | null, string | null | undefined>>;
4
+ from: zod.ZodString;
5
+ port: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
6
+ replyTo: zod.ZodPreprocess<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>>;
7
+ host: zod.ZodString;
8
+ user: zod.ZodString;
9
+ }, zod.core.$strip>;
@@ -0,0 +1,20 @@
1
+ import zod from "zod";
2
+ import { isMailboxAddress } from "../../utils/isMailboxAddress.js";
3
+ const validation_password = zod.string().describe("Password");
4
+ const mailboxAddress = zod.string().refine(isMailboxAddress, {
5
+ message: "Invalid email address."
6
+ });
7
+ const common = {
8
+ from: mailboxAddress.describe("Mail from"),
9
+ port: zod.number().optional().nullish().describe("Port"),
10
+ replyTo: zod.preprocess((value)=>"" === value ? null : value, mailboxAddress.optional().nullish()).describe("Mail reply-to"),
11
+ host: zod.string().describe("Hostname"),
12
+ user: zod.string().describe("User")
13
+ };
14
+ const saveValidation = zod.object({
15
+ ...common,
16
+ password: validation_password.nullish().optional().transform((value)=>void 0 === value ? null : value)
17
+ });
18
+ export { saveValidation };
19
+
20
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SaveSettings/validation.js","sources":["../../../src/features/SaveSettings/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { isMailboxAddress } from \"~/utils/isMailboxAddress.js\";\n\nconst password = zod.string().describe(\"Password\");\n\nconst mailboxAddress = zod.string().refine(isMailboxAddress, { message: \"Invalid email address.\" });\n\nconst common = {\n from: mailboxAddress.describe(\"Mail from\"),\n port: zod.number().optional().nullish().describe(\"Port\"),\n replyTo: zod\n .preprocess(\n // We need to set empty strings to `null` before address validation kicks in.\n value => (value === \"\" ? null : value),\n mailboxAddress.optional().nullish()\n )\n .describe(\"Mail reply-to\"),\n host: zod.string().describe(\"Hostname\"),\n user: zod.string().describe(\"User\")\n};\n\nexport const saveValidation = zod.object({\n ...common,\n password: password\n .nullish()\n .optional()\n .transform(value => {\n return value === undefined ? null : value;\n })\n});\n"],"names":["password","zod","mailboxAddress","isMailboxAddress","common","value","saveValidation","undefined"],"mappings":";;AAGA,MAAMA,sBAAWC,IAAI,MAAM,GAAG,QAAQ,CAAC;AAEvC,MAAMC,iBAAiBD,IAAI,MAAM,GAAG,MAAM,CAACE,kBAAkB;IAAE,SAAS;AAAyB;AAEjG,MAAMC,SAAS;IACX,MAAMF,eAAe,QAAQ,CAAC;IAC9B,MAAMD,IAAI,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjD,SAASA,IAAAA,UACM,CAEPI,CAAAA,QAAUA,AAAU,OAAVA,QAAe,OAAOA,OAChCH,eAAe,QAAQ,GAAG,OAAO,IAEpC,QAAQ,CAAC;IACd,MAAMD,IAAI,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,IAAI,MAAM,GAAG,QAAQ,CAAC;AAChC;AAEO,MAAMK,iBAAiBL,IAAI,MAAM,CAAC;IACrC,GAAGG,MAAM;IACT,UAAUJ,oBACL,OAAO,GACP,QAAQ,GACR,SAAS,CAACK,CAAAA,QACAA,AAAUE,WAAVF,QAAsB,OAAOA;AAEhD"}
@@ -0,0 +1,16 @@
1
+ import { EventPublisher as EventPublisherAbstraction } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import { SendMailUseCase } from "./abstractions.js";
3
+ import { MailerService } from "../../domain/MailerService/abstractions.js";
4
+ import type { TransportSendData } from "../../types.js";
5
+ import { MailValidationError } from "../../domain/errors.js";
6
+ import { Result } from "@webiny/feature/api";
7
+ declare class SendMailUseCaseImpl implements SendMailUseCase.Interface {
8
+ private mailerService;
9
+ private eventPublisher;
10
+ constructor(mailerService: MailerService.Interface, eventPublisher: EventPublisherAbstraction.Interface);
11
+ execute(data: TransportSendData): Promise<Result<never, MailValidationError> | Result<import("~/types.js").TransportSendResponse<any>, import("../../domain/MailerService/errors.js").NoTransportAvailableError | import("../../domain/MailerService/errors.js").NoSettingsConfiguredError | import("../../domain/MailerService/errors.js").TransportSendError>>;
12
+ }
13
+ export declare const SendMailUseCaseImplementation: typeof SendMailUseCaseImpl & {
14
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISendMailUseCase>;
15
+ };
16
+ export {};
@@ -0,0 +1,58 @@
1
+ import zod from "zod";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { SendMailUseCase } from "./abstractions.js";
4
+ import { MailAfterSendEvent, MailBeforeSendEvent, MailSendErrorEvent } from "./events.js";
5
+ import { MailerService } from "../../domain/MailerService/abstractions.js";
6
+ import { MailValidationError } from "../../domain/errors.js";
7
+ import { Result } from "@webiny/feature/api";
8
+ import { isMailboxAddress } from "../../utils/isMailboxAddress.js";
9
+ const requiredString = zod.string();
10
+ const mailboxAddress = zod.string().refine(isMailboxAddress, {
11
+ message: "Invalid email address."
12
+ });
13
+ const schema = zod.object({
14
+ to: zod.array(mailboxAddress).optional(),
15
+ from: mailboxAddress.optional(),
16
+ subject: requiredString.max(1024).min(2),
17
+ cc: zod.array(mailboxAddress).optional(),
18
+ bcc: zod.array(mailboxAddress).optional(),
19
+ replyTo: mailboxAddress.optional(),
20
+ text: zod.string().optional(),
21
+ html: zod.string().optional()
22
+ }).refine((data)=>!!data.text || !!data.html, "Either text or html is required.");
23
+ class SendMailUseCaseImpl {
24
+ constructor(mailerService, eventPublisher){
25
+ this.mailerService = mailerService;
26
+ this.eventPublisher = eventPublisher;
27
+ }
28
+ async execute(data) {
29
+ const validation = schema.safeParse(data);
30
+ if (!validation.success) return Result.fail(new MailValidationError(validation.error.issues));
31
+ await this.eventPublisher.publish(new MailBeforeSendEvent({
32
+ data
33
+ }));
34
+ const result = await this.mailerService.sendMail(data);
35
+ if (result.isFail()) {
36
+ await this.eventPublisher.publish(new MailSendErrorEvent({
37
+ data,
38
+ error: result.error
39
+ }));
40
+ return result;
41
+ }
42
+ await this.eventPublisher.publish(new MailAfterSendEvent({
43
+ data,
44
+ response: result.value
45
+ }));
46
+ return result;
47
+ }
48
+ }
49
+ const SendMailUseCaseImplementation = SendMailUseCase.createImplementation({
50
+ implementation: SendMailUseCaseImpl,
51
+ dependencies: [
52
+ MailerService,
53
+ EventPublisher
54
+ ]
55
+ });
56
+ export { SendMailUseCaseImplementation };
57
+
58
+ //# sourceMappingURL=SendMailUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SendMail/SendMailUseCase.js","sources":["../../../src/features/SendMail/SendMailUseCase.ts"],"sourcesContent":["import zod from \"zod\";\nimport {\n EventPublisher,\n EventPublisher as EventPublisherAbstraction\n} from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { SendMailUseCase } from \"./abstractions.js\";\nimport { MailBeforeSendEvent, MailAfterSendEvent, MailSendErrorEvent } from \"./events.js\";\nimport { MailerService } from \"~/domain/MailerService/abstractions.js\";\nimport type { TransportSendData } from \"~/types.js\";\nimport { MailValidationError } from \"~/domain/errors.js\";\nimport { Result } from \"@webiny/feature/api\";\nimport { isMailboxAddress } from \"~/utils/isMailboxAddress.js\";\n\nconst requiredString = zod.string();\nconst mailboxAddress = zod.string().refine(isMailboxAddress, { message: \"Invalid email address.\" });\n\nconst schema = zod\n .object({\n to: zod.array(mailboxAddress).optional(),\n from: mailboxAddress.optional(),\n subject: requiredString.max(1024).min(2),\n cc: zod.array(mailboxAddress).optional(),\n bcc: zod.array(mailboxAddress).optional(),\n replyTo: mailboxAddress.optional(),\n text: zod.string().optional(),\n html: zod.string().optional()\n })\n .refine(data => {\n return !!data.text || !!data.html;\n }, \"Either text or html is required.\");\n\nclass SendMailUseCaseImpl implements SendMailUseCase.Interface {\n constructor(\n private mailerService: MailerService.Interface,\n private eventPublisher: EventPublisherAbstraction.Interface\n ) {}\n\n async execute(data: TransportSendData) {\n const validation = schema.safeParse(data);\n if (!validation.success) {\n return Result.fail(new MailValidationError(validation.error.issues));\n }\n\n // Publish before send event\n await this.eventPublisher.publish(new MailBeforeSendEvent({ data }));\n\n // Send mail\n const result = await this.mailerService.sendMail(data);\n\n if (result.isFail()) {\n // Publish error event\n await this.eventPublisher.publish(\n new MailSendErrorEvent({\n data,\n error: result.error\n })\n );\n\n return result;\n }\n\n // Publish after send event\n await this.eventPublisher.publish(\n new MailAfterSendEvent({\n data,\n response: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const SendMailUseCaseImplementation = SendMailUseCase.createImplementation({\n implementation: SendMailUseCaseImpl,\n dependencies: [MailerService, EventPublisher]\n});\n"],"names":["requiredString","zod","mailboxAddress","isMailboxAddress","schema","data","SendMailUseCaseImpl","mailerService","eventPublisher","validation","Result","MailValidationError","MailBeforeSendEvent","result","MailSendErrorEvent","MailAfterSendEvent","SendMailUseCaseImplementation","SendMailUseCase","MailerService","EventPublisher"],"mappings":";;;;;;;;AAaA,MAAMA,iBAAiBC,IAAI,MAAM;AACjC,MAAMC,iBAAiBD,IAAI,MAAM,GAAG,MAAM,CAACE,kBAAkB;IAAE,SAAS;AAAyB;AAEjG,MAAMC,SAASH,IAAAA,MACJ,CAAC;IACJ,IAAIA,IAAI,KAAK,CAACC,gBAAgB,QAAQ;IACtC,MAAMA,eAAe,QAAQ;IAC7B,SAASF,eAAe,GAAG,CAAC,MAAM,GAAG,CAAC;IACtC,IAAIC,IAAI,KAAK,CAACC,gBAAgB,QAAQ;IACtC,KAAKD,IAAI,KAAK,CAACC,gBAAgB,QAAQ;IACvC,SAASA,eAAe,QAAQ;IAChC,MAAMD,IAAI,MAAM,GAAG,QAAQ;IAC3B,MAAMA,IAAI,MAAM,GAAG,QAAQ;AAC/B,GACC,MAAM,CAACI,CAAAA,OACG,CAAC,CAACA,KAAK,IAAI,IAAI,CAAC,CAACA,KAAK,IAAI,EAClC;AAEP,MAAMC;IACF,YACYC,aAAsC,EACtCC,cAAmD,CAC7D;aAFUD,aAAa,GAAbA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQH,IAAuB,EAAE;QACnC,MAAMI,aAAaL,OAAO,SAAS,CAACC;QACpC,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOC,OAAO,IAAI,CAAC,IAAIC,oBAAoBF,WAAW,KAAK,CAAC,MAAM;QAItE,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAIG,oBAAoB;YAAEP;QAAK;QAGjE,MAAMQ,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAACR;QAEjD,IAAIQ,OAAO,MAAM,IAAI;YAEjB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,mBAAmB;gBACnBT;gBACA,OAAOQ,OAAO,KAAK;YACvB;YAGJ,OAAOA;QACX;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,mBAAmB;YACnBV;YACA,UAAUQ,OAAO,KAAK;QAC1B;QAGJ,OAAOA;IACX;AACJ;AAEO,MAAMG,gCAAgCC,gBAAgB,oBAAoB,CAAC;IAC9E,gBAAgBX;IAChB,cAAc;QAACY;QAAeC;KAAe;AACjD"}