Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/33657-hook-form-refusal-reasons-params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@objectstack/spec': patch
'@objectstack/platform-objects': patch
'@object-ui/app-shell': patch
'@object-ui/console': patch
---

feat(spec): the Studio hook form offers a refusal's `reasons` and `params`

Clause-②: yes (widening)
Metadata-protocol: none

The hook form (`hookForm`) lays out a refusal entry as `message`, `status`, `reasons` and `params`, so a Studio author can declare the several sentences under one code and the named params that a hook's refusal catalogue accepts. `reasons` is a record keyed by the snake_case reason the body throws beside the code, each `{ message }`; it takes the same key-only record control as the catalogue, and the reason key rule it checks is the one the served `HookSchema` declares. `params` is a name list. The entry's `message` help text now says a `{{ name }}` hole fills a declared param, where it said the sentence takes no placeholders. The three new rows and the changed help text are translated in the ten locales of the platform's metadata-form bundles (`@objectstack/platform-objects`), and the console's zh-CN form labels (`@object-ui/app-shell`, shipped in `@object-ui/console`) name the three rows for the Pending changes sheet.

Nothing a metadata author can write changes: `reasons` and `params` were already accepted on a refusal entry; only the form now offers them. A catalogue that uses them already kept them through a Studio edit, and still does. A refusal with only `message` and `status` saves exactly as before.

