diff --git a/.changeset/35096-action-form-texts-refusals-rows.md b/.changeset/35096-action-form-texts-refusals-rows.md new file mode 100644 index 00000000000..18052b79cf3 --- /dev/null +++ b/.changeset/35096-action-form-texts-refusals-rows.md @@ -0,0 +1,12 @@ +--- +'@objectstack/spec': patch +'@objectstack/platform-objects': patch +--- + +feat(spec): the Studio action form offers an action's declared `refusals` and `texts` + +Clause-②: no +Metadata-protocol: none + +- **Studio action form.** `actionForm` gains two rows in the Behavior section, right after the script `body`, each shown only on a `type: 'script'` action as the body is: `refusals`, a key-only record keyed by the SCREAMING_SNAKE code the body throws, each entry editing its `message`, `status`, `reasons` (a key-only record of `{ message }`) and `params`; and `texts`, a key-only record keyed by the snake_case key the body asks for with `ctx.text`, each entry editing its `message` and `params`. They are the hook form's two rows, because the action entries are the hook entries. An author editing an action in the Studio can now write the `refusals` and `texts` the schema already accepts, instead of going through the metadata API or the package source. Nothing about what an action may declare changes. +- **Locale packs.** The rows' labels and help text ship in all eleven metadata-forms locale packs of `@objectstack/platform-objects`. diff --git a/packages/lint/src/validate-predicate-path-refs.test.ts b/packages/lint/src/validate-predicate-path-refs.test.ts index 8d38546b7e9..32b1a46de94 100644 --- a/packages/lint/src/validate-predicate-path-refs.test.ts +++ b/packages/lint/src/validate-predicate-path-refs.test.ts @@ -699,7 +699,10 @@ describe('#7010 corpus — shipped METADATA_FORM_REGISTRY', () => { // It is 91 today, an ADDITION of ONE: #29462 offered the field form's // `referenceNameVisible` row, gated on `data.type in ['lookup','user']`. It // is an in-list, so it does not reach the literal-comparison census below. - expect(predicates, 'the shipped metadata forms carry no predicates at all').toBe(91); + // It is 93 today, an ADDITION of TWO: #35096 and #34823 offered the action + // form's `texts` and `refusals` rows, each gated like `body` on + // `data.type == 'script'`. They reach the literal-comparison census below. + expect(predicates, 'the shipped metadata forms carry no predicates at all').toBe(93); const findings = validatePredicatePathRefs(corrupted); expect(findings).toHaveLength(predicates); @@ -827,7 +830,10 @@ describe('#7010 corpus — shipped METADATA_FORM_REGISTRY', () => { // It is 65 today: #35047's `field :: percentDisplay` gate also opens for a // percent formula, `data.type == 'formula' && data.returnType == 'percent'`, // two more single-quoted literal comparisons. - expect(comparisons, 'no shipped predicate carries an `==`/`!=` literal comparison').toBe(65); + // It is 67 today: #35096's `action :: texts` and #34823's + // `action :: refusals` rows are each gated on `data.type == 'script'`, two + // single-quoted literal comparisons. + expect(comparisons, 'no shipped predicate carries an `==`/`!=` literal comparison').toBe(67); const rhsFindings = validatePredicatePathRefs(corrupted) .filter((f) => f.rule === PREDICATE_RHS_PATH_SHAPED); diff --git a/packages/platform-objects/src/apps/translations/action-body-panel-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/action-body-panel-echo-decisions.test.ts index aeabac85761..dcd8766f4ee 100644 --- a/packages/platform-objects/src/apps/translations/action-body-panel-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/action-body-panel-echo-decisions.test.ts @@ -661,8 +661,16 @@ describe('#19403 round 5 — the blind spot, FIFTH shape: one schema, two forms, // `type === 'repeater'`, and `body` is a `composite`. All five echoed in // all three locales, and they are five of the six keys this round decides. // 7 since the action form offers the `onSuccess` composite — its two - // children, `navigate` and `openIn`, authored in all three locales. - expect(ACTION_ENUMERATED.skipped.length).toBe(7); + // children, `navigate` and `openIn`, authored in all three locales. 9 + // since #35096: the form offers the `texts` record, whose entry fields + // (`message`, `params`) are enumerated the same way. 14 since #34823: the + // form offers the `refusals` record, the hook row's five entry fields. + expect(ACTION_ENUMERATED.skipped.length).toBe(14); + expect(ACTION_ENUMERATED.skipped).toContain('texts.message'); + expect(ACTION_ENUMERATED.skipped).toContain('texts.params'); + for (const child of ['message', 'status', 'reasons', 'reasons.message', 'params']) { + expect(ACTION_ENUMERATED.skipped).toContain(`refusals.${child}`); + } for (const child of SHARED_BODY_CHILDREN) { expect(ACTION_ENUMERATED.skipped).toContain(`body.${child}`); expect( @@ -728,8 +736,10 @@ describe('#19403 round 5 — the blind spot, FIFTH shape: one schema, two forms, const coveredParents = new Set(ACTION_ENUMERATED.covered.map((k) => k.replace(/\.[^.]+$/, ''))); const skippedParents = new Set(ACTION_ENUMERATED.skipped.map((k) => k.replace(/\.[^.]+$/, ''))); expect([...coveredParents]).toEqual(['params']); - // `onSuccess` since the action form offers it as a composite beside `body`. - expect([...skippedParents]).toEqual(['body', 'onSuccess']); + // `onSuccess` since the action form offers it as a composite beside `body`, + // `texts` since #35096 and `refusals` (with its nested `reasons`) since + // #34823, the two record rows after `body`. + expect([...skippedParents]).toEqual(['body', 'refusals', 'refusals.reasons', 'texts', 'onSuccess']); for (const parent of ['params', 'body']) { expect(ACTION_ENUMERATED.covered.includes(parent), `${parent} is not itself a row property`).toBe(false); expect(ACTION_ENUMERATED.skipped.includes(parent), `${parent} is not itself an unwalked child`).toBe(false); diff --git a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts index 80a4be47550..ef6e1232aea 100644 --- a/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ar.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const arMetadataForms: NonNullable = { label: "الذاكرة (ميغابايت)", helpText: "حد الذاكرة لكل استدعاء (ميغابايت، بحد أقصى 256)" }, + refusals: { + label: "حالات الرفض", + helpText: "فهرس حالات الرفض، مفهرس برمز SCREAMING_SNAKE الذي يرميه متن الإجراء (مثل SIGN_IN_REQUIRED). يقرأ المستدعي الرسالة المُعلنة، مترجمة إلى لغته، مع الحالة المُعلنة. لمتن JavaScript ‏(L2) في إجراء script؛ ويُرفض في متن التعبير" + }, + "refusals.message": { + label: "الرسالة", + 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 }} قيمتها. عند الغياب: الجمل نص عادي" + }, + texts: { + label: "النصوص", + helpText: "الجمل التي يكتبها الإجراء في السجلات، مفهرسة بالمفتاح بصيغة snake_case الذي يطلبه متنه عبر ctx.text (مثل email_subject). يتلقى المتن الرسالة المُعلنة بلغة المؤسسة، مترجمة، مع الرسالة المُعلنة بديلًا عند غياب الترجمة. لمتن JavaScript ‏(L2) في إجراء script؛ ويُرفض في متن التعبير" + }, + "texts.message": { + label: "الرسالة", + helpText: "الجملة التي يكتبها الإجراء عندما يطلب متنه هذا المفتاح. نص عادي، ما لم يُعلن الإدخال params: عندها يملأ العنصر النائب {{ name }} معاملًا مُعلنًا" + }, + "texts.params": { + label: "المعاملات", + helpText: "الأسماء التي يمكن للجملة ملؤها (مثل subject): يطلب المتن ctx.text(key, { subject }) ويعرض العنصر النائب {{ subject }} قيمتها. عند الغياب: الجملة نص عادي" + }, params: { label: "المعلمات", helpText: "معلمات إدخال المستخدم (إظهار نموذج قبل التنفيذ)" diff --git a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts index 018b6e38ab8..414d5d22502 100644 --- a/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const deMetadataForms: NonNullable = { label: "Speicher (MB)", helpText: "Speicherobergrenze pro Aufruf (MB, max. 256)" }, + refusals: { + label: "Ablehnungen", + helpText: "Katalog der Ablehnungen, nach dem SCREAMING_SNAKE-Code, den der Rumpf der Aktion wirft (z. B. SIGN_IN_REQUIRED). Der Aufrufer liest die deklarierte Meldung, übersetzt in seine Sprache, mit dem deklarierten Status. Für den JavaScript-Rumpf (L2) einer script-Aktion; bei einem Ausdrucksrumpf abgelehnt" + }, + "refusals.message": { + label: "Meldung", + 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" + }, + texts: { + label: "Texte", + helpText: "Sätze, die die Aktion in Datensätze schreibt, nach dem snake_case-Schlüssel, den ihr Rumpf mit ctx.text anfragt (z. B. email_subject). Der Rumpf erhält die deklarierte Meldung in der Sprache der Organisation, übersetzt, mit der deklarierten Meldung als Rückfall. Für den JavaScript-Rumpf (L2) einer script-Aktion; bei einem Ausdrucksrumpf abgelehnt" + }, + "texts.message": { + label: "Meldung", + helpText: "Der Satz, den die Aktion schreibt, wenn ihr Rumpf diesen Schlüssel anfragt. Einfacher Text, außer der Eintrag deklariert params: dann füllt ein Platzhalter {{ name }} einen deklarierten Parameter" + }, + "texts.params": { + label: "Parameter", + helpText: "Namen, die der Satz füllen darf (z. B. subject): Der Rumpf fragt ctx.text(key, { subject }) an, und ein Platzhalter {{ subject }} zeigt den Wert. Fehlt er: Der Satz ist einfacher Text" + }, params: { label: "Parameter", helpText: "Benutzereingabeparameter (Formular vor der Ausführung anzeigen)" diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts index 628a3fca820..445d412b292 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts @@ -20,6 +20,7 @@ export const deGeneratedSourceHashes: Readonly> = { "metadataForms.action.fields.name.label": "5274417ff1ccaf01", "metadataForms.action.fields.patch.label": "815f68570a78eba1", + "metadataForms.action.fields.refusals.status.label": "64a420165247654b", "metadataForms.agent.fields.avatar.label": "0f06369995b69b8b", "metadataForms.agent.fields.name.label": "5274417ff1ccaf01", "metadataForms.app.fields.branding.label": "ec6e391065514b64", diff --git a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts index 1e70401ec93..0232e8c3966 100644 --- a/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/en.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const enMetadataForms: NonNullable = { label: "Memory Mb", helpText: "Per-invocation memory cap (MB, max 256)" }, + refusals: { + label: "Refusals", + helpText: "Refusal catalogue, keyed by the SCREAMING_SNAKE code the action's body throws (e.g. SIGN_IN_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. For a script action's JavaScript (L2) body; refused on an expression body" + }, + "refusals.message": { + label: "Message", + 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" + }, + texts: { + label: "Texts", + helpText: "Sentences the action writes into records, keyed by the snake_case key its body asks for with ctx.text (e.g. email_subject). The body gets the declared message in the organization's language, translated, with the declared message as the fallback. For a script action's JavaScript (L2) body; refused on an expression body" + }, + "texts.message": { + label: "Message", + helpText: "The sentence the action writes when its body asks for this key. Plain text, unless the entry declares params: then a {{ name }} hole fills a declared param" + }, + "texts.params": { + label: "Params", + helpText: "Names the sentence may fill (e.g. subject): the body asks for ctx.text(key, { subject }), and a {{ subject }} hole renders it. Absent: the sentence is plain text" + }, params: { label: "Params", helpText: "User input parameters (show form before executing)" diff --git a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts index 5207cbe7c62..3f978b6e41c 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const esESMetadataForms: NonNullable = label: "Memoria (MB)", helpText: "Límite de memoria por invocación (MB, máx. 256)" }, + refusals: { + label: "Rechazos", + helpText: "Catálogo de rechazos, indexado por el código SCREAMING_SNAKE que lanza el cuerpo de la acción (p. ej. SIGN_IN_REQUIRED). Quien llama recibe el mensaje declarado, traducido a su idioma, con el estado declarado. Para el cuerpo JavaScript (L2) de una acción script; se rechaza en un cuerpo de expresión" + }, + "refusals.message": { + label: "Mensaje", + 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" + }, + texts: { + label: "Textos", + helpText: "Frases que la acción escribe en los registros, indexadas por la clave snake_case que su cuerpo pide con ctx.text (p. ej. email_subject). El cuerpo recibe el mensaje declarado en el idioma de la organización, traducido, con el mensaje declarado como respaldo. Para el cuerpo JavaScript (L2) de una acción script; se rechaza en un cuerpo de expresión" + }, + "texts.message": { + label: "Mensaje", + helpText: "La frase que escribe la acción cuando su cuerpo pide esta clave. Texto plano, salvo que la entrada declare params: entonces un marcador {{ name }} se rellena con un parámetro declarado" + }, + "texts.params": { + label: "Parámetros", + helpText: "Nombres que la frase puede rellenar (p. ej. subject): el cuerpo pide ctx.text(key, { subject }) y un marcador {{ subject }} muestra su valor. Si se omite: la frase es texto plano" + }, params: { label: "Parámetros", helpText: "Parámetros de entrada de usuario (muestra el formulario antes de ejecutar)" diff --git a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts index f878de5e1b6..c8e95ad7efc 100644 --- a/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const frMetadataForms: NonNullable = { label: "Mémoire (Mo)", helpText: "Plafond de mémoire par appel (Mo, 256 max.)" }, + refusals: { + label: "Refus", + helpText: "Catalogue des refus, indexé par le code SCREAMING_SNAKE que lève le corps de l’action (par ex. SIGN_IN_REQUIRED). L’appelant lit le message déclaré, traduit dans sa langue, avec le statut déclaré. Pour le corps JavaScript (L2) d’une action script ; refusé sur un corps expression" + }, + "refusals.message": { + label: "Message", + 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" + }, + texts: { + label: "Textes", + helpText: "Les phrases que l’action écrit dans les enregistrements, indexées par la clé snake_case que son corps demande avec ctx.text (par ex. email_subject). Le corps reçoit le message déclaré dans la langue de l’organisation, traduit, avec le message déclaré comme repli. Pour le corps JavaScript (L2) d’une action script ; refusé sur un corps expression" + }, + "texts.message": { + label: "Message", + helpText: "La phrase que l’action écrit lorsque son corps demande cette clé. Texte brut, sauf si l’entrée déclare des params : un espace réservé {{ name }} reçoit alors un paramètre déclaré" + }, + "texts.params": { + label: "Paramètres", + helpText: "Les noms que la phrase peut remplir (par ex. subject) : le corps demande ctx.text(key, { subject }), et un espace réservé {{ subject }} en affiche la valeur. Absent : la phrase est du texte brut" + }, params: { label: "Paramètres", helpText: "Paramètres saisis par l’utilisateur (afficher un formulaire avant l’exécution)" diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts index 8399fd2d550..e75dd623269 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts @@ -21,6 +21,9 @@ export const frGeneratedSourceHashes: Readonly> = { "metadataForms.action.fields.body.source.label": "8fe786e8e29c8cec", "metadataForms.action.fields.description.label": "779a4342c8eb6707", "metadataForms.action.fields.mode.label": "74dde5013435abdc", + "metadataForms.action.fields.refusals.message.label": "2af15199795c25b9", + "metadataForms.action.fields.refusals.reasons.message.label": "2af15199795c25b9", + "metadataForms.action.fields.texts.message.label": "2af15199795c25b9", "metadataForms.action.fields.type.label": "901bb552898b2cab", "metadataForms.action.fields.visible.label": "7f733614bc9cea97", "metadataForms.action.label": "a36bba313a7aa9ab", diff --git a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts index 199daa412d8..30bdf25fa1e 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const jaJPMetadataForms: NonNullable = label: "メモリ(MB)", helpText: "呼び出しごとのメモリ上限(MB、最大 256)" }, + refusals: { + label: "拒否カタログ", + helpText: "アクションの本文がスローする SCREAMING_SNAKE のコード(例: SIGN_IN_REQUIRED)をキーとする拒否カタログ。呼び出し元には宣言したメッセージ(その言語に翻訳)と宣言したステータスが返ります。script アクションの JavaScript(L2)本文で使用可能。expression 本文では拒否されます" + }, + "refusals.message": { + label: "メッセージ", + 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 }} プレースホルダーにその値が表示されます。未指定: 文はプレーンテキストです" + }, + texts: { + label: "テキスト", + helpText: "アクションがレコードに書き込む文。本文が ctx.text で要求する snake_case のキー(例: email_subject)をキーとします。本文には宣言したメッセージが組織の言語に翻訳されて返り、翻訳がない場合は宣言したメッセージが返ります。script アクションの JavaScript(L2)本文で使用可能。expression 本文では拒否されます" + }, + "texts.message": { + label: "メッセージ", + helpText: "本文がこのキーを要求したときにアクションが書き込む文。プレーンテキスト。ただしエントリが params を宣言している場合、{{ name }} プレースホルダーに宣言済みのパラメーターが入ります" + }, + "texts.params": { + label: "パラメーター", + helpText: "文に埋め込める名前(例: subject)。本文が ctx.text(key, { subject }) を要求すると、{{ subject }} プレースホルダーにその値が表示されます。未指定: 文はプレーンテキストです" + }, params: { label: "パラメーター", helpText: "ユーザー入力パラメーター(実行前にフォームを表示)" diff --git a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts index 19ce1e15175..4a69b1d0e90 100644 --- a/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ko.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const koMetadataForms: NonNullable = { label: "메모리(MB)", helpText: "호출당 메모리 상한(MB, 최대 256)" }, + refusals: { + label: "거부", + helpText: "작업 본문이 던지는 SCREAMING_SNAKE 코드(예: SIGN_IN_REQUIRED)를 키로 하는 거부 카탈로그입니다. 호출자는 선언된 메시지를 자신의 언어로 번역해 선언된 상태와 함께 읽습니다. script 작업의 JavaScript(L2) 본문용이며, expression 본문에서는 거부됩니다" + }, + "refusals.message": { + label: "메시지", + 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 }} 자리 표시자에 그 값이 표시됩니다. 없으면 문장은 일반 텍스트입니다" + }, + texts: { + label: "텍스트", + helpText: "작업이 레코드에 쓰는 문장으로, 본문이 ctx.text로 요청하는 snake_case 키(예: email_subject)를 키로 합니다. 본문은 선언된 메시지를 조직의 언어로 번역해 받으며, 번역이 없으면 선언된 메시지를 받습니다. script 작업의 JavaScript(L2) 본문용이며, expression 본문에서는 거부됩니다" + }, + "texts.message": { + label: "메시지", + helpText: "본문이 이 키를 요청할 때 작업이 쓰는 문장입니다. 일반 텍스트이며, 항목이 params를 선언하면 {{ name }} 자리 표시자에 선언된 매개변수가 채워집니다" + }, + "texts.params": { + label: "매개변수", + helpText: "문장에 채울 수 있는 이름(예: subject)입니다. 본문이 ctx.text(key, { subject })를 요청하면 {{ subject }} 자리 표시자에 그 값이 표시됩니다. 없으면 문장은 일반 텍스트입니다" + }, params: { label: "매개변수", helpText: "사용자 입력 매개변수(실행 전에 양식 표시)" diff --git a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts index bc503d7d88f..da1f6a43fdf 100644 --- a/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts +++ b/packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts @@ -1292,7 +1292,12 @@ describe('#19403 round 10 — the verdicts, on the live bundles', () => { // 745 since the object form's `userActions` composite offers `transfer` // (the Change Owner switch, ruling 7000907189 point 1) — one row label, // authored in all three locales. - expect(translated.length, `${locale} positive control`).toBe(745); + // 748 since #35096: the action form offers the `texts` record and its + // `message` / `params` entry fields — three row labels, authored in all + // three locales. + // 754 since #34823: the action form offers the `refusals` record and its + // five entry fields — six row labels, authored in all three locales. + expect(translated.length, `${locale} positive control`).toBe(754); } // ⭐ 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 diff --git a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts index 09b27377c8d..5ae7d84d63f 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const ptBRMetadataForms: NonNullable = label: "Memória (MB)", helpText: "Limite de memória por invocação (MB, máx. 256)" }, + refusals: { + label: "Recusas", + helpText: "Catálogo de recusas, indexado pelo código SCREAMING_SNAKE que o corpo da ação lança (por exemplo SIGN_IN_REQUIRED). O chamador lê a mensagem declarada, traduzida para o idioma dele, com o status declarado. Para o corpo JavaScript (L2) de uma ação script; recusado em um corpo de expressão" + }, + "refusals.message": { + label: "Mensagem", + 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" + }, + texts: { + label: "Textos", + helpText: "Frases que a ação escreve nos registros, indexadas pela chave snake_case que o corpo dela pede com ctx.text (por exemplo email_subject). O corpo recebe a mensagem declarada no idioma da organização, traduzida, com a mensagem declarada como alternativa. Para o corpo JavaScript (L2) de uma ação script; recusado em um corpo de expressão" + }, + "texts.message": { + label: "Mensagem", + helpText: "A frase que a ação escreve quando o corpo dela pede esta chave. Texto simples, a menos que a entrada declare params: então um marcador {{ name }} é preenchido com um parâmetro declarado" + }, + "texts.params": { + label: "Parâmetros", + helpText: "Nomes que a frase pode preencher (por exemplo subject): o corpo pede ctx.text(key, { subject }) e um marcador {{ subject }} mostra o valor. Ausente: a frase é texto simples" + }, params: { label: "Parâmetros", helpText: "Parâmetros de entrada do usuário (mostrar um formulário antes de executar)" diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts index c86d9109f75..9c13fe5b331 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts @@ -19,6 +19,7 @@ export const ptBRGeneratedSourceHashes: Readonly> = { "metadataForms.action.fields.patch.label": "815f68570a78eba1", + "metadataForms.action.fields.refusals.status.label": "64a420165247654b", "metadataForms.agent.fields.avatar.label": "0f06369995b69b8b", "metadataForms.dashboard.fields.widgets.label": "bd4bf82396edd638", "metadataForms.dashboard.sections.layout.label": "7f508ea1bb2c3a6b", diff --git a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts index a58a356d74c..868424dccfa 100644 --- a/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/ru.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const ruMetadataForms: NonNullable = { label: "Память (МБ)", helpText: "Ограничение памяти на вызов (МБ, максимум 256)" }, + refusals: { + label: "Отказы", + helpText: "Каталог отказов с ключами — кодами SCREAMING_SNAKE, которые выбрасывает тело действия (например, SIGN_IN_REQUIRED). Вызывающий получает объявленное сообщение в переводе на свой язык и с объявленным статусом. Для тела JavaScript (L2) действия script; для тела-выражения отклоняется" + }, + "refusals.message": { + label: "Сообщение", + 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 }} показывает значение. Если отсутствует: фразы — простой текст" + }, + texts: { + label: "Тексты", + helpText: "Фразы, которые действие записывает в записи, с ключами в snake_case, которые его тело запрашивает через ctx.text (например, email_subject). Тело получает объявленное сообщение в переводе на язык организации, а без перевода — само объявленное сообщение. Для тела JavaScript (L2) действия script; для тела-выражения отклоняется" + }, + "texts.message": { + label: "Сообщение", + helpText: "Фраза, которую действие записывает, когда его тело запрашивает этот ключ. Простой текст, если запись не объявляет params: тогда заполнитель {{ name }} подставляет объявленный параметр" + }, + "texts.params": { + label: "Параметры", + helpText: "Имена, которые может заполнять фраза (например, subject): тело запрашивает ctx.text(key, { subject }), и заполнитель {{ subject }} показывает значение. Если отсутствует: фраза — простой текст" + }, params: { label: "Параметры", helpText: "Параметры ввода пользователя (показать форму перед выполнением)" diff --git a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts index d3a97434148..20e2ad4b211 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const zhCNMetadataForms: NonNullable = label: "内存(MB)", helpText: "单次调用内存上限(MB,最大 256)" }, + refusals: { + label: "拒绝目录", + helpText: "拒绝目录,以操作正文抛出的 SCREAMING_SNAKE 错误码为键(例如 SIGN_IN_REQUIRED)。调用方读到声明的提示语(按其语言翻译)和声明的状态码。适用于 script 操作的 JavaScript(L2)正文;表达式正文声明会被拒绝" + }, + "refusals.message": { + label: "提示语", + helpText: "正文抛出此错误码时用户读到的句子。纯文本;若该条目声明了参数,则 {{ name }} 占位符填入一个已声明的参数" + }, + "refusals.status": { + label: "状态码", + helpText: "拒绝的 HTTP 状态码(400–499)。不填:400" + }, + "refusals.reasons": { + label: "原因", + helpText: "同一错误码下的更多句子,以正文在错误码旁抛出的 snake_case 原因为键({ code, reason })。线上的错误码和状态码仍取本条目的;未在此声明的原因会被拒绝。不填:抛出的原因不被读取" + }, + "refusals.reasons.message": { + label: "提示语", + helpText: "正文在此错误码下抛出此原因时用户读到的句子。其中的 {{ }} 占位符遵循本条目的参数" + }, + "refusals.params": { + label: "参数", + helpText: "句子可填入的名称(例如 state):正文抛出 { code, params: { state } },{{ state }} 占位符即显示该值。不填:句子为纯文本" + }, + texts: { + label: "文本", + helpText: "操作写入记录的句子,以其正文通过 ctx.text 请求的 snake_case 键为键(例如 email_subject)。正文得到按组织语言翻译的声明句子,无翻译时回退为声明的句子。适用于 script 操作的 JavaScript(L2)正文;表达式正文声明会被拒绝" + }, + "texts.message": { + label: "句子", + helpText: "正文请求此键时操作写入的句子。纯文本;若该条目声明了参数,则 {{ name }} 占位符填入一个已声明的参数" + }, + "texts.params": { + label: "参数", + helpText: "句子可填入的名称(例如 subject):正文请求 ctx.text(key, { subject }),{{ subject }} 占位符即显示该值。不填:句子为纯文本" + }, params: { label: "参数", helpText: "执行前向用户收集的输入参数" diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts index 2b69556f0c7..5ca0d588b77 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.metadata-forms.generated.ts @@ -1897,6 +1897,42 @@ export const zhHantMetadataForms: NonNullable label: "記憶體(MB)", helpText: "單次呼叫記憶體上限(MB,最大 256)" }, + refusals: { + label: "拒絕目錄", + helpText: "拒絕目錄,以操作內文丟擲的 SCREAMING_SNAKE 錯誤碼為鍵(例如 SIGN_IN_REQUIRED)。呼叫方讀到宣告的提示語(依其語言翻譯)和宣告的狀態碼。適用於 script 操作的 JavaScript(L2)內文;運算式內文宣告會被拒絕" + }, + "refusals.message": { + label: "提示語", + helpText: "內文丟擲此錯誤碼時使用者讀到的句子。純文字;若該條目宣告了參數,則 {{ name }} 預留位置填入一個已宣告的參數" + }, + "refusals.status": { + label: "狀態碼", + helpText: "拒絕的 HTTP 狀態碼(400–499)。不填:400" + }, + "refusals.reasons": { + label: "原因", + helpText: "同一錯誤碼下的更多句子,以內文在錯誤碼旁丟擲的 snake_case 原因為鍵({ code, reason })。線上的錯誤碼和狀態碼仍取本條目的;未在此宣告的原因會被拒絕。不填:丟擲的原因不被讀取" + }, + "refusals.reasons.message": { + label: "提示語", + helpText: "內文在此錯誤碼下丟擲此原因時使用者讀到的句子。其中的 {{ }} 預留位置遵循本條目的參數" + }, + "refusals.params": { + label: "參數", + helpText: "句子可填入的名稱(例如 state):內文丟擲 { code, params: { state } },{{ state }} 預留位置即顯示該值。不填:句子為純文字" + }, + texts: { + label: "文字", + helpText: "操作寫入記錄的句子,以其內文透過 ctx.text 請求的 snake_case 鍵為鍵(例如 email_subject)。內文取得依組織語言翻譯的宣告句子,無翻譯時退回宣告的句子。適用於 script 操作的 JavaScript(L2)內文;運算式內文宣告會被拒絕" + }, + "texts.message": { + label: "句子", + helpText: "內文請求此鍵時操作寫入的句子。純文字;若該條目宣告了參數,則 {{ name }} 預留位置填入一個已宣告的參數" + }, + "texts.params": { + label: "參數", + helpText: "句子可填入的名稱(例如 subject):內文請求 ctx.text(key, { subject }),{{ subject }} 預留位置即顯示該值。不填:句子為純文字" + }, params: { label: "參數", helpText: "執行前向使用者收集的輸入參數" diff --git a/packages/spec/src/system/metadata-form-declared-rows.pin.test.ts b/packages/spec/src/system/metadata-form-declared-rows.pin.test.ts index e806b0555e5..4cd5b8ad431 100644 --- a/packages/spec/src/system/metadata-form-declared-rows.pin.test.ts +++ b/packages/spec/src/system/metadata-form-declared-rows.pin.test.ts @@ -43,6 +43,7 @@ import { describe, it, expect } from 'vitest'; import { METADATA_FORM_REGISTRY } from './metadata-form-registry'; +import { ActionRefusalSchema, ActionTextSchema } from '../ui/action.zod'; type FormEntry = { field?: string; @@ -252,3 +253,89 @@ describe('hook.condition declares the CEL predicate language it edits', () => { expect(row.language).toBe('expression'); }); }); + +/** + * **The action form edits the action's declared sentences beside its script + * body** (ruling 6913660232, parameter 7: an action declares its sentences). + * + * `ActionSchema.texts` is a record keyed by the snake_case key the body asks + * for with `ctx.text`, each entry `{ message, params? }` with no member that + * echoes its key, so its row is the hook form's: a `key-only-record`, which + * adds, renames and removes keys and never writes the key into the entry. + * `ActionSchema.refusals` is the same record shape keyed by the + * SCREAMING_SNAKE code the body throws, its entry the hook refusal entry + * (`{ message, status?, reasons?, params? }`, `reasons` the same shape one + * level down), so it takes the hook form's `refusals` row. The + * reconciliation gate proves the keys and their entry keys are offered + * somewhere on the form; it does not read the control, the gate or where the + * rows sit, so this pin keeps all three. + */ +describe('action.refusals and action.texts are key-only records beside the script body', () => { + type Section = { label?: string; fields?: FormEntry[] }; + const behaviorRows = () => + ((((METADATA_FORM_REGISTRY.action as any)?.sections ?? []) as Section[]).find((s) => s.label === 'Behavior') + ?.fields ?? []) as FormEntry[]; + const indexOf = (key: string) => behaviorRows().findIndex((r) => r?.field === key); + const REFUSAL_FACES = [ + 'message:textarea!', + 'status:number', + 'reasons:record:key-only-record', + 'params:tags', + ] as const; + /** A row's entry controls, as `field:type[:widget][!]` (`!` = required). */ + const entryFaces = (row: FormEntry | undefined) => + (row?.fields ?? []).map( + (f) => `${f.field}:${f.type}${f.widget ? `:${f.widget}` : ''}${(f as { required?: boolean }).required ? '!' : ''}`, + ); + + it('CONTROLS: the probe reads the hook form rows it mirrors, and reports a known absence', () => { + const [hookRow] = rowFor('hook', 'texts'); + expect(hookRow?.widget, 'lit control: the hook form row this one copies').toBe('key-only-record'); + expect(entryFaces(hookRow)).toEqual(['message:textarea!', 'params:tags']); + const [hookRefusals] = rowFor('hook', 'refusals'); + expect(entryFaces(hookRefusals)).toEqual([...REFUSAL_FACES]); + expect(rowFor('action', 'noSuchKeyAtAll'), 'dark control: a key the action form does not offer').toHaveLength(0); + expect(indexOf('body'), 'the Behavior section holds the script body').toBeGreaterThanOrEqual(0); + }); + + it('offers texts once, as a key-only record whose entry controls are the served entry keys', () => { + const [row, ...extra] = rowFor('action', 'texts'); + expect(row, '`texts` is declared by ActionSchema and live; the action form must offer it').toBeDefined(); + expect(extra, 'one row only').toEqual([]); + expect(row.type).toBe('record'); + expect(row.widget).toBe('key-only-record'); + expect(row.helpText).toContain('ctx.text'); + expect(entryFaces(row)).toEqual(['message:textarea!', 'params:tags']); + expect((row.fields ?? []).map((f) => f.field)).toEqual(Object.keys((ActionTextSchema as any).shape)); + }); + + it('offers refusals once, as a key-only record whose entry controls are the served entry keys', () => { + const [row, ...extra] = rowFor('action', 'refusals'); + expect(row, '`refusals` is declared by ActionSchema and live; the action form must offer it').toBeDefined(); + expect(extra, 'one row only').toEqual([]); + expect(row.type).toBe('record'); + expect(row.widget).toBe('key-only-record'); + expect(row.helpText).toContain('SCREAMING_SNAKE'); + expect(entryFaces(row)).toEqual([...REFUSAL_FACES]); + expect((row.fields ?? []).map((f) => f.field)).toEqual(Object.keys((ActionRefusalSchema as any).shape)); + const reasons = (row.fields ?? []).find((f) => f.field === 'reasons'); + expect(entryFaces(reasons), 'a reason is `{ message }`, the hook row\'s nested record').toEqual(['message:textarea!']); + }); + + it('refusals is gated like the body, and sits between it and texts', () => { + const [body] = rowFor('action', 'body'); + const [row] = rowFor('action', 'refusals'); + expect(row.visibleWhen).toEqual(body.visibleWhen); + expect(indexOf('refusals')).toBe(indexOf('body') + 1); + expect(indexOf('texts')).toBe(indexOf('refusals') + 1); + }); + + it('texts is gated like the body, and sits after it in the Behavior section', () => { + const [body] = rowFor('action', 'body'); + const [row] = rowFor('action', 'texts'); + expect(row.visibleWhen).toEqual({ dialect: 'cel', source: "data.type == 'script'" }); + expect(row.visibleWhen).toEqual(body.visibleWhen); + expect(indexOf('texts')).toBeGreaterThan(indexOf('body')); + expect(indexOf('texts'), 'beside the body, before the param dialog rows').toBeLessThan(indexOf('params')); + }); +}); diff --git a/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts b/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts index 88456f34fd4..5a062fefce0 100644 --- a/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts +++ b/packages/spec/src/system/metadata-form-zod-reconciliation.test.ts @@ -464,29 +464,6 @@ const LEDGER: ReadonlyArray = [ key: 'homeAmount', why: "planned, not yet written — the `{ field, rateDate, rateField }` pointers are validated at parse (all three required, each judged against the object's field map), but no engine converts the amount or stores the home amount and the rate until the write-time home-currency projection lands, which ADR-0144 D9 releases with this key. A form control offered today would let an author declare a home amount nothing writes", }, - // #34273 — an action's refusal catalogue lands in the action's source - // first, as a hook's declared texts did (#34374). The Studio row (a - // key-only record, with its help text in the eleven metadata-forms - // bundles) is a follow-up, so this row records why the key is not offered. - { - kind: 'omit', - type: 'action', - path: ROOT_PATH, - key: 'refusals', - why: "live, not yet offered in the Studio — the refusals a `script` action's `js` body throws by code (answered with the declared sentence in the caller's locale) are validated at parse (SCREAMING_SNAKE codes, the hook entry's closed-scope holes over declared `params`, a literal code or reason the catalogue does not declare refused at save) and read at run time, and they are declared in the action's package source beside the body that throws them. The Studio row, a key-only record, needs its labels and help text translated in the eleven metadata-forms bundles and is owed to a follow-up card; until then an action authored in the Studio declares `refusals` through the metadata API or its package source", - }, - // #34374 (action half) — an action's declared texts land in the action's - // source first, as its refusal catalogue (#34273) and a hook's declared - // texts did. The Studio row (a key-only record, with its help text in the - // eleven metadata-forms bundles) is a follow-up, so this row records why the - // key is not offered. - { - kind: 'omit', - type: 'action', - path: ROOT_PATH, - key: 'texts', - why: "live, not yet offered in the Studio — the sentences a `script` action's `js` body writes into records (`ctx.text`, answered in the organization's language) are validated at parse (snake_case keys, closed-scope holes over declared `params`, a literal `ctx.text` key the action does not declare refused at save) and read at run time, and they are declared in the action's package source beside the body that asks for them. The Studio row, a key-only record beside `refusals`, needs its labels and help text translated in the eleven metadata-forms bundles and is owed to a follow-up card; until then an action authored in the Studio declares `texts` through the metadata API or its package source", - }, // #27946 — an action's pressed-state predicate lands spec-first the same // way: `planned` in the liveness ledger, drawn by no action surface until // the console card that draws `aria-pressed` on the header buttons. diff --git a/packages/spec/src/ui/action.form.ts b/packages/spec/src/ui/action.form.ts index c86ce3de265..04b4afc2048 100644 --- a/packages/spec/src/ui/action.form.ts +++ b/packages/spec/src/ui/action.form.ts @@ -63,6 +63,53 @@ export const actionForm = defineForm({ { field: 'memoryMb', type: 'number', helpText: 'Per-invocation memory cap (MB, max 256)' }, ], }, + // The action's refusal catalogue sits beside the body that throws its + // codes, as on the hook form, and takes that form's row: a record keyed + // by the code, an entry with no member that echoes its key, so the + // key-only record control; an entry's `reasons` is the same shape one + // level down. The entry is the hook entry, built by the one factory + // (`declaredRefusalEntrySchema`), so its four controls are the hook + // row's. Gated like `body`: the parse refuses `refusals` on every + // action but a `script` one (and on its `expression` body, which the + // help text says). + { + field: 'refusals', + type: 'record', + widget: 'key-only-record', + visibleWhen: "data.type == 'script'", + helpText: "Refusal catalogue, keyed by the SCREAMING_SNAKE code the action's body throws (e.g. SIGN_IN_REQUIRED). The caller reads the declared message, translated into their language, with the declared status. For a script action's JavaScript (L2) body; 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' }, + { + field: 'reasons', + type: 'record', + widget: 'key-only-record', + 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', + fields: [ + { field: 'message', type: 'textarea', required: true, helpText: 'The sentence the user reads when the body throws this reason under the code. Its {{ }} holes follow the entry\'s params' }, + ], + }, + { field: 'params', type: 'tags', 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' }, + ], + }, + // The action's declared texts sit beside the body that asks for them, + // as on the hook form, and take its row: a record keyed by the + // snake_case key the code asks for, an entry `{ message, params? }` + // with no member that echoes its key, so the key-only record control. + // Gated like `body`: the parse refuses `texts` on every action but a + // `script` one (and on its `expression` body, which the help text says). + { + field: 'texts', + type: 'record', + widget: 'key-only-record', + visibleWhen: "data.type == 'script'", + helpText: "Sentences the action writes into records, keyed by the snake_case key its body asks for with ctx.text (e.g. email_subject). The body gets the declared message in the organization's language, translated, with the declared message as the fallback. For a script action's JavaScript (L2) body; refused on an expression body", + fields: [ + { field: 'message', type: 'textarea', required: true, helpText: 'The sentence the action writes when its body asks for this key. Plain text, unless the entry declares params: then a {{ name }} hole fills a declared param' }, + { field: 'params', type: 'tags', helpText: 'Names the sentence may fill (e.g. subject): the body asks for ctx.text(key, { subject }), and a {{ subject }} hole renders it. Absent: the sentence is plain text' }, + ], + }, { field: 'params', type: 'repeater',