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

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":["configDefaults","socketTimeout","connectionTimeout","greetingTimeout","SmtpConfig","fromTransportSettings","settings","baseConfig","host","port","auth","user","pass","password","Object","keys","reduce","config","key","configKey","undefined"],"sources":["SmtpConfig.ts"],"sourcesContent":["import type { TransportSettings } from \"~/types.js\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\n\nexport type SmtpTransportConfig = SMTPTransport.Options;\n\nconst configDefaults: Partial<SmtpTransportConfig> = {\n socketTimeout: 15000,\n connectionTimeout: 15000,\n greetingTimeout: 15000\n};\n\nexport class SmtpConfig {\n static fromTransportSettings(settings: TransportSettings): SmtpTransportConfig {\n const baseConfig: SmtpTransportConfig = {\n host: settings.host,\n port: settings.port,\n auth: {\n user: settings.user,\n pass: settings.password\n }\n };\n\n // Apply defaults\n return Object.keys(configDefaults).reduce<SmtpTransportConfig>((config, key) => {\n const configKey = key as keyof SmtpTransportConfig;\n if (config[configKey] === undefined || config[configKey] === null) {\n // @ts-expect-error\n config[configKey] = configDefaults[configKey];\n }\n return config;\n }, baseConfig);\n }\n}\n"],"mappings":"AAKA,MAAMA,cAA4C,GAAG;EACjDC,aAAa,EAAE,KAAK;EACpBC,iBAAiB,EAAE,KAAK;EACxBC,eAAe,EAAE;AACrB,CAAC;AAED,OAAO,MAAMC,UAAU,CAAC;EACpB,OAAOC,qBAAqBA,CAACC,QAA2B,EAAuB;IAC3E,MAAMC,UAA+B,GAAG;MACpCC,IAAI,EAAEF,QAAQ,CAACE,IAAI;MACnBC,IAAI,EAAEH,QAAQ,CAACG,IAAI;MACnBC,IAAI,EAAE;QACFC,IAAI,EAAEL,QAAQ,CAACK,IAAI;QACnBC,IAAI,EAAEN,QAAQ,CAACO;MACnB;IACJ,CAAC;;IAED;IACA,OAAOC,MAAM,CAACC,IAAI,CAACf,cAAc,CAAC,CAACgB,MAAM,CAAsB,CAACC,MAAM,EAAEC,GAAG,KAAK;MAC5E,MAAMC,SAAS,GAAGD,GAAgC;MAClD,IAAID,MAAM,CAACE,SAAS,CAAC,KAAKC,SAAS,IAAIH,MAAM,CAACE,SAAS,CAAC,KAAK,IAAI,EAAE;QAC/D;QACAF,MAAM,CAACE,SAAS,CAAC,GAAGnB,cAAc,CAACmB,SAAS,CAAC;MACjD;MACA,OAAOF,MAAM;IACjB,CAAC,EAAEV,UAAU,CAAC;EAClB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/SmtpTransport/SmtpConfig.js","sources":["../../../src/features/SmtpTransport/SmtpConfig.ts"],"sourcesContent":["import type { TransportSettings } from \"~/types.js\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\n\nexport type SmtpTransportConfig = SMTPTransport.Options;\n\nconst configDefaults: Partial<SmtpTransportConfig> = {\n socketTimeout: 15000,\n connectionTimeout: 15000,\n greetingTimeout: 15000\n};\n\nexport class SmtpConfig {\n static fromTransportSettings(settings: TransportSettings): SmtpTransportConfig {\n const baseConfig: SmtpTransportConfig = {\n host: settings.host,\n port: settings.port,\n secure: settings.secure,\n auth: {\n user: settings.user,\n pass: settings.password\n }\n };\n\n // Apply defaults\n return Object.keys(configDefaults).reduce<SmtpTransportConfig>((config, key) => {\n const configKey = key as keyof SmtpTransportConfig;\n if (config[configKey] === undefined || config[configKey] === null) {\n // @ts-expect-error\n config[configKey] = configDefaults[configKey];\n }\n return config;\n }, baseConfig);\n }\n}\n"],"names":["configDefaults","SmtpConfig","settings","baseConfig","Object","config","key","configKey","undefined"],"mappings":"AAKA,MAAMA,iBAA+C;IACjD,eAAe;IACf,mBAAmB;IACnB,iBAAiB;AACrB;AAEO,MAAMC;IACT,OAAO,sBAAsBC,QAA2B,EAAuB;QAC3E,MAAMC,aAAkC;YACpC,MAAMD,SAAS,IAAI;YACnB,MAAMA,SAAS,IAAI;YACnB,QAAQA,SAAS,MAAM;YACvB,MAAM;gBACF,MAAMA,SAAS,IAAI;gBACnB,MAAMA,SAAS,QAAQ;YAC3B;QACJ;QAGA,OAAOE,OAAO,IAAI,CAACJ,gBAAgB,MAAM,CAAsB,CAACK,QAAQC;YACpE,MAAMC,YAAYD;YAClB,IAAID,AAAsBG,WAAtBH,MAAM,CAACE,UAAU,IAAkBF,AAAsB,SAAtBA,MAAM,CAACE,UAAU,EAEpDF,MAAM,CAACE,UAAU,GAAGP,cAAc,CAACO,UAAU;YAEjD,OAAOF;QACX,GAAGF;IACP;AACJ"}
@@ -27,21 +27,18 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
27
27
  message: any;
28
28
  code: any;
