Repository navigation
fix(plugin-email): an option hole prints the option label in each recipient's language - #30781
Conversation
…a select value as its option label
`{{ stage | option:opportunity.stage }}` names the object and field the
value belongs to; the mail renderer hands `formatValue` a label table per
recipient locale, and a value outside the options prints as stored. The
mail grammar accepts it, the in-app dialect refuses it as an unknown
formatter, the email-template-hole-grammar rule judges the object and
field against the app's objects, and the spec's hole grammar sentence
quotes OPTION_ARGUMENT_RULE.
Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom
Co-authored-by: Claude <noreply@anthropic.com>
…erate the email_template reference page Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
…itten in backticks Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
…; option objects resolve on the object-reference ladder The `option` formatter throws optionTableRefusal's sentence when no label table for its object.field reached the render, as `currency` does with no tenant default, so the stored value is never printed where the grammar promises a label. The lint arm resolves the object on the object-reference ladder (own objects, the artifact's packages[] objects, platform-provided names with the field unjudged). OPTION_ARGUMENT_RULE states the multi-select reading. Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
…fixed object is advised, not refused The object-reference ladder's rung four: a name with a platform prefix that no rung above carries may still be registered by a package outside the app, so the mail grammar neither refuses nor judges it, and email-template-hole-grammar advises at warning at every door alike. Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
…ainst the live universe alone At the metadata publish door the objects are every object the deployment serves, so no sibling-package, platform-name or rung-four reading applies there: a name the live universe does not carry is refused, as a list view's unresolvable binding is. The CLI doors keep the ladder and its warning. Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
…package's closure gets the closure verdict At the publish door a write into a package is judged against the live universe narrowed to that package's closure, so an object missing there is outside the closure, refused with the declare-the-dependency remedy the list view door gives, not as an unknown object. The rule's options type is exported beside its finding type. Claude-Session: https://claude.ai/code/session_01L6bhgUtH2CXA8Qb8bDBRom Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czh582ycXhGxZNVPVi
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czh582ycXhGxZNVPVi
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 7 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 ed91d60f3cb735a4a239f3a1e3a82281cdeaaed8 && git checkout ed91d60f3cb735a4a239f3a1e3a82281cdeaaed8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3da9a4c132db7bf5ae1ca673930c1034e50d0195 6e5e8c9f9d87c0bfd16c1421a23d151bafda9cf4 && git checkout -B drift-repro 3da9a4c132db7bf5ae1ca673930c1034e50d0195 && git merge --no-ff 6e5e8c9f9d87c0bfd16c1421a23d151bafda9cf4
node scripts/docs-audit/affected-docs.mjs --json 3da9a4c132db7bf5ae1ca673930c1034e50d0195
|
|
domain:server#5 · os-elon-musk · session_016WV4cyvF7SP65frVFAYLv7 席位核对 · ACCEPTPR #30781 · head 维护者速读(席位校正)The body's six lines stand as written, read against the diff at this head. One correction: the body still says the diff carries #30727's commits until #30727 lands. #30727 has landed, so against 席位核对
|
Requested by Elon · project thread
Fixes #30730
Clause-②: no
Metadata-protocol: none
domain:server#5 card thread · session
session_016WV4czh582ycXhGxZNVPVi· branchclaude/project-thread-9ookwa(the card thread's platform-assigned branch, named in the re-posted claim on #30730). Built on PR #30727's head98f61ec6(branchclaude/project-thread-d8v0qv, the spec half), thenorigin/mainb3098661merged in. Until #30727 lands, this PR's diff againstmainalso carries #30727's commits; the plugin-email half is the last three commits.维护者速读
{{ stage | option:opportunity.stage }}现在真正按收件人的语言印出选项标签:同一封商机滞留通知,英文同事读到 Needs Analysis,中文同事读到「需求分析」;定时流程以系统身份发出也一样逐人翻译。optionformatter prints a select value as its option label in the recipient's language #30727)让这种写法通过保存校验,但邮件服务从不准备标签表,所以每次发送都以裸RangeError失败、一封也发不出;HotCRM 至今只能手写各语言标签表。option的模板;对象不存在、字段不存在、字段没有选项(含空选项列表)都整封拒发并报TEMPLATE_INVALID,不会发出错误内容。回滚即还原本 PR(之后这类模板回到发不出去的状态)。packages/plugins/plugin-email/src/option-label-table.ts(建表与拒绝);src/email-service.ts中resolveAndRenderTemplate新增的建表段(语言取发送的locale);src/template-engine.ts的option判定。pnpm --filter @objectstack/plugin-email exec vitest run src/template-option-formatter.render.test.ts src/template-option-labels.integration.test.ts,预期 2 个文件 20 例全绿,其中 zh-CN 收件人读到「需求分析」「赢单」,en-US 读到 Needs Analysis。optionformatter prints a select value as its option label in the recipient's language #30727 背靠背,规格半先落)。What changes
option-label-table.ts, new).buildOptionLabelTable(faces, locale, sources)collects theobject.fieldkeys the template'soptionholes name (parseMailHole(...).optionField), reads each named object's SERVED definition (IDataEngine.getObject, where a picklist-bound field carries its resolved list and itspicklistname), and builds, per key, stored value to label, with the i18n service's bundle laid over the option-declaring fields bytranslateObjectwith the samefallbackChain/defaultLocaleoptions. That is the step sequence of@objectstack/objectql'sreaderOptionLabels(formula-option-labels.ts), the path a formula'slabel()reads; see Acceptance notes for why it is taken through the same two published functions rather than imported. A test holds the two answers equal.locale(the recipient's; the messaging channels resolve it per recipient and pass it tosendTemplate/renderTemplate), trimmed as the template ladder reads it. Never the resolved row's locale and never an execution context's, so a scheduled flow running as the system still mails each recipient in their language. No locale reads the declared labels (ruling F, parameter 3).judgeMailHoleGrammar(face, { objects, liveUniverse: true })against the served objects the holes name: an object nothing serves (option-object-unknown), a field the object does not have (option-field-unknown), a field with no options (option-field-no-options). Each throwsTEMPLATE_INVALID, prefixed with the template and locale as every renderer refusal is, and the whole send is refused: nothing reaches the transport. Decided here (the carry note leaves it to this card): a field whose served option list is empty (options: [], which the formula side answers with a{}table and no refusal) is judged as a field with no options and refused the same way; the renderer also refuses a{}table handed to it directly.template-engine.ts).RenderOptions.optionLabels(new) is passed toformatValue. For anoptionhole the renderer asksoptionTableRefusalbeforeformatValueand prefixesTEMPLATE_INVALID, the way it askscurrencyDefaultRefusal; so a send with no table (a host with no data engine) is refusedTEMPLATE_INVALIDwith the formula's sentence, never a bareRangeError.email-service.ts,email-plugin.ts).EmailService.setOptionLabelSources(read)(new, not exported from the package index); the plugin wires it ininitto read the data engine (objectql, elsedata) and thei18nservice at each send (resolve where used: a service registered later is seen, nothing is recorded). The table is built once per send for the three faces, and only when a face has anoptionhole.@objectstack/plugin-emailpatch.Tests
src/template-option-formatter.render.test.ts(new), throughEmailService.renderTemplate/sendTemplatewith a recording transport:en-USand azh-CNrecipient each read their own label on all three faces (subject, HTML double and triple brace, text);dataobject built once, sent toen-US,zh-CN,en-USrecipients with nosentByand no organization, each reading their own label, the payload unchanged;zh-CN; a value outside the options prints as stored and a multi-select labels each value; a picklist-bound field reads the shared list's translation; the sources are asked once, only for the named object;TEMPLATE_INVALIDnaming the template and hole, with nothing sent; no sources wired isTEMPLATE_INVALIDwithoptionTableRefusal's sentence; the renderer refuses an empty table; a template with nooptionhole never asks for the sources;zh-CN,zh,en-USand no locale, the mail table's stage labels equal what a realObjectQLengine's formulalabel(record.stage)reads for the same object and i18n service.src/template-option-labels.integration.test.ts(new): the realEmailServicePluginbooted on anObjectKernelwithObjectQLPlugin, an app declaring the object and templates, and ani18nservice:en-USandzh-CNrecipients readNeeds Analysisand需求分析; a template naming an object the deployment does not serve is refusedTEMPLATE_INVALIDand nothing is sent.Acceptance notes
readerOptionLabels.@objectstack/objectqlis only a dev dependency of@objectstack/plugin-email, so no export offormula-option-labels.tsreaches it at runtime, and promoting it to a runtime dependency is apackage.json/ lockfile change outside this card's surface. Soformula-option-labels.tsis untouched (no export added), and the table takes the same steps through the same published functions (translateObjectfrom@objectstack/spec/system,declaresOptionsfrom@objectstack/formula), asservice-analytics'translateSelectOptionsalready does. The parity describe holds the answers equal; a later move of the shared steps into one module both packages depend on would delete the copy.sendTemplatethe way theemailchannel does after fan-out (one payload, the recipient'slocale, no user, no organization). The fan-out itself (service-automationnotify,service-messagingchannels) is outside this card's file surface and is not driven here; the channels already pass the recipient's locale (decision analysis 6658266694, reading 1).Clause-②: no,Metadata-protocol: none, re-derived from this diff. What an author can write is unchanged here: theoptionformatter, its grammar and its authoring checks are feat(spec,formula,lint): a mail template'soptionformatter prints a select value as its option label in the recipient's language #30727's (which declaresyes (widening)/added). This diff makes the runtime deliver what that grammar promises; no public export of the package changes (EmailServiceis not exported from the index) andIEmailServiceis unchanged.optionformatter, notlabel()in templateData (ruling F parameter 6, #30172) #30731 (the spec half's); nothing inskills/**changes here.Verification
At head
f5fee1af, after a whole-treeturbo run build(119/119 tasks,os-verify-lockVERDICT command-exit 0).Reproduction on PR #30727's head 98f61ec (before this change)
EmailService.sendTemplateof a template with{{ stage | option:opportunity.stage }},en-USandzh-CN: both threwRangeError: the hole option:opportunity.stage prints the option labels of opportunity.stage, and no label table for that field reached this render ..., outside theTEMPLATE_INVALIDvocabulary.98f61ec6): 2 failed / 2, the first with thatRangeError, the second "expected TEMPLATE_INVALID ... but got 'the hole option:mol_deal.stage prints…'".Package suite and typecheck
pnpm --filter @objectstack/plugin-email test && pnpm --filter @objectstack/plugin-email typecheckunderos-verify-lock: Test Files 50 passed (50), Tests 825 passed (825), VERDICT command-exit 0.eslint --no-inline-configon the six changed.tsfiles: exit 0.Ablation (scripts/ablation-replace.mjs; the tests import src, no dist involved)
buildOptionLabelTable(..., preferred || undefined, sources)to(..., undefined, sources)inemail-service.ts(anchor 1 to 0, blob61d0dba1tofa994bdd): 5 failed / 15 passed (zh-CN faces, the system-run fan-out, the out-of-options/multi-select zh-CN case, the picklist case, the booted en-US + zh-CN case). Restored: blob61d0dba1equals HEAD,git diff HEADempty.Derived gates (dispatch-gates --commands)
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackatf5fee1af: 105 families derived, every one run, every one exit 0 (after the whole-tree build, a deepened clone and the pinned teardown-shape commit fetched).dispatch-gates --ran: 105 derived, 105 run, 0 NOT-MEASURED, 0 UNRUN.pnpm lintexit 0,pnpm check:cli-command-idsexit 0,pnpm check:adr-symbol-anchorsexit 0.Generated by Claude Code