Repository navigation
feat(messaging): preview a saved notification template against sample values - #39622
Conversation
… values POST /api/v1/messaging/notification-templates/:id/preview renders a saved sys_notification_template row with renderNotification, the renderer the email channel sends with, against the caller's sample payload. The row is read under the caller's own context, never the system's; nothing is delivered and no row is written. Ledger row and conformance enumeration added. Claude-Session: https://claude.ai/code/session_01L9qibx73WZPdtRp9c7gYDR Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibx73WZPdtRp9c7gYDR Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 51 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 12 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4081624005226dd7fe1bb3e5ce5737baa0c7a3c8 && git checkout 4081624005226dd7fe1bb3e5ce5737baa0c7a3c8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin cefbc839cdf8a7ebd495b7126d781dff433127b3 53aea1c1427d1daa626d58d3644df82db95a04d7 && git checkout -B drift-repro cefbc839cdf8a7ebd495b7126d781dff433127b3 && git merge --no-ff 53aea1c1427d1daa626d58d3644df82db95a04d7
node scripts/docs-audit/affected-docs.mjs --json cefbc839cdf8a7ebd495b7126d781dff433127b3
|
…'s module The new messaging route module writes every body through the shared sendOk / sendError / sendServerFault pair, so it is declared with zero hand-built responses, like its four messaging siblings. Claude-Session: https://claude.ai/code/session_01L9qibx73WZPdtRp9c7gYDR Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibxZ1DSpavkJARmHCQF Contract reviewServed-tier: Face: the ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentNot owed on the declaration face. Implemented-by: VERDICT: PASS |
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibxZ1DSpavkJARmHCQF 席位核对L1-c · 2026-12-04T11:01Z · ACCEPT · head
|
|
repo:objectstack@os-tesla · os-tesla · session_01L9qibyrf8y7cWLVu7DMgBN Landing — zone ot-ux2 · 2026-12-04T11:02Z
|
Requested by Tesla · project thread
Fixes #39565
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
POST /api/v1/messaging/notification-templates/:id/preview(notification-template-preview-routes.ts). It reads one savedsys_notification_templaterow by id, under the caller's own execution context, and answersrenderNotification(row, { topic: row.topic, payload }): the same function and the same columns (TEMPLATE_RENDER_FIELDS, now shared with the store's send-time read) the email channel sends with. Answer:{ subject, html }for anhtml/mjmlrow,{ subject, text }formarkdown/text.{ payload }(optional; must be a JSON object). Query: closed empty set. Order before the row is read: caller (one composition) → held sign-in → anonymous → query → body → data engine → row.403code is relayed (PERMISSION_DENIED); a row the caller cannot see, or that does not exist, answers404 RECORD_NOT_FOUND.MessagingServicePluginbeside the other messaging doors (one call; the plugin file is over 1,000 lines, so the door lives in its own module). The "no HTTP server" warning names it.messaging-route-ledger.ts(server-only, consumer: the template form's preview pane, card 2 of the ruling), and the conformance test enumerates the new registrar.Ruling: 7405856818 on #39412 (item 2 = B). Maintainer ruling 6335348115 on #25082 respected: the door renders a SAVED row by id and refuses any body key but
payload(abodykey is refused400by name).Tests
Premise and pins, verbatim from the card:
How each is held:
pnpm dev -- --fresh, head3a33c7a3): anhtmlrow saved by the seeded admin through the data door; the same row read through the data door as a plain member of the same organization answers403 PERMISSION_DENIED. The door, as the admin, answered200with the rendered subject and escapedhtml; as the member,403 PERMISSION_DENIED. The store's loader is not called by the door (it reads the row itself, under the caller's context). Premise holds: no fork.a member without read on the template is refused with the gate's own PERMISSION_DENIED / 403(the gate's throw shape is plugin-security'sPermissionDeniedError).reads the row under the caller's own context, never the system's(the engine receives the caller's context object) andan administrator of another organization reads no row(two walled organizations on a realObjectQL+ better-sqlite3).sys_email/sys_notification/sys_notification_deliverytotals 1 / 4 / 4 before and after three previews; in-package, no engine write runs and every engine call touches only the template object.an html row answers the subject and html face the email channel sendsdrives the realcreateEmailChannelover the same engine with a capturing mail service and asserts the door's answer equals what the channel handed tosend, with hostile values (angle brackets, quotes, ampersand, apostrophe) entity-encoded in element text and in a quoted attribute; the markdown face equals the channel's verbatim text.messaging-route-ledger.conformance.test.tsenumeratesregisterNotificationTemplatePreviewRoutes.Readings
pnpm --filter @objectstack/service-messaging exec vitest run --maxWorkers=2at8866e046:Test Files 84 passed (84),Tests 1130 passed (1130).pnpm --filter @objectstack/service-messaging typecheckat8866e046: exit 0; the new test file is in the program (tsc --listFiles).scripts/ablation-replace.mjs, restored to the HEAD blob): 3 failed / 14 passed: the caller-context pin, the other-organization404and the member403.renderNotification): 5 failed / 12 passed, thehtmlequivalence pin among them. Restored to the HEAD blob.200with escaped html; member403 PERMISSION_DENIED; unknown id404 RECORD_NOT_FOUND; abodykey400 VALIDATION_ERROR;?locale=en400 VALIDATION_ERROR; anonymous401 UNAUTHENTICATED.Acceptance notes
is_active: truefilter or its locale ladder: a template is drafted before it is switched on, and the pane is on that row's form. A send never uses an inactive row; the answer does not say so (the form shows the row's own Active flag).payload.check:route-envelopeis red on this head and needs one declaration row for the new module inscripts/check-route-envelope.mjs({ responses: 0, ok: 0, err: 0 }, as its four messaging siblings carry). That file is outside the claim's file surface and the edit was refused in this session, so it is left to the seat: amend the surface and add the row, or dispatch it.Verification
First read (by risk):
packages/services/service-messaging/src/notification-template-preview-routes.ts: thefindOnecall under the caller's context and the refusal relay.packages/services/service-messaging/src/notification-template-preview-routes.integration.test.ts: the equivalence pin againstcreateEmailChannel.packages/services/service-messaging/src/template-renderer.ts:TEMPLATE_RENDER_FIELDSnow feeds the store's send-time read.Two-minute check:
pnpm --filter @objectstack/service-messaging exec vitest run src/notification-template-preview-routes.integration.test.tsshows 17 passed, including the html equivalence and the member refusal.L2 at CONTRACT_REVIEW_TIER is owed besides L1 (Clause-② yes, new route).
Generated by Claude Code