@vendure/email-plugin 2.0.0-next.15 → 2.0.0-next.16

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.
@@ -1,3 +1,4 @@
1
+ import { LanguageCode } from '@vendure/common/lib/generated-types';
1
2
  import { Type } from '@vendure/common/lib/shared-types';
2
3
  import { Injector } from '@vendure/core';
3
4
  import { EmailEventListener } from './event-listener';
@@ -117,6 +118,7 @@ export declare class EmailEventHandler<T extends string = string, Event extends
117
118
  listener: EmailEventListener<T>;
118
119
  event: Type<Event>;
119
120
  private setRecipientFn;
121
+ private setLanguageCodeFn;
120
122
  private setTemplateVarsFn;
121
123
  private setAttachmentsFn?;
122
124
  private setOptionalAddressFieldsFn?;
@@ -146,6 +148,13 @@ export declare class EmailEventHandler<T extends string = string, Event extends
146
148
  * Or a comma-separated list of addresses: `'foobar@example.com, "Ноде Майлер" <bar@example.com>'`
147
149
  */
148
150
  setRecipient(setRecipientFn: (event: Event) => string): EmailEventHandler<T, Event>;
151
+ /**
152
+ * @description
153
+ * A function which allows to override the language of the email. If not defined, the language from the context will be used.
154
+ *
155
+ * @since 1.8.0
156
+ */
157
+ setLanguageCode(setLanguageCodeFn: (event: Event) => LanguageCode | undefined): EmailEventHandler<T, Event>;
149
158
  /**
150
159
  * @description
151
160
  * A function which returns an object hash of variables which will be made available to the Handlebars template
@@ -151,6 +151,16 @@ class EmailEventHandler {
151
151
  this.setRecipientFn = setRecipientFn;
152
152
  return this;
153
153
  }
154
+ /**
155
+ * @description
156
+ * A function which allows to override the language of the email. If not defined, the language from the context will be used.
157
+ *
158
+ * @since 1.8.0
159
+ */
160
+ setLanguageCode(setLanguageCodeFn) {
161
+ this.setLanguageCodeFn = setLanguageCodeFn;
162
+ return this;
163
+ }
154
164
  /**
155
165
  * @description
156
166
  * A function which returns an object hash of variables which will be made available to the Handlebars template
@@ -270,7 +280,7 @@ class EmailEventHandler {
270
280
  * @internal
271
281
  */
