vintasend-pug 0.1.3 → 0.1.6

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
- export { PugEmailTemplateRenderer } from './pug-email-template-renderer';
1
+ export { PugEmailTemplateRenderer } from './pug-email-template-renderer';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PugEmailTemplateRenderer = void 0;
4
+ var pug_email_template_renderer_1 = require("./pug-email-template-renderer");
5
+ Object.defineProperty(exports, "PugEmailTemplateRenderer", { enumerable: true, get: function () { return pug_email_template_renderer_1.PugEmailTemplateRenderer; } });
@@ -0,0 +1,11 @@
1
+ import type { ContextGenerator } from 'vintasend/dist/services/notification-context-registry';
2
+ import type { BaseEmailTemplateRenderer, EmailTemplate } from 'vintasend/dist/services/notification-template-renderers/base-email-template-renderer';
3
+ import type { JsonObject } from 'vintasend/dist/types/json-values';
4
+ import type { Notification } from 'vintasend/dist/types/notification';
5
+ import type { Identifier } from 'vintasend/dist/types/identifier';
6
+ import pug from 'pug';
7
+ export declare class PugEmailTemplateRenderer<AvailableContexts extends Record<string, ContextGenerator>, NotificationIdType extends Identifier = Identifier, UserIdType extends Identifier = Identifier> implements BaseEmailTemplateRenderer<AvailableContexts, NotificationIdType, UserIdType> {
8
+ private options;
9
+ constructor(options?: pug.Options);
10
+ render(notification: Notification<AvailableContexts, NotificationIdType, UserIdType>, context: JsonObject): Promise<EmailTemplate>;
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PugEmailTemplateRenderer = void 0;
7
+ const pug_1 = __importDefault(require("pug"));
8
+ class PugEmailTemplateRenderer {
9
+ constructor(options = {}) {
10
+ this.options = options;
11
+ }
12
+ render(notification, context) {
13
+ const bodyTemplate = pug_1.default.compileFile(notification.bodyTemplate, this.options);
14
+ if (!notification.subjectTemplate) {
15
+ throw new Error('Subject template is required');
16
+ }
17
+ const subjectTemplate = pug_1.default.compileFile(notification.subjectTemplate, this.options);
18
+ return new Promise((resolve) => {
19
+ resolve({
20
+ subject: subjectTemplate(context || {}),
21
+ body: bodyTemplate(context || {}),
22
+ });
23
+ });
24
+ }
25
+ }
26
+ exports.PugEmailTemplateRenderer = PugEmailTemplateRenderer;
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "vintasend-pug",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "build": "tsc",
8
+ "prepublishOnly": "npm run build"
8
9
  },
9
- "author": "",
10
- "license": "ISC",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "author": "Hugo Bessa",
14
+ "license": "MIT",
11
15
  "dependencies": {
12
16
  "pug": "^3.0.3",
13
- "vintasend": "^0.1.3"
17
+ "vintasend": "^0.1.6"
14
18
  },
15
19
  "devDependencies": {
16
- "@types/pug": "^2.0.10"
20
+ "@types/pug": "^2.0.10",
21
+ "typescript": "^5.8.2"
17
22
  }
18
23
  }
package/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [{src,scripts}/**.{ts,json,js}]
4
- end_of_line = crlf
5
- charset = utf-8
6
- trim_trailing_whitespace = true
7
- insert_final_newline = true
8
- indent_style = space
9
- indent_size = 2
package/biome.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3
- "vcs": {
4
- "enabled": false,
5
- "clientKind": "git",
6
- "useIgnoreFile": false
7
- },
8
- "files": {
9
- "ignoreUnknown": false,
10
- "ignore": []
11
- },
12
- "formatter": {
13
- "enabled": true,
14
- "indentStyle": "space",
15
- "indentWidth": 2,
16
- "lineWidth": 100
17
- },
18
- "organizeImports": {
19
- "enabled": true
20
- },
21
- "linter": {
22
- "enabled": true,
23
- "rules": {
24
- "recommended": true
25
- }
26
- },
27
- "javascript": {
28
- "formatter": {
29
- "quoteStyle": "single",
30
- "semicolons": "always",
31
- "trailingCommas": "all"
32
- }
33
- }
34
- }
@@ -1,38 +0,0 @@
1
- import type { ContextGenerator } from 'vintasend/src/services/notification-context-registry';
2
- import type {
3
- BaseEmailTemplateRenderer,
4
- EmailTemplate,
5
- } from 'vintasend/src/services/notification-template-renderers/base-email-template-renderer';
6
- import type { JsonObject } from 'vintasend/src/types/json-values';
7
- import type { Notification } from 'vintasend/src/types/notification';
8
- import type { Identifier } from 'vintasend/src/types/identifier';
9
-
10
- import pug from 'pug';
11
-
12
- export class PugEmailTemplateRenderer<
13
- AvailableContexts extends Record<string, ContextGenerator>,
14
- NotificationIdType extends Identifier = Identifier,
15
- UserIdType extends Identifier = Identifier,
16
- > implements BaseEmailTemplateRenderer<AvailableContexts, NotificationIdType, UserIdType>
17
- {
18
- constructor(private options: pug.Options = {}) {}
19
-
20
- render(
21
- notification: Notification<AvailableContexts, NotificationIdType, UserIdType>,
22
- context: JsonObject,
23
- ): Promise<EmailTemplate> {
24
- const bodyTemplate = pug.compileFile(notification.bodyTemplate, this.options);
25
-
26
- if (!notification.subjectTemplate) {
27
- throw new Error('Subject template is required');
28
- }
29
-
30
- const subjectTemplate = pug.compileFile(notification.subjectTemplate, this.options);
31
- return new Promise((resolve) => {
32
- resolve({
33
- subject: subjectTemplate(context || {}),
34
- body: bodyTemplate(context || {}),
35
- });
36
- });
37
- }
38
- }