29
29
  data: {
30
- command: any;
31
- response: any;
32
- responseCode: any;
33
- to: string[];
30
+ to?: string[];
34
31
  cc?: string[];
35
- bcc?: string[];
32
+ bcc: string[];
36
33
  from?: string;
37
34
  subject: string;
38
35
  text?: string;
39
36
  html?: string;
40
37
  replyTo?: string;
41
- } | {
42
38
  command: any;
43
39
  response: any;
44
40
  responseCode: any;
41
+ } | {
45
42
  to?: string[];
46
43
  cc: string[];
47
44
  bcc?: string[];
@@ -50,18 +47,21 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
50
47
  text?: string;
51
48
  html?: string;
52
49
  replyTo?: string;
53
- } | {
54
50
  command: any;
55
51
  response: any;
56
52
  responseCode: any;
57
- to?: string[];
53
+ } | {
54
+ to: string[];
58
55
  cc?: string[];
59
- bcc: string[];
56
+ bcc?: string[];
60
57
  from?: string;
61
58
  subject: string;
62
59
  text?: string;
63
60
  html?: string;
64
61
  replyTo?: string;
62
+ command: any;
63
+ response: any;
64
+ responseCode: any;
65
65
  };
66
66
  };
67
67
  }>;
@@ -1,67 +1,53 @@
1
1
  import nodemailer from "nodemailer";
