vintasend-managed-templates 1.0.0-alpha4 → 1.0.0-alpha6
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/README.md
CHANGED
|
@@ -150,9 +150,17 @@ calls the inner renderer's `renderFromTemplateContent`. So the inner renderer re
|
|
|
150
150
|
source in the `body` field**, where a file-based renderer would expect a name a loader resolves.
|
|
151
151
|
|
|
152
152
|
Every renderer in the VintaSend ecosystem implements `renderFromTemplateContent` — it is the seam
|
|
153
|
-
VintaSend already uses to render content it holds rather than loads — so `vintasend-
|
|
154
|
-
`vintasend-
|
|
155
|
-
|
|
153
|
+
VintaSend already uses to render content it holds rather than loads — so `vintasend-liquidjs`,
|
|
154
|
+
`vintasend-pug` and the rest work unchanged. A renderer of your own only needs to compile the
|
|
155
|
+
string it is handed rather than open a file.
|
|
156
|
+
|
|
157
|
+
**Pick an engine that cannot run code.** A managed template is source that anyone who can edit
|
|
158
|
+
templates — through a dashboard, through the templates management API — hands straight to the
|
|
159
|
+
engine. Liquid (`vintasend-liquidjs`) evaluates expressions and filters only; set its DoS limits
|
|
160
|
+
(`parseLimit`, `renderLimit`, `memoryLimit`) as well. Pug compiles a template to JavaScript and
|
|
161
|
+
runs it, `- code` lines included, so with `vintasend-pug` as the inner renderer, editing a
|
|
162
|
+
template is running code on the server. Keep Pug for templates that live in your repository, such
|
|
163
|
+
as the fallbacks above.
|
|
156
164
|
|
|
157
165
|
The email content is VintaSend's `EmailTemplateContent` plus one field:
|
|
158
166
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* when the key itself has nothing published — not when a stored template fails to compose — and
|
|
43
43
|
* only to a registered key. Once a version of the key is activated, sends use it.
|
|
44
44
|
*/
|
|
45
|
-
import type
|
|
45
|
+
import { type AnyNotification, type BaseLogger, type BaseNotificationTemplateRenderer, type BaseNotificationTypeConfig, type EmailTemplate, type EmailTemplateContent, type JsonObject } from 'vintasend';
|
|
46
46
|
import type { BaseTemplateManagerBackend } from './base-template-manager-backend.js';
|
|
47
47
|
import { TemplateComposer, type TemplateComposerOptions } from './composition.js';
|
|
48
48
|
import type { ManagedTemplate } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-template-renderer.d.ts","sourceRoot":"","sources":["../src/managed-template-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"managed-template-renderer.d.ts","sourceRoot":"","sources":["../src/managed-template-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAIhB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG7E;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,CAAC,YAAY,IAAI;IACtD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,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,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IAmB/F,wFAAwF;YAC1E,eAAe;IAU7B;;;OAGG;IACH,OAAO,CAAC,WAAW;YAOL,cAAc;CAoB7B;AA+BD,6FAA6F;AAC7F,qBAAa,4BAA4B,CACvC,MAAM,SAAS,0BAA0B,CACzC,SAAQ,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,2BAA2B,CAAC;IACnF,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,2BAA2B;CAO9E;AAED,6FAA6F;AAC7F,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,wEAAwE;AACxE,qBAAa,2BAA2B,CACtC,MAAM,SAAS,0BAA0B,CACzC,SAAQ,uBAAuB,CAAC,MAAM,EAAE,YAAY,EAAE,mBAAmB,CAAC;IAC1E,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGtE"}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* when the key itself has nothing published — not when a stored template fails to compose — and
|
|
43
43
|
* only to a registered key. Once a version of the key is activated, sends use it.
|
|
44
44
|
*/
|
|
45
|
+
import { log, logId, logLabel, } from 'vintasend';
|
|
45
46
|
import { TemplateComposer } from './composition.js';
|
|
46
47
|
import { ManagedTemplateNotFoundError } from './errors.js';
|
|
47
48
|
import { resolveActiveTemplate } from './lifecycle.js';
|
|
@@ -213,8 +214,7 @@ export class ManagedTemplateRenderer {
|
|
|
213
214
|
}
|
|
214
215
|
async renderFallback(notification, fallback, context) {
|
|
215
216
|
// The key and the notification id only: the context is the recipient's data.
|
|
216
|
-
this.logger?.info(`[ManagedTemplateRenderer] template '${notification.bodyTemplate}' has nothing published;
|
|
217
|
-
`rendering the registered fallback for notification ${String(notification.id)}.`);
|
|
217
|
+
this.logger?.info(log `[ManagedTemplateRenderer] template '${logLabel(notification.bodyTemplate)}' has nothing published; rendering the registered fallback for notification ${logId(notification.id)}.`);
|
|
218
218
|
const renderer = this.fallback?.renderer ?? this.renderer;
|
|
219
219
|
const rendered = await renderer.render({
|
|
220
220
|
...notification,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vintasend-managed-templates",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-alpha6",
|
|
4
4
|
"description": "Database-backed notification templates for VintaSend: versioning, a draft/active/inactive/archived lifecycle with an audit trail, tags, composition and filtering — on top of a storage seam you implement.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "git+https://github.com/vintasoftware/vintasend-ts-managed-templates.git"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vintasend": "^1.0.0-
|
|
29
|
+
"vintasend": "^1.0.0-alpha6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@biomejs/biome": "^2.5.10",
|