In the metadata form (`@object-ui/app-shell`), removing the last entry of an optional record row now leaves the key absent rather than writing `{}`. The two read differently, though both draw the same empty list: an entry's `reasons: {}` refuses every reason the body throws under that code, where an absent `reasons` does not read the thrown reason; and a hook's `refusals: {}` refuses every code its body throws, where an absent catalogue leaves its throws as they were. A required record row, such as an object's `fields`, keeps `{}` as before.
Original file line number Diff line number Diff line change
Expand Up @@ -703,14 +703,19 @@ describe('#19403 round 5 — the blind spot, FIFTH shape: one schema, two forms,
// and CORRECT — `hookForm` enumerates no repeater at all — while seven
// children sit enumerated and outside it.
// 9 since #26835: the hook form offers the `refusals` record, whose two
// entry fields (`message`, `status`) are enumerated the same way.
// entry fields (`message`, `status`) are enumerated the same way. 12 since
// #33657: the entry also offers `reasons` (a record of `{ message }`) and
// `params`, three more enumerated children.
expect(HOOK_ENUMERATED.covered.length, 'hookForm enumerates no repeater row properties').toBe(0);
expect(HOOK_ENUMERATED.skipped.length).toBe(9);
expect(HOOK_ENUMERATED.skipped.length).toBe(12);
for (const child of SHARED_BODY_CHILDREN) expect(HOOK_ENUMERATED.skipped).toContain(`body.${child}`);
expect(HOOK_ENUMERATED.skipped).toContain('retryPolicy.maxRetries');
expect(HOOK_ENUMERATED.skipped).toContain('retryPolicy.backoffMs');
expect(HOOK_ENUMERATED.skipped).toContain('refusals.message');
expect(HOOK_ENUMERATED.skipped).toContain('refusals.status');
expect(HOOK_ENUMERATED.skipped).toContain('refusals.reasons');
expect(HOOK_ENUMERATED.skipped).toContain('refusals.reasons.message');
expect(HOOK_ENUMERATED.skipped).toContain('refusals.params');
//
// ⇒ one composite, two forms, two different greens: a lit control that
// passes on a sibling repeater, and a dark control that is right about
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const arMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"refusals.message": {
label: "الرسالة",
helpText: "الجملة التي يقرؤها المستخدم عندما يرمي المتن هذا الرمز — نص عادي، بلا عناصر نائبة"
helpText: "الجملة التي يقرؤها المستخدم عندما يرمي المتن هذا الرمز. نص عادي، ما لم يُعلن الإدخال params: عندها يملأ العنصر النائب {{ name }} معاملًا مُعلنًا"
},
"refusals.status": {
label: "الحالة",
helpText: "حالة HTTP للرفض (400–499). عند الغياب: 400"
},
"refusals.reasons": {
label: "الأسباب",
helpText: "جمل إضافية تحت الرمز نفسه، مفهرسة بالسبب بصيغة snake_case الذي يرميه المتن بجانب الرمز ({ code, reason }). يبقى الرمز والحالة المُرسَلان لهذا الإدخال؛ ويُرفض سبب غير مُعلن هنا. عند الغياب: لا يُقرأ السبب المرمي"
},
"refusals.reasons.message": {
label: "الرسالة",
helpText: "الجملة التي يقرؤها المستخدم عندما يرمي المتن هذا السبب تحت الرمز. تتبع عناصرها النائبة {{ }} معاملات params للإدخال"
},
"refusals.params": {
label: "المعاملات",
helpText: "الأسماء التي يمكن للجمل ملؤها (مثل state): يرمي المتن { code, params: { state } } ويعرض العنصر النائب {{ state }} قيمتها. عند الغياب: الجمل نص عادي"
},
handler: {
label: "المعالج",
helpText: "اسم دالة المعالج (مُهمَل — يُفضَّل `body`)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const deMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"refusals.message": {
label: "Meldung",
helpText: "Der Satz, den der Benutzer liest, wenn der Rumpf diesen Code wirft – einfacher Text ohne Platzhalter"
helpText: "Der Satz, den der Benutzer liest, wenn der Rumpf diesen Code wirft. Einfacher Text, außer der Eintrag deklariert params: dann füllt ein Platzhalter {{ name }} einen deklarierten Parameter"
},
"refusals.status": {
label: "Status",
helpText: "HTTP-Status der Ablehnung (400–499). Fehlt er: 400"
},
"refusals.reasons": {
label: "Gründe",
helpText: "Weitere Sätze unter demselben Code, nach dem snake_case-Grund, den der Rumpf neben dem Code wirft ({ code, reason }). Gesendeter Code und Status bleiben die dieses Eintrags; ein hier nicht deklarierter Grund wird abgelehnt. Fehlt er: Ein geworfener Grund wird nicht gelesen"
},
"refusals.reasons.message": {
label: "Meldung",
helpText: "Der Satz, den der Benutzer liest, wenn der Rumpf diesen Grund unter dem Code wirft. Seine {{ }}-Platzhalter folgen den params des Eintrags"
},
"refusals.params": {
label: "Parameter",
helpText: "Namen, die die Sätze füllen dürfen (z. B. state): Der Rumpf wirft { code, params: { state } }, und ein Platzhalter {{ state }} zeigt den Wert. Fehlt er: Die Sätze sind einfacher Text"
},
handler: {
label: "Handler",
helpText: "Name der Handler-Funktion (veraltet – besser `body`)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"refusals.message": {
label: "Message",
helpText: "The sentence the user reads when the body throws this code — plain text, with no placeholders"
helpText: "The sentence the user reads when the body throws this code. Plain text, unless the entry declares params: then a {{ name }} hole fills a declared param"
},
"refusals.status": {
label: "Status",
helpText: "HTTP status of the refusal (400–499). Absent: 400"
},
"refusals.reasons": {
label: "Reasons",
helpText: "Further sentences under this same code, keyed by the snake_case reason the body throws beside the code ({ code, reason }). The wire code and status stay this entry's; a reason not declared here is refused. Absent: a thrown reason is not read"
},
"refusals.reasons.message": {
label: "Message",
helpText: "The sentence the user reads when the body throws this reason under the code. Its {{ }} holes follow the entry's params"
},
"refusals.params": {
label: "Params",
helpText: "Names the sentences may fill (e.g. state): the body throws { code, params: { state } }, and a {{ state }} hole renders it. Absent: the sentences are plain text"
},
handler: {
label: "Handler",
helpText: "Handler function name (deprecated — prefer `body`)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
"refusals.message": {
label: "Mensaje",
helpText: "La frase que lee el usuario cuando el cuerpo lanza este código — texto plano, sin marcadores"
helpText: "La frase que lee el usuario cuando el cuerpo lanza este código. Texto plano, salvo que la entrada declare params: entonces un marcador {{ name }} se rellena con un parámetro declarado"
},
"refusals.status": {
label: "Estado",
helpText: "Estado HTTP del rechazo (400–499). Si se omite: 400"
},
"refusals.reasons": {
label: "Motivos",
helpText: "Más frases bajo este mismo código, indexadas por el motivo snake_case que el cuerpo lanza junto al código ({ code, reason }). El código y el estado que se envían siguen siendo los de esta entrada; se rechaza un motivo no declarado aquí. Si se omite: no se lee un motivo lanzado"
},
"refusals.reasons.message": {
label: "Mensaje",
helpText: "La frase que lee el usuario cuando el cuerpo lanza este motivo bajo el código. Sus marcadores {{ }} siguen los params de la entrada"
},
"refusals.params": {
label: "Parámetros",
helpText: "Nombres que las frases pueden rellenar (p. ej. state): el cuerpo lanza { code, params: { state } } y un marcador {{ state }} muestra su valor. Si se omite: las frases son texto plano"
},
handler: {
label: "Manejador",
helpText: "Nombre de función manejadora (obsoleto — preferir `body`)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const frMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"refusals.message": {
label: "Message",
helpText: "La phrase que lit l’utilisateur lorsque le corps lève ce code — texte brut, sans espaces réservés"
helpText: "La phrase que lit l’utilisateur lorsque le corps lève ce code. Texte brut, sauf si l’entrée déclare des params : un espace réservé {{ name }} reçoit alors un paramètre déclaré"
},
"refusals.status": {
label: "Statut",
helpText: "Statut HTTP du refus (400–499). Absent : 400"
},
"refusals.reasons": {
label: "Motifs",
helpText: "D’autres phrases sous ce même code, indexées par le motif snake_case que le corps lève avec le code ({ code, reason }). Le code et le statut transmis restent ceux de cette entrée ; un motif non déclaré ici est refusé. Absent : un motif levé n’est pas lu"
},
"refusals.reasons.message": {
label: "Message",
helpText: "La phrase que lit l’utilisateur lorsque le corps lève ce motif sous ce code. Ses espaces réservés {{ }} suivent les params de l’entrée"
},
"refusals.params": {
label: "Paramètres",
helpText: "Les noms que les phrases peuvent remplir (par ex. state) : le corps lève { code, params: { state } }, et un espace réservé {{ state }} en affiche la valeur. Absent : les phrases sont du texte brut"
},
handler: {
label: "Gestionnaire",
helpText: "Nom de la fonction de gestion (obsolète — préférez `body`)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const frGeneratedSourceHashes: Readonly<Record<string, string>> = {
"metadataForms.hook.fields.condition.label": "bfcca3fe6f93b90c",
"metadataForms.hook.fields.description.label": "779a4342c8eb6707",
"metadataForms.hook.fields.refusals.message.label": "2af15199795c25b9",
"metadataForms.hook.fields.refusals.reasons.message.label": "2af15199795c25b9",
"metadataForms.hook.label": "248bb1cdc692252d",
"metadataForms.object.fields.description.label": "779a4342c8eb6707",
"metadataForms.object.fields.fields.description.label": "779a4342c8eb6707",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,11 @@ describe('#19403 round 6 — the composite blind spot, hook side, CLOSED', () =>
// `hookForm` enumerates no repeater at all, so `repeater-row-properties.test.ts`
// is blind here through a DARK control that is TRUE and CORRECT — the shape
// round 5 wrote down. Seven children sit enumerated and outside it — 9
// since #26835, when the `refusals` record's `message` / `status` joined.
// since #26835, when the `refusals` record's `message` / `status` joined,
// and 12 since #33657, when its `reasons` (with `reasons.message`) and
// `params` joined.
expect(HOOK_ENUMERATED.covered.length, 'hookForm enumerates no repeater row properties').toBe(0);
expect(HOOK_ENUMERATED.skipped.length).toBe(9);
expect(HOOK_ENUMERATED.skipped.length).toBe(12);
for (const child of SHARED_BODY_CHILDREN) expect(HOOK_ENUMERATED.skipped).toContain(`body.${child}`);
expect(HOOK_ENUMERATED.skipped).toContain('retryPolicy.maxRetries');
expect(HOOK_ENUMERATED.skipped).toContain('retryPolicy.backoffMs');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const jaJPMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
"refusals.message": {
label: "メッセージ",
helpText: "本体がこのコードをスローしたときにユーザーが読む文 — プレーンテキスト、プレースホルダーなし"
helpText: "本体がこのコードをスローしたときにユーザーが読む文。プレーンテキスト。ただしエントリが params を宣言している場合、{{ name }} プレースホルダーに宣言済みのパラメーターが入ります"
},
"refusals.status": {
label: "ステータス",
helpText: "拒否の HTTP ステータス(400–499)。未指定: 400"
},
"refusals.reasons": {
label: "理由",
helpText: "同じコードの下に置く追加の文。本体がコードと一緒にスローする snake_case の理由({ code, reason })をキーとします。送信されるコードとステータスはこのエントリのものです。ここで宣言されていない理由は拒否されます。未指定: スローされた理由は読まれません"
},
"refusals.reasons.message": {
label: "メッセージ",
helpText: "本体がこのコードの下でこの理由をスローしたときにユーザーが読む文。{{ }} プレースホルダーはエントリの params に従います"
},
"refusals.params": {
label: "パラメーター",
helpText: "文に埋め込める名前(例: state)。本体が { code, params: { state } } をスローすると、{{ state }} プレースホルダーにその値が表示されます。未指定: 文はプレーンテキストです"
},
handler: {
label: "ハンドラー",
helpText: "ハンドラー関数名(非推奨 — `body` を推奨)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const koMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"refusals.message": {
label: "메시지",
helpText: "본문이 이 코드를 던질 때 사용자가 읽는 문장으로, 자리 표시자가 없는 일반 텍스트입니다"
helpText: "본문이 이 코드를 던질 때 사용자가 읽는 문장입니다. 일반 텍스트이며, 항목이 params를 선언하면 {{ name }} 자리 표시자에 선언된 매개변수가 채워집니다"
},
"refusals.status": {
label: "상태",
helpText: "거부의 HTTP 상태(400–499)입니다. 없으면 400"
},
"refusals.reasons": {
label: "사유",
helpText: "같은 코드 아래의 추가 문장으로, 본문이 코드와 함께 던지는 snake_case 사유({ code, reason })를 키로 합니다. 전송되는 코드와 상태는 이 항목의 것을 따릅니다. 여기에 선언되지 않은 사유는 거부됩니다. 없으면 던진 사유를 읽지 않습니다"
},
"refusals.reasons.message": {
label: "메시지",
helpText: "본문이 이 코드 아래에서 이 사유를 던질 때 사용자가 읽는 문장입니다. {{ }} 자리 표시자는 항목의 params를 따릅니다"
},
"refusals.params": {
label: "매개변수",
helpText: "문장에 채울 수 있는 이름(예: state)입니다. 본문이 { code, params: { state } }를 던지면 {{ state }} 자리 표시자에 그 값이 표시됩니다. 없으면 문장은 일반 텍스트입니다"
},
handler: {
label: "핸들러",
helpText: "핸들러 함수 이름(사용 중단, `body` 권장)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,10 @@ describe('#19403 round 10 — the verdicts, on the live bundles', () => {
// offers `writeRequiresMasterRead` (ADR-0055 §3 as amended: read on the
// master is enough to write) — one row label, authored in all three
// locales.
expect(translated.length, `${locale} positive control`).toBe(738);
// 741 since #33657: the hook form's refusal entry offers `reasons` (with
// its `message`) and `params` — three row labels, authored in all three
// locales.
expect(translated.length, `${locale} positive control`).toBe(741);
}
// ⭐ DARK — the blindness, executable. On a synthetic two-locale catalog the
// all-three predicate returns 0 while the per-locale one returns 1, so the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,24 @@ export const ptBRMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
"refusals.message": {
label: "Mensagem",
helpText: "A frase que o usuário lê quando o corpo lança este código — texto simples, sem marcadores"
helpText: "A frase que o usuário lê quando o corpo lança este código. Texto simples, a menos que a entrada declare params: então um marcador {{ name }} é preenchido com um parâmetro declarado"
},
"refusals.status": {
label: "Status",
helpText: "Status HTTP da recusa (400–499). Ausente: 400"
},
"refusals.reasons": {
label: "Motivos",
helpText: "Outras frases sob este mesmo código, indexadas pelo motivo snake_case que o corpo lança junto com o código ({ code, reason }). O código e o status enviados continuam sendo os desta entrada; um motivo não declarado aqui é recusado. Ausente: um motivo lançado não é lido"
},
"refusals.reasons.message": {
label: "Mensagem",
helpText: "A frase que o usuário lê quando o corpo lança este motivo sob o código. Seus marcadores {{ }} seguem os params da entrada"
},
"refusals.params": {
label: "Parâmetros",
helpText: "Nomes que as frases podem preencher (por exemplo state): o corpo lança { code, params: { state } } e um marcador {{ state }} mostra o valor. Ausente: as frases são texto simples"
},
handler: {
label: "Handler",
helpText: "Nome da função handler (obsoleto — prefira `body`)"
Expand Down
Loading
Loading