2
- export class SmtpMailTransport {
3
- name = "Mailer/SmtpTransport";
4
- constructor(config) {
5
- this.transporter = nodemailer.createTransport(config);
6
- }
7
- async send(params) {
8
- const {
9
- replyTo,
10
- text,
11
- html,
12
- to,
13
- bcc,
14
- cc,
15
- from,
16
- subject
17
- } = params;
18
- try {
19
- const result = await this.transporter.sendMail({
20
- replyTo,
21
- bcc,
22
- cc,
23
- from,
24
- text,
25
- html,
26
- to,
27
- subject
28
- });
29
- if (result.messageId) {
30
- return {
31
- result: result.response,
32
- error: null
33
- };
34
- }
35
- return {
36
- result: null,
37
- error: {
38
- message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
39
- code: "MAILER_ERROR",
40
- data: {
41
- ...result
42
- }
43
- }
44
- };
45
- } catch (ex) {
46
- // Allow-list specific nodemailer/SMTP error fields. Spreading `ex`
47
- // or `ex.data` blindly would risk surfacing the transporter's auth
48
- // config (or anything else a future nodemailer version stamps onto
49
- // its errors) in error responses.
50
- return {
51
- result: null,
52
- error: {
53
- message: ex.message,
54
- code: ex.code,
55
- data: {
56
- ...params,
57
- command: ex.command,
58
- response: ex.response,
59
- responseCode: ex.responseCode
60
- }
2
+ class SmtpMailTransport {
3
+ constructor(config){
4
+ this.name = "Mailer/SmtpTransport";
5
+ this.transporter = nodemailer.createTransport(config);
6
+ }
7
+ async send(params) {
8
+ const { replyTo, text, html, to, bcc, cc, from, subject } = params;
9
+ try {
10
+ const result = await this.transporter.sendMail({
11
+ replyTo,
12
+ bcc,
13
+ cc,
14
+ from,
15
+ text,
16
+ html,
17
+ to,
18
+ subject
19
+ });
20
+ if (result.messageId) return {
21
+ result: result.response,
22
+ error: null
23
+ };
24
+ return {
25
+ result: null,
26
+ error: {
27
+ message: "nodemailer.sendMail does not have a messageId in the result. Something went wrong...",
28
+ code: "MAILER_ERROR",
29
+ data: {
30
+ ...result
31
+ }
32
+ }
33
+ };
34
+ } catch (ex) {
35
+ return {
36
+ result: null,
37
+ error: {
38
+ message: ex.message,
39
+ code: ex.code,
40
+ data: {
41
+ ...params,
42
+ command: ex.command,
43
+ response: ex.response,
44
+ responseCode: ex.responseCode
45
+ }
46
+ }
47
+ };
61
48
  }
62
- };
63
49
  }
64
- }
65
50
  }
51
+ export { SmtpMailTransport };
66
52
 
67
53
  //# sourceMappingURL=SmtpMailTransport.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["nodemailer","SmtpMailTransport","name","constructor","config","transporter","createTransport","send","params","replyTo","text","html","to","bcc","cc","from","subject","result","sendMail","messageId","response","error","message","code","data","ex","command","responseCode"],"sources":["SmtpMailTransport.ts"],"sourcesContent":["import type { Transporter } from \"nodemailer\";\nimport nodemailer from \"nodemailer\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\nimport { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class SmtpMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n private readonly transporter: Transporter<SMTPTransport.SentMessageInfo>;\n\n constructor(config: SMTPTransport.Options) {\n this.transporter = nodemailer.createTransport(config);\n }\n\n async send(params: MailTransport.SendParams) {\n const { replyTo, text, html, to, bcc, cc, from, subject } = params;\n\n try {\n const result = await this.transporter.sendMail({\n replyTo,\n bcc,\n cc,\n from,\n text,\n html,\n to,\n subject\n });\n\n if (result.messageId) {\n return {\n result: result.response,\n error: null\n };\n }\n\n return {\n result: null,\n error: {\n message:\n \"nodemailer.sendMail does not have a messageId in the result. Something went wrong...\",\n code: \"MAILER_ERROR\",\n data: {\n ...result\n }\n }\n };\n } catch (ex: any) {\n // Allow-list specific nodemailer/SMTP error fields. Spreading `ex`\n // or `ex.data` blindly would risk surfacing the transporter's auth\n // config (or anything else a future nodemailer version stamps onto\n // its errors) in error responses.\n return {\n result: null,\n error: {\n message: ex.message,\n code: ex.code,\n data: {\n ...params,\n command: ex.command,\n response: ex.response,\n responseCode: ex.responseCode\n }\n }\n };\n }\n }\n}\n"],"mappings":"AACA,OAAOA,UAAU,MAAM,YAAY;AAInC,OAAO,MAAMC,iBAAiB,CAAoC;EAC9CC,IAAI,GAAG,sBAAsB;EAG7CC,WAAWA,CAACC,MAA6B,EAAE;IACvC,IAAI,CAACC,WAAW,GAAGL,UAAU,CAACM,eAAe,CAACF,MAAM,CAAC;EACzD;EAEA,MAAMG,IAAIA,CAACC,MAAgC,EAAE;IACzC,MAAM;MAAEC,OAAO;MAAEC,IAAI;MAAEC,IAAI;MAAEC,EAAE;MAAEC,GAAG;MAAEC,EAAE;MAAEC,IAAI;MAAEC;IAAQ,CAAC,GAAGR,MAAM;IAElE,IAAI;MACA,MAAMS,MAAM,GAAG,MAAM,IAAI,CAACZ,WAAW,CAACa,QAAQ,CAAC;QAC3CT,OAAO;QACPI,GAAG;QACHC,EAAE;QACFC,IAAI;QACJL,IAAI;QACJC,IAAI;QACJC,EAAE;QACFI;MACJ,CAAC,CAAC;MAEF,IAAIC,MAAM,CAACE,SAAS,EAAE;QAClB,OAAO;UACHF,MAAM,EAAEA,MAAM,CAACG,QAAQ;UACvBC,KAAK,EAAE;QACX,CAAC;MACL;MAEA,OAAO;QACHJ,MAAM,EAAE,IAAI;QACZI,KAAK,EAAE;UACHC,OAAO,EACH,sFAAsF;UAC1FC,IAAI,EAAE,cAAc;UACpBC,IAAI,EAAE;YACF,GAAGP;UACP;QACJ;MACJ,CAAC;IACL,CAAC,CAAC,OAAOQ,EAAO,EAAE;MACd;MACA;MACA;MACA;MACA,OAAO;QACHR,MAAM,EAAE,IAAI;QACZI,KAAK,EAAE;UACHC,OAAO,EAAEG,EAAE,CAACH,OAAO;UACnBC,IAAI,EAAEE,EAAE,CAACF,IAAI;UACbC,IAAI,EAAE;YACF,GAAGhB,MAAM;YACTkB,OAAO,EAAED,EAAE,CAACC,OAAO;YACnBN,QAAQ,EAAEK,EAAE,CAACL,QAAQ;YACrBO,YAAY,EAAEF,EAAE,CAACE;UACrB;QACJ;MACJ,CAAC;IACL;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"features/SmtpTransport/SmtpMailTransport.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransport.ts"],"sourcesContent":["import type { Transporter } from \"nodemailer\";\nimport nodemailer from \"nodemailer\";\nimport type SMTPTransport from \"nodemailer/lib/smtp-transport\";\nimport { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class SmtpMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n private readonly transporter: Transporter<SMTPTransport.SentMessageInfo>;\n\n constructor(config: SMTPTransport.Options) {\n this.transporter = nodemailer.createTransport(config);\n }\n\n async send(params: MailTransport.SendParams) {\n const { replyTo, text, html, to, bcc, cc, from, subject } = params;\n\n try {\n const result = await this.transporter.sendMail({\n replyTo,\n bcc,\n cc,\n from,\n text,\n html,\n to,\n subject\n });\n\n if (result.messageId) {\n return {\n result: result.response,\n error: null\n };\n }\n\n return {\n result: null,\n error: {\n message:\n \"nodemailer.sendMail does not have a messageId in the result. Something went wrong...\",\n code: \"MAILER_ERROR\",\n data: {\n ...result\n }\n }\n };\n } catch (ex: any) {\n // Allow-list specific nodemailer/SMTP error fields. Spreading `ex`\n // or `ex.data` blindly would risk surfacing the transporter's auth\n // config (or anything else a future nodemailer version stamps onto\n // its errors) in error responses.\n return {\n result: null,\n error: {\n message: ex.message,\n code: ex.code,\n data: {\n ...params,\n command: ex.command,\n response: ex.response,\n responseCode: ex.responseCode\n }\n }\n };\n }\n }\n}\n"],"names":["SmtpMailTransport","config","nodemailer","params","replyTo","text","html","to","bcc","cc","from","subject","result","ex"],"mappings":";AAKO,MAAMA;IAIT,YAAYC,MAA6B,CAAE;aAH3B,IAAI,GAAG;QAInB,IAAI,CAAC,WAAW,GAAGC,WAAW,eAAe,CAACD;IAClD;IAEA,MAAM,KAAKE,MAAgC,EAAE;QACzC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAEC,EAAE,EAAEC,GAAG,EAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGR;QAE5D,IAAI;YACA,MAAMS,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAC3CR;gBACAI;gBACAC;gBACAC;gBACAL;gBACAC;gBACAC;gBACAI;YACJ;YAEA,IAAIC,OAAO,SAAS,EAChB,OAAO;gBACH,QAAQA,OAAO,QAAQ;gBACvB,OAAO;YACX;YAGJ,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SACI;oBACJ,MAAM;oBACN,MAAM;wBACF,GAAGA,MAAM;oBACb;gBACJ;YACJ;QACJ,EAAE,OAAOC,IAAS;YAKd,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SAASA,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI;oBACb,MAAM;wBACF,GAAGV,MAAM;wBACT,SAASU,GAAG,OAAO;wBACnB,UAAUA,GAAG,QAAQ;wBACrB,cAAcA,GAAG,YAAY;oBACjC;gBACJ;YACJ;QACJ;IACJ;AACJ"}
@@ -2,6 +2,7 @@ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js
2
2
  import type { TransportSettings } from "../../types.js";
3
3
  declare class SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {
4
4
  readonly name = "Mailer/SmtpTransport";
5
+ canUse(settings: TransportSettings | null): boolean;
5
6
  createTransport(settings: TransportSettings): MailTransportFactory.Return;
6
7
  }
7
8
  export declare const SmtpMailTransportFactory: typeof SmtpMailTransportFactoryImpl & {
@@ -2,14 +2,20 @@ import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js
2
2
  import { SmtpMailTransport } from "./SmtpMailTransport.js";
3
3
  import { SmtpConfig } from "./SmtpConfig.js";
4
4
  class SmtpMailTransportFactoryImpl {
5
- name = "Mailer/SmtpTransport";
6
- async createTransport(settings) {
7
- return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));
8
- }
5
+ canUse(settings) {
6
+ return null !== settings;
7
+ }
8
+ async createTransport(settings) {
9
+ return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));
10
+ }
11
+ constructor(){
12
+ this.name = "Mailer/SmtpTransport";
13
+ }
9
14
  }
