@webiny/api-mailer 0.0.0-unstable.6f45466a1d → 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 (129) hide show
  1. package/constants.js +2 -1
  2. package/constants.js.map +1 -1
  3. package/domain/CodeMailerSettings/abstractions.d.ts +8 -0
  4. package/domain/CodeMailerSettings/abstractions.js +5 -0
  5. package/domain/CodeMailerSettings/abstractions.js.map +1 -0
  6. package/domain/MailTransport/abstractions.d.ts +8 -0
  7. package/domain/MailTransport/abstractions.js +4 -2
  8. package/domain/MailTransport/abstractions.js.map +1 -1
  9. package/domain/MailerService/abstractions.js +2 -1
  10. package/domain/MailerService/abstractions.js.map +1 -1
  11. package/domain/MailerService/errors.js +22 -24
  12. package/domain/MailerService/errors.js.map +1 -1
  13. package/domain/errors.d.ts +8 -4
  14. package/domain/errors.js +41 -37
  15. package/domain/errors.js.map +1 -1
  16. package/exports/api/mailer.d.ts +4 -0
  17. package/exports/api/mailer.js +4 -0
  18. package/features/CodeMailerSettings/CodeMailerSettingsImpl.d.ts +12 -0
  19. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js +23 -0
  20. package/features/CodeMailerSettings/CodeMailerSettingsImpl.js.map +1 -0
  21. package/features/CodeMailerSettings/feature.d.ts +4 -0
  22. package/features/CodeMailerSettings/feature.js +11 -0
  23. package/features/CodeMailerSettings/feature.js.map +1 -0
  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 +10 -6
  28. package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -1
  29. package/features/DummyTransport/feature.d.ts +4 -1
  30. package/features/DummyTransport/feature.js +6 -5
  31. package/features/DummyTransport/feature.js.map +1 -1
  32. package/features/GetSettings/GetSettingsRepository.d.ts +6 -5
  33. package/features/GetSettings/GetSettingsRepository.js +44 -29
  34. package/features/GetSettings/GetSettingsRepository.js.map +1 -1
  35. package/features/GetSettings/GetSettingsUseCase.d.ts +3 -4
  36. package/features/GetSettings/GetSettingsUseCase.js +13 -10
  37. package/features/GetSettings/GetSettingsUseCase.js.map +1 -1
  38. package/features/GetSettings/abstractions.d.ts +11 -5
  39. package/features/GetSettings/abstractions.js +3 -2
  40. package/features/GetSettings/abstractions.js.map +1 -1
  41. package/features/GetSettings/feature.d.ts +4 -1
  42. package/features/GetSettings/feature.js +7 -6
  43. package/features/GetSettings/feature.js.map +1 -1
  44. package/features/GetSettings/index.d.ts +1 -1
  45. package/features/GetSettings/index.js +1 -3
  46. package/features/MailerService/ActiveTransport.d.ts +10 -0
  47. package/features/MailerService/ActiveTransport.js +24 -0
  48. package/features/MailerService/ActiveTransport.js.map +1 -0
  49. package/features/MailerService/MailerService.d.ts +3 -2
  50. package/features/MailerService/MailerService.js +39 -42
  51. package/features/MailerService/MailerService.js.map +1 -1
  52. package/features/MailerService/feature.d.ts +4 -1
  53. package/features/MailerService/feature.js +8 -5
  54. package/features/MailerService/feature.js.map +1 -1
  55. package/features/SaveSettings/SaveSettingsRepository.d.ts +1 -1
  56. package/features/SaveSettings/SaveSettingsRepository.js +30 -44
  57. package/features/SaveSettings/SaveSettingsRepository.js.map +1 -1
  58. package/features/SaveSettings/SaveSettingsUseCase.d.ts +6 -2
  59. package/features/SaveSettings/SaveSettingsUseCase.js +41 -41
  60. package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -1
  61. package/features/SaveSettings/abstractions.d.ts +20 -12
  62. package/features/SaveSettings/abstractions.js +5 -8
  63. package/features/SaveSettings/abstractions.js.map +1 -1
  64. package/features/SaveSettings/events.d.ts +3 -3
  65. package/features/SaveSettings/events.js +17 -12
  66. package/features/SaveSettings/events.js.map +1 -1
  67. package/features/SaveSettings/feature.d.ts +4 -1
  68. package/features/SaveSettings/feature.js +7 -6
  69. package/features/SaveSettings/feature.js.map +1 -1
  70. package/features/SaveSettings/index.d.ts +1 -1
  71. package/features/SaveSettings/index.js +1 -3
  72. package/features/SaveSettings/validation.d.ts +3 -17
  73. package/features/SaveSettings/validation.js +14 -13
  74. package/features/SaveSettings/validation.js.map +1 -1
  75. package/features/SendMail/SendMailUseCase.d.ts +1 -1
  76. package/features/SendMail/SendMailUseCase.js +44 -48
  77. package/features/SendMail/SendMailUseCase.js.map +1 -1
  78. package/features/SendMail/abstractions.d.ts +7 -7
  79. package/features/SendMail/abstractions.js +5 -8
  80. package/features/SendMail/abstractions.js.map +1 -1
  81. package/features/SendMail/events.d.ts +4 -4
  82. package/features/SendMail/events.js +24 -17
  83. package/features/SendMail/events.js.map +1 -1
  84. package/features/SendMail/feature.d.ts +4 -1
  85. package/features/SendMail/feature.js +6 -5
  86. package/features/SendMail/feature.js.map +1 -1
  87. package/features/SendMail/index.d.ts +1 -0
  88. package/features/SendMail/index.js +1 -0
  89. package/features/SmtpTransport/SmtpConfig.js +20 -24
  90. package/features/SmtpTransport/SmtpConfig.js.map +1 -1
  91. package/features/SmtpTransport/SmtpMailTransport.d.ts +51 -1
  92. package/features/SmtpTransport/SmtpMailTransport.js +47 -55
  93. package/features/SmtpTransport/SmtpMailTransport.js.map +1 -1
  94. package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +1 -0
  95. package/features/SmtpTransport/SmtpMailTransportFactory.js +10 -6
  96. package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -1
  97. package/features/SmtpTransport/feature.d.ts +4 -1
  98. package/features/SmtpTransport/feature.js +6 -5
  99. package/features/SmtpTransport/feature.js.map +1 -1
  100. package/graphql/settings.js +58 -66
  101. package/graphql/settings.js.map +1 -1
  102. package/index.js +12 -16
  103. package/index.js.map +1 -1
  104. package/package.json +29 -32
  105. package/types.js +0 -3
  106. package/utils/isMailboxAddress.d.ts +6 -0
  107. package/utils/isMailboxAddress.js +5 -0
  108. package/utils/isMailboxAddress.js.map +1 -0
  109. package/domain/Encryption/abstractions.d.ts +0 -8
  110. package/domain/Encryption/abstractions.js +0 -4
  111. package/domain/Encryption/abstractions.js.map +0 -1
  112. package/features/Encryption/PasswordEncryption.d.ts +0 -9
  113. package/features/Encryption/PasswordEncryption.js +0 -23
  114. package/features/Encryption/PasswordEncryption.js.map +0 -1
  115. package/features/Encryption/feature.d.ts +0 -1
  116. package/features/Encryption/feature.js +0 -10
  117. package/features/Encryption/feature.js.map +0 -1
  118. package/features/Encryption/utils/password.d.ts +0 -7
  119. package/features/Encryption/utils/password.js +0 -56
  120. package/features/Encryption/utils/password.js.map +0 -1
  121. package/features/Encryption/utils/secret.d.ts +0 -1
  122. package/features/Encryption/utils/secret.js +0 -11
  123. package/features/Encryption/utils/secret.js.map +0 -1
  124. package/features/GetSettings/index.js.map +0 -1
  125. package/features/MailerService/TransportFactory.d.ts +0 -2
  126. package/features/MailerService/TransportFactory.js +0 -31
  127. package/features/MailerService/TransportFactory.js.map +0 -1
  128. package/features/SaveSettings/index.js.map +0 -1
  129. package/types.js.map +0 -1
