Repository navigation
Commit f5e6709
fix(service-messaging): declare currency on EmailSenderSurface template inputs (#28523)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XPJsT4EEFrtYn1kzHjMVaWz)_
Fixes #27754
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- **改了什么**:消息服务对外导出的 `EmailSenderSurface` 类型里,`sendTemplate` 和
`renderTemplate` 的入参补上可选的 `currency`
字段。邮件渠道和站内信渠道早就在传这个字段(租户默认币种,以及读取失败后试渲染用的 `XXX`),现在改成按名字赋值,不再靠对象展开塞进去。
- **为什么改**:#27730 的合约复核(6509670944,S3)指出:字段是靠展开写法传的,TypeScript
不检查,类型上看不出渠道会传币种,两边任何一边改名都不会编译报错。
- **风险与回滚**:只是类型扩面,运行时行为不变:没有默认币种时仍然不带 `currency`
键,有就原样传。字段可选,已有的第三方实现不用改。回滚即 revert。
-
**先看**:`packages/services/service-messaging/src/email-channel.ts`(接口两处声明与
`sendInput`
的赋值);`packages/services/service-messaging/src/inbox-channel.ts`(`renderInput`
的赋值)。
- **两分钟验证**:`pnpm --filter @objectstack/service-messaging exec vitest
run src/template-tenant-currency.test.ts` → 22 passed,其中「无默认币种时不带
`currency` 键」的断言原样通过。
- **需要你做的**:无,席位落地(发布类型扩面,席位先做合约评审)。
## What changes
- **`EmailSenderSurface` is published.**
`packages/services/service-messaging/src/index.ts:64` re-exports it
(`export type { EmailChannelOptions, EmailSenderSurface } from
'./email-channel.js'`), and the package is public
(`@objectstack/service-messaging` 18.2.0, `files: ["dist", …]`). The
card's "not re-exported" was measured false, so this is `Clause-②: yes
(widening)` per the order's ruling: one optional member on each of two
input types, nothing refused that compiled before.
- **The declarations.** `sendTemplate`'s and `renderTemplate`'s inputs
gain `currency?: string`, documented as the structural mirror of
`RenderTemplateInput.currency` (the default a no-argument `{{ amount |
currency }}` hole formats in, #26939).
- **The call sites name the key.** The email channel builds its
`sendTemplate` input as a typed `TemplateSendInput` and sets `if
(currency) sendInput.currency = currency;`; the inbox channel does the
same with `TemplateRenderInput` for `renderTemplate`. Both aliases are
module-private (each is the parameter type of the surface's own member),
so no export name is added. The trial render on both channels writes
`currency: probe` as a plain property instead of `...{ currency: probe
}`.
- **Why an assignment and not `currency,` in the literal.** "No default
sends no key" is pinned: `template-tenant-currency.test.ts` asserts
`not.toHaveProperty('currency')` at lines 111, 161, 253, 313 and 378,
and a literal `currency: undefined` is an own property. A conditional
spread (`...(currency ? { currency } : {})`) keeps the key out but is
exactly the shape TypeScript does not check: measured in a scratch file
under `--strict`, a spread of `{ currency }` (conditional or not) into a
call whose input names `currencyX` compiles, while the plain property
and the property assignment both fail. So the key is set by name, after
the literal.
- **No behaviour change.** Same keys sent in every case (absent stays
absent, a default is passed as is, the probe passes `XXX`); only the
`sendTemplate` input's key order moves (`currency` now after
`organizationId`), which no caller or test reads.
## Tests
- **Pinned by typecheck, as an ablation (six legs).** Committed first
(`88a517da`), each leg through `node scripts/ablation-replace.mjs`
(anchor must hit, blob proven moved, restored to the HEAD blob, `git
diff HEAD` empty after each), each running `tsc --noEmit` in
`packages/services/service-messaging`:
- L1 type side, `sendTemplate`'s `currency?` renamed `currencyCode?` →
`email-channel.ts(438,41): error TS2339: Property 'currency' does not
exist on type …`, tsc exit 2.
- L2 channel side, `sendInput.currency` renamed →
`email-channel.ts(438,41): error TS2551: Property 'currencyCode' does
not exist … Did you mean 'currency'?`, exit 2.
- L3 type side, `renderTemplate`'s `currency?` renamed → three errors:
`email-channel.ts(466,33)` TS2353 (email probe),
`inbox-channel.ts(220,43)` TS2339 (inbox first render),
`inbox-channel.ts(240,33)` TS2353 (inbox probe), exit 2.
- L4 channel side, `renderInput.currency` renamed →
`inbox-channel.ts(220,43): error TS2551`, exit 2.
- L5 channel side, inbox probe `currency: probe` renamed →
`inbox-channel.ts(240,33): error TS2561`, exit 2.
- L6 channel side, email probe `currency: probe` renamed →
`email-channel.ts(466,33): error TS2561`, exit 2.
- Every restore: blob after restore == blob at HEAD (`c1d8f83e1eb7`
email, `53d4cbd196b9` inbox).
- **Existing suites, unchanged and green.** On `88a517da` under
`os-verify-lock`: `pnpm --filter @objectstack/service-messaging
typecheck` and `test` → VERDICT command-exit 0, Test Files 62 passed
(62), Tests 759 passed (759). No test file is edited.
## Acceptance notes
- The probe calls keep their other conditional spreads (`data`,
`locale`, `organizationId`); the card and the order scope this to
`currency`.
## Verification
All readings on head `88a517da` (the only commit; base `origin/main`
`23d1303d`).
- **Derived gates.** `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack` named 56 commands; each run with its
exit code captured before any pipe, then reconciled: `✓ dispatch-gates
--ran: 56 derived famil(ies) accounted for — 55 run, 1 NOT-MEASURED (1
DERIVED from a recorded exit 3).`
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` (exit 3, PREREQUISITE
NOT MET: needs every package's `dist`, a full build). CI's lint job runs
it.
- `node scripts/check-plugin-teardown-shape.mjs --self-test` first
answered exit 3 (shallow clone, positive control unreachable); after
`git fetch --depth=1 origin 621a487…` it answered exit 0, 48 cases
pass.
- `pnpm check:i18n` first answered exit 3 (CLI not built); after the
gate's own one-command prerequisite build (under the lock, VERDICT
command-exit 0) it answered exit 0: `check-i18n-bundles: OK (10
package(s) — all bundles in sync, no undeclared authoring keys).`
- The four roster gates marked as rostered under a touched directory
also ran, each exit 0: `check:authz-resolver`, `check:changeset-fixed`,
`check:error-code-casing`, `check:filter-alias-parity`.
- **Lint.** `pnpm exec eslint --no-inline-config
packages/services/service-messaging` → exit 0, no findings.
- **Package.** `pnpm --filter @objectstack/service-messaging typecheck`
+ `test` under `os-verify-lock` (after the `^...` closure build, VERDICT
command-exit 0) → VERDICT command-exit 0; 62 files, 759 tests passed.
- **Changeset.** `patch` on `@objectstack/service-messaging`: the
changed type ships in `dist/index.d.ts` (the entry re-exports it), so
`skip-changeset` does not fit. `Clause-②: yes (widening)` and
`Metadata-protocol: none` are line-initial here and in
`.changeset/27754-email-sender-surface-currency.md`. No
`packages/spec/**`.
- **Open PRs touching these files.** None of the 19 open PRs touches
`email-channel.ts` or `inbox-channel.ts` (each PR's `/files` read before
`pr_create`).
- **CI.** Every family CI runs is read from this PR's check-runs by the
seat.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mAGmMrWhFqtKfMqYt)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent bff315c commit f5e6709
3 files changed
Lines changed: 58 additions & 20 deletions
File tree
- .changeset
- packages/services/service-messaging/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
| |||
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| 85 | + | |
| 86 | + | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| |||
408 | 421 | | |
409 | 422 | | |
410 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
411 | 439 | | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
424 | 443 | | |
425 | 444 | | |
426 | 445 | | |
| |||
444 | 463 | | |
445 | 464 | | |
446 | 465 | | |
447 | | - | |
| 466 | + | |
448 | 467 | | |
449 | 468 | | |
450 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
206 | 209 | | |
207 | 210 | | |
208 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
209 | 221 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 222 | + | |
216 | 223 | | |
217 | 224 | | |
218 | 225 | | |
| |||
230 | 237 | | |
231 | 238 | | |
232 | 239 | | |
233 | | - | |
| 240 | + | |
234 | 241 | | |
235 | 242 | | |
236 | 243 | | |
| |||
0 commit comments