10
- export const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
11
- implementation: SmtpMailTransportFactoryImpl,
12
- dependencies: []
15
+ const SmtpMailTransportFactory = MailTransportFactory.createImplementation({
16
+ implementation: SmtpMailTransportFactoryImpl,
17
+ dependencies: []
13
18
  });
19
+ export { SmtpMailTransportFactory };
14
20
 
15
21
  //# sourceMappingURL=SmtpMailTransportFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MailTransportFactory","SmtpMailTransport","SmtpConfig","SmtpMailTransportFactoryImpl","name","createTransport","settings","fromTransportSettings","SmtpMailTransportFactory","createImplementation","implementation","dependencies"],"sources":["SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n\n async createTransport(settings: TransportSettings): MailTransportFactory.Return {\n return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,oBAAoB;AAE7B,SAASC,iBAAiB;AAC1B,SAASC,UAAU;AAEnB,MAAMC,4BAA4B,CAA2C;EACzDC,IAAI,GAAG,sBAAsB;EAE7C,MAAMC,eAAeA,CAACC,QAA2B,EAA+B;IAC5E,OAAO,IAAIL,iBAAiB,CAACC,UAAU,CAACK,qBAAqB,CAACD,QAAQ,CAAC,CAAC;EAC5E;AACJ;AAEA,OAAO,MAAME,wBAAwB,GAAGR,oBAAoB,CAACS,oBAAoB,CAAC;EAC9EC,cAAc,EAAEP,4BAA4B;EAC5CQ,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/SmtpTransport/SmtpMailTransportFactory.js","sources":["../../../src/features/SmtpTransport/SmtpMailTransportFactory.ts"],"sourcesContent":["import { MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { SmtpMailTransport } from \"~/features/SmtpTransport/SmtpMailTransport.js\";\nimport { SmtpConfig } from \"~/features/SmtpTransport/SmtpConfig.js\";\n\nclass SmtpMailTransportFactoryImpl implements MailTransportFactory.Interface {\n public readonly name = \"Mailer/SmtpTransport\";\n\n canUse(settings: TransportSettings | null): boolean {\n return settings !== null;\n }\n\n async createTransport(settings: TransportSettings): MailTransportFactory.Return {\n return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));\n }\n}\n\nexport const SmtpMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: SmtpMailTransportFactoryImpl,\n dependencies: []\n});\n"],"names":["SmtpMailTransportFactoryImpl","settings","SmtpMailTransport","SmtpConfig","SmtpMailTransportFactory","MailTransportFactory"],"mappings":";;;AAKA,MAAMA;IAGF,OAAOC,QAAkC,EAAW;QAChD,OAAOA,AAAa,SAAbA;IACX;IAEA,MAAM,gBAAgBA,QAA2B,EAA+B;QAC5E,OAAO,IAAIC,kBAAkBC,WAAW,qBAAqB,CAACF;IAClE;;aARgB,IAAI,GAAG;;AAS3B;AAEO,MAAMG,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -1,10 +1,11 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { SmtpMailTransportFactory } from "./SmtpMailTransportFactory.js";