272
282
  async handle(event, globals = {}, injector) {
273
- var _a, _b, _c, _d;
283
+ var _a, _b, _c, _d, _e;
274
284
  for (const filterFn of this.filterFns) {
275
285
  if (!filterFn(event)) {
276
286
  return;
@@ -302,7 +312,8 @@ class EmailEventHandler {
302
312
  `Remember to call ".setFrom()" when setting up the EmailEventHandler for ${this.type}`);
303
313
  }
304
314
  const { ctx } = event;
305
- const configuration = this.getBestConfiguration(ctx.channel.code, ctx.languageCode);
315
+ const languageCode = ((_a = this.setLanguageCodeFn) === null || _a === void 0 ? void 0 : _a.call(this, event)) || ctx.languageCode;
316
+ const configuration = this.getBestConfiguration(ctx.channel.code, languageCode);
306
317
  const subject = configuration ? configuration.subject : this.defaultSubject;
307
318
  if (subject == null) {
308
319
  throw new Error(`No subject field has been defined. ` +
@@ -312,13 +323,13 @@ class EmailEventHandler {
312
323
  const templateVars = this.setTemplateVarsFn ? this.setTemplateVarsFn(event, globals) : {};
313
324
  let attachmentsArray = [];
314
325
  try {
315
- attachmentsArray = (_b = (await ((_a = this.setAttachmentsFn) === null || _a === void 0 ? void 0 : _a.call(this, event)))) !== null && _b !== void 0 ? _b : [];
326
+ attachmentsArray = (_c = (await ((_b = this.setAttachmentsFn) === null || _b === void 0 ? void 0 : _b.call(this, event)))) !== null && _c !== void 0 ? _c : [];
316
327
  }
317
328
  catch (e) {
318
329
  core_1.Logger.error(e, constants_1.loggerCtx, e.stack);
319
330
  }
320
331
  const attachments = await (0, attachment_utils_1.serializeAttachments)(attachmentsArray);
321
- const optionalAddressFields = (_d = (await ((_c = this.setOptionalAddressFieldsFn) === null || _c === void 0 ? void 0 : _c.call(this, event)))) !== null && _d !== void 0 ? _d : {};
332
+ const optionalAddressFields = (_e = (await ((_d = this.setOptionalAddressFieldsFn) === null || _d === void 0 ? void 0 : _d.call(this, event)))) !== null && _e !== void 0 ? _e : {};
322
333
  return Object.assign({ type: this.type, recipient, from: this.from, templateVars: Object.assign(Object.assign({}, globals), templateVars), subject, templateFile: configuration ? configuration.templateFile : 'body.hbs', attachments }, optionalAddressFields);
323
334
  }
324
335
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"event-handler.js","sourceRoot":"","sources":["../../src/event-handler.ts"],"names":[],"mappings":";;;AAEA,wCAAiD;AAEjD,yDAA0D;AAC1D,2CAAwC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AACH,MAAa,iBAAiB;IAe1B,YAAmB,QAA+B,EAAS,KAAkB;QAA1D,aAAQ,GAAR,QAAQ,CAAuB;QAAS,UAAK,GAAL,KAAK,CAAa;QAVrE,cAAS,GAAqC,EAAE,CAAC;QACjD,mBAAc,GAA0B,EAAE,CAAC;IAS6B,CAAC;IAEjF,gBAAgB;IAChB,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAmC;QACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,YAAY,CAAC,cAAwC;QACjD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,cAAwC;QACpD,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC;QACxC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,cAAsB;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAY;QAChB,IAA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C,CAAC,WAAW,KAAK,SAAS,CAAC;gBAC9D,CAAC,CAAC,YAAY,KAAK,YAAY,CAClC,CAAC;QACN,CAAC,CAAC,CAAC;QACH,IAAI,UAAU,EAAE;YACZ,OAAO,UAAU,CAAC;SACrB;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,CACrE,CAAC;QACF,IAAI,YAAY,EAAE;YACd,OAAO,YAAY,CAAC;SACvB;QACD,OAAO;IACX,CAAC;CACJ;AAtSD,8CAsSC;AAED;;;;;;GAMG;AACH,MAAa,8BAKX,SAAQ,iBAA2B;IACjC,YACW,WAAyC,EAChD,QAA+B,EAC/B,KAAuB;QAEvB,KAAK,CAAC,QAAQ,EAAE,KAAY,CAAC,CAAC;QAJvB,gBAAW,GAAX,WAAW,CAA8B;IAKpD,CAAC;CACJ;AAbD,wEAaC"}
@@ -2,6 +2,7 @@ import { LanguageCode } from '@vendure/common/lib/generated-types';
2
2
  import { Omit } from '@vendure/common/lib/omit';
3
3
  import { Injector, RequestContext, VendureEvent } from '@vendure/core';
4
4
  import { Attachment } from 'nodemailer/lib/mailer';
5
+ import SMTPTransport from 'nodemailer/lib/smtp-transport';
5
6
  import { EmailEventHandler } from './event-handler';
6
7
  /**
7
8
  * @description
@@ -97,19 +98,6 @@ export interface EmailPluginDevModeOptions extends Omit<EmailPluginOptions, 'tra
97
98
  */
98
99
  route: string;
99
100
  }
100
- /**
101
- * @description
102
- * The credentials used for sending email via SMTP
103
- *
104
- * @docsCategory EmailPlugin
105
- * @docsPage Email Plugin Types
106
- */
107
- export interface SMTPCredentials {
108
- /** @description The username */
109
- user: string;
110
- /** @description The password */
111
- pass: string;
112
- }
113
101
  /**
114
102
  * @description
115
103
  * A union of all the possible transport options for sending emails.
@@ -120,58 +108,13 @@ export interface SMTPCredentials {
120
108
  export declare type EmailTransportOptions = SMTPTransportOptions | SendmailTransportOptions | FileTransportOptions | NoopTransportOptions | TestingTransportOptions;
121
109
  /**
122
110
  * @description
123
- * A subset of the SMTP transport options of [Nodemailer](https://nodemailer.com/smtp/)
111
+ * The SMTP transport options of [Nodemailer](https://nodemailer.com/smtp/)
124
112
  *
125
113
  * @docsCategory EmailPlugin
126
114
  * @docsPage Transport Options
127
115
  */
128
- export interface SMTPTransportOptions {
116
+ export interface SMTPTransportOptions extends SMTPTransport.Options {
129
117
  type: 'smtp';
130
- /**
131
- * @description
132
- * the hostname or IP address to connect to (defaults to ‘localhost’)
133
- */
134
- host: string;
135
- /**
136
- * @description
137
- * The port to connect to (defaults to 25 or 465)
138
- */
139
- port: number;
140
- /**
141
- * @description
142
- * Defines authentication data
143
- */
144
- auth: SMTPCredentials;
145
- /**
146
- * @description
147
- * Defines if the connection should use SSL (if true) or not (if false)
148
- */
149
- secure?: boolean;
150
- /**
151
- * @description
152
- * Turns off STARTTLS support if true
153
- */
154
- ignoreTLS?: boolean;
155
- /**
156
- * @description
157
- * Forces the client to use STARTTLS. Returns an error if upgrading the connection is not possible or fails.
158
- */
159
- requireTLS?: boolean;
160
- /**
161
- * @description
162
- * Optional hostname of the client, used for identifying to the server
163
- */
164
- name?: string;
165
- /**
166
- * @description
167
- * The local interface to bind to for network connections
168
- */
169
- localAddress?: string;
170
- /**
171
- * @description
172
- * Defines preferred authentication method, e.g. ‘PLAIN’
173
- */
174
- authMethod?: string;
175
118
  /**
176
119
  * @description
177
120
  * If true, uses the configured {@link VendureLogger} to log messages from Nodemailer as it interacts with
@@ -180,20 +123,6 @@ export interface SMTPTransportOptions {
180
123
  * @default false
181
124
  */
182
125
  logging?: boolean;
183
- /**
184
- * @description
185
- * If set to true, then logs SMTP traffic without message content.
186
- *
187
- * @default false
188
- */
189
- transactionLog?: boolean;
190
- /**
191
- * @description
192
- * If set to true, then logs SMTP traffic and message content, otherwise logs only transaction events.
193
- *
194
- * @default false
195
- */
196
- debug?: boolean;
197
126
  }
198
127
  /**
199
128
  * @description
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure/email-plugin",
3
- "version": "2.0.0-next.15",
3
+ "version": "2.0.0-next.16",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -35,10 +35,10 @@
35
35
  "@types/fs-extra": "^9.0.1",
36
36
  "@types/handlebars": "^4.1.0",
37
37
  "@types/mjml": "^4.0.4",
38
- "@vendure/common": "^2.0.0-next.15",
39
- "@vendure/core": "^2.0.0-next.15",
38
+ "@vendure/common": "^2.0.0-next.16",
39
+ "@vendure/core": "^2.0.0-next.16",
40
40
  "rimraf": "^3.0.2",
41
41
  "typescript": "4.5.5"
42
42
  },
43
- "gitHead": "bd7fd45f9dcfcac6aff57fc1181acd01f2fd3dcd"
43
+ "gitHead": "43181d69c3ede04ec8e59f6f79bcf50ae1def7d6"
44
44
  }