From f48717397cb1245a471d87fe91c59c4d148cc96f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 21:01:10 +0000 Subject: [PATCH 1/2] feat(service-messaging): a keyed notification param can be a list, read in the recipient's language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A keyed param resolved through `t(key, locale)` with no params, so a hole held one text or one hole-free key. The approval submitter's notice could spell a slate of slots per reader only with one derived sentence per slate size (2 to 8, #36463), and a larger slate named its slots in English inside the reader's sentence. `keyedText.params` now accepts `{ list, separator }`: each item a catalog sentence with its own scalar params, rendered per recipient (else its fallback), joined by the separator entry. emit() refuses a malformed list before writing; a stored malformed one is delivered as its literal. The approval notice spells a slate of two or more slots through it, so every slot reads in the reader's language whatever the slate's size. The 2–8 slot sentences stay in the packs for notices already delivered. Claude-Session: https://claude.ai/code/session_01L6bhgU7eeqHgQrtv5CeJK6 Co-authored-by: Claude --- .changeset/36853-notification-list-param.md | 13 ++ ...min-rescue-named-slate.integration.test.ts | 31 +++- .../src/approval-notification-text.ts | 24 ++- .../src/no-approver-note.test.ts | 73 ++++++-- .../plugin-approvals/src/no-approver-note.ts | 57 ++++-- .../services/service-messaging/src/index.ts | 4 + ...notification-text-list-param-36853.test.ts | 130 +++++++++++++ .../src/notification-text.ts | 172 +++++++++++++++--- 8 files changed, 438 insertions(+), 66 deletions(-) create mode 100644 .changeset/36853-notification-list-param.md create mode 100644 packages/services/service-messaging/src/notification-text-list-param-36853.test.ts diff --git a/.changeset/36853-notification-list-param.md b/.changeset/36853-notification-list-param.md new file mode 100644 index 00000000000..e3c3a0f823d --- /dev/null +++ b/.changeset/36853-notification-list-param.md @@ -0,0 +1,13 @@ +--- +'@objectstack/service-messaging': patch +'@objectstack/plugin-approvals': patch +--- + +feat(service-messaging): a keyed notification param can be a list, each item rendered in the recipient's language; the approval "no one can approve" notice names a slate of any size in the reader's language + +Clause-②: yes (widening) +Metadata-protocol: none + +- `EmitInput.keyedText.params` accepts a new value shape, `{ list, separator }`. Each `list` item is `{ key, params?, fallback }`: a catalog sentence with its own `{{hole}}` params, rendered per recipient. An item param can be text, `{ key, fallback }` or `{ object, fallback }`, but not another list. A sentence with no entry falls back to the item's `fallback`. The rendered items are joined by the `separator` entry (`{ key, fallback }`), so a list of any length reads in one language. A list holds 1 to `NOTIFICATION_LIST_PARAM_MAX_ITEMS` (100) items, and `emit()` refuses a malformed one before it writes anything. The new types are exported: `NotificationListParam`, `NotificationListItem` and `NotificationScalarParam`. Every existing param shape renders as before. +- The approval submitter's notice for a request no one else can approve now names a slate of two or more slots through this list param, one `approvalNoApproverSlot` clause per slot, joined by `approvalNoApproverSlotSeparator`. Before, a slate of more than 8 slots named its slots in English inside a zh-CN, ja-JP or other non-English sentence. Now every slot reads in the recipient's language. The literal English body is unchanged. +- The `approvalNoApproverHoldingSlots2` to `…Slots8` sentences stay in the packs, because notices already delivered carry those keys and are rendered again whenever the inbox is read. diff --git a/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts b/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts index 05dd5c1ec57..264dc28c6ce 100644 --- a/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts +++ b/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts @@ -657,7 +657,8 @@ describe('an empty admin_rescue slate opens on the organization\'s administrator { type: 'position', value: 'sales_manager' }, { type: 'position', value: 'treasury' }, ]); const [notice] = told.filter((e) => e.source?.id === row.id); - expect(notice.keyedText.bodyKey).toBe('messages.approvalNoApproverHoldingSlots2'); + // [#36853] The slate rides `{{who}}` as a list param, one keyed clause per slot. + expect(notice.keyedText.bodyKey).toBe('messages.approvalNoApproverHolding'); expect(notice.payload.body).toBe(holding("position 'Sales Manager', position 'treasury'")); const renderer = new NotificationTextRenderer({ getData: () => undefined, getI18n: () => i18n as any }); const zh = renderer.render(notice.keyedText, notice.payload, 'zh-CN').body; @@ -669,6 +670,34 @@ describe('an empty admin_rescue slate opens on the organization\'s administrator .toBe(holding("position 'Sales Manager', position 'treasury'")); }); + // [#36853] A slate larger than the 2–8 slot sentences #36463 spelled: the + // real renderer reads every slot in zh-CN, no English approver type and no + // English separator, and the literal body is the English the row stores. + it('the submitter\'s notice: a slate of nine slots reads entirely in zh-CN through the real renderer', async () => { + const slate = [ + { type: 'position', value: 'sales_manager' }, + ...Array.from({ length: 4 }, (_, i) => ({ type: 'team', value: `团队${i + 1}` })), + ...Array.from({ length: 4 }, (_, i) => ({ type: 'department', value: `部门${i + 1}` })), + ]; + const row = await openLabelled('none_notice_nine', slate); + const [notice] = told.filter((e) => e.source?.id === row.id); + expect(notice.keyedText.bodyKey).toBe('messages.approvalNoApproverHolding'); + expect(notice.payload.body).toBe(holding([ + "position 'Sales Manager'", + ...Array.from({ length: 4 }, (_, i) => `team '团队${i + 1}'`), + ...Array.from({ length: 4 }, (_, i) => `department '部门${i + 1}'`), + ].join(', '))); + const renderer = new NotificationTextRenderer({ getData: () => undefined, getI18n: () => i18n as any }); + const zh = renderer.render(notice.keyedText, notice.payload, 'zh-CN').body; + expect(zh).toBe(holdingZh([ + '岗位「销售经理」', + ...Array.from({ length: 4 }, (_, i) => `团队「团队${i + 1}」`), + ...Array.from({ length: 4 }, (_, i) => `部门「部门${i + 1}」`), + ].join('、'))); + expect(zh).not.toMatch(/[A-Za-z]/); + expect(renderer.render(notice.keyedText, notice.payload, 'en').body).toBe(notice.payload.body); + }); + it('CONTROL: a note written before the slot was stored renders exactly as before', async () => { const row = await open('none_legacy', UNSTAFFED, {}, LEADERLESS_ORG); // The stored shape of a note written before #36035: `who`, pre-composed. diff --git a/packages/plugins/plugin-approvals/src/approval-notification-text.ts b/packages/plugins/plugin-approvals/src/approval-notification-text.ts index 8609f9063a4..93063a56b41 100644 --- a/packages/plugins/plugin-approvals/src/approval-notification-text.ts +++ b/packages/plugins/plugin-approvals/src/approval-notification-text.ts @@ -48,11 +48,28 @@ import { enMessages, type ApprovalMessageId } from './translations/messages.js'; * back to, or [#35384] an object's label by the object's name with the text it * falls back to (the messaging service's `NotificationObjectLabelParam`). */ -export type ApprovalTextParam = +export type ApprovalTextParam = ApprovalScalarParam | ApprovalListParam; + +/** [#36853] A value that fills one hole by itself (the messaging service's `NotificationScalarParam`). */ +export type ApprovalScalarParam = | string | { readonly key: string; readonly fallback: string } | ApprovalObjectLabelParam; +/** + * [#36853] The structural mirror of the messaging service's + * `NotificationListParam`: a list of catalog sentences, each with its own + * params, rendered per recipient and joined by the `separator` entry. + */ +export interface ApprovalListParam { + readonly list: readonly { + readonly key: string; + readonly params?: Readonly>; + readonly fallback: string; + }[]; + readonly separator: { readonly key: string; readonly fallback: string }; +} + /** [#35384] The structural mirror of the messaging service's `NotificationObjectLabelParam`. */ export interface ApprovalObjectLabelParam { /** The object's API name, never its label. */ @@ -123,7 +140,10 @@ export function interpolate(template: string, params: Readonly { const param = params[name]; if (param === undefined) return hole; - return typeof param === 'string' ? param : param.fallback; + if (typeof param === 'string') return param; + // [#36853] A list's literal is its items' fallbacks, joined by the separator's. + if ('list' in param) return param.list.map((item) => item.fallback).join(param.separator.fallback); + return param.fallback; }); } diff --git a/packages/plugins/plugin-approvals/src/no-approver-note.test.ts b/packages/plugins/plugin-approvals/src/no-approver-note.test.ts index 874db4e51e0..8069b49717f 100644 --- a/packages/plugins/plugin-approvals/src/no-approver-note.test.ts +++ b/packages/plugins/plugin-approvals/src/no-approver-note.test.ts @@ -12,7 +12,7 @@ import { describe, it, expect } from 'vitest'; import { noApproverNoteText, noApproverNotice, noApproverWho, submitterRefusalUserMessage } from './no-approver-note.js'; -import { interpolate, type ApprovalTextParam } from './approval-notification-text.js'; +import { interpolate, type ApprovalScalarParam, type ApprovalTextParam } from './approval-notification-text.js'; import type { ApprovalSentenceRender } from './admin-rescue-note.js'; import { approvalMessages, enMessages, NO_APPROVER_NOTICE_MAX_SLOTS } from './translations/messages.js'; @@ -31,7 +31,10 @@ const renderIn = (locale: Locale, drop: string[] = []): ApprovalSentenceRender = * A notice's body as the messaging service renders it for a recipient in * `locale` (`NotificationTextRenderer`): a keyed param is its key in that * locale, a `messages.*` key from the catalog and a `positions.*` key from - * `pack`, else its fallback; then the body's template is filled. + * `pack`, else its fallback; [#36853] a list param is each item's sentence + * filled with its own params the same way, joined by the separator entry; + * then the body's template is filled. The real renderer's half is + * `admin-rescue-named-slate.integration.test.ts`. */ const deliveredIn = ( locale: Locale, @@ -39,13 +42,27 @@ const deliveredIn = ( pack: Record = {}, ): string => { const catalog = approvalMessages[locale] as Record; + const keyed = (key: string): string | undefined => + key.startsWith('messages.') ? catalog[key.slice('messages.'.length)] : pack[key]; + const scalar = (param: ApprovalScalarParam): string => { + if (typeof param === 'string') return param; + // [#35384] An object-label param is resolved off the object's metadata, which no notice here names. + if ('object' in param) return param.fallback; + return keyed(param.key) ?? param.fallback; + }; const params: Record = {}; for (const [name, param] of Object.entries(notice.params)) { - if (typeof param === 'string') { params[name] = param; continue; } - // [#35384] An object-label param is resolved off the object's metadata, which no notice here names. - if ('object' in param) { params[name] = param.fallback; continue; } - const looked = param.key.startsWith('messages.') ? catalog[param.key.slice('messages.'.length)] : pack[param.key]; - params[name] = looked ?? param.fallback; + if (typeof param === 'object' && 'list' in param) { + params[name] = param.list.map((item) => { + const sentence = keyed(item.key); + if (sentence === undefined) return item.fallback; + const own: Record = {}; + for (const [hole, value] of Object.entries(item.params ?? {})) own[hole] = scalar(value); + return interpolate(sentence, own); + }).join(keyed(param.separator.key) ?? param.separator.fallback); + continue; + } + params[name] = scalar(param); } return interpolate(catalog[notice.id], params); }; @@ -135,18 +152,32 @@ describe('[#36308] the submitter\'s notice', () => { }); }); -describe('[#36463] the submitter\'s notice names several slots in the reader\'s language', () => { +describe('[#36463 · #36853] the submitter\'s notice names several slots in the reader\'s language', () => { const declared = (name: string) => (name === 'legal' ? 'Legal Counsel' : undefined); - it('a slate of two slots spells each inline, keyed, in the slate\'s order', () => { + it('a slate of two slots rides `{{who}}` as a list: one keyed clause per slot, in the slate\'s order', () => { const notice = noApproverNotice({ slots: ['position:legal', 'team:ops'] }, declared); expect(notice).toEqual({ - id: 'approvalNoApproverHoldingSlots2', + id: 'approvalNoApproverHolding', params: { - type1: { key: 'messages.approvalApproverTypePosition', fallback: 'position' }, - value1: { key: 'positions.legal.label', fallback: 'Legal Counsel' }, - type2: { key: 'messages.approvalApproverTypeTeam', fallback: 'team' }, - value2: 'ops', + who: { + list: [ + { + key: 'messages.approvalNoApproverSlot', + params: { + type: { key: 'messages.approvalApproverTypePosition', fallback: 'position' }, + value: { key: 'positions.legal.label', fallback: 'Legal Counsel' }, + }, + fallback: "position 'Legal Counsel'", + }, + { + key: 'messages.approvalNoApproverSlot', + params: { type: { key: 'messages.approvalApproverTypeTeam', fallback: 'team' }, value: 'ops' }, + fallback: "team 'ops'", + }, + ], + separator: { key: 'messages.approvalNoApproverSlotSeparator', fallback: ', ' }, + }, }, }); // The acceptance: a zh-CN submitter reads it entirely in Chinese, the @@ -162,9 +193,9 @@ describe('[#36463] the submitter\'s notice names several slots in the reader\'s + "must add a member who holds position 'Legal Counsel', team 'ops'; that member can then decide it."); }); - it('for every slate size it spells, in every pack, the notice reads the timeline\'s sentence for the same slate', () => { + it('for every slate size, past the sentences #36463 spelled, in every pack, the notice reads the timeline\'s sentence for the same slate', () => { const kinds = ['position:legal', 'team:ops', 'department:west', 'org_membership_level:admin', 'role:admin']; - for (let n = 2; n <= NO_APPROVER_NOTICE_MAX_SLOTS; n++) { + for (let n = 2; n <= NO_APPROVER_NOTICE_MAX_SLOTS + 4; n++) { const slate = Array.from({ length: n }, (_, i) => `${kinds[i % kinds.length]}_${i}`); for (const locale of Object.keys(approvalMessages) as Locale[]) { expect(deliveredIn(locale, noApproverNotice({ slots: slate })), `${locale} ${n}`) @@ -173,11 +204,15 @@ describe('[#36463] the submitter\'s notice names several slots in the reader\'s } }); - it('a slate of more slots than it spells keeps one English `who` inside the reader\'s sentence', () => { - const slate = Array.from({ length: NO_APPROVER_NOTICE_MAX_SLOTS + 1 }, (_, i) => `team:t${i}`); + it('a slate of nine slots names no English approver type in any pack but `en`, whose literal is the English the row stores', () => { + const slate = Array.from({ length: NO_APPROVER_NOTICE_MAX_SLOTS + 1 }, (_, i) => `${i % 2 ? 'team' : 'department'}:t${i}`); const notice = noApproverNotice({ slots: slate }); expect(notice.id).toBe('approvalNoApproverHolding'); - expect(notice.params).toEqual({ who: noApproverWho(slate) }); + expect(interpolate(enMessages.approvalNoApproverHolding, notice.params)).toBe(noApproverNoteText({ slots: slate })); + for (const locale of Object.keys(approvalMessages) as Locale[]) { + if (locale === 'en') continue; + expect(deliveredIn(locale, notice), locale).not.toMatch(/team|department/); + } }); }); diff --git a/packages/plugins/plugin-approvals/src/no-approver-note.ts b/packages/plugins/plugin-approvals/src/no-approver-note.ts index b17052b3f88..4e6e19b9b71 100644 --- a/packages/plugins/plugin-approvals/src/no-approver-note.ts +++ b/packages/plugins/plugin-approvals/src/no-approver-note.ts @@ -22,8 +22,14 @@ * the slate, the request is reassigned to that member. */ -import { approvalMessageKey, interpolate, type ApprovalTextParam } from './approval-notification-text.js'; -import { enMessages, noApproverHoldingSlotsId, type ApprovalMessageId } from './translations/messages.js'; +import { + approvalMessageKey, + interpolate, + type ApprovalListParam, + type ApprovalScalarParam, + type ApprovalTextParam, +} from './approval-notification-text.js'; +import { enMessages, type ApprovalMessageId } from './translations/messages.js'; import { slatePositions, type ApprovalSentenceRender, type PositionLabelOf } from './admin-rescue-note.js'; import { isPlatformAdminAddress, slateNamesAPerson } from './approver-address.js'; import { positionLabelKey } from './reader-locale-labels.js'; @@ -135,7 +141,7 @@ export function namesNoOneBut(slate: readonly string[], submitter: string): bool * falling back to `declaredLabel`, else the name. */ function slotParams(slot: Slot, declaredLabel: PositionLabelOf | undefined): { - type: ApprovalTextParam; value: ApprovalTextParam; + type: ApprovalScalarParam; value: ApprovalScalarParam; } { const word = APPROVER_TYPE_WORDS[slot.type]; const value = slotValue(slot, declaredLabel); @@ -145,6 +151,25 @@ function slotParams(slot: Slot, declaredLabel: PositionLabelOf | undefined): { }; } +/** + * [#36853] The slate as the messaging service's list param: each slot its + * `approvalNoApproverSlot` clause with the slot's params, falling back to the + * English clause the row stores, joined by the separator entry. + */ +function slotList(slots: readonly Slot[], declaredLabel: PositionLabelOf | undefined): ApprovalListParam { + return { + list: slots.map((slot) => ({ + key: approvalMessageKey('approvalNoApproverSlot'), + params: slotParams(slot, declaredLabel), + fallback: slotClause(slot, slotValue(slot, declaredLabel), undefined), + })), + separator: { + key: approvalMessageKey('approvalNoApproverSlotSeparator'), + fallback: enMessages.approvalNoApproverSlotSeparator, + }, + }; +} + /** * The submitter's notice body for the note: its catalog sentence and the * params the messaging service fills per recipient, at delivery @@ -156,12 +181,15 @@ function slotParams(slot: Slot, declaredLabel: PositionLabelOf | undefined): { * the approver type's word as a key, and a position's `value` is its * reader-language label as a key (`positions..label`, the key the * timeline reads) falling back to `declaredLabel`, else the name — the order - * the timeline note names it in. [#36463] A slate of 2 to - * `NO_APPROVER_NOTICE_MAX_SLOTS` slots is spelled inline the same way, in - * `approvalNoApproverHoldingSlots`, slot `i` under `type` / `value` - * in the slate's order. A slate of more slots names them in English inside - * the reader's sentence, each position by `declaredLabel`; a note that stored - * `who` keeps it as written. + * the timeline note names it in. [#36853] A slate of more slots rides + * `approvalNoApproverHolding` with `who` the messaging service's list param: + * one `approvalNoApproverSlot` per slot in the slate's order, each with the + * same `type` / `value` params, joined by `approvalNoApproverSlotSeparator`, + * so every slot reads in the recipient's language whatever the slate's size. + * (The `approvalNoApproverHoldingSlots` sentences #36463 spelled slates of + * 2 to 8 slots with stay in the packs: notices already delivered carry those + * keys and are rendered again at every inbox read.) A note that stored `who` + * keeps it as written. */ export function noApproverNotice(note: Pick, declaredLabel?: PositionLabelOf): { id: ApprovalMessageId; params: Record; @@ -171,16 +199,7 @@ export function noApproverNotice(note: Pick, de const { type, value } = slotParams(slots[0], declaredLabel); return { id: 'approvalNoApproverHoldingSlot', params: { type, value } }; } - const listed = noApproverHoldingSlotsId(slots.length); - if (listed) { - const params: Record = {}; - slots.forEach((slot, i) => { - const { type, value } = slotParams(slot, declaredLabel); - params[`type${i + 1}`] = type; - params[`value${i + 1}`] = value; - }); - return { id: listed, params }; - } + if (slots.length > 1) return { id: 'approvalNoApproverHolding', params: { who: slotList(slots, declaredLabel) } }; const who = note.slots ? noApproverWho(note.slots, declaredLabel) : note.who; return who ? { id: 'approvalNoApproverHolding', params: { who } } diff --git a/packages/services/service-messaging/src/index.ts b/packages/services/service-messaging/src/index.ts index 337985dd667..c2ca7dba3b5 100644 --- a/packages/services/service-messaging/src/index.ts +++ b/packages/services/service-messaging/src/index.ts @@ -110,11 +110,15 @@ export { SLACK_SETUP_UI_BUNDLE, SLACK_SETUP_COMPONENT_REF } from './slack-setup- export { NotificationTextRenderer, assertNotificationTextKeys, + NOTIFICATION_LIST_PARAM_MAX_ITEMS, } from './notification-text.js'; export type { NotificationTextKeys, NotificationTextParam, NotificationObjectLabelParam, + NotificationScalarParam, + NotificationListParam, + NotificationListItem, NotificationTextI18n, NotificationTextItem, NotificationTextRendererOptions, diff --git a/packages/services/service-messaging/src/notification-text-list-param-36853.test.ts b/packages/services/service-messaging/src/notification-text-list-param-36853.test.ts new file mode 100644 index 00000000000..2b0d5c375ec --- /dev/null +++ b/packages/services/service-messaging/src/notification-text-list-param-36853.test.ts @@ -0,0 +1,130 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [#36853] A keyed param that is a LIST: each item its catalog sentence with + * its own params, rendered in the recipient's language, joined by the + * separator entry. + * + * A `{ key }` param resolves through `t(key, locale)` with no params, so a + * hole held one text or one hole-free key, and a list whose items are + * sentences with holes of their own could reach a reader only as the + * producer's literal (the approval submitter's notice named a slate of more + * than 8 slots in English inside a zh-CN sentence). Drives the real + * `NotificationTextRenderer` over the kernel's in-memory `i18n` service. + */ + +import { describe, it, expect } from 'vitest'; +import { createMemoryI18n } from '@objectstack/core'; +import { + NOTIFICATION_LIST_PARAM_MAX_ITEMS, + NotificationTextRenderer, + assertNotificationTextKeys, + readNotificationTextKeys, + type NotificationListParam, + type NotificationTextKeys, +} from './notification-text.js'; + +const CATALOG = { + en: { + messages: { + holding: 'A member who holds {{who}} can decide it.', + slot: "{{type}} '{{value}}'", + separator: ', ', + team: 'team', + }, + }, + 'zh-CN': { + messages: { + holding: '担任{{who}}的成员可以决定它。', + slot: '{{type}}「{{value}}」', + separator: '、', + team: '团队', + }, + }, +}; + +function renderer() { + const i18n = createMemoryI18n(); + for (const [locale, data] of Object.entries(CATALOG)) i18n.loadTranslations(locale, data); + return new NotificationTextRenderer({ getData: () => undefined, getI18n: () => i18n as any }); +} + +/** A slate of `n` team slots as the list param. */ +function slate(n: number, itemKey = 'messages.slot'): NotificationListParam { + return { + list: Array.from({ length: n }, (_, i) => ({ + key: itemKey, + params: { type: { key: 'messages.team', fallback: 'team' }, value: `t${i + 1}` }, + fallback: `team 't${i + 1}'`, + })), + separator: { key: 'messages.separator', fallback: ', ' }, + }; +} + +const LITERAL = { title: 'Notice', body: 'literal body' }; +const keysOf = (who: NotificationListParam): NotificationTextKeys => ({ bodyKey: 'messages.holding', params: { who } }); + +describe('#36853 — a list param renders every item in the recipient\'s language', () => { + it('nine items in zh-CN: each its own sentence with its own params, joined by the zh-CN separator', () => { + const body = renderer().render(keysOf(slate(9)), LITERAL, 'zh-CN').body; + + expect(body).toBe(`担任${Array.from({ length: 9 }, (_, i) => `团队「t${i + 1}」`).join('、')}的成员可以决定它。`); + expect(body).not.toMatch(/team|, /); + }); + + it('in en, the English items and separator', () => { + expect(renderer().render(keysOf(slate(2)), LITERAL, 'en').body) + .toBe("A member who holds team 't1', team 't2' can decide it."); + }); + + it('an item whose sentence has no entry is its fallback; a separator with no entry is its fallback', () => { + const who: NotificationListParam = { + list: [slate(1).list[0], { key: 'messages.nowhere', fallback: 'role \'admin\'' }], + separator: { key: 'messages.no_separator', fallback: ' / ' }, + }; + expect(renderer().render(keysOf(who), LITERAL, 'zh-CN').body) + .toBe("担任团队「t1」 / role 'admin'的成员可以决定它。"); + }); + + it('an item may take an object-label param and plain text, as a top-level hole does', () => { + const who: NotificationListParam = { + list: [{ key: 'messages.slot', params: { type: 'role', value: { object: 'crm_deal', fallback: 'Deal' } }, fallback: 'x' }], + separator: { key: 'messages.separator', fallback: ', ' }, + }; + expect(renderer().render(keysOf(who), LITERAL, 'zh-CN').body).toBe('担任role「Deal」的成员可以决定它。'); + }); +}); + +describe('#36853 — emit() refuses a malformed list param, and a stored one is read back', () => { + const refused = (who: unknown) => () => assertNotificationTextKeys({ bodyKey: 'messages.holding', params: { who } }); + + it('accepts the declared shape, and a stored row carrying it reads back', () => { + expect(() => assertNotificationTextKeys(keysOf(slate(3)))).not.toThrow(); + expect(readNotificationTextKeys(keysOf(slate(3)))).toEqual(keysOf(slate(3))); + }); + + it('refuses an empty list, an oversized list, and a list with an undeclared member', () => { + expect(refused({ list: [], separator: { key: 'messages.separator', fallback: ', ' } })).toThrow(/non-empty array/); + expect(refused(slate(NOTIFICATION_LIST_PARAM_MAX_ITEMS + 1))).toThrow(/at most/); + expect(refused({ ...slate(1), joiner: ', ' })).toThrow(/undeclared member 'joiner'/); + }); + + it('refuses a missing or malformed separator', () => { + expect(refused({ list: slate(1).list })).toThrow(/separator must be/); + expect(refused({ list: slate(1).list, separator: { key: 'separator', fallback: ', ' } })).toThrow(/separator\.key must be a catalog key/); + }); + + it('refuses an item that is not { key, params?, fallback }, and an item param that is a list', () => { + expect(refused({ ...slate(1), list: ['team t1'] })).toThrow(/list\[0\] must be/); + expect(refused(slate(1, 'slot'))).toThrow(/list\[0\]\.key must be a catalog key/); + expect(refused({ ...slate(1), list: [{ key: 'messages.slot' }] })).toThrow(/list\[0\]\.fallback must be a string/); + expect(refused({ ...slate(1), list: [{ key: 'messages.slot', params: { who: slate(1) }, fallback: 'x' }] })) + .toThrow(/cannot be a list/); + expect(refused({ ...slate(1), list: [{ key: 'messages.slot', params: { type: 42 }, fallback: 'x' }] })) + .toThrow(/list\[0\]\.params\.type must be a string/); + }); + + it('a stored row whose list is malformed is delivered as its literal, as any malformed row is', () => { + expect(readNotificationTextKeys({ bodyKey: 'messages.holding', params: { who: { list: [] } } })).toBeUndefined(); + }); +}); diff --git a/packages/services/service-messaging/src/notification-text.ts b/packages/services/service-messaging/src/notification-text.ts index 8037d9c870b..9657437fb8f 100644 --- a/packages/services/service-messaging/src/notification-text.ts +++ b/packages/services/service-messaging/src/notification-text.ts @@ -28,7 +28,11 @@ * or, spelled `{ key, fallback }`, is itself the recipient-language text of * the catalog entry `key`, else `fallback`; or, spelled * `{ object, fallback }`, is the label of the object whose API name is - * `object`, in the recipient's language, else `fallback`. + * `object`, in the recipient's language, else `fallback`; or [#36853], + * spelled `{ list, separator }`, is a list of catalog sentences, each with + * its own params, every item rendered in the recipient's language (else + * its `fallback`) and the items joined by the separator entry, so a list + * of any length reads in one language ({@link NotificationListParam}). * - [#35384] An object's label is METADATA, not a catalog sentence, so the * `{ object }` param is resolved as `GET /meta/object/:name` serves it: * by `translateObject` (`@objectstack/spec/system`) over the object's @@ -92,11 +96,44 @@ import { DEFAULT_LOCALE } from './template-renderer.js'; * object's name, resolved as the metadata route serves it with `fallback` as * the text when nothing resolves ({@link NotificationObjectLabelParam}). */ -export type NotificationTextParam = +export type NotificationTextParam = NotificationScalarParam | NotificationListParam; + +/** + * [#36853] A value that fills one hole by itself: the text, a catalog key with + * its `fallback`, or an object's label ({@link NotificationObjectLabelParam}). + * A {@link NotificationListItem}'s own params take these, never a list. + */ +export type NotificationScalarParam = | string | { readonly key: string; readonly fallback: string } | NotificationObjectLabelParam; +/** + * [#36853] A `{{name}}` value that is a list read in the recipient's language: + * each item its catalog sentence rendered with its own params (else the + * item's `fallback`), joined by the `separator` entry (else its `fallback`). + * + * A `{ key }` param renders a hole-free entry, so a list whose items are + * sentences with holes of their own (an approval slate's `{{type}} '{{value}}'`) + * could ride only as literal text, in the producer's language, or as one + * catalog sentence per list length. This renders a list of any length. + */ +export interface NotificationListParam { + readonly list: readonly NotificationListItem[]; + /** The joining text as a catalog entry (`messages.mySeparator`), with the text it falls back to. */ + readonly separator: { readonly key: string; readonly fallback: string }; +} + +/** [#36853] One item of a {@link NotificationListParam}. */ +export interface NotificationListItem { + /** The item's catalog sentence, e.g. `messages.approvalNoApproverSlot`. */ + readonly key: string; + /** Values for the item sentence's own `{{name}}` holes. */ + readonly params?: Readonly>; + /** The item's text when its sentence has no entry. */ + readonly fallback: string; +} + /** * [#35384] A `{{name}}` value that is the label of the object whose API name * `object` holds (`crm_deal`), in the recipient's language, as @@ -160,6 +197,15 @@ const PARAM_NAME_SHAPE = /^\w+$/; const TEXT_MEMBERS: ReadonlySet = new Set(['titleKey', 'bodyKey', 'params']); const KEYED_PARAM_MEMBERS: ReadonlySet = new Set(['key', 'fallback']); const OBJECT_LABEL_PARAM_MEMBERS: ReadonlySet = new Set(['object', 'fallback']); +const LIST_PARAM_MEMBERS: ReadonlySet = new Set(['list', 'separator']); +const LIST_ITEM_MEMBERS: ReadonlySet = new Set(['key', 'params', 'fallback']); + +/** + * [#36853] The most items one list param holds. A list is rendered item by + * item at every delivery and every inbox read, so it is bounded; an approval + * slate is a handful of slots. + */ +export const NOTIFICATION_LIST_PARAM_MAX_ITEMS = 100; /** * An object's API name: one segment of {@link CATALOG_KEY_SHAPE}, so every @@ -194,27 +240,76 @@ function problemOf(value: unknown): string | undefined { if (!isPlainObject(params)) return '.params must be an object'; for (const [name, param] of Object.entries(params)) { if (!PARAM_NAME_SHAPE.test(name)) return `.params has a name '${name}' no {{hole}} can spell`; - if (typeof param === 'string') continue; - if (!isPlainObject(param)) return `.params.${name} must be a string, { key, fallback } or { object, fallback }`; - if ('object' in param) { - for (const member of Object.keys(param)) { - if (!OBJECT_LABEL_PARAM_MEMBERS.has(member)) { - return `.params.${name} has an undeclared member '${member}' (declared: object, fallback)`; - } - } - if (typeof param.object !== 'string' || !OBJECT_NAME_SHAPE.test(param.object)) { - return `.params.${name}.object must be an object's API name such as 'crm_deal' (got ${JSON.stringify(param.object)})`; + const problem = isPlainObject(param) && 'list' in param + ? listParamProblem(`.params.${name}`, param) + : scalarParamProblem(`.params.${name}`, param); + if (problem !== undefined) return problem; + } + return undefined; +} + +/** The first thing wrong with `param` as a {@link NotificationScalarParam} at `at`, or `undefined`. */ +function scalarParamProblem(at: string, param: unknown): string | undefined { + if (typeof param === 'string') return undefined; + if (!isPlainObject(param)) return `${at} must be a string, { key, fallback }, { object, fallback } or { list, separator }`; + if ('object' in param) { + for (const member of Object.keys(param)) { + if (!OBJECT_LABEL_PARAM_MEMBERS.has(member)) { + return `${at} has an undeclared member '${member}' (declared: object, fallback)`; } - if (typeof param.fallback !== 'string') return `.params.${name}.fallback must be a string`; - continue; } - for (const member of Object.keys(param)) { - if (!KEYED_PARAM_MEMBERS.has(member)) return `.params.${name} has an undeclared member '${member}' (declared: key, fallback)`; + if (typeof param.object !== 'string' || !OBJECT_NAME_SHAPE.test(param.object)) { + return `${at}.object must be an object's API name such as 'crm_deal' (got ${JSON.stringify(param.object)})`; + } + if (typeof param.fallback !== 'string') return `${at}.fallback must be a string`; + return undefined; + } + return keyedParamProblem(at, param); +} + +/** The first thing wrong with `param` as `{ key, fallback }` at `at`, or `undefined`. */ +function keyedParamProblem(at: string, param: Record): string | undefined { + for (const member of Object.keys(param)) { + if (!KEYED_PARAM_MEMBERS.has(member)) return `${at} has an undeclared member '${member}' (declared: key, fallback)`; + } + if (typeof param.key !== 'string' || !CATALOG_KEY_SHAPE.test(param.key)) { + return `${at}.key must be a catalog key such as 'objects.my_object.label' (got ${JSON.stringify(param.key)})`; + } + if (typeof param.fallback !== 'string') return `${at}.fallback must be a string`; + return undefined; +} + +/** [#36853] The first thing wrong with `param` as a {@link NotificationListParam} at `at`, or `undefined`. */ +function listParamProblem(at: string, param: Record): string | undefined { + for (const member of Object.keys(param)) { + if (!LIST_PARAM_MEMBERS.has(member)) return `${at} has an undeclared member '${member}' (declared: list, separator)`; + } + const list = param.list; + if (!Array.isArray(list) || list.length === 0) return `${at}.list must be a non-empty array`; + if (list.length > NOTIFICATION_LIST_PARAM_MAX_ITEMS) { + return `${at}.list holds ${list.length} items (at most ${NOTIFICATION_LIST_PARAM_MAX_ITEMS})`; + } + if (!isPlainObject(param.separator)) return `${at}.separator must be { key, fallback }`; + const separator = keyedParamProblem(`${at}.separator`, param.separator); + if (separator !== undefined) return separator; + for (const [i, item] of list.entries()) { + const itemAt = `${at}.list[${i}]`; + if (!isPlainObject(item)) return `${itemAt} must be { key, params?, fallback }`; + for (const member of Object.keys(item)) { + if (!LIST_ITEM_MEMBERS.has(member)) return `${itemAt} has an undeclared member '${member}' (declared: key, params, fallback)`; + } + if (typeof item.key !== 'string' || !CATALOG_KEY_SHAPE.test(item.key)) { + return `${itemAt}.key must be a catalog key such as 'messages.mySentence' (got ${JSON.stringify(item.key)})`; } - if (typeof param.key !== 'string' || !CATALOG_KEY_SHAPE.test(param.key)) { - return `.params.${name}.key must be a catalog key such as 'objects.my_object.label' (got ${JSON.stringify(param.key)})`; + if (typeof item.fallback !== 'string') return `${itemAt}.fallback must be a string`; + if (item.params === undefined) continue; + if (!isPlainObject(item.params)) return `${itemAt}.params must be an object`; + for (const [name, value] of Object.entries(item.params)) { + if (!PARAM_NAME_SHAPE.test(name)) return `${itemAt}.params has a name '${name}' no {{hole}} can spell`; + if (isPlainObject(value) && 'list' in value) return `${itemAt}.params.${name}: a list item's param cannot be a list`; + const problem = scalarParamProblem(`${itemAt}.params.${name}`, value); + if (problem !== undefined) return problem; } - if (typeof param.fallback !== 'string') return `.params.${name}.fallback must be a string`; } return undefined; } @@ -373,14 +468,26 @@ export class NotificationTextRenderer { const params: Record = {}; // [#35384] Built on the first object label this render asks, once. let translation: { value: MetaLabelTranslation | undefined } | undefined; - for (const [name, param] of Object.entries(keys.params ?? {})) { - if (typeof param === 'string') { - params[name] = param; - } else if ('object' in param) { + const scalar = (param: NotificationScalarParam): string => { + if (typeof param === 'string') return param; + if ('object' in param) { translation ??= { value: metaLabelTranslation(i18n, locale) }; - params[name] = this.objectLabel(translation.value, param.object) ?? param.fallback; + return this.objectLabel(translation.value, param.object) ?? param.fallback; + } + return lookup(i18n, param.key, locale) ?? param.fallback; + }; + for (const [name, param] of Object.entries(keys.params ?? {})) { + if (typeof param === 'object' && 'list' in param) { + // [#36853] Each item its own sentence in the recipient's + // language, with its own params, joined by the separator entry. + const items = param.list.map((item) => { + const itemParams: Record = {}; + for (const [hole, value] of Object.entries(item.params ?? {})) itemParams[hole] = scalar(value); + return lookup(i18n, item.key, locale, itemParams) ?? item.fallback; + }); + params[name] = items.join(lookupSeparator(i18n, param.separator.key, locale) ?? param.separator.fallback); } else { - params[name] = lookup(i18n, param.key, locale) ?? param.fallback; + params[name] = scalar(param); } } const entry = (key: string): string | undefined => announceMisses @@ -540,6 +647,21 @@ function lookup( } } +/** + * [#36853] A list param's joining text, or `undefined` for a miss. Unlike + * {@link lookup} it keeps an answer that is only whitespace or punctuation + * (`', '`, `'、'`): a separator is not a sentence. An empty answer and the + * echoed key are still misses. + */ +function lookupSeparator(i18n: NotificationTextI18n, key: string, locale: string): string | undefined { + try { + const text = i18n.t(key, locale); + return typeof text === 'string' && text.length > 0 && text !== key ? text : undefined; + } catch { + return undefined; + } +} + /** * The locale `i18n` can ANSWER in, for the locale the recipient holds: * `resolveBundleLocale` over what `getLocales()` reports. The requested tag From b487097576deb8a3ca437c89e3960908e289a24b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 21:50:48 +0000 Subject: [PATCH 2/2] fix(plugin-approvals): a no-approver slate past the list cap is still sent, as English clauses A slate of more than NOTIFICATION_LIST_PARAM_MAX_ITEMS slots would make emit() refuse the list param, and notify() only logs the refusal, so the submitter was told nothing. The notice now caps the list at the mirrored APPROVAL_LIST_PARAM_MAX_ITEMS and, past it, sends `who` as the English clauses. A pin test drives both sides of the cap through the emit's own assertNotificationTextKeys. The changeset names the new constant export, the widened read side (Notification.keyedText) and what an older reader does with a list row. Claude-Session: https://claude.ai/code/session_01L6bhgU7eeqHgQrtv5CeJK6 Co-authored-by: Claude --- .changeset/36853-notification-list-param.md | 6 ++-- ...min-rescue-named-slate.integration.test.ts | 30 ++++++++++++++++++- .../src/approval-notification-text.ts | 8 +++++ .../plugin-approvals/src/no-approver-note.ts | 12 ++++++-- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/.changeset/36853-notification-list-param.md b/.changeset/36853-notification-list-param.md index e3c3a0f823d..c620c9be71e 100644 --- a/.changeset/36853-notification-list-param.md +++ b/.changeset/36853-notification-list-param.md @@ -8,6 +8,8 @@ feat(service-messaging): a keyed notification param can be a list, each item ren Clause-②: yes (widening) Metadata-protocol: none -- `EmitInput.keyedText.params` accepts a new value shape, `{ list, separator }`. Each `list` item is `{ key, params?, fallback }`: a catalog sentence with its own `{{hole}}` params, rendered per recipient. An item param can be text, `{ key, fallback }` or `{ object, fallback }`, but not another list. A sentence with no entry falls back to the item's `fallback`. The rendered items are joined by the `separator` entry (`{ key, fallback }`), so a list of any length reads in one language. A list holds 1 to `NOTIFICATION_LIST_PARAM_MAX_ITEMS` (100) items, and `emit()` refuses a malformed one before it writes anything. The new types are exported: `NotificationListParam`, `NotificationListItem` and `NotificationScalarParam`. Every existing param shape renders as before. -- The approval submitter's notice for a request no one else can approve now names a slate of two or more slots through this list param, one `approvalNoApproverSlot` clause per slot, joined by `approvalNoApproverSlotSeparator`. Before, a slate of more than 8 slots named its slots in English inside a zh-CN, ja-JP or other non-English sentence. Now every slot reads in the recipient's language. The literal English body is unchanged. +- `EmitInput.keyedText.params` accepts a new value shape, `{ list, separator }`. Each `list` item is `{ key, params?, fallback }`: a catalog sentence with its own `{{hole}}` params, rendered per recipient. An item param can be text, `{ key, fallback }` or `{ object, fallback }`, but not another list. A sentence with no entry falls back to the item's `fallback`. The rendered items are joined by the `separator` entry (`{ key, fallback }`), so a list of any length reads in one language. A list holds 1 to `NOTIFICATION_LIST_PARAM_MAX_ITEMS` (100) items, and `emit()` refuses a malformed one before it writes anything. The new exports are the types `NotificationListParam`, `NotificationListItem` and `NotificationScalarParam`, and the constant `NOTIFICATION_LIST_PARAM_MAX_ITEMS`. Every existing param shape renders as before. +- The widening reaches the read side too. `NotificationTextParam` is now `NotificationScalarParam | NotificationListParam`, so the exported channel contract `Notification.keyedText` can carry a list param. A channel that reads `keyedText.params` must handle the list shape. +- An older reader does not understand a list row. After a rollback to a version before this one, it reads the row's keys as malformed and delivers or shows the whole notice as its stored English literal, title and body alike. Nothing fails. Within one install this cannot otherwise happen, because the two packages always release together. +- The approval submitter's notice for a request no one else can approve now names a slate of two or more slots through this list param, one `approvalNoApproverSlot` clause per slot, joined by `approvalNoApproverSlotSeparator`. Before, a slate of more than 8 slots named its slots in English inside a zh-CN, ja-JP or other non-English sentence. Now every slot reads in the recipient's language. The literal English body is unchanged. A slate of more slots than a list param holds (more than 100) is sent with the slots as one English clause list instead, as before, so `emit()` does not refuse the notice and the submitter is still told. - The `approvalNoApproverHoldingSlots2` to `…Slots8` sentences stay in the packs, because notices already delivered carry those keys and are rendered again whenever the inbox is read. diff --git a/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts b/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts index 264dc28c6ce..61fd72a106d 100644 --- a/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts +++ b/packages/plugins/plugin-approvals/src/admin-rescue-named-slate.integration.test.ts @@ -47,7 +47,12 @@ import { } from '@objectstack/core'; import { ApprovalService } from './approval-service.js'; import { ApprovalsServicePlugin } from './approvals-plugin.js'; -import { NotificationTextRenderer } from '@objectstack/service-messaging'; +import { + NotificationTextRenderer, + assertNotificationTextKeys, + NOTIFICATION_LIST_PARAM_MAX_ITEMS, +} from '@objectstack/service-messaging'; +import { APPROVAL_LIST_PARAM_MAX_ITEMS } from './approval-notification-text.js'; import { ApprovalsTranslations } from './translations/index.js'; import { relaxTenantColumns } from './pre-18-tenant-column.testkit.js'; @@ -698,6 +703,29 @@ describe('an empty admin_rescue slate opens on the organization\'s administrator expect(renderer.render(notice.keyedText, notice.payload, 'en').body).toBe(notice.payload.body); }); + // [#36853] The emit refuses a list param of more than + // NOTIFICATION_LIST_PARAM_MAX_ITEMS items and `notify` only logs it, so a + // slate past that is sent as one English `who`: the submitter is told. + it('the submitter\'s notice: a slate past the list cap is still sent, as the English clauses; at the cap it stays a list', async () => { + expect(APPROVAL_LIST_PARAM_MAX_ITEMS).toBe(NOTIFICATION_LIST_PARAM_MAX_ITEMS); + const slateOf = (n: number) => Array.from({ length: n }, (_, i) => ({ type: 'team', value: `t${i}` })); + + const over = await openLabelled('none_notice_over_cap', slateOf(NOTIFICATION_LIST_PARAM_MAX_ITEMS + 1)); + const [overNotice] = told.filter((e) => e.source?.id === over.id); + expect(overNotice.keyedText.bodyKey).toBe('messages.approvalNoApproverHolding'); + expect(() => assertNotificationTextKeys(overNotice.keyedText)).not.toThrow(); + const english = slateOf(NOTIFICATION_LIST_PARAM_MAX_ITEMS + 1).map((s) => `team '${s.value}'`).join(', '); + expect(overNotice.keyedText.params.who).toBe(english); + expect(overNotice.payload.body).toBe(holding(english)); + + const at = await openLabelled('none_notice_at_cap', slateOf(NOTIFICATION_LIST_PARAM_MAX_ITEMS)); + const [atNotice] = told.filter((e) => e.source?.id === at.id); + expect(() => assertNotificationTextKeys(atNotice.keyedText)).not.toThrow(); + expect(atNotice.keyedText.params.who.list).toHaveLength(NOTIFICATION_LIST_PARAM_MAX_ITEMS); + const renderer = new NotificationTextRenderer({ getData: () => undefined, getI18n: () => i18n as any }); + expect(renderer.render(atNotice.keyedText, atNotice.payload, 'zh-CN').body).not.toMatch(/team/); + }); + it('CONTROL: a note written before the slot was stored renders exactly as before', async () => { const row = await open('none_legacy', UNSTAFFED, {}, LEADERLESS_ORG); // The stored shape of a note written before #36035: `who`, pre-composed. diff --git a/packages/plugins/plugin-approvals/src/approval-notification-text.ts b/packages/plugins/plugin-approvals/src/approval-notification-text.ts index 93063a56b41..40a64170a77 100644 --- a/packages/plugins/plugin-approvals/src/approval-notification-text.ts +++ b/packages/plugins/plugin-approvals/src/approval-notification-text.ts @@ -70,6 +70,14 @@ export interface ApprovalListParam { readonly separator: { readonly key: string; readonly fallback: string }; } +/** + * [#36853] The mirror of the messaging service's + * `NOTIFICATION_LIST_PARAM_MAX_ITEMS`: the most items an emit takes in one + * list param. A longer list is refused there (and `notify` only logs it), so a + * producer with more items must not send them as a list. + */ +export const APPROVAL_LIST_PARAM_MAX_ITEMS = 100; + /** [#35384] The structural mirror of the messaging service's `NotificationObjectLabelParam`. */ export interface ApprovalObjectLabelParam { /** The object's API name, never its label. */ diff --git a/packages/plugins/plugin-approvals/src/no-approver-note.ts b/packages/plugins/plugin-approvals/src/no-approver-note.ts index 4e6e19b9b71..82bc122b36c 100644 --- a/packages/plugins/plugin-approvals/src/no-approver-note.ts +++ b/packages/plugins/plugin-approvals/src/no-approver-note.ts @@ -23,6 +23,7 @@ */ import { + APPROVAL_LIST_PARAM_MAX_ITEMS, approvalMessageKey, interpolate, type ApprovalListParam, @@ -188,8 +189,11 @@ function slotList(slots: readonly Slot[], declaredLabel: PositionLabelOf | undef * so every slot reads in the recipient's language whatever the slate's size. * (The `approvalNoApproverHoldingSlots` sentences #36463 spelled slates of * 2 to 8 slots with stay in the packs: notices already delivered carry those - * keys and are rendered again at every inbox read.) A note that stored `who` - * keeps it as written. + * keys and are rendered again at every inbox read.) A slate of more slots + * than a list param takes (`APPROVAL_LIST_PARAM_MAX_ITEMS`) rides + * `approvalNoApproverHolding` with `who` the English clauses joined, so the + * emit is not refused and the submitter is still told. A note that stored + * `who` keeps it as written. */ export function noApproverNotice(note: Pick, declaredLabel?: PositionLabelOf): { id: ApprovalMessageId; params: Record; @@ -199,7 +203,9 @@ export function noApproverNotice(note: Pick, de const { type, value } = slotParams(slots[0], declaredLabel); return { id: 'approvalNoApproverHoldingSlot', params: { type, value } }; } - if (slots.length > 1) return { id: 'approvalNoApproverHolding', params: { who: slotList(slots, declaredLabel) } }; + if (slots.length > 1 && slots.length <= APPROVAL_LIST_PARAM_MAX_ITEMS) { + return { id: 'approvalNoApproverHolding', params: { who: slotList(slots, declaredLabel) } }; + } const who = note.slots ? noApproverWho(note.slots, declaredLabel) : note.who; return who ? { id: 'approvalNoApproverHolding', params: { who } }