3
- export const SmtpTransportFeature = createFeature({
4
- name: "SmtpTransport",
5
- register(container) {
6
- container.register(SmtpMailTransportFactory).inSingletonScope();
7
- }
3
+ const SmtpTransportFeature = createFeature({
4
+ name: "SmtpTransport",
5
+ register (container) {
6
+ container.register(SmtpMailTransportFactory).inSingletonScope();
7
+ }
8
8
  });
9
+ export { SmtpTransportFeature };
9
10
 
10
11
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","SmtpMailTransportFactory","SmtpTransportFeature","name","register","container","inSingletonScope"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SmtpMailTransportFactory } from \"./SmtpMailTransportFactory.js\";\n\nexport const SmtpTransportFeature = createFeature({\n name: \"SmtpTransport\",\n register(container) {\n container.register(SmtpMailTransportFactory).inSingletonScope();\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,oBAAoB,GAAGF,aAAa,CAAC;EAC9CG,IAAI,EAAE,eAAe;EACrBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,wBAAwB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EACnE;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/SmtpTransport/feature.js","sources":["../../../src/features/SmtpTransport/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SmtpMailTransportFactory } from \"./SmtpMailTransportFactory.js\";\n\nexport const SmtpTransportFeature = createFeature({\n name: \"SmtpTransport\",\n register(container) {\n container.register(SmtpMailTransportFactory).inSingletonScope();\n }\n});\n"],"names":["SmtpTransportFeature","createFeature","container","SmtpMailTransportFactory"],"mappings":";;AAGO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,0BAA0B,gBAAgB;IACjE;AACJ"}
@@ -0,0 +1,10 @@
1
+ import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
+ declare class MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
5
+ execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
6
+ }
7
+ export declare const MailerSchemaFactory: typeof MailerSchemaFactoryImpl & {
8
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.public").IGraphQLSchemaFactory>;
9
+ };
10
+ export {};
@@ -0,0 +1,120 @@
1
+ import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
3
+ import { ErrorResponse } from "@webiny/api-graphql/responses.js";
4
+ import { GetSettingsUseCase } from "../features/GetSettings/abstractions.js";
5
+ import { SaveSettingsUseCase } from "../features/SaveSettings/abstractions.js";
6
+ const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
7
+ const toPublicSettings = (settings, source)=>{
8
+ if (!settings) return null;
9
+ const { password: _password, ...publicSettings } = settings;
10
+ return {
11
+ ...publicSettings,
12
+ source
13
+ };
14
+ };
15
+ class MailerSchemaFactoryImpl {
16
+ async execute(builder) {
17
+ builder.addTypeDefs(`
18
+ type MailerTransportSettingsError {
19
+ message: String!
20
+ code: String
21
+ data: JSON
22
+ }
23
+
24
+ type MailerTransportSettings {
25
+ host: String
26
+ port: Number
27
+ secure: Boolean
28
+ user: String
29
+ from: String
30
+ replyTo: String
31
+ source: String
32
+ }
33
+
34
+ type MailerTransportSettingsResponse {
35
+ data: MailerTransportSettings
36
+ error: MailerTransportSettingsError
37
+ }
38
+
39
+ type MailerQuery {
40
+ getSettings: MailerTransportSettingsResponse!
41
+ }
42
+
43
+ input MailerTransportSettingsInput {
44
+ host: String!
45
+ port: Number
46
+ secure: Boolean
47
+ user: String!
48
+ password: String
49
+ from: String!
50
+ replyTo: String
51
+ }
52
+
53
+ type MailerMutation {
54
+ saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!
55
+ }
56
+
57
+ extend type Query {
58
+ mailer: MailerQuery
59
+ }
60
+ extend type Mutation {
61
+ mailer: MailerMutation
62
+ }
63
+ `);
64
+ builder.addResolver({
65
+ path: "Query.mailer",
66
+ resolver: ()=>async ()=>({})
67
+ });
68
+ builder.addResolver({
69
+ path: "Mutation.mailer",
70
+ resolver: ()=>async ()=>({})
71
+ });
72
+ builder.addResolver({
73
+ path: "MailerQuery.getSettings",
74
+ dependencies: [
75
+ GetSettingsUseCase
76
+ ],
77
+ resolver: (getSettings)=>async ()=>{
78
+ try {
79
+ const result = await getSettings.execute(SMTP_TRANSPORT_NAME);
80
+ const { settings, source } = result.value;
81
+ return {
82
+ data: toPublicSettings(settings, source),
83
+ error: null
84
+ };
85
+ } catch (ex) {
86
+ return new ErrorResponse(ex);
87
+ }
88
+ }
89
+ });
90
+ builder.addResolver({
91
+ path: "MailerMutation.saveSettings",
92
+ dependencies: [
93
+ SaveSettingsUseCase
94
+ ],
95
+ resolver: (saveSettings)=>async ({ args })=>{
96
+ try {
97
+ const result = await saveSettings.execute(args.data);
98
+ if (result.isFail()) return new ErrorResponse(result.error);
99
+ return {
100
+ data: toPublicSettings(result.value, "storage"),
101
+ error: null
102
+ };
103
+ } catch (ex) {
104
+ return new ErrorResponse(ex);
105
+ }
106
+ }
107
+ });
108
+ return builder;
109
+ }
110
+ constructor(){
111
+ this.getSchemaKey = staticSchemaKey("api-mailer/MailerSchemaFactoryImpl");
112
+ }
113
+ }
114
+ const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({
115
+ implementation: MailerSchemaFactoryImpl,
116
+ dependencies: []
117
+ });
118
+ export { MailerSchemaFactory };
119
+
120
+ //# sourceMappingURL=MailerSchemaFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql/MailerSchemaFactory.js","sources":["../../src/graphql/MailerSchemaFactory.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse } from \"@webiny/api-graphql/responses.js\";\nimport { GetSettingsUseCase } from \"~/features/GetSettings/abstractions.js\";\nimport { SaveSettingsUseCase } from \"~/features/SaveSettings/abstractions.js\";\nimport type { MailerSettingsSource } from \"~/features/GetSettings/abstractions.js\";\nimport type { SaveSettingsInput } from \"~/features/SaveSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\n\n// Strip `password` before the settings leave the server and tack on `source`\n// so the admin UI can branch on code-vs-storage. Accepts both the full\n// `TransportSettings` (from getSettings) and the already-stripped\n// `Omit<TransportSettings, \"password\">` (from saveSettings) — defense in depth\n// even when the input type carries no password to begin with.\nconst toPublicSettings = (\n settings: TransportSettings | Omit<TransportSettings, \"password\"> | null,\n source: MailerSettingsSource\n): (Omit<TransportSettings, \"password\"> & { source: MailerSettingsSource }) | null => {\n if (!settings) {\n return null;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { password: _password, ...publicSettings } = settings as TransportSettings;\n return { ...publicSettings, source };\n};\n\nclass MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-mailer/MailerSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(`\n type MailerTransportSettingsError {\n message: String!\n code: String\n data: JSON\n }\n\n type MailerTransportSettings {\n host: String\n port: Number\n secure: Boolean\n user: String\n from: String\n replyTo: String\n source: String\n }\n\n type MailerTransportSettingsResponse {\n data: MailerTransportSettings\n error: MailerTransportSettingsError\n }\n\n type MailerQuery {\n getSettings: MailerTransportSettingsResponse!\n }\n\n input MailerTransportSettingsInput {\n host: String!\n port: Number\n secure: Boolean\n user: String!\n password: String\n from: String!\n replyTo: String\n }\n\n type MailerMutation {\n saveSettings(data: MailerTransportSettingsInput!): MailerTransportSettingsResponse!\n }\n\n extend type Query {\n mailer: MailerQuery\n }\n extend type Mutation {\n mailer: MailerMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.mailer\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"MailerQuery.getSettings\",\n dependencies: [GetSettingsUseCase],\n resolver: (getSettings: GetSettingsUseCase.Interface) => async () => {\n try {\n const result = await getSettings.execute(SMTP_TRANSPORT_NAME);\n\n const { settings, source } = result.value;\n\n return {\n data: toPublicSettings(settings, source),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n builder.addResolver<{ data: SaveSettingsInput }>({\n path: \"MailerMutation.saveSettings\",\n dependencies: [SaveSettingsUseCase],\n resolver:\n (saveSettings: SaveSettingsUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await saveSettings.execute(args.data);\n\n if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\n\n return {\n data: toPublicSettings(result.value, \"storage\"),\n error: null\n };\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({\n implementation: MailerSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["SMTP_TRANSPORT_NAME","toPublicSettings","settings","source","_password","publicSettings","MailerSchemaFactoryImpl","builder","GetSettingsUseCase","getSettings","result","ex","ErrorResponse","SaveSettingsUseCase","saveSettings","args","staticSchemaKey","MailerSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;;;AAUA,MAAMA,sBAAsB;AAO5B,MAAMC,mBAAmB,CACrBC,UACAC;IAEA,IAAI,CAACD,UACD,OAAO;IAGX,MAAM,EAAE,UAAUE,SAAS,EAAE,GAAGC,gBAAgB,GAAGH;IACnD,OAAO;QAAE,GAAGG,cAAc;QAAEF;IAAO;AACvC;AAEA,MAAMG;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8CrB,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAmB;YAClC,UAAU,CAACC,cAA8C;oBACrD,IAAI;wBACA,MAAMC,SAAS,MAAMD,YAAY,OAAO,CAACT;wBAEzC,MAAM,EAAEE,QAAQ,EAAEC,MAAM,EAAE,GAAGO,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMT,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOQ,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACJ;QAEAJ,QAAQ,WAAW,CAA8B;YAC7C,MAAM;YACN,cAAc;gBAACM;aAAoB;YACnC,UACI,CAACC,eACD,OAAO,EAAEC,IAAI,EAAE;oBACX,IAAI;wBACA,MAAML,SAAS,MAAMI,aAAa,OAAO,CAACC,KAAK,IAAI;wBAEnD,IAAIL,OAAO,MAAM,IACb,OAAO,IAAIE,cAAcF,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMT,iBAAiBS,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOC,IAAI;wBACT,OAAO,IAAIC,cAAcD;oBAC7B;gBACJ;QACR;QAEA,OAAOJ;IACX;;aAxGO,YAAY,GAAGS,gBAAgB;;AAyG1C;AAEO,MAAMC,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
+ export { MailerFeature } from "./MailerFeature.js";
1
2
  export { MailerService } from "./domain/MailerService/abstractions.js";
