email-generator.ts 929 B

1234567891011121314151617181920212223242526272829303132
  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 core plugins/EmailPlugin
  8. * @docsPage EmailGenerator
  9. * @docsWeight 0
  10. */
  11. export interface EmailGenerator<T extends string = any, E extends VendureEvent = any>
  12. extends InjectableStrategy {
  13. /**
  14. * @description
  15. * Any necessary setup can be performed here.
  16. */
  17. onInit?(options: EmailPluginOptions): void | Promise<void>;
  18. /**
  19. * @description
  20. * Given a subject and body from an email template, this method generates the final
  21. * interpolated email text.
  22. */
  23. generate(
  24. from: string,
  25. subject: string,
  26. body: string,
  27. templateVars: { [key: string]: any },
  28. ): Pick<EmailDetails, 'from' | 'subject' | 'body'>;
  29. }