@webiny/api-mailer 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.e9333b3f0b

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 (105) hide show
  1. package/MailerFeature.d.ts +4 -0
  2. package/MailerFeature.js +25 -0
  3. package/MailerFeature.js.map +1 -0
  4. package/constants.js +2 -1
  5. package/constants.js.map +1 -1
  6. package/domain/CodeMailerSettings/abstractions.js +2 -1
  7. package/domain/CodeMailerSettings/abstractions.js.map +1 -1
  8. package/domain/MailTransport/abstractions.d.ts +1 -7
  9. package/domain/MailTransport/abstractions.js +3 -3
  10. package/domain/MailTransport/abstractions.js.map +1 -1
  11. package/domain/MailerService/abstractions.d.ts +2 -2
  12. package/domain/MailerService/abstractions.js +2 -1
  13. package/domain/MailerService/abstractions.js.map +1 -1
  14. package/domain/MailerService/errors.d.ts +4 -0
  15. package/domain/MailerService/errors.js +29 -24
  16. package/domain/MailerService/errors.js.map +1 -1
  17. package/domain/errors.js +40 -44
  18. package/domain/errors.js.map +1 -1
  19. package/exports/api/mailer.js +3 -5
  20. package/features/CodeMailerSettings/CodeMailerSettings.js +23 -0
  21. package/features/CodeMailerSettings/CodeMailerSettings.js.map +1 -0
  22. package/features/CodeMailerSettings/feature.js +7 -6
  23. package/features/CodeMailerSettings/feature.js.map +1 -1
  24. package/features/DummyTransport/DummyMailTransport.js +11 -9
  25. package/features/DummyTransport/DummyMailTransport.js.map +1 -1
  26. package/features/DummyTransport/DummyMailTransportFactory.d.ts +1 -0
  27. package/features/DummyTransport/DummyMailTransportFactory.js +13 -7
  28. package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -1
  29. package/features/DummyTransport/feature.js +6 -5
  30. package/features/DummyTransport/feature.js.map +1 -1
  31. package/features/GetSettings/GetSettingsRepository.js +43 -45
  32. package/features/GetSettings/GetSettingsRepository.js.map +1 -1
  33. package/features/GetSettings/GetSettingsUseCase.js +13 -10
  34. package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
  35. package/features/GetSettings/abstractions.js +3 -2
  36. package/features/GetSettings/abstractions.js.map +1 -1
  37. package/features/GetSettings/feature.js +7 -6
  38. package/features/GetSettings/feature.js.map +1 -1
  39. package/features/GetSettings/index.js +1 -3
  40. package/features/MailerService/MailerService.d.ts +3 -4
  41. package/features/MailerService/MailerService.js +49 -43
  42. package/features/MailerService/MailerService.js.map +1 -1
  43. package/features/MailerService/feature.js +6 -7
  44. package/features/MailerService/feature.js.map +1 -1
  45. package/features/SaveSettings/SaveSettingsRepository.js +32 -46
  46. package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
  47. package/features/SaveSettings/SaveSettingsUseCase.d.ts +4 -4
  48. package/features/SaveSettings/SaveSettingsUseCase.js +44 -57
  49. package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
  50. package/features/SaveSettings/abstractions.d.ts +1 -0
  51. package/features/SaveSettings/abstractions.js +5 -17
  52. package/features/SaveSettings/abstractions.js.map +1 -1
  53. package/features/SaveSettings/events.js +16 -11
  54. package/features/SaveSettings/events.js.map +1 -1
  55. package/features/SaveSettings/feature.js +7 -6
  56. package/features/SaveSettings/feature.js.map +1 -1
  57. package/features/SaveSettings/index.js +1 -3
  58. package/features/SaveSettings/validation.d.ts +2 -1
  59. package/features/SaveSettings/validation.js +12 -14
  60. package/features/SaveSettings/validation.js.map +1 -1
  61. package/features/SendMail/SendMailUseCase.d.ts +1 -1
  62. package/features/SendMail/SendMailUseCase.js +40 -47
  63. package/features/SendMail/SendMailUseCase.js.map +1 -1
  64. package/features/SendMail/abstractions.js +5 -8
  65. package/features/SendMail/abstractions.js.map +1 -1
  66. package/features/SendMail/events.js +23 -16
  67. package/features/SendMail/events.js.map +1 -1
  68. package/features/SendMail/feature.js +6 -5
  69. package/features/SendMail/feature.js.map +1 -1
  70. package/features/SendMail/index.js +1 -3
  71. package/features/SmtpTransport/SmtpConfig.js +21 -24
  72. package/features/SmtpTransport/SmtpConfig.js.map +1 -1
  73. package/features/SmtpTransport/SmtpMailTransport.d.ts +9 -9
  74. package/features/SmtpTransport/SmtpMailTransport.js +47 -61
  75. package/features/SmtpTransport/SmtpMailTransport.js.map +1 -1
  76. package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +1 -0
  77. package/features/SmtpTransport/SmtpMailTransportFactory.js +13 -7
  78. package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -1
  79. package/features/SmtpTransport/feature.js +6 -5
  80. package/features/SmtpTransport/feature.js.map +1 -1
  81. package/graphql/MailerSchemaFactory.d.ts +10 -0
  82. package/graphql/MailerSchemaFactory.js +120 -0
  83. package/graphql/MailerSchemaFactory.js.map +1 -0
  84. package/index.d.ts +1 -2
  85. package/index.js +1 -26
  86. package/package.json +21 -22
  87. package/types.d.ts +1 -0
  88. package/types.js +0 -3
  89. package/utils/isMailboxAddress.js +3 -10
  90. package/utils/isMailboxAddress.js.map +1 -1
  91. package/exports/api/mailer.js.map +0 -1
  92. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +0 -22
  93. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +0 -1
  94. package/features/GetSettings/index.js.map +0 -1
  95. package/features/MailerService/ActiveTransport.d.ts +0 -10
  96. package/features/MailerService/ActiveTransport.js +0 -20
  97. package/features/MailerService/ActiveTransport.js.map +0 -1
  98. package/features/SaveSettings/index.js.map +0 -1
  99. package/features/SendMail/index.js.map +0 -1
  100. package/graphql/settings.d.ts +0 -3
  101. package/graphql/settings.js +0 -127
  102. package/graphql/settings.js.map +0 -1
  103. package/index.js.map +0 -1
  104. package/types.js.map +0 -1
  105. /package/features/CodeMailerSettings/{CodeMailerSettingsImpl.d.ts → CodeMailerSettings.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["Result","Encryption","KeyValueStore","GetSettingsRepository","CodeMailerSettings","MAILER_TRANSPORT_SETTINGS","GetSettingsRepositoryImpl","constructor","keyValueStore","encryption","codeSettings","get","transportName","codeSettingsValue","ok","settings","source","result","isFail","value","password","decrypt","String","transportSettings","host","port","Number","user","from","replyTo","undefined","GetSettingsRepositoryImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { GetSettingsRepository, type ISettingsWithSource } from \"./abstractions.js\";\nimport { CodeMailerSettings } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { MAILER_TRANSPORT_SETTINGS } from \"~/constants.js\";\n\nclass GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface,\n private codeSettings: CodeMailerSettings.Interface\n ) {}\n\n async get(transportName: string): Promise<Result<ISettingsWithSource>> {\n // Code-defined settings win over the KV store.\n const codeSettingsValue = this.codeSettings.get(transportName);\n if (codeSettingsValue !== null) {\n return Result.ok({\n settings: codeSettingsValue,\n source: \"code\"\n });\n }\n\n const result = await this.keyValueStore.get<TransportSettings>(MAILER_TRANSPORT_SETTINGS);\n\n if (result.isFail()) {\n return Result.ok({ settings: null, source: null });\n }\n\n const settings = result.value;\n if (!settings) {\n return Result.ok({ settings: null, source: null });\n }\n\n // Decrypt password if present.\n const password = settings.password\n ? this.encryption.decrypt(String(settings.password))\n : \"\";\n\n const transportSettings: TransportSettings = {\n host: String(settings.host || \"\"),\n port: Number(settings.port || 25),\n user: String(settings.user || \"\"),\n password,\n from: String(settings.from || \"\"),\n replyTo: settings.replyTo ? String(settings.replyTo) : undefined\n };\n\n return Result.ok({ settings: transportSettings, source: \"storage\" });\n }\n}\n\nexport const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption, CodeMailerSettings]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,UAAU,QAAQ,+CAA+C;AAC1E,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAE3B,SAASC,yBAAyB;AAElC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,aAAsC,EACtCC,UAAgC,EAChCC,YAA0C,EACpD;IAAA,KAHUF,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,YAA0C,GAA1CA,YAA0C;EACnD;EAEH,MAAMC,GAAGA,CAACC,aAAqB,EAAwC;IACnE;IACA,MAAMC,iBAAiB,GAAG,IAAI,CAACH,YAAY,CAACC,GAAG,CAACC,aAAa,CAAC;IAC9D,IAAIC,iBAAiB,KAAK,IAAI,EAAE;MAC5B,OAAOb,MAAM,CAACc,EAAE,CAAC;QACbC,QAAQ,EAAEF,iBAAiB;QAC3BG,MAAM,EAAE;MACZ,CAAC,CAAC;IACN;IAEA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACT,aAAa,CAACG,GAAG,CAAoBN,yBAAyB,CAAC;IAEzF,IAAIY,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOlB,MAAM,CAACc,EAAE,CAAC;QAAEC,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;MAAK,CAAC,CAAC;IACtD;IAEA,MAAMD,QAAQ,GAAGE,MAAM,CAACE,KAAK;IAC7B,IAAI,CAACJ,QAAQ,EAAE;MACX,OAAOf,MAAM,CAACc,EAAE,CAAC;QAAEC,QAAQ,EAAE,IAAI;QAAEC,MAAM,EAAE;MAAK,CAAC,CAAC;IACtD;;IAEA;IACA,MAAMI,QAAQ,GAAGL,QAAQ,CAACK,QAAQ,GAC5B,IAAI,CAACX,UAAU,CAACY,OAAO,CAACC,MAAM,CAACP,QAAQ,CAACK,QAAQ,CAAC,CAAC,GAClD,EAAE;IAER,MAAMG,iBAAoC,GAAG;MACzCC,IAAI,EAAEF,MAAM,CAACP,QAAQ,CAACS,IAAI,IAAI,EAAE,CAAC;MACjCC,IAAI,EAAEC,MAAM,CAACX,QAAQ,CAACU,IAAI,IAAI,EAAE,CAAC;MACjCE,IAAI,EAAEL,MAAM,CAACP,QAAQ,CAACY,IAAI,IAAI,EAAE,CAAC;MACjCP,QAAQ;MACRQ,IAAI,EAAEN,MAAM,CAACP,QAAQ,CAACa,IAAI,IAAI,EAAE,CAAC;MACjCC,OAAO,EAAEd,QAAQ,CAACc,OAAO,GAAGP,MAAM,CAACP,QAAQ,CAACc,OAAO,CAAC,GAAGC;IAC3D,CAAC;IAED,OAAO9B,MAAM,CAACc,EAAE,CAAC;MAAEC,QAAQ,EAAEQ,iBAAiB;MAAEP,MAAM,EAAE;IAAU,CAAC,CAAC;EACxE;AACJ;AAEA,OAAO,MAAMe,mCAAmC,GAAG5B,qBAAqB,CAAC6B,oBAAoB,CAAC;EAC1FC,cAAc,EAAE3B,yBAAyB;EACzC4B,YAAY,EAAE,CAAChC,aAAa,EAAED,UAAU,EAAEG,kBAAkB;AAChE,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetSettings/GetSettingsRepository.js","sources":["../../../src/features/GetSettings/GetSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"@webiny/api-core/features/encryption/index.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { GetSettingsRepository, type ISettingsWithSource } from \"./abstractions.js\";\nimport { CodeMailerSettings } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { MAILER_TRANSPORT_SETTINGS } from \"~/constants.js\";\n\nclass GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface,\n private codeSettings: CodeMailerSettings.Interface\n ) {}\n\n async get(transportName: string): Promise<Result<ISettingsWithSource>> {\n // Code-defined settings win over the KV store.\n const codeSettingsValue = this.codeSettings.get(transportName);\n if (codeSettingsValue !== null) {\n return Result.ok({\n settings: codeSettingsValue,\n source: \"code\"\n });\n }\n\n const result = await this.keyValueStore.get<TransportSettings>(MAILER_TRANSPORT_SETTINGS);\n\n if (result.isFail()) {\n return Result.ok({ settings: null, source: null });\n }\n\n const settings = result.value;\n if (!settings) {\n return Result.ok({ settings: null, source: null });\n }\n\n // Decrypt password if present.\n const password = settings.password\n ? await this.encryption.decrypt(String(settings.password))\n : \"\";\n\n const port = Number(settings.port || 587);\n\n const transportSettings: TransportSettings = {\n host: String(settings.host || \"\"),\n port,\n secure: settings.secure ?? port === 465,\n user: String(settings.user || \"\"),\n password,\n from: String(settings.from || \"\"),\n replyTo: settings.replyTo ? String(settings.replyTo) : undefined\n };\n\n return Result.ok({ settings: transportSettings, source: \"storage\" });\n }\n}\n\nexport const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption, CodeMailerSettings]\n});\n"],"names":["GetSettingsRepositoryImpl","keyValueStore","encryption","codeSettings","transportName","codeSettingsValue","Result","result","MAILER_TRANSPORT_SETTINGS","settings","password","String","port","Number","transportSettings","undefined","GetSettingsRepositoryImplementation","GetSettingsRepository","KeyValueStore","Encryption","CodeMailerSettings"],"mappings":";;;;;;AAQA,MAAMA;IACF,YACYC,aAAsC,EACtCC,UAAgC,EAChCC,YAA0C,CACpD;aAHUF,aAAa,GAAbA;aACAC,UAAU,GAAVA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,IAAIC,aAAqB,EAAwC;QAEnE,MAAMC,oBAAoB,IAAI,CAAC,YAAY,CAAC,GAAG,CAACD;QAChD,IAAIC,AAAsB,SAAtBA,mBACA,OAAOC,OAAO,EAAE,CAAC;YACb,UAAUD;YACV,QAAQ;QACZ;QAGJ,MAAME,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAoBC;QAE/D,IAAID,OAAO,MAAM,IACb,OAAOD,OAAO,EAAE,CAAC;YAAE,UAAU;YAAM,QAAQ;QAAK;QAGpD,MAAMG,WAAWF,OAAO,KAAK;QAC7B,IAAI,CAACE,UACD,OAAOH,OAAO,EAAE,CAAC;YAAE,UAAU;YAAM,QAAQ;QAAK;QAIpD,MAAMI,WAAWD,SAAS,QAAQ,GAC5B,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACE,OAAOF,SAAS,QAAQ,KACtD;QAEN,MAAMG,OAAOC,OAAOJ,SAAS,IAAI,IAAI;QAErC,MAAMK,oBAAuC;YACzC,MAAMH,OAAOF,SAAS,IAAI,IAAI;YAC9BG;YACA,QAAQH,SAAS,MAAM,IAAIG,AAAS,QAATA;YAC3B,MAAMD,OAAOF,SAAS,IAAI,IAAI;YAC9BC;YACA,MAAMC,OAAOF,SAAS,IAAI,IAAI;YAC9B,SAASA,SAAS,OAAO,GAAGE,OAAOF,SAAS,OAAO,IAAIM;QAC3D;QAEA,OAAOT,OAAO,EAAE,CAAC;YAAE,UAAUQ;YAAmB,QAAQ;QAAU;IACtE;AACJ;AAEO,MAAME,sCAAsCC,sBAAsB,oBAAoB,CAAC;IAC1F,gBAAgBjB;IAChB,cAAc;QAACkB;QAAeC;QAAYC;KAAmB;AACjE"}
@@ -1,15 +1,18 @@
1
- import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
1
+ import { GetSettingsRepository, GetSettingsUseCase } from "./abstractions.js";
2
2
  class GetSettingsUseCaseImpl {
3
- constructor(repository) {
4
- this.repository = repository;
5
- }
6
- execute(transportName) {
7
- return this.repository.get(transportName);
8
- }
3
+ constructor(repository){
4
+ this.repository = repository;
5
+ }
6
+ execute(transportName) {
7
+ return this.repository.get(transportName);
8
+ }
9
9
  }
10
- export const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
11
- implementation: GetSettingsUseCaseImpl,
12
- dependencies: [GetSettingsRepository]
10
+ const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
11
+ implementation: GetSettingsUseCaseImpl,
12
+ dependencies: [
13
+ GetSettingsRepository
14
+ ]
13
15
  });