2
3
  export type { IMailerService, IMailerServiceErrors } from "./domain/MailerService/abstractions.js";
3
- export declare const createMailerContext: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>;
4
- export declare const createMailerGraphQL: () => import("@webiny/handler-graphql/index.js").GraphQLSchemaPlugin<import("@webiny/api/types.js").Context>;
package/index.js CHANGED
@@ -1,27 +1,2 @@
1
- import { createContextPlugin } from "@webiny/api";
2
- import { CodeMailerSettingsFeature } from "./features/CodeMailerSettings/feature.js";
3
- import { GetSettingsFeature } from "./features/GetSettings/feature.js";
4
- import { SaveSettingsFeature } from "./features/SaveSettings/feature.js";
5
- import { DummyTransportFeature } from "./features/DummyTransport/feature.js";
6
- import { SmtpTransportFeature } from "./features/SmtpTransport/feature.js";
7
- import { MailerServiceFeature } from "./features/MailerService/feature.js";
8
- import { SendMailFeature } from "./features/SendMail/feature.js";
9
- import { createSettingsGraphQL } from "./graphql/settings.js";
1
+ export { MailerFeature } from "./MailerFeature.js";
10
2
  export { MailerService } from "./domain/MailerService/abstractions.js";
11
- export const createMailerContext = () => {
12
- return createContextPlugin(context => {
13
- // Register all features.
14
- CodeMailerSettingsFeature.register(context.container);
15
- DummyTransportFeature.register(context.container);
16
- SmtpTransportFeature.register(context.container);
17
- GetSettingsFeature.register(context.container);
18
- SaveSettingsFeature.register(context.container);
19
- MailerServiceFeature.register(context.container);
20
- SendMailFeature.register(context.container);
21
- });
22
- };
23
- export const createMailerGraphQL = () => {
24
- return createSettingsGraphQL();
25
- };
26
-
27
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-mailer",
3
- "version": "0.0.0-unstable.e6f0dc8ca7",
3
+ "version": "0.0.0-unstable.eb81deee7e",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,33 +18,32 @@
18
18
  "description": "The API to send e-mails.",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@webiny/api": "0.0.0-unstable.e6f0dc8ca7",
