@webiny/api-mailer 6.6.0-alpha.0 → 6.6.0-alpha.10

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.
@@ -2,7 +2,7 @@ import zod from "zod";
2
2
  export declare const saveValidation: zod.ZodObject<{
3
3
  from: zod.ZodString;
4
4
  port: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
5
- replyTo: zod.ZodPreprocess<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>>;
5
+ replyTo: zod.ZodPreprocess<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>, unknown>;
6
6
  host: zod.ZodString;
7
7
  user: zod.ZodString;
8
8
  secure: zod.ZodOptional<zod.ZodBoolean>;
@@ -1,9 +1,10 @@
1
1
  import type SMTPTransport from "nodemailer/lib/smtp-transport";
2
2
  import { MailTransport } from "../../domain/MailTransport/abstractions.js";
3
3
  export declare class SmtpMailTransport implements MailTransport.Interface {
4
+ private readonly defaultFrom?;
4
5
  readonly name = "Mailer/SmtpTransport";
5
6
  private readonly transporter;
6
- constructor(config: SMTPTransport.Options);
7
+ constructor(config: SMTPTransport.Options, defaultFrom?: string | undefined);
7
8
  send(params: MailTransport.SendParams): Promise<{
8
9
  result: string;
9
10
  error: null;
@@ -13,12 +14,20 @@ export declare class SmtpMailTransport implements MailTransport.Interface {
13
14
  message: string;
14
15
  code: string;
15
16
  data: {
16
- envelope: import("nodemailer/lib/mime-node").Envelope;
17
+ [key: string]: any;
18
+ ehlo?: string[] | undefined;
19
+ rejectedErrors?: import("nodemailer").NodemailerError[] | undefined;
20
+ envelopeTime: number;
21
+ messageTime: number;
22
+ messageSize: number;
23
+ serverMessageId?: string | undefined;
24
+ envelope: import("nodemailer/lib/mime-node").MimeNodeEnvelope;
17
25
  messageId: string;
18
- accepted: Array<string | import("nodemailer/lib/mailer").Address>;
19
- rejected: Array<string | import("nodemailer/lib/mailer").Address>;
20
- pending: Array<string | import("nodemailer/lib/mailer").Address>;
26
+ accepted: string[];
27
+ rejected: string[];
21
28
  response: string;
29
+ pending?: string[] | undefined;
30
+ message?: any;
22
31
  };
23
32
  };
24
33
  } | {
@@ -1,6 +1,7 @@
1
1
  import nodemailer from "nodemailer";
2
2
  class SmtpMailTransport {
3
- constructor(config){
3
+ constructor(config, defaultFrom){
4
+ this.defaultFrom = defaultFrom;
4
5
  this.name = "Mailer/SmtpTransport";
5
6
  this.transporter = nodemailer.createTransport(config);
6
7
  }
@@ -11,7 +12,7 @@ class SmtpMailTransport {
11
12
  replyTo,
12
13
  bcc,
13
14
  cc,
14
- from,
15
+ from: from || this.defaultFrom || void 0,
15
16
  text,
16
17
  html,
17
18
  to,
@@ -1 +1 @@
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"}
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(\n config: SMTPTransport.Options,\n private readonly defaultFrom?: string\n ) {\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 // An explicit sender wins; otherwise the configured settings sender (R201).\n // An empty default counts as none, so a missing settings `from` changes nothing.\n from: from || this.defaultFrom || undefined,\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","defaultFrom","nodemailer","params","replyTo","text","html","to","bcc","cc","from","subject","result","undefined","ex"],"mappings":";AAKO,MAAMA;IAIT,YACIC,MAA6B,EACZC,WAAoB,CACvC;aADmBA,WAAW,GAAXA;aALL,IAAI,GAAG;QAOnB,IAAI,CAAC,WAAW,GAAGC,WAAW,eAAe,CAACF;IAClD;IAEA,MAAM,KAAKG,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;gBAGA,MAAMC,QAAQ,IAAI,CAAC,WAAW,IAAIG;gBAClCR;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,OAAOE,IAAS;YAKd,OAAO;gBACH,QAAQ;gBACR,OAAO;oBACH,SAASA,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI;oBACb,MAAM;wBACF,GAAGX,MAAM;wBACT,SAASW,GAAG,OAAO;wBACnB,UAAUA,GAAG,QAAQ;wBACrB,cAAcA,GAAG,YAAY;oBACjC;gBACJ;YACJ;QACJ;IACJ;AACJ"}
@@ -6,7 +6,7 @@ class SmtpMailTransportFactoryImpl {
6
6
  return null !== settings;
7
7
  }
8
8
  async createTransport(settings) {
9
- return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings));
9
+ return new SmtpMailTransport(SmtpConfig.fromTransportSettings(settings), settings.from);
10
10
  }
11
11
  constructor(){
12
12
  this.name = "Mailer/SmtpTransport";
@@ -1 +1 @@
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
+ {"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), settings.from);\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,WAAWA,SAAS,IAAI;IAC1F;;aARgB,IAAI,GAAG;;AAS3B;AAEO,MAAMG,2BAA2BC,qBAAqB,oBAAoB,CAAC;IAC9E,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -1,6 +1,7 @@
1
1
  import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
2
  import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
3
  declare class MailerSchemaFactoryImpl implements GraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
4
5
  execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
5
6
  }
6
7
  export declare const MailerSchemaFactory: typeof MailerSchemaFactoryImpl & {
@@ -1,4 +1,5 @@
1
1
  import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
2
3
  import { ErrorResponse } from "@webiny/api-graphql/responses.js";
3
4
  import { GetSettingsUseCase } from "../features/GetSettings/abstractions.js";
4
5
  import { SaveSettingsUseCase } from "../features/SaveSettings/abstractions.js";
@@ -76,6 +77,7 @@ class MailerSchemaFactoryImpl {
76
77
  resolver: (getSettings)=>async ()=>{
77
78
  try {
78
79
  const result = await getSettings.execute(SMTP_TRANSPORT_NAME);
80
+ if (result.isFail()) return new ErrorResponse(result.error);
79
81
  const { settings, source } = result.value;
80
82
  return {
81
83
  data: toPublicSettings(settings, source),
@@ -106,6 +108,9 @@ class MailerSchemaFactoryImpl {
106
108
  });
107
109
  return builder;
108
110
  }
111
+ constructor(){
112
+ this.getSchemaKey = staticSchemaKey("api-mailer/MailerSchemaFactoryImpl");
113
+ }
109
114
  }
110
115
  const MailerSchemaFactory = GraphQLSchemaFactory.createImplementation({
111
116
  implementation: MailerSchemaFactoryImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/MailerSchemaFactory.js","sources":["../../src/graphql/MailerSchemaFactory.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.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 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","MailerSchemaFactory","GraphQLSchemaFactory"],"mappings":";;;;AASA,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;IACF,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;AACJ;AAEO,MAAMS,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
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 if (result.isFail()) {\n return new ErrorResponse(result.error);\n }\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","ErrorResponse","ex","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,IAAIU,OAAO,MAAM,IACb,OAAO,IAAIC,cAAcD,OAAO,KAAK;wBAGzC,MAAM,EAAER,QAAQ,EAAEC,MAAM,EAAE,GAAGO,OAAO,KAAK;wBAEzC,OAAO;4BACH,MAAMT,iBAAiBC,UAAUC;4BACjC,OAAO;wBACX;oBACJ,EAAE,OAAOS,IAAI;wBACT,OAAO,IAAID,cAAcC;oBAC7B;gBACJ;QACJ;QAEAL,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,IAAIC,cAAcD,OAAO,KAAK;wBAGzC,OAAO;4BACH,MAAMT,iBAAiBS,OAAO,KAAK,EAAE;4BACrC,OAAO;wBACX;oBACJ,EAAE,OAAOE,IAAI;wBACT,OAAO,IAAID,cAAcC;oBAC7B;gBACJ;QACR;QAEA,OAAOL;IACX;;aA5GO,YAAY,GAAGS,gBAAgB;;AA6G1C;AAEO,MAAMC,sBAAsBC,qBAAqB,oBAAoB,CAAC;IACzE,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-mailer",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,25 +18,26 @@
18
18
  "description": "The API to send e-mails.",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@webiny/api-graphql": "6.6.0-alpha.0",
22
- "@webiny/feature": "6.6.0-alpha.0",
23
- "@webiny/plugins": "6.6.0-alpha.0",
21
+ "@webiny/api-graphql": "6.6.0-alpha.10",
22
+ "@webiny/feature": "6.6.0-alpha.10",
23
+ "@webiny/plugins": "6.6.0-alpha.10",
24
24
  "email-addresses": "5.0.0",
25
- "nodemailer": "9.0.3",
26
- "zod": "4.4.3"
25
+ "nodemailer": "10.3.1",
26
+ "zod": "4.6.7"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/nodemailer": "8.0.1",
30
- "@webiny/api-core": "6.6.0-alpha.0",
31
- "@webiny/build-tools": "6.6.0-alpha.0",
32
- "@webiny/di": "1.0.2",
33
- "@webiny/event-handler-core": "6.6.0-alpha.0",
34
- "@webiny/handler": "6.6.0-alpha.0",
35
- "@webiny/project-utils": "6.6.0-alpha.0",
29
+ "@types/nodemailer": "8.0.2",
30
+ "@webiny/api": "6.6.0-alpha.10",
31
+ "@webiny/api-core": "6.6.0-alpha.10",
32
+ "@webiny/build-tools": "6.6.0-alpha.10",
33
+ "@webiny/db-dynamodb": "6.6.0-alpha.10",
34
+ "@webiny/di": "2.0.0",
35
+ "@webiny/event-handler-core": "6.6.0-alpha.10",
36
+ "@webiny/handler": "6.6.0-alpha.10",
36
37
  "graphql": "16.14.2",
37
38
  "rimraf": "6.1.3",
38
39
  "typescript": "7.0.2",
39
- "vitest": "4.1.10"
40
+ "vitest": "5.0.5"
40
41
  },
41
42
  "publishConfig": {
42
43
  "access": "public"