16
+ export { GetSettingsUseCaseImplementation };
14
17
 
15
18
  //# sourceMappingURL=GetSettingsUseCase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GetSettingsUseCase","GetSettingsRepository","GetSettingsUseCaseImpl","constructor","repository","execute","transportName","get","GetSettingsUseCaseImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetSettingsUseCase,\n GetSettingsRepository,\n type ISettingsWithSource\n} from \"./abstractions.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute(transportName: string): Promise<Result<ISettingsWithSource>> {\n return this.repository.get(transportName);\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"mappings":"AACA,SACIA,kBAAkB,EAClBC,qBAAqB;AAIzB,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CAASC,UAA2C,EAAE;IAAA,KAA7CA,UAA2C,GAA3CA,UAA2C;EAAG;EAElEC,OAAOA,CAACC,aAAqB,EAAwC;IACjE,OAAO,IAAI,CAACF,UAAU,CAACG,GAAG,CAACD,aAAa,CAAC;EAC7C;AACJ;AAEA,OAAO,MAAME,gCAAgC,GAAGR,kBAAkB,CAACS,oBAAoB,CAAC;EACpFC,cAAc,EAAER,sBAAsB;EACtCS,YAAY,EAAE,CAACV,qBAAqB;AACxC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetSettings/GetSettingsUseCase.js","sources":["../../../src/features/GetSettings/GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetSettingsUseCase,\n GetSettingsRepository,\n type ISettingsWithSource\n} from \"./abstractions.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute(transportName: string): Promise<Result<ISettingsWithSource>> {\n return this.repository.get(transportName);\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"names":["GetSettingsUseCaseImpl","repository","transportName","GetSettingsUseCaseImplementation","GetSettingsUseCase","GetSettingsRepository"],"mappings":";AAOA,MAAMA;IACF,YAAoBC,UAA2C,CAAE;aAA7CA,UAAU,GAAVA;IAA8C;IAElE,QAAQC,aAAqB,EAAwC;QACjE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACA;IAC/B;AACJ;AAEO,MAAMC,mCAAmCC,mBAAmB,oBAAoB,CAAC;IACpF,gBAAgBJ;IAChB,cAAc;QAACK;KAAsB;AACzC"}