22
- "@webiny/api-headless-cms": "0.0.0-unstable.e6f0dc8ca7",
23
- "@webiny/feature": "0.0.0-unstable.e6f0dc8ca7",
24
- "@webiny/handler-graphql": "0.0.0-unstable.e6f0dc8ca7",
25
- "@webiny/plugins": "0.0.0-unstable.e6f0dc8ca7",
21
+ "@webiny/api-graphql": "0.0.0-unstable.eb81deee7e",
22
+ "@webiny/feature": "0.0.0-unstable.eb81deee7e",
23
+ "@webiny/plugins": "0.0.0-unstable.eb81deee7e",
26
24
  "email-addresses": "5.0.0",
27
- "nodemailer": "8.0.7",
25
+ "nodemailer": "9.0.5",
28
26
  "zod": "4.4.3"
29
27
  },
30
28
  "devDependencies": {
31
- "@types/nodemailer": "8.0.0",
32
- "@webiny/api-core": "0.0.0-unstable.e6f0dc8ca7",
33
- "@webiny/build-tools": "0.0.0-unstable.e6f0dc8ca7",
34
- "@webiny/db-dynamodb": "0.0.0-unstable.e6f0dc8ca7",
35
- "@webiny/handler": "0.0.0-unstable.e6f0dc8ca7",
36
- "@webiny/handler-aws": "0.0.0-unstable.e6f0dc8ca7",
37
- "@webiny/handler-db": "0.0.0-unstable.e6f0dc8ca7",
38
- "@webiny/project-utils": "0.0.0-unstable.e6f0dc8ca7",
39
- "graphql": "16.14.0",
40
- "jest-dynalite": "3.6.1",
29
+ "@types/nodemailer": "8.0.1",
30
+ "@webiny/api": "0.0.0-unstable.eb81deee7e",
31
+ "@webiny/api-core": "0.0.0-unstable.eb81deee7e",
32
+ "@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
33
+ "@webiny/db-dynamodb": "0.0.0-unstable.eb81deee7e",
34
+ "@webiny/di": "1.1.0",
35
+ "@webiny/event-handler-core": "0.0.0-unstable.eb81deee7e",
36
+ "@webiny/handler": "0.0.0-unstable.eb81deee7e",
37
+ "graphql": "16.14.2",
41
38
  "rimraf": "6.1.3",
42
- "typescript": "6.0.3",
43
- "vitest": "4.1.5"
39
+ "typescript": "7.0.2",
40
+ "vitest": "4.1.11"
44
41
  },
45
42
  "publishConfig": {
46
- "access": "public",
47
- "directory": "dist"
43
+ "access": "public"
48
44
  },
49
- "gitHead": "e6f0dc8ca741c1fcc3fec9a5b9e86fdd49544641"
45
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
46
+ "webiny": {
47
+ "publishFrom": "dist"
48
+ }
50
49
  }
