@classytic/arc-notifications 0.6.1 → 0.6.3
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.mjs +28 -3
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -340,14 +340,39 @@ function interpolate$1(template, vars) {
|
|
|
340
340
|
return v === void 0 || v === null ? `{${key}}` : String(v);
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
|
+
const UNRESOLVED = /\{\w+\}/;
|
|
344
|
+
/**
|
|
345
|
+
* Interpolate a MACHINE field — a link, an entity ref — and return `undefined`
|
|
346
|
+
* when any placeholder went unresolved.
|
|
347
|
+
*
|
|
348
|
+
* Leaving `{key}` verbatim is right for COPY: a literal `{orderNumber}` in a
|
|
349
|
+
* sentence is a visible bug someone fixes. It is wrong for a field something
|
|
350
|
+
* PARSES, because the placeholder becomes a plausible value:
|
|
351
|
+
*
|
|
352
|
+
* - `link: '/dashboard/orders?_id={orderId}'` filters for the literal string and
|
|
353
|
+
* returns zero rows, which reads as "the order was deleted".
|
|
354
|
+
* - `entityId: '{orderId}'` is the SAME identity for every order, so a feed that
|
|
355
|
+
* deduplicates on it collapses distinct orders into one notification — worse
|
|
356
|
+
* than not deduplicating.
|
|
357
|
+
*
|
|
358
|
+
* Absent degrades honestly: the link falls back to the unfiltered list, and a
|
|
359
|
+
* missing entity ref makes the feed skip dedup rather than dedupe wrongly.
|
|
360
|
+
*/
|
|
361
|
+
function interpolateRef(template, vars) {
|
|
362
|
+
const out = interpolate$1(template, vars);
|
|
363
|
+
return UNRESOLVED.test(out) ? void 0 : out;
|
|
364
|
+
}
|
|
343
365
|
/** Render a trigger's in-app template against event data + priority. */
|
|
344
366
|
function renderInApp(template, vars, priority = "normal") {
|
|
367
|
+
const link = template.link === void 0 ? void 0 : interpolateRef(template.link, vars);
|
|
368
|
+
const entityType = template.entityType === void 0 ? void 0 : interpolateRef(template.entityType, vars);
|
|
369
|
+
const entityId = template.entityId === void 0 ? void 0 : interpolateRef(template.entityId, vars);
|
|
345
370
|
return {
|
|
346
371
|
title: interpolate$1(template.title, vars),
|
|
347
372
|
message: interpolate$1(template.message, vars),
|
|
348
|
-
...
|
|
349
|
-
...
|
|
350
|
-
...
|
|
373
|
+
...link !== void 0 ? { link } : {},
|
|
374
|
+
...entityType !== void 0 ? { entityType } : {},
|
|
375
|
+
...entityId !== void 0 ? { entityId } : {},
|
|
351
376
|
priority
|
|
352
377
|
};
|
|
353
378
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/arc-notifications",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Notifications module for @classytic/arc — domain events → multi-channel notifications via @classytic/notifications, with DB-draftable templates, repo-backed delivery log, and a templates resource",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"prepublishOnly": "node ../../scripts/prepublish-gate.mjs"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@classytic/arc": ">=2.
|
|
32
|
+
"@classytic/arc": ">=2.38.0",
|
|
33
33
|
"@classytic/notifications": ">=2.5.0",
|
|
34
|
-
"@classytic/primitives": ">=0.
|
|
35
|
-
"@classytic/repo-core": ">=0.
|
|
34
|
+
"@classytic/primitives": ">=0.26.4",
|
|
35
|
+
"@classytic/repo-core": ">=0.26.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
38
38
|
"arc",
|