@vendure/email-plugin 1.7.4 → 1.8.1
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.
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/src/email-generator.d.ts +25 -0
- package/lib/src/email-generator.js +3 -0
- package/lib/src/email-generator.js.map +1 -0
- package/lib/src/email-processor.d.ts +3 -1
- package/lib/src/email-processor.js.map +1 -1
- package/lib/src/email-sender.d.ts +45 -0
- package/lib/src/email-sender.js +3 -0
- package/lib/src/email-sender.js.map +1 -0
- package/lib/src/event-handler.d.ts +9 -0
- package/lib/src/event-handler.js +15 -4
- package/lib/src/event-handler.js.map +1 -1
- package/lib/src/handlebars-mjml-generator.d.ts +2 -1
- package/lib/src/handlebars-mjml-generator.js.map +1 -1
- package/lib/src/nodemailer-email-sender.d.ts +2 -1
- package/lib/src/nodemailer-email-sender.js.map +1 -1
- package/lib/src/noop-email-generator.d.ts +1 -1
- package/lib/src/plugin.d.ts +59 -6
- package/lib/src/plugin.js +89 -13
- package/lib/src/plugin.js.map +1 -1
- package/lib/src/types.d.ts +5 -140
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -19,4 +19,6 @@ __exportStar(require("./src/noop-email-generator"), exports);
|
|
|
19
19
|
__exportStar(require("./src/plugin"), exports);
|
|
20
20
|
__exportStar(require("./src/template-loader"), exports);
|
|
21
21
|
__exportStar(require("./src/types"), exports);
|
|
22
|
+
__exportStar(require("./src/email-generator"), exports);
|
|
23
|
+
__exportStar(require("./src/email-sender"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,uDAAqC;AACrC,kEAAgD;AAChD,6DAA2C;AAC3C,+CAA6B;AAC7B,wDAAsC;AACtC,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,gEAA8C;AAC9C,sDAAoC;AACpC,uDAAqC;AACrC,kEAAgD;AAChD,6DAA2C;AAC3C,+CAA6B;AAC7B,wDAAsC;AACtC,8CAA4B;AAC5B,wDAAsC;AACtC,qDAAmC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InjectableStrategy, VendureEvent } from '@vendure/core';
|
|
2
|
+
import { EmailDetails, EmailPluginOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* An EmailGenerator generates the subject and body details of an email.
|
|
6
|
+
*
|
|
7
|
+
* @docsCategory EmailPlugin
|
|
8
|
+
* @docsPage EmailGenerator
|
|
9
|
+
* @docsWeight 0
|
|
10
|
+
*/
|
|
11
|
+
export interface EmailGenerator<T extends string = any, E extends VendureEvent = any> extends InjectableStrategy {
|
|
12
|
+
/**
|
|
13
|
+
* @description
|
|
14
|
+
* Any necessary setup can be performed here.
|
|
15
|
+
*/
|
|
16
|
+
onInit?(options: EmailPluginOptions): void | Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* Given a subject and body from an email template, this method generates the final
|
|
20
|
+
* interpolated email text.
|
|
21
|
+
*/
|
|
22
|
+
generate(from: string, subject: string, body: string, templateVars: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}): Pick<EmailDetails, 'from' | 'subject' | 'body'>;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-generator.js","sourceRoot":"","sources":["../../src/email-generator.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { EmailGenerator } from './email-generator';
|
|
2
|
+
import { EmailSender } from './email-sender';
|
|
1
3
|
import { TemplateLoader } from './template-loader';
|
|
2
|
-
import {
|
|
4
|
+
import { EmailPluginOptions, EmailTransportOptions, IntermediateEmailDetails } from './types';
|
|
3
5
|
/**
|
|
4
6
|
* This class combines the template loading, generation, and email sending - the actual "work" of
|
|
5
7
|
* the EmailPlugin. It is arranged this way primarily to accommodate easier testing, so that the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-processor.js","sourceRoot":"","sources":["../../src/email-processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAA4D;AAC5D,wDAA0B;AAE1B,yDAA4D;AAC5D,qCAA4C;AAC5C,2CAA8D;
|
|
1
|
+
{"version":3,"file":"email-processor.js","sourceRoot":"","sources":["../../src/email-processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAA4D;AAC5D,wDAA0B;AAE1B,yDAA4D;AAC5D,qCAA4C;AAC5C,2CAA8D;AAG9D,2EAAsE;AACtE,uEAAkE;AAClE,uDAAmD;AAGnD;;;;GAIG;AAEH,IAAa,cAAc,GAA3B,MAAa,cAAc;IAMvB,YAAoD,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAEnF,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,+CAAqB,EAAE,CAAC;QACrG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc;YACxC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc;YAC7B,CAAC,CAAC,IAAI,mDAAuB,EAAE,CAAC;QACpC,IAAI,IAAI,C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AAC,EAAE,EACX,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,OAAO,EAAE,IAAI,CAAC,OAAO,GACxB,CAAC;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;SACf;QAAC,OAAO,GAAY,EAAE;YACnB,IAAI,GAAG,YAAY,KAAK,EAAE;gBACtB,aAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAS,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;aACnD;iBAAM;gBACH,aAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,qBAAS,CAAC,CAAC;aACxC;YACD,MAAM,GAAG,CAAC;SACb;IACL,CAAC;CACJ,CAAA;AAnEY,cAAc;IAD1B,mBAAU,EAAE;IAOI,WAAA,eAAM,CAAC,gCAAoB,CAAC,CAAA;;GANhC,cAAc,CAmE1B;AAnEY,wCAAc"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { InjectableStrategy } from '@vendure/core';
|
|
2
|
+
import { EmailDetails, EmailTransportOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* An EmailSender is responsible for sending the email, e.g. via an SMTP connection
|
|
6
|
+
* or using some other mail-sending API. By default, the EmailPlugin uses the
|
|
7
|
+
* {@link NodemailerEmailSender}, but it is also possible to supply a custom implementation:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```TypeScript
|
|
11
|
+
* const sgMail = require('\@sendgrid/mail');
|
|
12
|
+
*
|
|
13
|
+
* sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
14
|
+
*
|
|
15
|
+
* class SendgridEmailSender implements EmailSender {
|
|
16
|
+
* async send(email: EmailDetails) {
|
|
17
|
+
* await sgMail.send({
|
|
18
|
+
* to: email.recipient,
|
|
19
|
+
* from: email.from,
|
|
20
|
+
* subject: email.subject,
|
|
21
|
+
* html: email.body,
|
|
22
|
+
* });
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* const config: VendureConfig = {
|
|
27
|
+
* logger: new DefaultLogger({ level: LogLevel.Debug })
|
|
28
|
+
* // ...
|
|
29
|
+
* plugins: [
|
|
30
|
+
* EmailPlugin.init({
|
|
31
|
+
* // ... template, handlers config omitted
|
|
32
|
+
* transport: { type: 'none' },
|
|
33
|
+
* emailSender: new SendgridEmailSender(),
|
|
34
|
+
* }),
|
|
35
|
+
* ],
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @docsCategory EmailPlugin
|
|
40
|
+
* @docsPage EmailSender
|
|
41
|
+
* @docsWeight 0
|
|
42
|
+
*/
|
|
43
|
+
export interface EmailSender extends InjectableStrategy {
|
|
44
|
+
send: (email: EmailDetails, options: EmailTransportOptions) => void | Promise<void>;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-sender.js","sourceRoot":"","sources":["../../src/email-sender.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
package/lib/src/event-handler.js
CHANGED
|
@@ -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
|
|
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 = (
|
|
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 attachment_utils_1.serializeAttachments(attachmentsArray);
|
|
321
|
-
const optionalAddressFields = (
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC,UAAU,EACrE,WAAW,IACR,qBAAqB,EAC1B;IACN,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,KAAkC;QAC3C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,oBAAoB,CACxB,WAAmB,EACnB,YAA0B;QAE1B,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO;SACV;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YAC5C,OAAO,CACH,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,IAAI,CAAC,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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EmailGenerator
|
|
1
|
+
import { EmailGenerator } from './email-generator';
|
|
2
|
+
import { EmailPluginDevModeOptions, EmailPluginOptions } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
4
5
|
* Uses Handlebars (https://handlebarsjs.com/) to output MJML (https://mjml.io) which is then
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlebars-mjml-generator.js","sourceRoot":"","sources":["../../src/handlebars-mjml-generator.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AACpC,wDAA0B;AAC1B,4DAAoC;AACpC,gDAA6B;AAC7B,gDAAwB;
|
|
1
|
+
{"version":3,"file":"handlebars-mjml-generator.js","sourceRoot":"","sources":["../../src/handlebars-mjml-generator.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AACpC,wDAA0B;AAC1B,4DAAoC;AACpC,gDAA6B;AAC7B,gDAAwB;AAKxB;;;;;;;GAOG;AACH,MAAa,uBAAuB;IAChC,MAAM,CAAC,OAAuD;QAC1D,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACjE,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACpC,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,IAAY,EAAE,OAAe,EAAE,QAAgB,EAAE,YAAiB;QACvE,MAAM,YAAY,GAAG,oBAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,MAAM,eAAe,GAAG,oBAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACpD,MAAM,gBAAgB,GAAG,oBAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,0EAA0E;QAC1E,kHAAkH;QAClH,yEAAyE;QACzE,kEAAkE;QAClE,MAAM,eAAe,GAAmB,EAAE,6BAA6B,EAAE,IAAI,EAAE,CAAC;QAChF,MAAM,UAAU,GAAG,YAAY,CAAC,YAAY,EAAE,EAAE,6BAA6B,EAAE,IAAI,EAAE,CAAC,CAAC;QACvF,MAAM,aAAa,GA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AC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAjDD,0DAiDC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Stream } from 'stream';
|
|
3
|
-
import {
|
|
3
|
+
import { EmailSender } from './email-sender';
|
|
4
|
+
import { EmailDetails, EmailTransportOptions } from './types';
|
|
4
5
|
export declare type StreamTransportInfo = {
|
|
5
6
|
envelope: {
|
|
6
7
|
from: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodemailer-email-sender.js","sourceRoot":"","sources":["../../src/nodemailer-email-sender.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAuE;AACvE,mEAA+D;AAC/D,wCAAuC;AACvC,wDAA0B;AAC1B,2CAA6C;AAG7C,gDAAwB;AAExB,+BAA8B;AAE9B,2CAAwC;
|
|
1
|
+
{"version":3,"file":"nodemailer-email-sender.js","sourceRoot":"","sources":["../../src/nodemailer-email-sender.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAuE;AACvE,mEAA+D;AAC/D,wCAAuC;AACvC,wDAA0B;AAC1B,2CAA6C;AAG7C,gDAAwB;AAExB,+BAA8B;AAE9B,2CAAwC;AAaxC;;;;;;GAMG;AACH,MAAa,qBAAqB;IAI9B,KAAK,CAAC,IAAI,CAAC,KAAmB,EAAE,OAA8B;QAC1D,QAAQ,OAAO,CAAC,IAAI,EAAE;YAClB,KAAK,MAAM;gBACP,OAAO;gBACP,MAAM;YACV,KAAK,MAAM;gBACP,MAAM,QAAQ,GAAG,kCAAe,CAC5B,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,EAAE,EACjE,GAAG,CACN,CAAC;gBACF,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBACzD,IAAI,OAAO,CAAC,GAAG,EAAE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C,EAAE,qBAAS,CAAC,CAAC;YACjD,CAAC;YACD,KAAK,CAAC,GAAG,MAAW;gBAChB,aAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,qBAAS,CAAC,CAAC;YACjD,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AAlID,sDAkIC"}
|
package/lib/src/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MiddlewareConsumer, NestModule, OnApplicationBootstrap } from '@nestjs/common';
|
|
1
|
+
import { MiddlewareConsumer, NestModule, OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
2
2
|
import { ModuleRef } from '@nestjs/core';
|
|
3
3
|
import { EventBus, JobQueueService, ProcessContext, Type } from '@vendure/core';
|
|
4
4
|
import { EmailProcessor } from './email-processor';
|
|
@@ -98,8 +98,57 @@ import { EmailPluginDevModeOptions, EmailPluginOptions } from './types';
|
|
|
98
98
|
*
|
|
99
99
|
* The `defaultEmailHandlers` array defines the default handlers such as for handling new account registration, order confirmation, password reset
|
|
100
100
|
* etc. These defaults can be extended by adding custom templates for languages other than the default, or even completely new types of emails
|
|
101
|
-
* which respond to any of the available [VendureEvents](/docs/typescript-api/events/).
|
|
102
|
-
*
|
|
101
|
+
* which respond to any of the available [VendureEvents](/docs/typescript-api/events/).
|
|
102
|
+
*
|
|
103
|
+
* A good way to learn how to create your own email handlers is to take a look at the
|
|
104
|
+
* [source code of the default handlers](https://github.com/vendure-ecommerce/vendure/blob/master/packages/email-plugin/src/default-email-handlers.ts).
|
|
105
|
+
* New handlers are defined in exactly the same way.
|
|
106
|
+
*
|
|
107
|
+
* It is also possible to modify the default handlers:
|
|
108
|
+
*
|
|
109
|
+
* ```TypeScript
|
|
110
|
+
* // Rather than importing `defaultEmailHandlers`, you can
|
|
111
|
+
* // import the handlers individually
|
|
112
|
+
* import {
|
|
113
|
+
* orderConfirmationHandler,
|
|
114
|
+
* emailVerificationHandler,
|
|
115
|
+
* passwordResetHandler,
|
|
116
|
+
* emailAddressChangeHandler,
|
|
117
|
+
* } from '\@vendure/email-plugin';
|
|
118
|
+
* import { CustomerService } from '\@vendure/core';
|
|
119
|
+
*
|
|
120
|
+
* // This allows you to then customize each handler to your needs.
|
|
121
|
+
* // For example, let's set a new subject line to the order confirmation:
|
|
122
|
+
* orderConfirmationHandler
|
|
123
|
+
* .setSubject(`We received your order!`);
|
|
124
|
+
*
|
|
125
|
+
* // Another example: loading additional data and setting new
|
|
126
|
+
* // template variables.
|
|
127
|
+
* passwordResetHandler
|
|
128
|
+
* .loadData(async ({ event, injector }) => {
|
|
129
|
+
* const customerService = injector.get(CustomerService);
|
|
130
|
+
* const customer = await customerService.findOneByUserId(event.ctx, event.user.id);
|
|
131
|
+
* return { customer };
|
|
132
|
+
* })
|
|
133
|
+
* .setTemplateVars(event => ({
|
|
134
|
+
* passwordResetToken: event.user.getNativeAuthenticationMethod().passwordResetToken,
|
|
135
|
+
* customer: event.data.customer,
|
|
136
|
+
* }));
|
|
137
|
+
*
|
|
138
|
+
* // Then you pass the handlers to the EmailPlugin init method
|
|
139
|
+
* // individually
|
|
140
|
+
* EmailPlugin.init({
|
|
141
|
+
* handlers: [
|
|
142
|
+
* orderConfirmationHandler,
|
|
143
|
+
* emailVerificationHandler,
|
|
144
|
+
* passwordResetHandler,
|
|
145
|
+
* emailAddressChangeHandler,
|
|
146
|
+
* ],
|
|
147
|
+
* // ...
|
|
148
|
+
* }),
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* For all available methods of extending a handler, see the {@link EmailEventHandler} documentation.
|
|
103
152
|
*
|
|
104
153
|
* ## Dev mode
|
|
105
154
|
*
|
|
@@ -107,7 +156,7 @@ import { EmailPluginDevModeOptions, EmailPluginOptions } from './types';
|
|
|
107
156
|
* file transport (See {@link FileTransportOptions}) and outputs emails as rendered HTML files in the directory specified by the
|
|
108
157
|
* `outputPath` property.
|
|
109
158
|
*
|
|
110
|
-
* ```
|
|
159
|
+
* ```TypeScript
|
|
111
160
|
* EmailPlugin.init({
|
|
112
161
|
* devMode: true,
|
|
113
162
|
* route: 'mailbox',
|
|
@@ -153,25 +202,29 @@ import { EmailPluginDevModeOptions, EmailPluginOptions } from './types';
|
|
|
153
202
|
*
|
|
154
203
|
* @docsCategory EmailPlugin
|
|
155
204
|
*/
|
|
156
|
-
export declare class EmailPlugin implements OnApplicationBootstrap, NestModule {
|
|
205
|
+
export declare class EmailPlugin implements OnApplicationBootstrap, OnApplicationShutdown, NestModule {
|
|
157
206
|
private eventBus;
|
|
158
207
|
private moduleRef;
|
|
159
208
|
private emailProcessor;
|
|
160
209
|
private jobQueueService;
|
|
161
210
|
private processContext;
|
|
211
|
+
private options;
|
|
162
212
|
private static options;
|
|
163
213
|
private devMailbox;
|
|
164
214
|
private jobQueue;
|
|
165
215
|
private testingProcessor;
|
|
166
216
|
/** @internal */
|
|
167
|
-
constructor(eventBus: EventBus, moduleRef: ModuleRef, emailProcessor: EmailProcessor, jobQueueService: JobQueueService, processContext: ProcessContext);
|
|
217
|
+
constructor(eventBus: EventBus, moduleRef: ModuleRef, emailProcessor: EmailProcessor, jobQueueService: JobQueueService, processContext: ProcessContext, options: EmailPluginOptions);
|
|
168
218
|
/**
|
|
169
219
|
* Set the plugin options.
|
|
170
220
|
*/
|
|
171
221
|
static init(options: EmailPluginOptions | EmailPluginDevModeOptions): Type<EmailPlugin>;
|
|
172
222
|
/** @internal */
|
|
173
223
|
onApplicationBootstrap(): Promise<void>;
|
|
224
|
+
onApplicationShutdown(): Promise<void>;
|
|
174
225
|
configure(consumer: MiddlewareConsumer): void;
|
|
226
|
+
private initInjectableStrategies;
|
|
227
|
+
private destroyInjectableStrategies;
|
|
175
228
|
private setupEventSubscribers;
|
|
176
229
|
private handleEvent;
|
|
177
230
|
}
|
package/lib/src/plugin.js
CHANGED
|
@@ -8,12 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var EmailPlugin_1;
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
16
|
exports.EmailPlugin = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
14
18
|
const core_1 = require("@nestjs/core");
|
|
15
19
|
const core_2 = require("@vendure/core");
|
|
16
|
-
const
|
|
20
|
+
const common_2 = require("./common");
|
|
17
21
|
const constants_1 = require("./constants");
|
|
18
22
|
const dev_mailbox_1 = require("./dev-mailbox");
|
|
19
23
|
const email_processor_1 = require("./email-processor");
|
|
@@ -112,8 +116,57 @@ const email_processor_1 = require("./email-processor");
|
|
|
112
116
|
*
|
|
113
117
|
* The `defaultEmailHandlers` array defines the default handlers such as for handling new account registration, order confirmation, password reset
|
|
114
118
|
* etc. These defaults can be extended by adding custom templates for languages other than the default, or even completely new types of emails
|
|
115
|
-
* which respond to any of the available [VendureEvents](/docs/typescript-api/events/).
|
|
116
|
-
*
|
|
119
|
+
* which respond to any of the available [VendureEvents](/docs/typescript-api/events/).
|
|
120
|
+
*
|
|
121
|
+
* A good way to learn how to create your own email handlers is to take a look at the
|
|
122
|
+
* [source code of the default handlers](https://github.com/vendure-ecommerce/vendure/blob/master/packages/email-plugin/src/default-email-handlers.ts).
|
|
123
|
+
* New handlers are defined in exactly the same way.
|
|
124
|
+
*
|
|
125
|
+
* It is also possible to modify the default handlers:
|
|
126
|
+
*
|
|
127
|
+
* ```TypeScript
|
|
128
|
+
* // Rather than importing `defaultEmailHandlers`, you can
|
|
129
|
+
* // import the handlers individually
|
|
130
|
+
* import {
|
|
131
|
+
* orderConfirmationHandler,
|
|
132
|
+
* emailVerificationHandler,
|
|
133
|
+
* passwordResetHandler,
|
|
134
|
+
* emailAddressChangeHandler,
|
|
135
|
+
* } from '\@vendure/email-plugin';
|
|
136
|
+
* import { CustomerService } from '\@vendure/core';
|
|
137
|
+
*
|
|
138
|
+
* // This allows you to then customize each handler to your needs.
|
|
139
|
+
* // For example, let's set a new subject line to the order confirmation:
|
|
140
|
+
* orderConfirmationHandler
|
|
141
|
+
* .setSubject(`We received your order!`);
|
|
142
|
+
*
|
|
143
|
+
* // Another example: loading additional data and setting new
|
|
144
|
+
* // template variables.
|
|
145
|
+
* passwordResetHandler
|
|
146
|
+
* .loadData(async ({ event, injector }) => {
|
|
147
|
+
* const customerService = injector.get(CustomerService);
|
|
148
|
+
* const customer = await customerService.findOneByUserId(event.ctx, event.user.id);
|
|
149
|
+
* return { customer };
|
|
150
|
+
* })
|
|
151
|
+
* .setTemplateVars(event => ({
|
|
152
|
+
* passwordResetToken: event.user.getNativeAuthenticationMethod().passwordResetToken,
|
|
153
|
+
* customer: event.data.customer,
|
|
154
|
+
* }));
|
|
155
|
+
*
|
|
156
|
+
* // Then you pass the handlers to the EmailPlugin init method
|
|
157
|
+
* // individually
|
|
158
|
+
* EmailPlugin.init({
|
|
159
|
+
* handlers: [
|
|
160
|
+
* orderConfirmationHandler,
|
|
161
|
+
* emailVerificationHandler,
|
|
162
|
+
* passwordResetHandler,
|
|
163
|
+
* emailAddressChangeHandler,
|
|
164
|
+
* ],
|
|
165
|
+
* // ...
|
|
166
|
+
* }),
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* For all available methods of extending a handler, see the {@link EmailEventHandler} documentation.
|
|
117
170
|
*
|
|
118
171
|
* ## Dev mode
|
|
119
172
|
*
|
|
@@ -121,7 +174,7 @@ const email_processor_1 = require("./email-processor");
|
|
|
121
174
|
* file transport (See {@link FileTransportOptions}) and outputs emails as rendered HTML files in the directory specified by the
|
|
122
175
|
* `outputPath` property.
|
|
123
176
|
*
|
|
124
|
-
* ```
|
|
177
|
+
* ```TypeScript
|
|
125
178
|
* EmailPlugin.init({
|
|
126
179
|
* devMode: true,
|
|
127
180
|
* route: 'mailbox',
|
|
@@ -169,12 +222,13 @@ const email_processor_1 = require("./email-processor");
|
|
|
169
222
|
*/
|
|
170
223
|
let EmailPlugin = EmailPlugin_1 = class EmailPlugin {
|
|
171
224
|
/** @internal */
|
|
172
|
-
constructor(eventBus, moduleRef, emailProcessor, jobQueueService, processContext) {
|
|
225
|
+
constructor(eventBus, moduleRef, emailProcessor, jobQueueService, processContext, options) {
|
|
173
226
|
this.eventBus = eventBus;
|
|
174
227
|
this.moduleRef = moduleRef;
|
|
175
228
|
this.emailProcessor = emailProcessor;
|
|
176
229
|
this.jobQueueService = jobQueueService;
|
|
177
230
|
this.processContext = processContext;
|
|
231
|
+
this.options = options;
|
|
178
232
|
}
|
|
179
233
|
/**
|
|
180
234
|
* Set the plugin options.
|
|
@@ -185,12 +239,12 @@ let EmailPlugin = EmailPlugin_1 = class EmailPlugin {
|
|
|
185
239
|
}
|
|
186
240
|
/** @internal */
|
|
187
241
|
async onApplicationBootstrap() {
|
|
188
|
-
|
|
242
|
+
await this.initInjectableStrategies();
|
|
189
243
|
await this.setupEventSubscribers();
|
|
190
|
-
if (!
|
|
244
|
+
if (!common_2.isDevModeOptions(this.options) && this.options.transport.type === 'testing') {
|
|
191
245
|
// When running tests, we don't want to go through the JobQueue system,
|
|
192
246
|
// so we just call the email sending logic directly.
|
|
193
|
-
this.testingProcessor = new email_processor_1.EmailProcessor(options);
|
|
247
|
+
this.testingProcessor = new email_processor_1.EmailProcessor(this.options);
|
|
194
248
|
await this.testingProcessor.init();
|
|
195
249
|
}
|
|
196
250
|
else {
|
|
@@ -203,14 +257,35 @@ let EmailPlugin = EmailPlugin_1 = class EmailPlugin {
|
|
|
203
257
|
});
|
|
204
258
|
}
|
|
205
259
|
}
|
|
260
|
+
async onApplicationShutdown() {
|
|
261
|
+
await this.destroyInjectableStrategies();
|
|
262
|
+
}
|
|
206
263
|
configure(consumer) {
|
|
207
|
-
|
|
208
|
-
if (common_1.isDevModeOptions(options) && this.processContext.isServer) {
|
|
264
|
+
if (common_2.isDevModeOptions(this.options) && this.processContext.isServer) {
|
|
209
265
|
core_2.Logger.info('Creating dev mailbox middleware', constants_1.loggerCtx);
|
|
210
266
|
this.devMailbox = new dev_mailbox_1.DevMailbox();
|
|
211
|
-
consumer.apply(this.devMailbox.serve(options)).forRoutes(options.route);
|
|
267
|
+
consumer.apply(this.devMailbox.serve(this.options)).forRoutes(this.options.route);
|
|
212
268
|
this.devMailbox.handleMockEvent((handler, event) => this.handleEvent(handler, event));
|
|
213
|
-
core_2.registerPluginStartupMessage('Dev mailbox', options.route);
|
|
269
|
+
core_2.registerPluginStartupMessage('Dev mailbox', this.options.route);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async initInjectableStrategies() {
|
|
273
|
+
var _a, _b;
|
|
274
|
+
const injector = new core_2.Injector(this.moduleRef);
|
|
275
|
+
if (typeof ((_a = this.options.emailGenerator) === null || _a === void 0 ? void 0 : _a.init) === 'function') {
|
|
276
|
+
await this.options.emailGenerator.init(injector);
|
|
277
|
+
}
|
|
278
|
+
if (typeof ((_b = this.options.emailSender) === null || _b === void 0 ? void 0 : _b.init) === 'function') {
|
|
279
|
+
await this.options.emailSender.init(injector);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async destroyInjectableStrategies() {
|
|
283
|
+
var _a, _b;
|
|
284
|
+
if (typeof ((_a = this.options.emailGenerator) === null || _a === void 0 ? void 0 : _a.destroy) === 'function') {
|
|
285
|
+
await this.options.emailGenerator.destroy();
|
|
286
|
+
}
|
|
287
|
+
if (typeof ((_b = this.options.emailSender) === null || _b === void 0 ? void 0 : _b.destroy) === 'function') {
|
|
288
|
+
await this.options.emailSender.destroy();
|
|
214
289
|
}
|
|
215
290
|
}
|
|
216
291
|
async setupEventSubscribers() {
|
|
@@ -246,11 +321,12 @@ EmailPlugin = EmailPlugin_1 = __decorate([
|
|
|
246
321
|
imports: [core_2.PluginCommonModule],
|
|
247
322
|
providers: [{ provide: constants_1.EMAIL_PLUGIN_OPTIONS, useFactory: () => EmailPlugin_1.options }, email_processor_1.EmailProcessor],
|
|
248
323
|
}),
|
|
324
|
+
__param(5, common_1.Inject(constants_1.EMAIL_PLUGIN_OPTIONS)),
|
|
249
325
|
__metadata("design:paramtypes", [core_2.EventBus,
|
|
250
326
|
core_1.ModuleRef,
|
|
251
327
|
email_processor_1.EmailProcessor,
|
|
252
328
|
core_2.JobQueueService,
|
|
253
|
-
core_2.ProcessContext])
|
|
329
|
+
core_2.ProcessContext, Object])
|
|
254
330
|
], EmailPlugin);
|
|
255
331
|
exports.EmailPlugin = EmailPlugin;
|
|
256
332
|
//# sourceMappingURL=plugin.js.map
|
package/lib/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,uCAAyC;AACzC,wCAWuB;AAEvB,qCAA4C;AAC5C,2CAA8D;AAC9D,+CAA2C;AAC3C,uDAAmD;AASnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsMG;AAKH,IAAa,WAAW,mBAAxB,MAAa,WAAW;IAMpB,gBAAgB;IAChB,YACY,QAAkB,EAClB,SAAoB,EACpB,cAA8B,EAC9B,eAAgC,EAChC,cAA8B,EACA,OAA2B;QALzD,aAAQ,GAAR,QAAQ,CAAU;QAClB,cAAS,GAAT,SAAS,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BAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/C;IACL,CAAC;CACJ,CAAA;AA9GY,WAAW;IAJvB,oBAAa,CAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,gCAAoB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,aAAW,CAAC,OAAO,EAAE,EAAE,gCAAc,CAAC;KACxG,CAAC;IAcO,WAAA,eAAM,CAAC,gCAAoB,CAAC,CAAA;qCALX,eAAQ;QACP,gBAAS;QACJ,gCAAc;QACb,sBAAe;QAChB,qBAAc;GAZjC,WAAW,CA8GvB;AA9GY,kCAAW"}
|
package/lib/src/types.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ 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';
|
|
6
|
+
import { EmailGenerator } from './email-generator';
|
|
7
|
+
import { EmailSender } from './email-sender';
|
|
5
8
|
import { EmailEventHandler } from './event-handler';
|
|
6
9
|
/**
|
|
7
10
|
* @description
|
|
@@ -97,19 +100,6 @@ export interface EmailPluginDevModeOptions extends Omit<EmailPluginOptions, 'tra
|
|
|
97
100
|
*/
|
|
98
101
|
route: string;
|
|
99
102
|
}
|
|
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
103
|
/**
|
|
114
104
|
* @description
|
|
115
105
|
* A union of all the possible transport options for sending emails.
|
|
@@ -120,58 +110,13 @@ export interface SMTPCredentials {
|
|
|
120
110
|
export declare type EmailTransportOptions = SMTPTransportOptions | SendmailTransportOptions | FileTransportOptions | NoopTransportOptions | TestingTransportOptions;
|
|
121
111
|
/**
|
|
122
112
|
* @description
|
|
123
|
-
*
|
|
113
|
+
* The SMTP transport options of [Nodemailer](https://nodemailer.com/smtp/)
|
|
124
114
|
*
|
|
125
115
|
* @docsCategory EmailPlugin
|
|
126
116
|
* @docsPage Transport Options
|
|
127
117
|
*/
|
|
128
|
-
export interface SMTPTransportOptions {
|
|
118
|
+
export interface SMTPTransportOptions extends SMTPTransport.Options {
|
|
129
119
|
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
120
|
/**
|
|
176
121
|
* @description
|
|
177
122
|
* If true, uses the configured {@link VendureLogger} to log messages from Nodemailer as it interacts with
|
|
@@ -180,20 +125,6 @@ export interface SMTPTransportOptions {
|
|
|
180
125
|
* @default false
|
|
181
126
|
*/
|
|
182
127
|
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
128
|
}
|
|
198
129
|
/**
|
|
199
130
|
* @description
|
|
@@ -266,72 +197,6 @@ export interface TestingTransportOptions {
|
|
|
266
197
|
*/
|
|
267
198
|
onSend: (details: EmailDetails) => void;
|
|
268
199
|
}
|
|
269
|
-
/**
|
|
270
|
-
* @description
|
|
271
|
-
* An EmailSender is responsible for sending the email, e.g. via an SMTP connection
|
|
272
|
-
* or using some other mail-sending API. By default, the EmailPlugin uses the
|
|
273
|
-
* {@link NodemailerEmailSender}, but it is also possible to supply a custom implementation:
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* ```TypeScript
|
|
277
|
-
* const sgMail = require('\@sendgrid/mail');
|
|
278
|
-
*
|
|
279
|
-
* sgMail.setApiKey(process.env.SENDGRID_API_KEY);
|
|
280
|
-
*
|
|
281
|
-
* class SendgridEmailSender implements EmailSender {
|
|
282
|
-
* async send(email: EmailDetails) {
|
|
283
|
-
* await sgMail.send({
|
|
284
|
-
* to: email.recipient,
|
|
285
|
-
* from: email.from,
|
|
286
|
-
* subject: email.subject,
|
|
287
|
-
* html: email.body,
|
|
288
|
-
* });
|
|
289
|
-
* }
|
|
290
|
-
* }
|
|
291
|
-
*
|
|
292
|
-
* const config: VendureConfig = {
|
|
293
|
-
* logger: new DefaultLogger({ level: LogLevel.Debug })
|
|
294
|
-
* // ...
|
|
295
|
-
* plugins: [
|
|
296
|
-
* EmailPlugin.init({
|
|
297
|
-
* // ... template, handlers config omitted
|
|
298
|
-
* transport: { type: 'none' },
|
|
299
|
-
* emailSender: new SendgridEmailSender(),
|
|
300
|
-
* }),
|
|
301
|
-
* ],
|
|
302
|
-
* };
|
|
303
|
-
* ```
|
|
304
|
-
*
|
|
305
|
-
* @docsCategory EmailPlugin
|
|
306
|
-
* @docsPage EmailSender
|
|
307
|
-
* @docsWeight 0
|
|
308
|
-
*/
|
|
309
|
-
export interface EmailSender {
|
|
310
|
-
send: (email: EmailDetails, options: EmailTransportOptions) => void | Promise<void>;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @description
|
|
314
|
-
* An EmailGenerator generates the subject and body details of an email.
|
|
315
|
-
*
|
|
316
|
-
* @docsCategory EmailPlugin
|
|
317
|
-
* @docsPage EmailGenerator
|
|
318
|
-
* @docsWeight 0
|
|
319
|
-
*/
|
|
320
|
-
export interface EmailGenerator<T extends string = any, E extends VendureEvent = any> {
|
|
321
|
-
/**
|
|
322
|
-
* @description
|
|
323
|
-
* Any necessary setup can be performed here.
|
|
324
|
-
*/
|
|
325
|
-
onInit?(options: EmailPluginOptions): void | Promise<void>;
|
|
326
|
-
/**
|
|
327
|
-
* @description
|
|
328
|
-
* Given a subject and body from an email template, this method generates the final
|
|
329
|
-
* interpolated email text.
|
|
330
|
-
*/
|
|
331
|
-
generate(from: string, subject: string, body: string, templateVars: {
|
|
332
|
-
[key: string]: any;
|
|
333
|
-
}): Pick<EmailDetails, 'from' | 'subject' | 'body'>;
|
|
334
|
-
}
|
|
335
200
|
/**
|
|
336
201
|
* @description
|
|
337
202
|
* A function used to load async data for use by an {@link EmailEventHandler}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/email-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
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": "^1.
|
|
39
|
-
"@vendure/core": "^1.
|
|
38
|
+
"@vendure/common": "^1.8.1",
|
|
39
|
+
"@vendure/core": "^1.8.1",
|
|
40
40
|
"rimraf": "^3.0.2",
|
|
41
41
|
"typescript": "4.3.5"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "8019726d5af6dc8d72185d07f673387d1aec8887"
|
|
44
44
|
}
|