package/constants.js CHANGED
@@ -1,3 +1,4 @@
1
- export const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
1
+ const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
2
+ export { MAILER_TRANSPORT_SETTINGS };
2
3
 
3
4
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["MAILER_TRANSPORT_SETTINGS"],"sources":["constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\n"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG,2BAA2B","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\n"],"names":["MAILER_TRANSPORT_SETTINGS"],"mappings":"AAAO,MAAMA,4BAA4B"}
@@ -0,0 +1,8 @@
1
+ import type { TransportSettings } from "../../types.js";
2
+ export interface ICodeMailerSettings {
3
+ get(transportName: string): TransportSettings | null;
4
+ }
5
+ export declare const CodeMailerSettings: import("@webiny/di").Abstraction<ICodeMailerSettings>;
6
+ export declare namespace CodeMailerSettings {
7
+ type Interface = ICodeMailerSettings;
8
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const CodeMailerSettings = createAbstraction("CodeMailerSettings");
3
+ export { CodeMailerSettings };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain/CodeMailerSettings/abstractions.js","sources":["../../../src/domain/CodeMailerSettings/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport interface ICodeMailerSettings {\n get(transportName: string): TransportSettings | null;\n}\n\nexport const CodeMailerSettings = createAbstraction<ICodeMailerSettings>(\"CodeMailerSettings\");\n\nexport namespace CodeMailerSettings {\n export type Interface = ICodeMailerSettings;\n}\n"],"names":["CodeMailerSettings","createAbstraction"],"mappings":";AAOO,MAAMA,qBAAqBC,kBAAuC"}
@@ -9,6 +9,7 @@ export declare namespace MailTransport {
9
9
  type SendParams = TransportSendData;
10
10
  }
11
11
  export interface IMailTransportFactory {
12
+ name: string;
12
13
  createTransport(settings: TransportSettings): Promise<IMailTransport>;
13
14
  }
14
15
  export declare const MailTransportFactory: import("@webiny/di").Abstraction<IMailTransportFactory>;
@@ -16,3 +17,10 @@ export declare namespace MailTransportFactory {
16
17
  type Interface = IMailTransportFactory;
17
18
  type Return = Promise<IMailTransport>;
18
19
  }
20
+ export interface IActiveTransport {
21
+ name(): string | null;
22
+ }
23
+ export declare const ActiveTransport: import("@webiny/di").Abstraction<IActiveTransport>;
24
+ export declare namespace ActiveTransport {
25
+ type Interface = IActiveTransport;
26
+ }
@@ -1,5 +1,7 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const MailTransport = createAbstraction("MailTransport");
3
- export const MailTransportFactory = createAbstraction("MailTransportFactory");
2
+ const MailTransport = createAbstraction("MailTransport");
3
+ const MailTransportFactory = createAbstraction("MailTransportFactory");
4
+ const ActiveTransport = createAbstraction("ActiveTransport");
5
+ export { ActiveTransport, MailTransport, MailTransportFactory };
4
6
 
5
7
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","MailTransport","MailTransportFactory"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse, TransportSettings } from \"~/types.js\";\n\nexport interface IMailTransport {\n name: string;\n send(params: TransportSendData): Promise<TransportSendResponse>;\n}\n\nexport const MailTransport = createAbstraction<IMailTransport>(\"MailTransport\");\n\nexport namespace MailTransport {\n export type Interface = IMailTransport;\n export type SendParams = TransportSendData;\n}\n\nexport interface IMailTransportFactory {\n createTransport(settings: TransportSettings): Promise<IMailTransport>;\n}\n\nexport const MailTransportFactory =\n createAbstraction<IMailTransportFactory>(\"MailTransportFactory\");\n\nexport namespace MailTransportFactory {\n export type Interface = IMailTransportFactory;\n export type Return = Promise<IMailTransport>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC;AAW/E,OAAO,MAAME,oBAAoB,GAC7BF,iBAAiB,CAAwB,sBAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"domain/MailTransport/abstractions.js","sources":["../../../src/domain/MailTransport/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse, TransportSettings } from \"~/types.js\";\n\nexport interface IMailTransport {\n name: string;\n send(params: TransportSendData): Promise<TransportSendResponse>;\n}\n\nexport const MailTransport = createAbstraction<IMailTransport>(\"MailTransport\");\n\nexport namespace MailTransport {\n export type Interface = IMailTransport;\n export type SendParams = TransportSendData;\n}\n\nexport interface IMailTransportFactory {\n name: string;\n createTransport(settings: TransportSettings): Promise<IMailTransport>;\n}\n\nexport const MailTransportFactory =\n createAbstraction<IMailTransportFactory>(\"MailTransportFactory\");\n\nexport namespace MailTransportFactory {\n export type Interface = IMailTransportFactory;\n export type Return = Promise<IMailTransport>;\n}\n\nexport interface IActiveTransport {\n name(): string | null;\n}\n\nexport const ActiveTransport = createAbstraction<IActiveTransport>(\"ActiveTransport\");\n\nexport namespace ActiveTransport {\n export type Interface = IActiveTransport;\n}\n"],"names":["MailTransport","createAbstraction","MailTransportFactory","ActiveTransport"],"mappings":";AAQO,MAAMA,gBAAgBC,kBAAkC;AAYxD,MAAMC,uBACTD,kBAAyC;AAWtC,MAAME,kBAAkBF,kBAAoC"}
@@ -1,4 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- export const MailerService = createAbstraction("MailerService");
2
+ const MailerService = createAbstraction("MailerService");
3
+ export { MailerService };
3
4
 
