vintasend-pug 0.4.0 → 0.4.7
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/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAChF,YAAY,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PugEmailTemplateRendererFactory = void 0;
|
|
4
|
-
var pug_email_template_renderer_1 = require("./pug-email-template-renderer");
|
|
5
|
-
Object.defineProperty(exports, "PugEmailTemplateRendererFactory", { enumerable: true, get: function () { return pug_email_template_renderer_1.PugEmailTemplateRendererFactory; } });
|
|
1
|
+
export { PugEmailTemplateRendererFactory } from './pug-email-template-renderer';
|
|
@@ -2,12 +2,19 @@ import type { BaseEmailTemplateRenderer, EmailTemplate } from 'vintasend/dist/se
|
|
|
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';
|
|
5
|
+
import type { BaseLogger } from 'vintasend/dist/services/loggers/base-logger';
|
|
5
6
|
import pug from 'pug';
|
|
6
7
|
export declare class PugEmailTemplateRenderer<Config extends BaseNotificationTypeConfig> implements BaseEmailTemplateRenderer<Config> {
|
|
7
8
|
private options;
|
|
9
|
+
private logger;
|
|
8
10
|
constructor(options: pug.Options);
|
|
11
|
+
/**
|
|
12
|
+
* Inject logger (called by VintaSend when logger exists)
|
|
13
|
+
*/
|
|
14
|
+
injectLogger(logger: BaseLogger): void;
|
|
9
15
|
render(notification: DatabaseNotification<Config>, context: JsonObject): Promise<EmailTemplate>;
|
|
10
16
|
}
|
|
11
17
|
export declare class PugEmailTemplateRendererFactory<Config extends BaseNotificationTypeConfig> {
|
|
12
18
|
create(options?: pug.Options): PugEmailTemplateRenderer<Config>;
|
|
13
19
|
}
|
|
20
|
+
//# sourceMappingURL=pug-email-template-renderer.d.ts.map
|
|
@@ -0,0 +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,SAAS,0BAA0B,CAC7E,YAAW,yBAAyB,CAAC,MAAM,CAAC;IAIhC,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,MAAM,CAA2B;gBAErB,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;CAqB1B;AAED,qBAAa,+BAA+B,CAAC,MAAM,SAAS,0BAA0B;IACpF,MAAM,CAAC,OAAO,GAAE,GAAG,CAAC,OAAY;CAGjC"}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PugEmailTemplateRendererFactory = exports.PugEmailTemplateRenderer = void 0;
|
|
7
|
-
const pug_1 = __importDefault(require("pug"));
|
|
8
|
-
class PugEmailTemplateRenderer {
|
|
1
|
+
import pug from 'pug';
|
|
2
|
+
export class PugEmailTemplateRenderer {
|
|
9
3
|
constructor(options) {
|
|
10
4
|
this.options = options;
|
|
5
|
+
this.logger = null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Inject logger (called by VintaSend when logger exists)
|
|
9
|
+
*/
|
|
10
|
+
injectLogger(logger) {
|
|
11
|
+
this.logger = logger;
|
|
11
12
|
}
|
|
12
13
|
async render(notification, context) {
|
|
13
|
-
|
|
14
|
+
this.logger?.info(`Rendering email template for notification ${notification.id}`);
|
|
15
|
+
this.logger?.info(`Compiling body template: ${notification.bodyTemplate}`);
|
|
16
|
+
const bodyTemplate = pug.compileFile(notification.bodyTemplate, this.options);
|
|
14
17
|
if (!notification.subjectTemplate) {
|
|
18
|
+
this.logger?.info('Subject template missing');
|
|
15
19
|
throw new Error('Subject template is required');
|
|
16
20
|
}
|
|
17
|
-
|
|
21
|
+
this.logger?.info(`Compiling subject template: ${notification.subjectTemplate}`);
|
|
22
|
+
const subjectTemplate = pug.compileFile(notification.subjectTemplate, this.options);
|
|
18
23
|
return new Promise((resolve) => {
|
|
19
|
-
|
|
24
|
+
const rendered = {
|
|
20
25
|
subject: subjectTemplate(context),
|
|
21
26
|
body: bodyTemplate(context),
|
|
22
|
-
}
|
|
27
|
+
};
|
|
28
|
+
this.logger?.info(`Email template rendered successfully for notification ${notification.id}`);
|
|
29
|
+
resolve(rendered);
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
class PugEmailTemplateRendererFactory {
|
|
33
|
+
export class PugEmailTemplateRendererFactory {
|
|
28
34
|
create(options = {}) {
|
|
29
35
|
return new PugEmailTemplateRenderer(options);
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
|
-
exports.PugEmailTemplateRendererFactory = PugEmailTemplateRendererFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vintasend-pug",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"pug": "^3.0.3",
|
|
18
|
-
"vintasend": "^0.4.
|
|
18
|
+
"vintasend": "^0.4.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/jest": "^
|
|
21
|
+
"@types/jest": "^30.0.0",
|
|
22
22
|
"@types/pug": "^2.0.10",
|
|
23
|
-
"jest": "^
|
|
24
|
-
"ts-jest": "^29.
|
|
25
|
-
"typescript": "^5.
|
|
23
|
+
"jest": "^30.2.0",
|
|
24
|
+
"ts-jest": "^29.4.6",
|
|
25
|
+
"typescript": "^5.9.3"
|
|
26
26
|
}
|
|
27
27
|
}
|