@@ -1,5 +1,6 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const GetSettingsRepository = createAbstraction("GetSettingsRepository");
3
- export const GetSettingsUseCase = createAbstraction("GetSettingsUseCase");
2
+ const GetSettingsRepository = createAbstraction("GetSettingsRepository");
3
+ const GetSettingsUseCase = createAbstraction("GetSettingsUseCase");
4
+ export { GetSettingsRepository, GetSettingsUseCase };
4
5
 
5
6
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","GetSettingsRepository","GetSettingsUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\nexport interface ISettingsWithSource {\n settings: TransportSettings | null;\n source: MailerSettingsSource;\n}\n\nexport interface IGetSettingsRepository {\n get(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n export type Return = Promise<Result<ISettingsWithSource>>;\n}\n\nexport interface IGetSettingsUseCase {\n execute(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAevD,OAAO,MAAMC,qBAAqB,GAC9BD,iBAAiB,CAAyB,uBAAuB,CAAC;AAWtE,OAAO,MAAME,kBAAkB,GAAGF,iBAAiB,CAAsB,oBAAoB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/GetSettings/abstractions.js","sources":["../../../src/features/GetSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\nexport interface ISettingsWithSource {\n settings: TransportSettings | null;\n source: MailerSettingsSource;\n}\n\nexport interface IGetSettingsRepository {\n get(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n export type Return = Promise<Result<ISettingsWithSource>>;\n}\n\nexport interface IGetSettingsUseCase {\n execute(transportName: string): Promise<Result<ISettingsWithSource>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUseCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUseCase;\n}\n"],"names":["GetSettingsRepository","createAbstraction","GetSettingsUseCase"],"mappings":";AAeO,MAAMA,wBACTC,kBAA0C;AAWvC,MAAMC,qBAAqBD,kBAAuC"}
@@ -1,12 +1,13 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { GetSettingsRepositoryImplementation } from "./GetSettingsRepository.js";
3
3
  import { GetSettingsUseCaseImplementation } from "./GetSettingsUseCase.js";
4
- export const GetSettingsFeature = createFeature({
5
- name: "GetSettings",
6
- register(container) {
7
- container.register(GetSettingsRepositoryImplementation).inSingletonScope();
8
- container.register(GetSettingsUseCaseImplementation);
9
- }
4
+ const GetSettingsFeature = createFeature({
5
+ name: "GetSettings",
6
+ register (container) {
7
+ container.register(GetSettingsRepositoryImplementation).inSingletonScope();
8
+ container.register(GetSettingsUseCaseImplementation);
9
+ }
10
10
  });
11
+ export { GetSettingsFeature };
11
12
 
12
13
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","GetSettingsRepositoryImplementation","GetSettingsUseCaseImplementation","GetSettingsFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,mCAAmC;AAC5C,SAASC,gCAAgC;AAEzC,OAAO,MAAMC,kBAAkB,GAAGH,aAAa,CAAC;EAC5CI,IAAI,EAAE,aAAa;EACnBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACJ,mCAAmC,CAAC,CAACM,gBAAgB,CAAC,CAAC;IAC1ED,SAAS,CAACD,QAAQ,CAACH,gCAAgC,CAAC;EACxD;AACJ,CAAC,CAAC","ignoreList":[]}
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"}
@@ -1,3 +1 @@
1
- export { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export { GetSettingsRepository, GetSettingsUseCase } from "./abstractions.js";
@@ -1,14 +1,13 @@
1
1
  import { MailerService as Abstraction } from "../../domain/MailerService/abstractions.js";
2
- import { ActiveTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
3
3
  import { GetSettingsRepository } from "../GetSettings/abstractions.js";
4
4
  import type { TransportSendData } from "../../types.js";
5
5
  declare class MailerServiceImpl implements Abstraction.Interface {
6
6
  private getSettingsRepository;
7
- private activeTransport;
8
7
  private transportFactories;
9
- constructor(getSettingsRepository: GetSettingsRepository.Interface, activeTransport: ActiveTransport.Interface, transportFactories: MailTransportFactory.Interface[]);
8
+ constructor(getSettingsRepository: GetSettingsRepository.Interface, transportFactories: MailTransportFactory.Interface[]);
10
9
  sendMail<T = any>(data: TransportSendData): Abstraction.Return<T>;
11
- private getTransport;
10
+ private resolveTransport;
12
11
  }
13
12
  export declare const MailerService: typeof MailerServiceImpl & {
14
13
  __abstraction: import("@webiny/di").Abstraction<import("~/domain/MailerService/abstractions.js").IMailerService>;
@@ -1,53 +1,59 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { MailerService as Abstraction } from "../../domain/MailerService/abstractions.js";
3
- import { NoTransportAvailableError, NoSettingsConfiguredError, TransportSendError } from "../../domain/MailerService/errors.js";
4
- import { ActiveTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
+ import { MailerService } from "../../domain/MailerService/abstractions.js";
3
+ import { NoTransportAvailableError, TransportCreateError, TransportSendError } from "../../domain/MailerService/errors.js";
4
+ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
5
5
  import { GetSettingsRepository } from "../GetSettings/abstractions.js";
6
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) {
15
- return Result.fail(new NoTransportAvailableError());
7
+ constructor(getSettingsRepository, transportFactories){
8
+ this.getSettingsRepository = getSettingsRepository;
9
+ this.transportFactories = transportFactories;
16
10
  }
17
- const result = await this.getSettingsRepository.get(transportName);
18
- const {
19
- settings
20
- } = result.value;
21
- if (!settings) {
22
- return Result.fail(new NoSettingsConfiguredError());
11
+ async sendMail(data) {
12
+ const { factory, transport } = await this.resolveTransport();
13
+ if (!factory || !transport) return Result.fail(new NoTransportAvailableError());
14
+ try {
15
+ const response = await transport.send(data);
16
+ if (response.error) return Result.fail(new TransportSendError(response.error));
17
+ return Result.ok(response);
18
+ } catch (error) {
19
+ return Result.fail(new TransportSendError(error));
20
+ }
23
21
  }
24
- const transport = await this.getTransport(transportName, settings);
25
- if (!transport) {
26
- return Result.fail(new NoTransportAvailableError());
22
+ async resolveTransport() {
23
+ const factories = [
24
+ ...this.transportFactories
25
+ ].reverse();
26
+ for (const factory of factories){
27
+ const result = await this.getSettingsRepository.get(factory.name);
28
+ const { settings } = result.value;
29
+ if (factory.canUse(settings)) try {
30
+ const transport = await factory.createTransport(settings);
31
+ return {
32
+ factory,
33
+ transport
34
+ };
35
+ } catch (error) {
36
+ throw new TransportCreateError(error);
37
+ }
38
+ }
39
+ return {
40
+ factory: null,
41
+ transport: null
42
+ };
27
43
  }
28
- try {
29
- const response = await transport.send(data);
30
- if (response.error) {
31
- return Result.fail(new TransportSendError(response.error));
32
- }
33
- return Result.ok(response);
34
- } catch (error) {
35
- return Result.fail(new TransportSendError(error));
36
- }
37
- }
38
- async getTransport(transportName, settings) {
39
- const factory = this.transportFactories.find(f => f.name === transportName);
40
- if (!factory) {
41
- return null;
42
- }
43
- return factory.createTransport(settings);
44
- }
45
44
  }
46
- export const MailerService = Abstraction.createImplementation({
47
- implementation: MailerServiceImpl,
48
- dependencies: [GetSettingsRepository, ActiveTransport, [MailTransportFactory, {
49
- multiple: true
50
- }]]
45
+ const MailerService_MailerService = MailerService.createImplementation({
46
+ implementation: MailerServiceImpl,
47
+ dependencies: [
48
+ GetSettingsRepository,
49
+ [
50
+ MailTransportFactory,
51
+ {
52
+ multiple: true
53
+ }
54
+ ]
55
+ ]
51
56
  });
57
+ export { MailerService_MailerService as MailerService };
52
58
 
53
59
  //# sourceMappingURL=MailerService.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","MailerService","Abstraction","NoTransportAvailableError","NoSettingsConfiguredError","TransportSendError","ActiveTransport","MailTransportFactory","GetSettingsRepository","MailerServiceImpl","constructor","getSettingsRepository","activeTransport","transportFactories","sendMail","data","transportName","name","fail","result","get","settings","value","transport","getTransport","response","send","error","ok","factory","find","f","createTransport","createImplementation","implementation","dependencies","multiple"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,aAAa,IAAIC,WAAW;AACrC,SACIC,yBAAyB,EACzBC,yBAAyB,EACzBC,kBAAkB;AAEtB,SACIC,eAAe,EAEfC,oBAAoB;AAExB,SAASC,qBAAqB;AAG9B,MAAMC,iBAAiB,CAAkC;EACrDC,WAAWA,CACCC,qBAAsD,EACtDC,eAA0C,EAC1CC,kBAAoD,EAC9D;IAAA,KAHUF,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,kBAAoD,GAApDA,kBAAoD;EAC7D;EAEH,MAAMC,QAAQA,CAAUC,IAAuB,EAAyB;IACpE,MAAMC,aAAa,GAAG,IAAI,CAACJ,eAAe,CAACK,IAAI,CAAC,CAAC;IAEjD,IAAI,CAACD,aAAa,EAAE;MAChB,OAAOhB,MAAM,CAACkB,IAAI,CAAC,IAAIf,yBAAyB,CAAC,CAAC,CAAC;IACvD;IAEA,MAAMgB,MAAM,GAAG,MAAM,IAAI,CAACR,qBAAqB,CAACS,GAAG,CAACJ,aAAa,CAAC;IAClE,MAAM;MAAEK;IAAS,CAAC,GAAGF,MAAM,CAACG,KAAK;IAEjC,IAAI,CAACD,QAAQ,EAAE;MACX,OAAOrB,MAAM,CAACkB,IAAI,CAAC,IAAId,yBAAyB,CAAC,CAAC,CAAC;IACvD;IAEA,MAAMmB,SAAS,GAAG,MAAM,IAAI,CAACC,YAAY,CAACR,aAAa,EAAEK,QAAQ,CAAC;IAElE,IAAI,CAACE,SAAS,EAAE;MACZ,OAAOvB,MAAM,CAACkB,IAAI,CAAC,IAAIf,yBAAyB,CAAC,CAAC,CAAC;IACvD;IAEA,IAAI;MACA,MAAMsB,QAAQ,GAAG,MAAMF,SAAS,CAACG,IAAI,CAACX,IAAI,CAAC;MAE3C,IAAIU,QAAQ,CAACE,KAAK,EAAE;QAChB,OAAO3B,MAAM,CAACkB,IAAI,CAAC,IAAIb,kBAAkB,CAACoB,QAAQ,CAACE,KAAK,CAAC,CAAC;MAC9D;MAEA,OAAO3B,MAAM,CAAC4B,EAAE,CAACH,QAAQ,CAAC;IAC9B,CAAC,CAAC,OAAOE,KAAK,EAAE;MACZ,OAAO3B,MAAM,CAACkB,IAAI,CAAC,IAAIb,kBAAkB,CAACsB,KAAK,CAAC,CAAC;IACrD;EACJ;EAEA,MAAcH,YAAYA,CACtBR,aAAqB,EACrBK,QAA2B,EACY;IACvC,MAAMQ,OAAO,GAAG,IAAI,CAAChB,kBAAkB,CAACiB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACd,IAAI,KAAKD,aAAa,CAAC;IAC3E,IAAI,CAACa,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,OAAOA,OAAO,CAACG,eAAe,CAACX,QAAQ,CAAC;EAC5C;AACJ;AAEA,OAAO,MAAMpB,aAAa,GAAGC,WAAW,CAAC+B,oBAAoB,CAAC;EAC1DC,cAAc,EAAEzB,iBAAiB;EACjC0B,YAAY,EAAE,CACV3B,qBAAqB,EACrBF,eAAe,EACf,CAACC,oBAAoB,EAAE;IAAE6B,QAAQ,EAAE;EAAK,CAAC,CAAC;AAElD,CAAC,CAAC","ignoreList":[]}
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 TransportCreateError,\n TransportSendError\n} from \"~/domain/MailerService/errors.js\";\nimport { MailTransport, MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { GetSettingsRepository } from \"../GetSettings/abstractions.js\";\nimport type { TransportSendData } from \"~/types.js\";\n\nclass MailerServiceImpl implements Abstraction.Interface {\n constructor(\n private getSettingsRepository: GetSettingsRepository.Interface,\n private transportFactories: MailTransportFactory.Interface[]\n ) {}\n\n async sendMail<T = any>(data: TransportSendData): Abstraction.Return<T> {\n const { factory, transport } = await this.resolveTransport();\n\n if (!factory || !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 resolveTransport(): Promise<{\n factory: MailTransportFactory.Interface | null;\n transport: MailTransport.Interface | null;\n }> {\n const factories = [...this.transportFactories].reverse();\n\n for (const factory of factories) {\n const result = await this.getSettingsRepository.get(factory.name);\n const { settings } = result.value;\n\n if (!factory.canUse(settings)) {\n continue;\n }\n\n try {\n const transport = await factory.createTransport(settings!);\n return { factory, transport };\n } catch (error) {\n throw new TransportCreateError(error);\n }\n }\n\n return { factory: null, transport: null };\n }\n}\n\nexport const MailerService = Abstraction.createImplementation({\n implementation: MailerServiceImpl,\n dependencies: [GetSettingsRepository, [MailTransportFactory, { multiple: true }]]\n});\n"],"names":["MailerServiceImpl","getSettingsRepository","transportFactories","data","factory","transport","Result","NoTransportAvailableError","response","TransportSendError","error","factories","result","settings","TransportCreateError","MailerService","Abstraction","GetSettingsRepository","MailTransportFactory"],"mappings":";;;;;AAWA,MAAMA;IACF,YACYC,qBAAsD,EACtDC,kBAAoD,CAC9D;aAFUD,qBAAqB,GAArBA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,SAAkBC,IAAuB,EAAyB;QACpE,MAAM,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB;QAE1D,IAAI,CAACD,WAAW,CAACC,WACb,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,IAAI;YACA,MAAMC,WAAW,MAAMH,UAAU,IAAI,CAACF;YAEtC,IAAIK,SAAS,KAAK,EACd,OAAOF,OAAO,IAAI,CAAC,IAAIG,mBAAmBD,SAAS,KAAK;YAG5D,OAAOF,OAAO,EAAE,CAACE;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOJ,OAAO,IAAI,CAAC,IAAIG,mBAAmBC;QAC9C;IACJ;IAEA,MAAc,mBAGX;QACC,MAAMC,YAAY;eAAI,IAAI,CAAC,kBAAkB;SAAC,CAAC,OAAO;QAEtD,KAAK,MAAMP,WAAWO,UAAW;YAC7B,MAAMC,SAAS,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAACR,QAAQ,IAAI;YAChE,MAAM,EAAES,QAAQ,EAAE,GAAGD,OAAO,KAAK;YAEjC,IAAKR,QAAQ,MAAM,CAACS,WAIpB,IAAI;gBACA,MAAMR,YAAY,MAAMD,QAAQ,eAAe,CAACS;gBAChD,OAAO;oBAAET;oBAASC;gBAAU;YAChC,EAAE,OAAOK,OAAO;gBACZ,MAAM,IAAII,qBAAqBJ;YACnC;QACJ;QAEA,OAAO;YAAE,SAAS;YAAM,WAAW;QAAK;IAC5C;AACJ;AAEO,MAAMK,8BAAgBC,cAAAA,oBAAgC,CAAC;IAC1D,gBAAgBhB;IAChB,cAAc;QAACiB;QAAuB;YAACC;YAAsB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACrF"}
@@ -1,12 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { MailerService } from "./MailerService.js";
3
- import { ActiveTransport } from "./ActiveTransport.js";
4
- export const MailerServiceFeature = createFeature({
5
- name: "Mailer/MailerService",
6
- register(container) {
7
- container.register(ActiveTransport).inSingletonScope();
8
- container.register(MailerService).inSingletonScope();
9
- }
3
+ const MailerServiceFeature = createFeature({
4
+ name: "Mailer/MailerService",
5
+ register (container) {
6
+ container.register(MailerService).inSingletonScope();
7
+ }
10
8
  });
9
+ export { MailerServiceFeature };
11
10
 
12
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","MailerService","ActiveTransport","MailerServiceFeature","name","register","container","inSingletonScope"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,aAAa;AACtB,SAASC,eAAe;AAExB,OAAO,MAAMC,oBAAoB,GAAGH,aAAa,CAAC;EAC9CI,IAAI,EAAE,sBAAsB;EAC5BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,eAAe,CAAC,CAACK,gBAAgB,CAAC,CAAC;IACtDD,SAAS,CAACD,QAAQ,CAACJ,aAAa,CAAC,CAACM,gBAAgB,CAAC,CAAC;EACxD;AACJ,CAAC,CAAC","ignoreList":[]}
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\";\n\nexport const MailerServiceFeature = createFeature({\n name: \"Mailer/MailerService\",\n register(container) {\n container.register(MailerService).inSingletonScope();\n }\n});\n"],"names":["MailerServiceFeature","createFeature","container","MailerService"],"mappings":";;AAGO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,eAAe,gBAAgB;IACtD;AACJ"}
@@ -4,56 +4,42 @@ import { SaveSettingsRepository } from "./abstractions.js";
4
4
  import { SettingsPersistenceError } from "../../domain/errors.js";
5
5
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
6
6
  import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
7
- const DEFAULT_PORT = 25;
7
+ const DEFAULT_PORT = 587;
8
8
  class SaveSettingsRepositoryImpl {
9
- constructor(keyValueStore, encryption) {
10
- this.keyValueStore = keyValueStore;
11
- this.encryption = encryption;
12
- }
13
- async execute(input) {
14
- // Check if settings exist
15
- const existingResult = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
16
- const existingSettings = existingResult.isOk() ? existingResult.value : null;
17
- const transportSettings = existingSettings ?? {};
18
-
19
- // If updating and no password provided, keep the existing password
20
- let passwordToStore = input.password || "";
21
- if (!input.password && existingSettings) {
22
- passwordToStore = this.encryption.decrypt(transportSettings.password || "");
9
+ constructor(keyValueStore, encryption){
10
+ this.keyValueStore = keyValueStore;
11
+ this.encryption = encryption;
23
12
  }
24
-
25
- // Encrypt password
26
- const encryptedPassword = this.encryption.encrypt(passwordToStore);
27
-
28
- // Prepare data
29
- const data = {
30
- host: input.host ?? transportSettings.host,
31
- port: input.port ?? transportSettings.port ?? DEFAULT_PORT,
32
- user: input.user ?? transportSettings.user,
33
- password: encryptedPassword,
34
- from: input.from ?? transportSettings.from,
35
- replyTo: input.replyTo ?? transportSettings.replyTo
36
- };
37
-
38
- // Save settings.
39
- const result = await this.keyValueStore.set(MAILER_TRANSPORT_SETTINGS, data);
40
- if (result.isFail()) {
41
- return Result.fail(new SettingsPersistenceError(result.error));
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 port = input.port ?? transportSettings.port ?? DEFAULT_PORT;
21
+ const data = {
22
+ host: input.host ?? transportSettings.host,
23
+ port,
24
+ secure: input.secure ?? transportSettings.secure ?? 465 === port,
25
+ user: input.user ?? transportSettings.user,
26
+ password: encryptedPassword,
27
+ from: input.from ?? transportSettings.from,
28
+ replyTo: input.replyTo ?? transportSettings.replyTo
29
+ };
30
+ const result = await this.keyValueStore.set(MAILER_TRANSPORT_SETTINGS, data);
31
+ if (result.isFail()) return Result.fail(new SettingsPersistenceError(result.error));
32
+ const { password: _password, ...savedSettings } = data;
33
+ return Result.ok(savedSettings);
42
34
  }
43
-
44
- // Return the stored state without the password. Callers that need the
45
- // plaintext password go through GetSettingsRepository.get(transportName).
46
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
- const {
48
- password: _password,
49
- ...savedSettings
50
- } = data;
51
- return Result.ok(savedSettings);
52
- }
53
35
  }
54
- export const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({
55
- implementation: SaveSettingsRepositoryImpl,
56
- dependencies: [KeyValueStore, Encryption]
36
+ const SaveSettingsRepositoryImplementation = SaveSettingsRepository.createImplementation({
37
+ implementation: SaveSettingsRepositoryImpl,
38
+ dependencies: [
39
+ KeyValueStore,
40
+ Encryption
41
+ ]
57
42
  });
43
+ export { SaveSettingsRepositoryImplementation };
58
44
 
59
45
  //# sourceMappingURL=SaveSettingsRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","Encryption","SaveSettingsRepository","SettingsPersistenceError","KeyValueStore","MAILER_TRANSPORT_SETTINGS","DEFAULT_PORT","SaveSettingsRepositoryImpl","constructor","keyValueStore","encryption","execute","input","existingResult","get","existingSettings","isOk","value","transportSettings","passwordToStore","password","decrypt","encryptedPassword","encrypt","data","host","port","user","from","replyTo","result","set","isFail","fail","error","_password","savedSettings","ok","SaveSettingsRepositoryImplementation","createImplementation","implementation","dependencies"],"sources":["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 = this.encryption.decrypt(transportSettings.password || \"\");\n }\n\n // Encrypt password\n const encryptedPassword = 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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,UAAU,QAAQ,+CAA+C;AAC1E,SAASC,sBAAsB;AAE/B,SAASC,wBAAwB;AACjC,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,yBAAyB;AAElC,MAAMC,YAAY,GAAG,EAAE;AAEvB,MAAMC,0BAA0B,CAA6C;EACzEC,WAAWA,CACCC,aAAsC,EACtCC,UAAgC,EAC1C;IAAA,KAFUD,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;EACzC;EAEH,MAAMC,OAAOA,CAACC,KAAwB,EAAiC;IACnE;IACA,MAAMC,cAAc,GAChB,MAAM,IAAI,CAACJ,aAAa,CAACK,GAAG,CAAoBT,yBAAyB,CAAC;IAC9E,MAAMU,gBAAgB,GAAGF,cAAc,CAACG,IAAI,CAAC,CAAC,GAAGH,cAAc,CAACI,KAAK,GAAG,IAAI;IAC5E,MAAMC,iBAA6C,GAAGH,gBAAgB,IAAI,CAAC,CAAC;;IAE5E;IACA,IAAII,eAAe,GAAGP,KAAK,CAACQ,QAAQ,IAAI,EAAE;IAC1C,IAAI,CAACR,KAAK,CAACQ,QAAQ,IAAIL,gBAAgB,EAAE;MACrCI,eAAe,GAAG,IAAI,CAACT,UAAU,CAACW,OAAO,CAACH,iBAAiB,CAACE,QAAQ,IAAI,EAAE,CAAC;IAC/E;;IAEA;IACA,MAAME,iBAAiB,GAAG,IAAI,CAACZ,UAAU,CAACa,OAAO,CAACJ,eAAe,CAAC;;IAElE;IACA,MAAMK,IAAI,GAAG;MACTC,IAAI,EAAEb,KAAK,CAACa,IAAI,IAAIP,iBAAiB,CAACO,IAAI;MAC1CC,IAAI,EAAEd,KAAK,CAACc,IAAI,IAAIR,iBAAiB,CAACQ,IAAI,IAAIpB,YAAY;MAC1DqB,IAAI,EAAEf,KAAK,CAACe,IAAI,IAAIT,iBAAiB,CAACS,IAAI;MAC1CP,QAAQ,EAAEE,iBAAiB;MAC3BM,IAAI,EAAEhB,KAAK,CAACgB,IAAI,IAAIV,iBAAiB,CAACU,IAAI;MAC1CC,OAAO,EAAEjB,KAAK,CAACiB,OAAO,IAAIX,iBAAiB,CAACW;IAChD,CAAC;;IAED;IACA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACrB,aAAa,CAACsB,GAAG,CAAC1B,yBAAyB,EAAEmB,IAAI,CAAC;IAE5E,IAAIM,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOhC,MAAM,CAACiC,IAAI,CAAC,IAAI9B,wBAAwB,CAAC2B,MAAM,CAACI,KAAK,CAAC,CAAC;IAClE;;IAEA;IACA;IACA;IACA,MAAM;MAAEd,QAAQ,EAAEe,SAAS;MAAE,GAAGC;IAAc,CAAC,GAAGZ,IAAyB;IAC3E,OAAOxB,MAAM,CAACqC,EAAE,CAACD,aAAa,CAAC;EACnC;AACJ;AAEA,OAAO,MAAME,oCAAoC,GAAGpC,sBAAsB,CAACqC,oBAAoB,CAAC;EAC5FC,cAAc,EAAEjC,0BAA0B;EAC1CkC,YAAY,EAAE,CAACrC,aAAa,EAAEH,UAAU;AAC5C,CAAC,CAAC","ignoreList":[]}
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 = 587;\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 port = input.port ?? transportSettings.port ?? DEFAULT_PORT;\n\n const data = {\n host: input.host ?? transportSettings.host,\n port,\n secure: input.secure ?? transportSettings.secure ?? port === 465,\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","port","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,OAAOP,MAAM,IAAI,IAAII,kBAAkB,IAAI,IAAIR;QAErD,MAAMY,OAAO;YACT,MAAMR,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1CG;YACA,QAAQP,MAAM,MAAM,IAAII,kBAAkB,MAAM,IAAIG,AAAS,QAATA;YACpD,MAAMP,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1C,UAAUE;YACV,MAAMN,MAAM,IAAI,IAAII,kBAAkB,IAAI;YAC1C,SAASJ,MAAM,OAAO,IAAII,kBAAkB,OAAO;QACvD;QAGA,MAAMK,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAACP,2BAA2BM;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,gBAAgBlB;IAChB,cAAc;QAACmB;QAAeC;KAAW;AAC7C"}
@@ -1,15 +1,15 @@
1
- import { EventPublisher as EventPublisherAbstraction } from "@webiny/api-core/features/eventPublisher/index.js";
1
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
2
2
  import { SaveSettingsUseCase, SaveSettingsRepository, type SaveSettingsInput } from "./abstractions.js";
3
3
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
4
4
  import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
5
- import { ActiveTransport } from "../../domain/MailTransport/abstractions.js";
5
+ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
6
6
  declare class SaveSettingsUseCaseImpl implements SaveSettingsUseCase.Interface {
7
7
  private identityContext;
8
8
  private eventPublisher;
9
9
  private repository;
10
10
  private codeSettings;
11
- private activeTransport;
12
- constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisherAbstraction.Interface, repository: SaveSettingsRepository.Interface, codeSettings: CodeMailerSettings.Interface, activeTransport: ActiveTransport.Interface);
11
+ private transportFactories;
12
+ constructor(identityContext: IdentityContext.Interface, eventPublisher: EventPublisher.Interface, repository: SaveSettingsRepository.Interface, codeSettings: CodeMailerSettings.Interface, transportFactories: MailTransportFactory.Interface[]);
13
13
  execute(input: SaveSettingsInput): SaveSettingsUseCase.Return;
14
14
  }
15
15
  export declare const SaveSettingsUseCaseImplementation: typeof SaveSettingsUseCaseImpl & {
@@ -1,69 +1,56 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
- import { SaveSettingsUseCase, SaveSettingsRepository } from "./abstractions.js";
4
- import { MailerSettingsBeforeSaveEvent, MailerSettingsAfterSaveEvent } from "./events.js";
3
+ import { SaveSettingsRepository, SaveSettingsUseCase } from "./abstractions.js";
4
+ import { MailerSettingsAfterSaveEvent, MailerSettingsBeforeSaveEvent } from "./events.js";
5
5
  import { saveValidation } from "./validation.js";
6
- import { SettingsValidationError, SettingsPersistenceError, SettingsNotAuthorized, SettingsLockedByCode } from "../../domain/errors.js";
6
+ import { SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError } from "../../domain/errors.js";
7
7
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
8
8
  import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
9
- import { ActiveTransport } from "../../domain/MailTransport/abstractions.js";
9
+ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
10
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) {
21
- return Result.fail(new SettingsNotAuthorized());
11
+ constructor(identityContext, eventPublisher, repository, codeSettings, transportFactories){
12
+ this.identityContext = identityContext;
13
+ this.eventPublisher = eventPublisher;
14
+ this.repository = repository;
15
+ this.codeSettings = codeSettings;
16
+ this.transportFactories = transportFactories;
22
17
  }
23
-
24
- // Validate input.
25
- const validationResult = saveValidation.safeParse(input);
26
- if (!validationResult.success) {
27
- return Result.fail(new SettingsValidationError(validationResult.error.issues));
28
- }
29
-
30
- // Refuse when settings are defined via code.
31
- const transportName = this.activeTransport.name();
32
- if (transportName && this.codeSettings.get(transportName) !== null) {
33
- return Result.fail(new SettingsLockedByCode());
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 isLockedByCode = this.transportFactories.some((f)=>null !== this.codeSettings.get(f.name));
24
+ if (isLockedByCode) 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;
34
37
  }
35
-
36
- // Publish before save event. Strip the password — subscribers (audit
37
- // logs, telemetry) must never see the plaintext value from the input.
38
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
- const {
40
- password: _beforePassword,
41
- ...inputForEvent
42
- } = input;
43
- const beforeSaveEvent = new MailerSettingsBeforeSaveEvent({
44
- input: inputForEvent
45
- });
46
- await this.eventPublisher.publish(beforeSaveEvent);
47
-
48
- // Save settings.
49
- const result = await this.repository.execute(input);
50
- if (result.isFail()) {
51
- return Result.fail(new SettingsPersistenceError(result.error));
52
- }
53
-
54
- // Publish after save event. The repository return is already password-free
55
- // (its type is Omit<TransportSettings, "password">), so no runtime strip
56
- // is needed here.
57
- const afterSaveEvent = new MailerSettingsAfterSaveEvent({
58
- settings: result.value
59
- });
60
- await this.eventPublisher.publish(afterSaveEvent);
61
- return result;
62
- }
63
38
  }
64
- export const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({
65
- implementation: SaveSettingsUseCaseImpl,
66
- dependencies: [IdentityContext, EventPublisher, SaveSettingsRepository, CodeMailerSettings, ActiveTransport]
39
+ const SaveSettingsUseCaseImplementation = SaveSettingsUseCase.createImplementation({
40
+ implementation: SaveSettingsUseCaseImpl,
41
+ dependencies: [
42
+ IdentityContext,
43
+ EventPublisher,
44
+ SaveSettingsRepository,
45
+ CodeMailerSettings,
46
+ [
47
+ MailTransportFactory,
48
+ {
49
+ multiple: true
50
+ }
51
+ ]
52
+ ]
67
53
  });
54
+ export { SaveSettingsUseCaseImplementation };
68
55
 
69
56
  //# sourceMappingURL=SaveSettingsUseCase.js.map