4
5
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","MailerService"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse } from \"~/types.js\";\nimport {\n NoTransportAvailableError,\n NoSettingsConfiguredError,\n TransportSendError\n} from \"./errors.js\";\n\nexport interface IMailerServiceErrors {\n noTransport: NoTransportAvailableError;\n noSettings: NoSettingsConfiguredError;\n transportSend: TransportSendError;\n}\n\ntype MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];\n\nexport interface IMailerService {\n sendMail<T = any>(\n data: TransportSendData\n ): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n}\n\nexport const MailerService = createAbstraction<IMailerService>(\"MailerService\");\n\nexport namespace MailerService {\n export type Interface = IMailerService;\n export type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n export type Error = MailerServiceError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAuBvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"domain/MailerService/abstractions.js","sources":["../../../src/domain/MailerService/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse } from \"~/types.js\";\nimport {\n NoTransportAvailableError,\n NoSettingsConfiguredError,\n TransportSendError\n} from \"./errors.js\";\n\nexport interface IMailerServiceErrors {\n noTransport: NoTransportAvailableError;\n noSettings: NoSettingsConfiguredError;\n transportSend: TransportSendError;\n}\n\ntype MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];\n\nexport interface IMailerService {\n sendMail<T = any>(\n data: TransportSendData\n ): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n}\n\nexport const MailerService = createAbstraction<IMailerService>(\"MailerService\");\n\nexport namespace MailerService {\n export type Interface = IMailerService;\n export type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n export type Error = MailerServiceError;\n}\n"],"names":["MailerService","createAbstraction"],"mappings":";AAuBO,MAAMA,gBAAgBC,kBAAkC"}
@@ -1,30 +1,28 @@
1
1
  import { BaseError } from "@webiny/feature/api";
