vintasend-pug 0.6.2 → 0.7.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.
@@ -1,4 +1,4 @@
1
- import type { BaseEmailTemplateRenderer, EmailTemplate } from 'vintasend/dist/services/notification-template-renderers/base-email-template-renderer';
1
+ import type { BaseEmailTemplateRenderer, EmailTemplateContent, EmailTemplate } from 'vintasend/dist/services/notification-template-renderers/base-email-template-renderer';
2
2
  import type { JsonObject } from 'vintasend/dist/types/json-values';
3
3
  import type { DatabaseNotification } from 'vintasend/dist/types/notification';
4
4
  import type { BaseNotificationTypeConfig } from 'vintasend/dist/types/notification-type-config';
@@ -13,6 +13,7 @@ export declare class PugEmailTemplateRenderer<Config extends BaseNotificationTyp
13
13
  */
14
14
  injectLogger(logger: BaseLogger): void;
15
15
  render(notification: DatabaseNotification<Config>, context: JsonObject): Promise<EmailTemplate>;
16
+ renderFromTemplateContent(notification: DatabaseNotification<Config>, templateContent: EmailTemplateContent, context: JsonObject): Promise<EmailTemplate>;
16
17
  }
17
18
  export declare class PugEmailTemplateRendererFactory<Config extends BaseNotificationTypeConfig> {
18
19
  create(options?: pug.Options): PugEmailTemplateRenderer<Config>;
@@ -1 +1 @@
1
- {"version":3,"file":"pug-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/pug-email-template-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EACd,MAAM,sFAAsF,CAAC;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAE9E,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,qBAAa,wBAAwB,CAAC,MAAM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IAsBnB,yBAAyB,CAC7B,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;CAiB1B;AAED,qBAAa,+BAA+B,CAAC,MAAM,SAAS,0BAA0B;IACpF,MAAM,CAAC,OAAO,GAAE,GAAG,CAAC,OAAY;CAGjC"}
@@ -29,6 +29,19 @@ export class PugEmailTemplateRenderer {
29
29
  resolve(rendered);
30
30
  });
31
31
  }
32
+ async renderFromTemplateContent(notification, templateContent, context) {
33
+ this.logger?.info(`Rendering email template from content for notification ${notification.id}`);
34
+ const bodyTemplate = pug.compile(templateContent.body, this.options);
35
+ if (!templateContent.subject) {
36
+ this.logger?.info('Subject template content missing');
37
+ throw new Error('Subject template is required');
38
+ }
39
+ const subjectTemplate = pug.compile(templateContent.subject, this.options);
40
+ return {
41
+ subject: subjectTemplate(context),
42
+ body: bodyTemplate(context),
43
+ };
44
+ }
32
45
  }
33
46
  export class PugEmailTemplateRendererFactory {
34
47
  create(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vintasend-pug",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "pug": "^3.0.3",
20
- "vintasend": "^0.6.2"
20
+ "vintasend": "^0.7.1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/jest": "^30.0.0",