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
11 changes: 11 additions & 0 deletions .changeset/33803-hook-refusals-help-handler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@objectstack/spec': patch
'@objectstack/platform-objects': patch
---

fix(spec): the hook form's refusal catalogue help names the handler beside the JavaScript body

Clause-②: no — help text only
Metadata-protocol: none

The Studio hook form's `refusals` row ended its help with "JavaScript (L2) bodies only", while `HookSchema` answers a refusal catalogue on a sandboxed `js` body and on an in-process `handler` alike, and refuses it on an `expression` body. The help now reads "For a JavaScript (L2) body or a handler; refused on an expression body", and says the code is the one the hook throws rather than the body. The translated copies in the ten metadata-form bundles of `@objectstack/platform-objects` carry the same correction. No behaviour changes: what a hook may declare, and what is refused, is exactly as before.
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const arMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "حالات الرفض",
helpText: "فهرس حالات الرفض، مفهرس برمز SCREAMING_SNAKE الذي يرميه المتن (مثل CLEAN_VERSION_REQUIRED). يقرأ المستدعي الرسالة المُعلنة، مترجمة إلى لغته، مع الحالة المُعلنة. لمتون JavaScript ‏(L2) فقط"
helpText: "فهرس حالات الرفض، مفهرس برمز SCREAMING_SNAKE الذي يرميه الخطاف (مثل CLEAN_VERSION_REQUIRED). يقرأ المستدعي الرسالة المُعلنة، مترجمة إلى لغته، مع الحالة المُعلنة. لمتن JavaScript ‏(L2) أو معالج؛ ويُرفض في متن التعبير"
},
"refusals.message": {
label: "الرسالة",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const deMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "Ablehnungen",
helpText: "Katalog der Ablehnungen, nach dem SCREAMING_SNAKE-Code, den der Rumpf wirft (z. B. CLEAN_VERSION_REQUIRED). Der Aufrufer liest die deklarierte Meldung, übersetzt in seine Sprache, mit dem deklarierten Status. Nur JavaScript-Rümpfe (L2)"
helpText: "Katalog der Ablehnungen, nach dem SCREAMING_SNAKE-Code, den der Hook wirft (z. B. CLEAN_VERSION_REQUIRED). Der Aufrufer liest die deklarierte Meldung, übersetzt in seine Sprache, mit dem deklarierten Status. Für einen JavaScript-Rumpf (L2) oder einen Handler; bei einem Ausdrucksrumpf abgelehnt"
},
"refusals.message": {
label: "Meldung",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "Refusals",
helpText: "Refusal catalogue, keyed by the SCREAMING_SNAKE code the body throws (e.g. CLEAN_VERSION_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. JavaScript (L2) bodies only"
helpText: "Refusal catalogue, keyed by the SCREAMING_SNAKE code the hook throws (e.g. CLEAN_VERSION_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. For a JavaScript (L2) body or a handler; refused on an expression body"
},
"refusals.message": {
label: "Message",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const esESMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
refusals: {
label: "Rechazos",
helpText: "Catálogo de rechazos, indexado por el código SCREAMING_SNAKE que lanza el cuerpo (p. ej. CLEAN_VERSION_REQUIRED). Quien llama recibe el mensaje declarado, traducido a su idioma, con el estado declarado. Solo cuerpos JavaScript (L2)"
helpText: "Catálogo de rechazos, indexado por el código SCREAMING_SNAKE que lanza el gancho (p. ej. CLEAN_VERSION_REQUIRED). Quien llama recibe el mensaje declarado, traducido a su idioma, con el estado declarado. Para un cuerpo JavaScript (L2) o un manejador; se rechaza en un cuerpo de expresión"
},
"refusals.message": {
label: "Mensaje",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const frMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "Refus",
helpText: "Catalogue des refus, indexé par le code SCREAMING_SNAKE que lève le corps (par ex. CLEAN_VERSION_REQUIRED). L’appelant lit le message déclaré, traduit dans sa langue, avec le statut déclaré. Corps JavaScript (L2) uniquement"
helpText: "Catalogue des refus, indexé par le code SCREAMING_SNAKE que lève le hook (par ex. CLEAN_VERSION_REQUIRED). L’appelant lit le message déclaré, traduit dans sa langue, avec le statut déclaré. Pour un corps JavaScript (L2) ou un gestionnaire ; refusé sur un corps expression"
},
"refusals.message": {
label: "Message",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const jaJPMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
refusals: {
label: "拒否カタログ",
helpText: "本体がスローする SCREAMING_SNAKE のコード(例: CLEAN_VERSION_REQUIRED)をキーとする拒否カタログ。呼び出し元には宣言したメッセージ(その言語に翻訳)と宣言したステータスが返ります。JavaScript(L2)本体のみ"
helpText: "フックがスローする SCREAMING_SNAKE のコード(例: CLEAN_VERSION_REQUIRED)をキーとする拒否カタログ。呼び出し元には宣言したメッセージ(その言語に翻訳)と宣言したステータスが返ります。JavaScript(L2)本体またはハンドラーで使用可能。expression 本体では拒否されます"
},
"refusals.message": {
label: "メッセージ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const koMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "거부",
helpText: "본문이 던지는 SCREAMING_SNAKE 코드(예: CLEAN_VERSION_REQUIRED)를 키로 하는 거부 카탈로그입니다. 호출자는 선언된 메시지를 자신의 언어로 번역해 선언된 상태와 함께 읽습니다. JavaScript(L2) 본문 전용"
helpText: "훅이 던지는 SCREAMING_SNAKE 코드(예: CLEAN_VERSION_REQUIRED)를 키로 하는 거부 카탈로그입니다. 호출자는 선언된 메시지를 자신의 언어로 번역해 선언된 상태와 함께 읽습니다. JavaScript(L2) 본문 또는 핸들러용이며, expression 본문에서는 거부됩니다"
},
"refusals.message": {
label: "메시지",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const ptBRMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
refusals: {
label: "Recusas",
helpText: "Catálogo de recusas, indexado pelo código SCREAMING_SNAKE que o corpo lança (por exemplo CLEAN_VERSION_REQUIRED). O chamador lê a mensagem declarada, traduzida para o idioma dele, com o status declarado. Somente corpos JavaScript (L2)"
helpText: "Catálogo de recusas, indexado pelo código SCREAMING_SNAKE que o hook lança (por exemplo CLEAN_VERSION_REQUIRED). O chamador lê a mensagem declarada, traduzida para o idioma dele, com o status declarado. Para um corpo JavaScript (L2) ou um handler; recusado em um corpo de expressão"
},
"refusals.message": {
label: "Mensagem",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const ruMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
refusals: {
label: "Отказы",
helpText: "Каталог отказов с ключами — кодами SCREAMING_SNAKE, которые выбрасывает тело (например, CLEAN_VERSION_REQUIRED). Вызывающий получает объявленное сообщение в переводе на свой язык и с объявленным статусом. Только для тел JavaScript (L2)"
helpText: "Каталог отказов с ключами — кодами SCREAMING_SNAKE, которые выбрасывает хук (например, CLEAN_VERSION_REQUIRED). Вызывающий получает объявленное сообщение в переводе на свой язык и с объявленным статусом. Для тела JavaScript (L2) или обработчика; для тела-выражения отклоняется"
},
"refusals.message": {
label: "Сообщение",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const zhCNMetadataForms: NonNullable<TranslationData['metadataForms']> =
},
refusals: {
label: "拒绝目录",
helpText: "拒绝目录,以正文抛出的 SCREAMING_SNAKE 错误码为键(例如 CLEAN_VERSION_REQUIRED)。调用方读到声明的提示语(按其语言翻译)和声明的状态码。仅适用于 JavaScript(L2)正文"
helpText: "拒绝目录,以钩子抛出的 SCREAMING_SNAKE 错误码为键(例如 CLEAN_VERSION_REQUIRED)。调用方读到声明的提示语(按其语言翻译)和声明的状态码。适用于 JavaScript(L2)正文或处理器;表达式正文声明会被拒绝"
},
"refusals.message": {
label: "提示语",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export const zhHantMetadataForms: NonNullable<TranslationData['metadataForms']>
},
refusals: {
label: "拒絕目錄",
helpText: "拒絕目錄,以內文丟擲的 SCREAMING_SNAKE 錯誤碼為鍵(例如 CLEAN_VERSION_REQUIRED)。呼叫方讀到宣告的提示語(依其語言翻譯)和宣告的狀態碼。僅適用於 JavaScript(L2)內文"
helpText: "拒絕目錄,以掛鉤丟擲的 SCREAMING_SNAKE 錯誤碼為鍵(例如 CLEAN_VERSION_REQUIRED)。呼叫方讀到宣告的提示語(依其語言翻譯)和宣告的狀態碼。適用於 JavaScript(L2)內文或處理器;運算式內文宣告會被拒絕"
},
"refusals.message": {
label: "提示語",
Expand Down
24 changes: 24 additions & 0 deletions packages/spec/src/data/hook-refusals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from './hook-refusal-codes';
import { hookRefusalMessageKey } from '../system/i18n-resolver';
import { TranslationDataSchema } from '../system/translation.zod';
import { hookForm } from './hook.form';

// #26170 (maintainer ruling 6431311681, letter A): a hook declares its refusal
// catalogue, `refusals: { <CODE>: { message, status? } }`, and its body refuses
Expand Down Expand Up @@ -450,3 +451,26 @@ describe('the translation address of a reason — `hooks.<hook>.refusals.<CODE>.
expect(r.success).toBe(false);
});
});

// The form row says who may declare a catalogue, and that is what HookSchema
// answers: a sandboxed js body or an in-process handler (the form offers the
// legacy `handler` row too), never an expression body.
describe('hookForm refusals row — help names every hook kind that may declare one', () => {
type Row = { field?: string; helpText?: string; fields?: Row[] };
const rows: Row[] = (hookForm.sections ?? []).flatMap((s) => (s.fields ?? []) as Row[]);
const help = (field: string): string => {
const found = rows.flatMap((r) => [r, ...(r.fields ?? [])]).filter((r) => r.field === field);
expect(found).toHaveLength(1);
return found[0].helpText ?? '';
};

it('names the handler beside the js body and does not limit the catalogue to js bodies', () => {
const text = help('refusals');
expect(text).toMatch(/\bhandler\b/);
expect(text).not.toMatch(/bodies only/i);
});

it('the handler it names is a row the same form offers', () => {
expect(help('handler')).not.toBe('');
});
});
5 changes: 3 additions & 2 deletions packages/spec/src/data/hook.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { defineForm } from '../ui/view.zod';
* Hooks intercept the data lifecycle. The body field is a composite
* (`{ language, source, capabilities?, timeoutMs?, memoryMb? }`) whose
* `source` renders in a Monaco code editor with language-appropriate
* syntax highlighting. The body's refusal catalogue (`refusals`) sits beside it.
* syntax highlighting. The hook's refusal catalogue (`refusals`) sits beside it:
* a js body or a handler may declare one, an expression body may not.
*/
export const hookForm = defineForm({
schemaId: 'hook',
Expand Down Expand Up @@ -56,7 +57,7 @@ export const hookForm = defineForm({
field: 'refusals',
type: 'record',
widget: 'key-only-record',
helpText: 'Refusal catalogue, keyed by the SCREAMING_SNAKE code the body throws (e.g. CLEAN_VERSION_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. JavaScript (L2) bodies only',
helpText: 'Refusal catalogue, keyed by the SCREAMING_SNAKE code the hook throws (e.g. CLEAN_VERSION_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. For a JavaScript (L2) body or a handler; refused on an expression body',
fields: [
{ field: 'message', type: 'textarea', required: true, 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' },
{ field: 'status', type: 'number', helpText: 'HTTP status of the refusal (400–499). Absent: 400' },
Expand Down
Loading