vintasend-pug 1.0.0-alpha4 → 1.0.0-alpha5
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pug-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/pug-email-template-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EACV,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"pug-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/pug-email-template-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,EACV,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;AAGnB,qBAAa,wBAAwB,CAAC,MAAM,SAAS,0BAA0B,CAC7E,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAIhC,OAAO,CAAC,OAAO;IAF3B,MAAM,EAAE,UAAU,GAAG,IAAI,CAAQ;gBAEb,OAAO,EAAE,GAAG,CAAC,OAAO;IAExC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIhC,MAAM,CACV,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;IAwBnB,yBAAyB,CAC7B,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,aAAa,CAAC;CAmB1B;AAED,qBAAa,+BAA+B,CAAC,MAAM,SAAS,0BAA0B;IACpF,MAAM,CAAC,OAAO,GAAE,GAAG,CAAC,OAAY;CAGjC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import pug from 'pug';
|
|
2
|
+
import { log, logId, logLabel } from 'vintasend';
|
|
2
3
|
export class PugEmailTemplateRenderer {
|
|
3
4
|
constructor(options) {
|
|
4
5
|
this.options = options;
|
|
@@ -11,29 +12,29 @@ export class PugEmailTemplateRenderer {
|
|
|
11
12
|
this.logger = logger;
|
|
12
13
|
}
|
|
13
14
|
async render(notification, context) {
|
|
14
|
-
this.logger?.info(`Rendering email template for notification ${notification.id}`);
|
|
15
|
-
this.logger?.info(`Compiling body template: ${notification.bodyTemplate}`);
|
|
15
|
+
this.logger?.info(log `Rendering email template for notification ${logId(notification.id)}`);
|
|
16
|
+
this.logger?.info(log `Compiling body template: ${logLabel(notification.bodyTemplate)}`);
|
|
16
17
|
const bodyTemplate = pug.compileFile(notification.bodyTemplate, this.options);
|
|
17
18
|
if (!notification.subjectTemplate) {
|
|
18
|
-
this.logger?.info(
|
|
19
|
+
this.logger?.info(log `Subject template missing`);
|
|
19
20
|
throw new Error('Subject template is required');
|
|
20
21
|
}
|
|
21
|
-
this.logger?.info(`Compiling subject template: ${notification.subjectTemplate}`);
|
|
22
|
+
this.logger?.info(log `Compiling subject template: ${logLabel(notification.subjectTemplate)}`);
|
|
22
23
|
const subjectTemplate = pug.compileFile(notification.subjectTemplate, this.options);
|
|
23
24
|
return new Promise((resolve) => {
|
|
24
25
|
const rendered = {
|
|
25
26
|
subject: subjectTemplate(context),
|
|
26
27
|
body: bodyTemplate(context),
|
|
27
28
|
};
|
|
28
|
-
this.logger?.info(`Email template rendered successfully for notification ${notification.id}`);
|
|
29
|
+
this.logger?.info(log `Email template rendered successfully for notification ${logId(notification.id)}`);
|
|
29
30
|
resolve(rendered);
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
async renderFromTemplateContent(notification, templateContent, context) {
|
|
33
|
-
this.logger?.info(`Rendering email template from content for notification ${notification.id}`);
|
|
34
|
+
this.logger?.info(log `Rendering email template from content for notification ${logId(notification.id)}`);
|
|
34
35
|
const bodyTemplate = pug.compile(templateContent.body, this.options);
|
|
35
36
|
if (!templateContent.subject) {
|
|
36
|
-
this.logger?.info(
|
|
37
|
+
this.logger?.info(log `Subject template content missing`);
|
|
37
38
|
throw new Error('Subject template is required');
|
|
38
39
|
}
|
|
39
40
|
const subjectTemplate = pug.compile(templateContent.subject, this.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pug-inline-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/pug-inline-email-template-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"pug-inline-email-template-renderer.d.ts","sourceRoot":"","sources":["../src/pug-inline-email-template-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,yBAAyB,EACzB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACX,MAAM,WAAW,CAAC;AAGnB;;;;;;GAMG;AACH,qBAAa,8BAA8B,CAAC,MAAM,SAAS,0BAA0B,CACnF,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAE5C,OAAO,CAAC,SAAS,CAAyB;IAC1C,MAAM,EAAE,UAAU,GAAG,IAAI,CAAQ;gBAErB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItD;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAIhC,MAAM,CACV,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAkDvC,yBAAyB,CAC7B,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,EAC1C,eAAe,EAAE,oBAAoB,EACrC,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAqC9C;AAED,qBAAa,qCAAqC,CAAC,MAAM,SAAS,0BAA0B;IAC1F,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,8BAA8B,CAAC,MAAM,CAAC;CAG3F"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as pug from 'pug';
|
|
2
|
+
import { log, logError, logId, logLabel } from 'vintasend';
|
|
2
3
|
/**
|
|
3
4
|
* Custom email template renderer that compiles Pug templates from strings
|
|
4
5
|
* instead of reading from file paths.
|
|
@@ -42,7 +43,7 @@ export class PugInlineEmailTemplateRenderer {
|
|
|
42
43
|
}
|
|
43
44
|
catch (error) {
|
|
44
45
|
if (this.logger) {
|
|
45
|
-
this.logger.error(
|
|
46
|
+
this.logger.error(log `[PugInlineEmailTemplateRenderer] Error rendering body template ${logLabel(bodyTemplateKey)} for notification ${logId(notification.id)}: ${logError(error)}`);
|
|
46
47
|
}
|
|
47
48
|
throw error;
|
|
48
49
|
}
|
|
@@ -54,14 +55,14 @@ export class PugInlineEmailTemplateRenderer {
|
|
|
54
55
|
}
|
|
55
56
|
catch (error) {
|
|
56
57
|
if (this.logger) {
|
|
57
|
-
this.logger.error(
|
|
58
|
+
this.logger.error(log `[PugInlineEmailTemplateRenderer] Error rendering subject template ${logLabel(subjectTemplateKey)} for notification ${logId(notification.id)}: ${logError(error)}`);
|
|
58
59
|
}
|
|
59
60
|
throw error;
|
|
60
61
|
}
|
|
61
62
|
return { subject, body };
|
|
62
63
|
}
|
|
63
64
|
async renderFromTemplateContent(notification, templateContent, context) {
|
|
64
|
-
this.logger?.info(`[PugInlineEmailTemplateRenderer] Rendering template from content for notification ${notification.id}`);
|
|
65
|
+
this.logger?.info(log `[PugInlineEmailTemplateRenderer] Rendering template from content for notification ${logId(notification.id)}`);
|
|
65
66
|
let body;
|
|
66
67
|
try {
|
|
67
68
|
const bodyTemplate = pug.compile(templateContent.body);
|
|
@@ -69,7 +70,7 @@ export class PugInlineEmailTemplateRenderer {
|
|
|
69
70
|
}
|
|
70
71
|
catch (error) {
|
|
71
72
|
if (this.logger) {
|
|
72
|
-
this.logger.error(
|
|
73
|
+
this.logger.error(log `[PugInlineEmailTemplateRenderer] Error rendering body template content for notification ${logId(notification.id)}: ${logError(error)}`);
|
|
73
74
|
}
|
|
74
75
|
throw error;
|
|
75
76
|
}
|
|
@@ -83,7 +84,7 @@ export class PugInlineEmailTemplateRenderer {
|
|
|
83
84
|
}
|
|
84
85
|
catch (error) {
|
|
85
86
|
if (this.logger) {
|
|
86
|
-
this.logger.error(
|
|
87
|
+
this.logger.error(log `[PugInlineEmailTemplateRenderer] Error rendering subject template content for notification ${logId(notification.id)}: ${logError(error)}`);
|
|
87
88
|
}
|
|
88
89
|
throw error;
|
|
89
90
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vintasend-pug",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-alpha5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/vintasoftware/vintasend-pug.git"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"pug": "^3.0.3",
|
|
32
|
-
"vintasend": "^1.0.0-
|
|
32
|
+
"vintasend": "^1.0.0-alpha5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@biomejs/biome": "^2.5.10",
|