2
- export class NoTransportAvailableError extends BaseError {
3
- code = "Mailer/MailerService/NoTransportAvailable";
4
- constructor() {
5
- super({
6
- message: "There is no transport available."
7
- });
8
- }
2
+ class NoTransportAvailableError extends BaseError {
3
+ constructor(){
4
+ super({
5
+ message: "There is no transport available."
6
+ }), this.code = "Mailer/MailerService/NoTransportAvailable";
7
+ }
9
8
  }
10
- export class NoSettingsConfiguredError extends BaseError {
11
- code = "Mailer/MailerService/NoSettingsConfigured";
12
- constructor() {
13
- super({
14
- message: "No mailer settings are configured and no environment variables are set."
15
- });
16
- }
9
+ class NoSettingsConfiguredError extends BaseError {
10
+ constructor(){
11
+ super({
12
+ message: "No mailer settings are configured and no environment variables are set."
13
+ }), this.code = "Mailer/MailerService/NoSettingsConfigured";
14
+ }
17
15
  }
18
- export class TransportSendError extends BaseError {
19
- code = "Mailer/MailerService/TransportSendError";
20
- constructor(error) {
21
- super({
22
- message: error.message,
23
- data: {
24
- error
25
- }
26
- });
27
- }
16
+ class TransportSendError extends BaseError {
17
+ constructor(error){
18
+ super({
19
+ message: error.message,
20
+ data: {
21
+ error
22
+ }
23
+ }), this.code = "Mailer/MailerService/TransportSendError";
24
+ }
28
25
  }
26
+ export { NoSettingsConfiguredError, NoTransportAvailableError, TransportSendError };
29
27
 
30
28
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BaseError","NoTransportAvailableError","code","constructor","message","NoSettingsConfiguredError","TransportSendError","error","data"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { TransportSendResponse } from \"~/types.js\";\n\nexport class NoTransportAvailableError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoTransportAvailable\" as const;\n\n constructor() {\n super({\n message: \"There is no transport available.\"\n });\n }\n}\n\nexport class NoSettingsConfiguredError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoSettingsConfigured\" as const;\n\n constructor() {\n super({\n message: \"No mailer settings are configured and no environment variables are set.\"\n });\n }\n}\n\nexport class TransportSendError extends BaseError<{ error: TransportSendResponse[\"error\"] }> {\n override readonly code = \"Mailer/MailerService/TransportSendError\" as const;\n\n constructor(error: NonNullable<TransportSendResponse[\"error\"]>) {\n super({\n message: error.message,\n data: {\n error\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,yBAAyB,SAASD,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMC,yBAAyB,SAASL,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAME,kBAAkB,SAASN,SAAS,CAA4C;EACvEE,IAAI,GAAG,yCAAyC;EAElEC,WAAWA,CAACI,KAAkD,EAAE;IAC5D,KAAK,CAAC;MACFH,OAAO,EAAEG,KAAK,CAACH,OAAO;MACtBI,IAAI,EAAE;QACFD;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"domain/MailerService/errors.js","sources":["../../../src/domain/MailerService/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { TransportSendResponse } from \"~/types.js\";\n\nexport class NoTransportAvailableError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoTransportAvailable\" as const;\n\n constructor() {\n super({\n message: \"There is no transport available.\"\n });\n }\n}\n\nexport class NoSettingsConfiguredError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoSettingsConfigured\" as const;\n\n constructor() {\n super({\n message: \"No mailer settings are configured and no environment variables are set.\"\n });\n }\n}\n\nexport class TransportSendError extends BaseError<{ error: TransportSendResponse[\"error\"] }> {\n override readonly code = \"Mailer/MailerService/TransportSendError\" as const;\n\n constructor(error: NonNullable<TransportSendResponse[\"error\"]>) {\n super({\n message: error.message,\n data: {\n error\n }\n });\n }\n}\n"],"names":["NoTransportAvailableError","BaseError","NoSettingsConfiguredError","TransportSendError","error"],"mappings":";AAGO,MAAMA,kCAAkCC;IAG3C,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAMC,kCAAkCD;IAG3C,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ;AAEO,MAAME,2BAA2BF;IAGpC,YAAYG,KAAkD,CAAE;QAC5D,KAAK,CAAC;YACF,SAASA,MAAM,OAAO;YACtB,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ"}
@@ -1,16 +1,16 @@
1
1
  import { BaseError } from "@webiny/feature/api";
2
2
  import type { ZodError } from "zod";
3
3
  export declare class MailValidationError extends BaseError<{
4
- errors: ZodError["errors"];
4
+ errors: ZodError["issues"];
5
5
  }> {
6
6
  readonly code: "Mailer/SendMail/Validation";
7
- constructor(errors: ZodError["errors"]);
7
+ constructor(errors: ZodError["issues"]);
8
8
  }
9
9
  export declare class SettingsValidationError extends BaseError<{
10
- errors: ZodError["errors"];
10
+ errors: ZodError["issues"];
11
11
  }> {
12
12
  readonly code: "Mailer/Settings/Validation";
13
- constructor(errors: ZodError["errors"]);
13
+ constructor(errors: ZodError["issues"]);
14
14
  }
15
15
  export declare class SettingsNotAuthorized extends BaseError {
16
16
  readonly code: "Mailer/Settings/NotAuthorized";
@@ -22,3 +22,7 @@ export declare class SettingsPersistenceError extends BaseError<{
22
22
  readonly code: "Mailer/Settings/Persistence";
23
23
  constructor(error: Error);
24
24
  }
25
+ export declare class SettingsLockedByCode extends BaseError {
26
+ readonly code: "Mailer/Settings/LockedByCode";
27
+ constructor();
28
+ }
package/domain/errors.js CHANGED
@@ -1,44 +1,48 @@
1
1
  import { BaseError } from "@webiny/feature/api";
2
- export class MailValidationError extends BaseError {
3
- code = "Mailer/SendMail/Validation";
4
- constructor(errors) {
5
- super({
6
- message: "Email params are invalid.",
7
- data: {
8
- errors
9
- }
10
- });
11
- }
2
+ class MailValidationError extends BaseError {
3
+ constructor(errors){
4
+ super({
5
+ message: "Email params are invalid.",
6
+ data: {
7
+ errors
8
+ }
9
+ }), this.code = "Mailer/SendMail/Validation";
10
+ }
12
11
  }
13
- export class SettingsValidationError extends BaseError {
14
- code = "Mailer/Settings/Validation";
15
- constructor(errors) {
16
- super({
17
- message: "Settings validation failed.",
18
- data: {
19
- errors
20
- }
21
- });
22
- }
12
+ class SettingsValidationError extends BaseError {
13
+ constructor(errors){
14
+ super({
15
+ message: "Settings validation failed.",
16
+ data: {
17
+ errors
18
+ }
19
+ }), this.code = "Mailer/Settings/Validation";
20
+ }
23
21
  }
24
- export class SettingsNotAuthorized extends BaseError {
25
- code = "Mailer/Settings/NotAuthorized";
26
- constructor() {
27
- super({
28
- message: "Not allowed to update the mailer settings."
29
- });
30
- }
22
+ class SettingsNotAuthorized extends BaseError {
23
+ constructor(){
24
+ super({
25
+ message: "Not allowed to update the mailer settings."
26
+ }), this.code = "Mailer/Settings/NotAuthorized";
27
+ }
31
28
  }
32
- export class SettingsPersistenceError extends BaseError {
33
- code = "Mailer/Settings/Persistence";
34
- constructor(error) {
35
- super({
36
- message: "Failed to persist settings.",
37
- data: {
38
- error
39
- }
40
- });
41
- }
29
+ class SettingsPersistenceError extends BaseError {
30
+ constructor(error){
31
+ super({
32
+ message: "Failed to persist settings.",
33
+ data: {
34
+ error
35
+ }
36
+ }), this.code = "Mailer/Settings/Persistence";
37
+ }
42
38
  }
39
+ class SettingsLockedByCode extends BaseError {
40
+ constructor(){
41
+ super({
42
+ message: "Mailer settings are managed by code and cannot be saved via the API."
43
+ }), this.code = "Mailer/Settings/LockedByCode";
44
+ }
45
+ }
46
+ export { MailValidationError, SettingsLockedByCode, SettingsNotAuthorized, SettingsPersistenceError, SettingsValidationError };
43
47
 
44
48
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BaseError","MailValidationError","code","constructor","errors","message","data","SettingsValidationError","SettingsNotAuthorized","SettingsPersistenceError","error"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"errors\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"errors\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"errors\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"errors\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not allowed to update the mailer settings.\" });\n }\n}\n\nexport class SettingsPersistenceError extends BaseError<{ error: Error }> {\n override readonly code = \"Mailer/Settings/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: \"Failed to persist settings.\",\n data: {\n error\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAiC;EAC7DE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,2BAA2B;MACpCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMG,uBAAuB,SAASP,SAAS,CAAiC;EACjEE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMI,qBAAqB,SAASR,SAAS,CAAC;EAC/BE,IAAI,GAAG,+BAA+B;EAExDC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MAAEE,OAAO,EAAE;IAA6C,CAAC,CAAC;EACpE;AACJ;AAEA,OAAO,MAAMI,wBAAwB,SAAST,SAAS,CAAmB;EACpDE,IAAI,GAAG,6BAA6B;EAEtDC,WAAWA,CAACO,KAAY,EAAE;IACtB,KAAK,CAAC;MACFL,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFI;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"domain/errors.js","sources":["../../src/domain/errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"issues\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"issues\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not allowed to update the mailer settings.\" });\n }\n}\n\nexport class SettingsPersistenceError extends BaseError<{ error: Error }> {\n override readonly code = \"Mailer/Settings/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: \"Failed to persist settings.\",\n data: {\n error\n }\n });\n }\n}\n\nexport class SettingsLockedByCode extends BaseError {\n override readonly code = \"Mailer/Settings/LockedByCode\" as const;\n\n constructor() {\n super({\n message: \"Mailer settings are managed by code and cannot be saved via the API.\"\n });\n }\n}\n"],"names":["MailValidationError","BaseError","errors","SettingsValidationError","SettingsNotAuthorized","SettingsPersistenceError","error","SettingsLockedByCode"],"mappings":";AAGO,MAAMA,4BAA4BC;IAGrC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,gCAAgCF;IAGzC,YAAYC,MAA0B,CAAE;QACpC,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAME,8BAA8BH;IAGvC,aAAc;QACV,KAAK,CAAC;YAAE,SAAS;QAA6C,SAHhD,IAAI,GAAG;IAIzB;AACJ;AAEO,MAAMI,iCAAiCJ;IAG1C,YAAYK,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBACFA;YACJ;QACJ,SARc,IAAI,GAAG;IASzB;AACJ;AAEO,MAAMC,6BAA6BN;IAGtC,aAAc;QACV,KAAK,CAAC;YACF,SAAS;QACb,SALc,IAAI,GAAG;IAMzB;AACJ"}
@@ -0,0 +1,4 @@
1
+ export { SendMailUseCase, MailSendErrorEventHandler, MailBeforeSendEventHandler, MailAfterSendEventHandler } from "../../features/SendMail/index.js";
2
+ export { GetSettingsUseCase, GetSettingsRepository } from "../../features/GetSettings/index.js";
3
+ export { SaveSettingsUseCase, SaveSettingsRepository, MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler } from "../../features/SaveSettings/index.js";
4
+ export { MailerService } from "../../domain/MailerService/abstractions.js";
@@ -0,0 +1,4 @@
1
+ export { MailAfterSendEventHandler, MailBeforeSendEventHandler, MailSendErrorEventHandler, SendMailUseCase } from "../../features/SendMail/index.js";
2
+ export { GetSettingsRepository, GetSettingsUseCase } from "../../features/GetSettings/index.js";
3
+ export { MailerSettingsAfterSaveEventHandler, MailerSettingsBeforeSaveEventHandler, SaveSettingsRepository, SaveSettingsUseCase } from "../../features/SaveSettings/index.js";
4
+ export { MailerService } from "../../domain/MailerService/abstractions.js";
@@ -0,0 +1,12 @@
1
+ import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
2
+ import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
3
+ import type { TransportSettings } from "../../types.js";
4
+ declare class CodeMailerSettingsImpl implements Abstraction.Interface {
5
+ private buildParams;
6
+ constructor(buildParams: BuildParams.Interface);
7
+ get(transportName: string): TransportSettings | null;
8
+ }
9
+ export declare const CodeMailerSettings: typeof CodeMailerSettingsImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("~/domain/CodeMailerSettings/abstractions.js").ICodeMailerSettings>;
11
+ };
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
2
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
3
+ const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
4
+ const SMTP_BUILD_PARAM_KEY = "Mailer.SmtpSettings";
5
+ class CodeMailerSettingsImpl {
6
+ constructor(buildParams){
7
+ this.buildParams = buildParams;
8
+ }
9
+ get(transportName) {
10
+ if (transportName !== SMTP_TRANSPORT_NAME) return null;
11
+ const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
12
+ return value ?? null;
13
+ }
14
+ }
15
+ const CodeMailerSettingsImpl_CodeMailerSettings = CodeMailerSettings.createImplementation({
16
+ implementation: CodeMailerSettingsImpl,
17
+ dependencies: [
18
+ BuildParams
19
+ ]
20
+ });
21
+ export { CodeMailerSettingsImpl_CodeMailerSettings as CodeMailerSettings };
22
+
23
+ //# sourceMappingURL=CodeMailerSettingsImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CodeMailerSettings/CodeMailerSettingsImpl.js","sources":["../../../src/features/CodeMailerSettings/CodeMailerSettingsImpl.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"names":["SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","buildParams","transportName","value","CodeMailerSettings","Abstraction","BuildParams"],"mappings":";;AAIA,MAAMA,sBAAsB;AAC5B,MAAMC,uBAAuB;AAE7B,MAAMC;IACF,YAAoBC,WAAkC,CAAE;aAApCA,WAAW,GAAXA;IAAqC;IAEzD,IAAIC,aAAqB,EAA4B;QACjD,IAAIA,kBAAkBJ,qBAClB,OAAO;QAEX,MAAMK,QAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAoBJ;QACtD,OAAOI,SAAS;IACpB;AACJ;AAEO,MAAMC,4CAAqBC,mBAAAA,oBAAgC,CAAC;IAC/D,gBAAgBL;IAChB,cAAc;QAACM;KAAY;AAC/B"}
@@ -0,0 +1,4 @@
1
+ export declare const CodeMailerSettingsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { CodeMailerSettings } from "./CodeMailerSettingsImpl.js";
3
+ const CodeMailerSettingsFeature = createFeature({
4
+ name: "Mailer/CodeMailerSettings",
5
+ register (container) {
6
+ container.register(CodeMailerSettings).inSingletonScope();
7
+ }
8
+ });
9
+ export { CodeMailerSettingsFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CodeMailerSettings/feature.js","sources":["../../../src/features/CodeMailerSettings/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CodeMailerSettings } from \"./CodeMailerSettingsImpl.js\";\n\nexport const CodeMailerSettingsFeature = createFeature({\n name: \"Mailer/CodeMailerSettings\",\n register(container) {\n container.register(CodeMailerSettings).inSingletonScope();\n }\n});\n"],"names":["CodeMailerSettingsFeature","createFeature","container","CodeMailerSettings"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;IAC3D;AACJ"}
@@ -1,12 +1,14 @@
1
- export class DummyMailTransport {
2
- name = "Mailer/DummyTransport";
3
- constructor() {}
4
- async send() {
5
- return {
6
- result: true,
7
- error: null
8
- };
9
- }
1
+ class DummyMailTransport {
2
+ constructor(){
3
+ this.name = "Mailer/DummyTransport";
4
+ }
5
+ async send() {
6
+ return {
7
+ result: true,
8
+ error: null
9
+ };
10
+ }
10
11
  }
12
+ export { DummyMailTransport };
11
13
 
12
14
  //# sourceMappingURL=DummyMailTransport.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DummyMailTransport","name","constructor","send","result","error"],"sources":["DummyMailTransport.ts"],"sourcesContent":["import { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class DummyMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n constructor() {}\n\n async send() {\n return {\n result: true,\n error: null\n };\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAAoC;EAC/CC,IAAI,GAAG,uBAAuB;EAE9CC,WAAWA,CAAA,EAAG,CAAC;EAEf,MAAMC,IAAIA,CAAA,EAAG;IACT,OAAO;MACHC,MAAM,EAAE,IAAI;MACZC,KAAK,EAAE;IACX,CAAC;EACL;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/DummyTransport/DummyMailTransport.js","sources":["../../../src/features/DummyTransport/DummyMailTransport.ts"],"sourcesContent":["import { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class DummyMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n constructor() {}\n\n async send() {\n return {\n result: true,\n error: null\n };\n }\n}\n"],"names":["DummyMailTransport"],"mappings":"AAEO,MAAMA;IAGT,aAAc;aAFE,IAAI,GAAG;IAER;IAEf,MAAM,OAAO;QACT,OAAO;YACH,QAAQ;YACR,OAAO;QACX;IACJ;AACJ"}
@@ -1,5 +1,6 @@
1
1
  import { type IMailTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
2
  declare class DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {
3
+ readonly name = "Mailer/DummyTransport";
3
4
  createTransport(): Promise<IMailTransport>;
4
5
  }
5
6
  export declare const DummyMailTransportFactory: typeof DummyMailTransportFactoryImpl & {
@@ -1,13 +1,17 @@
1
1
  import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
2
  import { DummyMailTransport } from "./DummyMailTransport.js";
3
3
  class DummyMailTransportFactoryImpl {
4
- async createTransport() {
5
- return new DummyMailTransport();
6
- }
4
+ async createTransport() {
5
+ return new DummyMailTransport();
6
+ }
7
+ constructor(){
8
+ this.name = "Mailer/DummyTransport";
9
+ }
7
10
  }
8
- export const DummyMailTransportFactory = MailTransportFactory.createImplementation({
9
- implementation: DummyMailTransportFactoryImpl,
10
- dependencies: []
11
+ const DummyMailTransportFactory = MailTransportFactory.createImplementation({
12
+ implementation: DummyMailTransportFactoryImpl,
13
+ dependencies: []
11
14
  });
15
+ export { DummyMailTransportFactory };
12
16
 
13
17
  //# sourceMappingURL=DummyMailTransportFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MailTransportFactory","DummyMailTransport","DummyMailTransportFactoryImpl","createTransport","DummyMailTransportFactory","createImplementation","implementation","dependencies"],"sources":["DummyMailTransportFactory.ts"],"sourcesContent":["import { type IMailTransport, MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { DummyMailTransport } from \"./DummyMailTransport.js\";\n\nclass DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {\n async createTransport(): Promise<IMailTransport> {\n return new DummyMailTransport();\n }\n}\n\nexport const DummyMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: DummyMailTransportFactoryImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAA8BA,oBAAoB;AAClD,SAASC,kBAAkB;AAE3B,MAAMC,6BAA6B,CAA2C;EAC1E,MAAMC,eAAeA,CAAA,EAA4B;IAC7C,OAAO,IAAIF,kBAAkB,CAAC,CAAC;EACnC;AACJ;AAEA,OAAO,MAAMG,yBAAyB,GAAGJ,oBAAoB,CAACK,oBAAoB,CAAC;EAC/EC,cAAc,EAAEJ,6BAA6B;EAC7CK,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/DummyTransport/DummyMailTransportFactory.js","sources":["../../../src/features/DummyTransport/DummyMailTransportFactory.ts"],"sourcesContent":["import { type IMailTransport, MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { DummyMailTransport } from \"./DummyMailTransport.js\";\n\nclass DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n async createTransport(): Promise<IMailTransport> {\n return new DummyMailTransport();\n }\n}\n\nexport const DummyMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: DummyMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["DummyMailTransportFactoryImpl","DummyMailTransport","DummyMailTransportFactory","MailTransportFactory"],"mappings":";;AAGA,MAAMA;IAGF,MAAM,kBAA2C;QAC7C,OAAO,IAAIC;IACf;;aAJgB,IAAI,GAAG;;AAK3B;AAEO,MAAMC,4BAA4BC,qBAAqB,oBAAoB,CAAC;IAC/E,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1 +1,4 @@
1
- export declare const DummyTransportFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const DummyTransportFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { DummyMailTransportFactory } from "./DummyMailTransportFactory.js";
3
- export const DummyTransportFeature = createFeature({
4
- name: "Mailer/DummyTransport",
5
- register(container) {
6
- container.register(DummyMailTransportFactory).inSingletonScope();
7
- }
3
+ const DummyTransportFeature = createFeature({
4
+ name: "Mailer/DummyTransport",
5
+ register (container) {
6
+ container.register(DummyMailTransportFactory).inSingletonScope();
7
+ }
8
8
  });
9
+ export { DummyTransportFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","DummyMailTransportFactory","DummyTransportFeature","name","register","container","inSingletonScope"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DummyMailTransportFactory } from \"./DummyMailTransportFactory.js\";\n\nexport const DummyTransportFeature = createFeature({\n name: \"Mailer/DummyTransport\",\n register(container) {\n container.register(DummyMailTransportFactory).inSingletonScope();\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;AAElC,OAAO,MAAMC,qBAAqB,GAAGF,aAAa,CAAC;EAC/CG,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yBAAyB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EACpE;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/DummyTransport/feature.js","sources":["../../../src/features/DummyTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DummyMailTransportFactory } from \"./DummyMailTransportFactory.js\";\n\nexport const DummyTransportFeature = createFeature({\n name: \"Mailer/DummyTransport\",\n register(container) {\n container.register(DummyMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["DummyTransportFeature","createFeature","container","DummyMailTransportFactory"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,2BAA2B,gBAAgB;IAClE;AACJ"}
@@ -1,13 +1,14 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { Encryption } from "../../domain/Encryption/abstractions.js";
3
- import { GetSettingsRepository } from "./abstractions.js";
4
- import type { TransportSettings } from "../../types.js";
2
+ import { Encryption } from "@webiny/api-core/features/encryption/index.js";
5
3
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
4
+ import { GetSettingsRepository, type ISettingsWithSource } from "./abstractions.js";
5
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
6
6
  declare class GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {
7
7
  private keyValueStore;
8
8
  private encryption;
9
- constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface);
10
- get(): Promise<Result<TransportSettings | null>>;
9
+ private codeSettings;
10
+ constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface, codeSettings: CodeMailerSettings.Interface);
11
+ get(transportName: string): Promise<Result<ISettingsWithSource>>;
11
12
  }
12
13
  export declare const GetSettingsRepositoryImplementation: typeof GetSettingsRepositoryImpl & {
13
14
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsRepository>;
@@ -1,39 +1,54 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { Encryption } from "../../domain/Encryption/abstractions.js";
3
- import { GetSettingsRepository } from "./abstractions.js";
2
+ import { Encryption } from "@webiny/api-core/features/encryption/index.js";
4
3
  import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
4
+ import { GetSettingsRepository } from "./abstractions.js";
5
+ import { CodeMailerSettings } from "../../domain/CodeMailerSettings/abstractions.js";
5
6
  import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
6
7
  class GetSettingsRepositoryImpl {
7
- constructor(keyValueStore, encryption) {
8
- this.keyValueStore = keyValueStore;
9
- this.encryption = encryption;
10
- }
11
- async get() {
12
- const result = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
13
- if (result.isFail()) {
14
- return Result.ok(null);
8
+ constructor(keyValueStore, encryption, codeSettings){
9
+ this.keyValueStore = keyValueStore;
10
+ this.encryption = encryption;
11
+ this.codeSettings = codeSettings;
15
12
  }
16
- const settings = result.value;
17
- if (!settings) {
18
- return Result.ok(null);
13
+ async get(transportName) {
14
+ const codeSettingsValue = this.codeSettings.get(transportName);
15
+ if (null !== codeSettingsValue) return Result.ok({
16
+ settings: codeSettingsValue,
17
+ source: "code"
18
+ });
19
+ const result = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
20
+ if (result.isFail()) return Result.ok({
21
+ settings: null,
22
+ source: null
23
+ });
24
+ const settings = result.value;
25
+ if (!settings) return Result.ok({
26
+ settings: null,
27
+ source: null
28
+ });
29
+ const password = settings.password ? await this.encryption.decrypt(String(settings.password)) : "";
30
+ const transportSettings = {
31
+ host: String(settings.host || ""),
32
+ port: Number(settings.port || 25),
33
+ user: String(settings.user || ""),
34
+ password,
35
+ from: String(settings.from || ""),
36
+ replyTo: settings.replyTo ? String(settings.replyTo) : void 0
37
+ };
38
+ return Result.ok({
39
+ settings: transportSettings,
40
+ source: "storage"
41
+ });
19
42
  }
20
-
21
- // Decrypt password if present
22
- const password = settings.password ? await this.encryption.decrypt(String(settings.password)) : "";
23
- const transportSettings = {
24
- host: String(settings.host || ""),
25
- port: Number(settings.port || 25),
26
- user: String(settings.user || ""),
27
- password,
28
- from: String(settings.from || ""),
29
- replyTo: settings.replyTo ? String(settings.replyTo) : undefined
30
- };
31
- return Result.ok(transportSettings);
32
- }
33
43
  }
34
- export const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
35
- implementation: GetSettingsRepositoryImpl,
36
- dependencies: [KeyValueStore, Encryption]
44
+ const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
45
+ implementation: GetSettingsRepositoryImpl,
46
+ dependencies: [
47
+ KeyValueStore,
48
+ Encryption,
49
+ CodeMailerSettings
50
+ ]
37
51
  });
52
+ export { GetSettingsRepositoryImplementation };
38
53
 
39
54
  //# sourceMappingURL=GetSettingsRepository.js.map