Parcourir la source

docs: Improve email event handler docs

Michael Bromley il y a 1 an
Parent
commit
3db383133f

+ 1 - 1
docs/docs/reference/core-plugins/email-plugin/email-event-handler-with-async-data.md

@@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
 
 ## EmailEventHandlerWithAsyncData
 
-<GenerationInfo sourceFile="packages/email-plugin/src/handler/event-handler.ts" sourceLine="438" packageName="@vendure/email-plugin" />
+<GenerationInfo sourceFile="packages/email-plugin/src/handler/event-handler.ts" sourceLine="446" packageName="@vendure/email-plugin" />
 
 Identical to the <a href='/reference/core-plugins/email-plugin/email-event-handler#emaileventhandler'>EmailEventHandler</a> but with a `data` property added to the `event` based on the result
 of the `.loadData()` function.

+ 9 - 4
docs/docs/reference/core-plugins/email-plugin/email-event-handler.md

@@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
 
 ## EmailEventHandler
 
-<GenerationInfo sourceFile="packages/email-plugin/src/handler/event-handler.ts" sourceLine="131" packageName="@vendure/email-plugin" />
+<GenerationInfo sourceFile="packages/email-plugin/src/handler/event-handler.ts" sourceLine="135" packageName="@vendure/email-plugin" />
 
 The EmailEventHandler defines how the EmailPlugin will respond to a given event.
 
@@ -25,6 +25,7 @@ const confirmationHandler = new EmailEventListener('order-confirmation')
   .on(OrderStateTransitionEvent)
   .filter(event => event.toState === 'PaymentSettled')
   .setRecipient(event => event.order.customer.emailAddress)
+  .setFrom('{{ fromAddress }}')
   .setSubject(`Order confirmation for #{{ order.code }}`)
   .setTemplateVars(event => ({ order: event.order }));
 ```
@@ -74,13 +75,16 @@ const quoteRequestedHandler = new EmailEventListener('quote-requested')
   .on(QuoteRequestedEvent)
   .setRecipient(event => event.customer.emailAddress)
   .setSubject(`Here's the quote you requested`)
+  .setFrom('{{ fromAddress }}')
   .setTemplateVars(event => ({ details: event.details }));
 ```
 
 ### 2. Create the email template
 
-Next you need to make sure there is a template defined at `<app root>/static/email/templates/quote-requested/body.hbs`. The template
-would look something like this:
+Next you need to make sure there is a template defined at `<app root>/static/email/templates/quote-requested/body.hbs`. The path
+segment `quote-requested` must match the string passed to the `EmailEventListener` constructor.
+
+The template would look something like this:
 
 ```handlebars
 {{> header title="Here's the quote you requested" }}
@@ -246,7 +250,8 @@ new EmailEventListener('order-confirmation')
   .setTemplateVars(event => ({
     order: event.order,
     payments: event.data,
-  }));
+  }))
+  // ...
 ```
 ### setMockEvent
 

+ 1 - 1
docs/docs/reference/typescript-api/common/bootstrap.md

@@ -60,7 +60,7 @@ Parameters
 
 ### options
 
-<MemberInfo kind="parameter" type={`<a href='/reference/typescript-api/common/bootstrap#bootstrapoptions'>BootstrapOptions</a>`} />
+<MemberInfo kind="parameter" type={`<a href='/reference/typescript-api/common/<a href='/reference/typescript-api/common/bootstrap#bootstrap'>bootstrap</a>#bootstrapoptions'>BootstrapOptions</a>`} />
 
 
 

+ 1 - 1
docs/docs/reference/typescript-api/data-access/transactional-connection.md

@@ -11,7 +11,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
 
 ## TransactionalConnection
 
-<GenerationInfo sourceFile="packages/core/src/connection/transactional-connection.ts" sourceLine="39" packageName="@vendure/core" />
+<GenerationInfo sourceFile="packages/core/src/connection/transactional-connection.ts" sourceLine="40" packageName="@vendure/core" />
 
 The TransactionalConnection is a wrapper around the TypeORM `Connection` object which works in conjunction
 with the <a href='/reference/typescript-api/request/transaction-decorator#transaction'>Transaction</a> decorator to implement per-request transactions. All services which access the

+ 12 - 4
packages/email-plugin/src/handler/event-handler.ts

@@ -30,6 +30,7 @@ import {
  *   .on(OrderStateTransitionEvent)
  *   .filter(event => event.toState === 'PaymentSettled')
  *   .setRecipient(event => event.order.customer.emailAddress)
+ *   .setFrom('{{ fromAddress }}')
  *   .setSubject(`Order confirmation for #{{ order.code }}`)
  *   .setTemplateVars(event => ({ order: event.order }));
  * ```
@@ -78,13 +79,16 @@ import {
  *   .on(QuoteRequestedEvent)
  *   .setRecipient(event => event.customer.emailAddress)
  *   .setSubject(`Here's the quote you requested`)
+ *   .setFrom('{{ fromAddress }}')
  *   .setTemplateVars(event => ({ details: event.details }));
  * ```
  *
  * ### 2. Create the email template
  *
- * Next you need to make sure there is a template defined at `<app root>/static/email/templates/quote-requested/body.hbs`. The template
- * would look something like this:
+ * Next you need to make sure there is a template defined at `<app root>/static/email/templates/quote-requested/body.hbs`. The path
+ * segment `quote-requested` must match the string passed to the `EmailEventListener` constructor.
+ *
+ * The template would look something like this:
  *
  * ```handlebars
  * {{> header title="Here's the quote you requested" }}
@@ -144,7 +148,10 @@ export class EmailEventHandler<T extends string = string, Event extends EventWit
     };
     private _mockEvent: Omit<Event, 'ctx' | 'data'> | undefined;
 
-    constructor(public listener: EmailEventListener<T>, public event: Type<Event>) {}
+    constructor(
+        public listener: EmailEventListener<T>,
+        public event: Type<Event>,
+    ) {}
 
     /** @internal */
     get type(): T {
@@ -297,7 +304,8 @@ export class EmailEventHandler<T extends string = string, Event extends EventWit
      *   .setTemplateVars(event => ({
      *     order: event.order,
      *     payments: event.data,
-     *   }));
+     *   }))
+     *   // ...
      * ```
      */
     loadData<R>(