package/types.d.ts CHANGED
@@ -34,6 +34,7 @@ export type TransportSendData = BaseTransportSendData & (TransportSendToData | T
34
34
  export interface TransportSettings {
35
35
  host: string;
36
36
  port: number;
37
+ secure: boolean;
37
38
  user: string;
38
39
  password: string;
39
40
  from: string;
package/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,12 +1,5 @@
1
- import emailAddresses from "email-addresses";
2
-
3
- /**
4
- * RFC 5322 mailbox validator. Accepts both addr-spec ("addr@domain") and
5
- * name-addr ("Display Name <addr@domain>") forms — both are valid SMTP
6
- * From / Reply-To inputs that nodemailer and most providers accept.
7
- */
8
- export const isMailboxAddress = value => {
9
- return emailAddresses.parseOneAddress(value) !== null;
10
- };
1
+ import email_addresses from "email-addresses";
2
+ const isMailboxAddress = (value)=>null !== email_addresses.parseOneAddress(value);
3
+ export { isMailboxAddress };
11
4
 
12
5
  //# sourceMappingURL=isMailboxAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["emailAddresses","isMailboxAddress","value","parseOneAddress"],"sources":["isMailboxAddress.ts"],"sourcesContent":["import emailAddresses from \"email-addresses\";\n\n/**\n * RFC 5322 mailbox validator. Accepts both addr-spec (\"addr@domain\") and\n * name-addr (\"Display Name <addr@domain>\") forms — both are valid SMTP\n * From / Reply-To inputs that nodemailer and most providers accept.\n */\nexport const isMailboxAddress = (value: string): boolean => {\n return emailAddresses.parseOneAddress(value) !== null;\n};\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,iBAAiB;;AAE5C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAIC,KAAa,IAAc;EACxD,OAAOF,cAAc,CAACG,eAAe,CAACD,KAAK,CAAC,KAAK,IAAI;AACzD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/isMailboxAddress.js","sources":["../../src/utils/isMailboxAddress.ts"],"sourcesContent":["import emailAddresses from \"email-addresses\";\n\n/**\n * RFC 5322 mailbox validator. Accepts both addr-spec (\"addr@domain\") and\n * name-addr (\"Display Name <addr@domain>\") forms — both are valid SMTP\n * From / Reply-To inputs that nodemailer and most providers accept.\n */\nexport const isMailboxAddress = (value: string): boolean => {\n return emailAddresses.parseOneAddress(value) !== null;\n};\n"],"names":["isMailboxAddress","value","emailAddresses"],"mappings":";AAOO,MAAMA,mBAAmB,CAACC,QACtBC,AAA0C,SAA1CA,gBAAAA,eAA8B,CAACD"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["SendMailUseCase","MailSendErrorEventHandler","MailBeforeSendEventHandler","MailAfterSendEventHandler","GetSettingsUseCase","GetSettingsRepository","SaveSettingsUseCase","SaveSettingsRepository","MailerSettingsAfterSaveEventHandler","MailerSettingsBeforeSaveEventHandler","MailerService"],"sources":["mailer.ts"],"sourcesContent":["export {\n SendMailUseCase,\n MailSendErrorEventHandler,\n MailBeforeSendEventHandler,\n MailAfterSendEventHandler\n} from \"~/features/SendMail/index.js\";\nexport { GetSettingsUseCase, GetSettingsRepository } from \"~/features/GetSettings/index.js\";\nexport {\n SaveSettingsUseCase,\n SaveSettingsRepository,\n MailerSettingsAfterSaveEventHandler,\n MailerSettingsBeforeSaveEventHandler\n} from \"~/features/SaveSettings/index.js\";\nexport { MailerService } from \"~/domain/MailerService/abstractions.js\";\n"],"mappings":"AAAA,SACIA,eAAe,EACfC,yBAAyB,EACzBC,0BAA0B,EAC1BC,yBAAyB;AAE7B,SAASC,kBAAkB,EAAEC,qBAAqB;AAClD,SACIC,mBAAmB,EACnBC,sBAAsB,EACtBC,mCAAmC,EACnCC,oCAAoC;AAExC,SAASC,aAAa","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- import { BuildParams } from "@webiny/api-core/features/buildParams/index.js";
2
- import { CodeMailerSettings as Abstraction } from "../../domain/CodeMailerSettings/abstractions.js";
3
- const SMTP_TRANSPORT_NAME = "Mailer/SmtpTransport";
4
- const SMTP_BUILD_PARAM_KEY = "Mailer.SmtpSettings";
5
- class CodeMailerSettingsImpl {
6
- constructor(buildParams) {
7
- this.buildParams = buildParams;
8
- }
9
- get(transportName) {
10
- if (transportName !== SMTP_TRANSPORT_NAME) {
11
- return null;
12
- }
13
- const value = this.buildParams.get(SMTP_BUILD_PARAM_KEY);
14
- return value ?? null;
15
- }
16
- }
17
- export const CodeMailerSettings = Abstraction.createImplementation({
18
- implementation: CodeMailerSettingsImpl,
19
- dependencies: [BuildParams]
20
- });
21
-
22
- //# sourceMappingURL=CodeMailerSettingsImpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BuildParams","CodeMailerSettings","Abstraction","SMTP_TRANSPORT_NAME","SMTP_BUILD_PARAM_KEY","CodeMailerSettingsImpl","constructor","buildParams","get","transportName","value","createImplementation","implementation","dependencies"],"sources":["CodeMailerSettingsImpl.ts"],"sourcesContent":["import { BuildParams } from \"@webiny/api-core/features/buildParams/index.js\";\nimport { CodeMailerSettings as Abstraction } from \"~/domain/CodeMailerSettings/abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nconst SMTP_TRANSPORT_NAME = \"Mailer/SmtpTransport\";\nconst SMTP_BUILD_PARAM_KEY = \"Mailer.SmtpSettings\";\n\nclass CodeMailerSettingsImpl implements Abstraction.Interface {\n constructor(private buildParams: BuildParams.Interface) {}\n\n get(transportName: string): TransportSettings | null {\n if (transportName !== SMTP_TRANSPORT_NAME) {\n return null;\n }\n const value = this.buildParams.get<TransportSettings>(SMTP_BUILD_PARAM_KEY);\n return value ?? null;\n }\n}\n\nexport const CodeMailerSettings = Abstraction.createImplementation({\n implementation: CodeMailerSettingsImpl,\n dependencies: [BuildParams]\n});\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,gDAAgD;AAC5E,SAASC,kBAAkB,IAAIC,WAAW;AAG1C,MAAMC,mBAAmB,GAAG,sBAAsB;AAClD,MAAMC,oBAAoB,GAAG,qBAAqB;AAElD,MAAMC,sBAAsB,CAAkC;EAC1DC,WAAWA,CAASC,WAAkC,EAAE;IAAA,KAApCA,WAAkC,GAAlCA,WAAkC;EAAG;EAEzDC,GAAGA,CAACC,aAAqB,EAA4B;IACjD,IAAIA,aAAa,KAAKN,mBAAmB,EAAE;MACvC,OAAO,IAAI;IACf;IACA,MAAMO,KAAK,GAAG,IAAI,CAACH,WAAW,CAACC,GAAG,CAAoBJ,oBAAoB,CAAC;IAC3E,OAAOM,KAAK,IAAI,IAAI;EACxB;AACJ;AAEA,OAAO,MAAMT,kBAAkB,GAAGC,WAAW,CAACS,oBAAoB,CAAC;EAC/DC,cAAc,EAAEP,sBAAsB;EACtCQ,YAAY,EAAE,CAACb,WAAW;AAC9B,CAAC,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["GetSettingsUseCase","GetSettingsRepository"],"sources":["index.ts"],"sourcesContent":["export { GetSettingsUseCase, GetSettingsRepository } from \"./abstractions.js\";\n"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,qBAAqB","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import { ActiveTransport as ActiveTransportAbstraction, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
2
- declare class ActiveTransportImpl implements ActiveTransportAbstraction.Interface {
3
- private transportFactories;
4
- constructor(transportFactories: MailTransportFactory.Interface[]);
5
- name(): string | null;
6
- }
7
- export declare const ActiveTransport: typeof ActiveTransportImpl & {
8
- __abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IActiveTransport>;
9
- };
10
- export {};