|
124 | 124 | * node, is pointed at `approvals.<node_id>.label` rather than told only that |
125 | 125 | * the node is not a screen. |
126 | 126 | * |
| 127 | + * `hooks.<name>.refusals.<CODE>.message` (#26170) is judged against the hook's |
| 128 | + * refusal catalogue: the hook must be one the stack defines (or a sibling |
| 129 | + * package's, through the artifact carrier), and the code one its `refusals` |
| 130 | + * declares — the body runner reads the key for a declared code and nothing |
| 131 | + * else. An unknown hook and an undeclared code are each an orphan. |
| 132 | + * |
127 | 133 | * `flows.<name>.successMessage` / `.errorMessage` (#22507), the terminal |
128 | 134 | * toasts, are judged against the flow itself: `translateFlow` overlays a toast |
129 | 135 | * only where the flow AUTHORS one, so a translated toast over a flow that |
@@ -493,6 +499,12 @@ interface Universe { |
493 | 499 | dashboards: Map<string, { widgets: Set<string>; actions: Set<string> }>; |
494 | 500 | /** Flow name (`Flow.name`) → its screen nodes and their declared fields. */ |
495 | 501 | flows: Map<string, FlowFacts>; |
| 502 | + /** |
| 503 | + * [#26170] Hook name (`Hook.name`) → the codes its refusal catalogue |
| 504 | + * (`HookSchema.refusals`) declares — what a `hooks.<name>.refusals.<CODE>` |
| 505 | + * key may name. Empty for a hook that declares no catalogue. |
| 506 | + */ |
| 507 | + hooks: Map<string, Set<string>>; |
496 | 508 | /** Object-less actions — the ones `globalActions.*` may name. */ |
497 | 509 | globalActions: Map<string, AnyRec>; |
498 | 510 | /** Action name → owning object, so a misfiled `globalActions` key can say where it belongs. */ |
@@ -1622,6 +1634,25 @@ function buildUniverse(stack: AnyRec): Universe { |
1622 | 1634 | collectFlowRecord(flow, { ownDeclaration: false }); |
1623 | 1635 | } |
1624 | 1636 |
|
| 1637 | + // ── Hooks: the refusal codes `hooks.<name>.refusals.<CODE>` may name (#26170) ── |
| 1638 | + // |
| 1639 | + // The body runner reads `hooks.<hook>.refusals.<CODE>.message` for a code the |
| 1640 | + // hook's catalogue declares, so the universe is each hook's declared codes. |
| 1641 | + // `hooks` carries disposition `concat` in `COMPOSE_KEY_DISPOSITIONS`, so a |
| 1642 | + // sibling package's hooks are read through the artifact carrier; the |
| 1643 | + // declaration this leg is JUDGING keeps the slot, the flows' decision. |
| 1644 | + const hooks = new Map<string, Set<string>>(); |
| 1645 | + const collectHookRecord = (hook: AnyRec, { ownDeclaration }: { ownDeclaration: boolean }) => { |
| 1646 | + const hookName = strName(hook.name); |
| 1647 | + if (!hookName) return; |
| 1648 | + if (!ownDeclaration && hooks.has(hookName)) return; |
| 1649 | + hooks.set(hookName, new Set(Object.keys(asRecord(hook.refusals)))); |
| 1650 | + }; |
| 1651 | + for (const hook of recordsOf(stack.hooks)) collectHookRecord(hook, { ownDeclaration: true }); |
| 1652 | + for (const hook of artifactProvidedRecords(stack, 'hooks')) { |
| 1653 | + collectHookRecord(hook, { ownDeclaration: false }); |
| 1654 | + } |
| 1655 | + |
1625 | 1656 | // ── Picklists: the option values `picklists.<name>.options.<key>` may name (#23566) ── |
1626 | 1657 | // |
1627 | 1658 | // The runtime reads this face through `lookupPicklistOption` |
@@ -1699,6 +1730,7 @@ function buildUniverse(stack: AnyRec): Universe { |
1699 | 1730 | contributedOnlyApps, |
1700 | 1731 | dashboards, |
1701 | 1732 | flows, |
| 1733 | + hooks, |
1702 | 1734 | globalActions, |
1703 | 1735 | actionOwners, |
1704 | 1736 | picklists, |
@@ -2315,6 +2347,39 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind |
2315 | 2347 | ); |
2316 | 2348 | } |
2317 | 2349 | } |
| 2350 | + |
| 2351 | + // ── hooks.<name>.refusals.<CODE> (#26170) ─────────────────────────── |
| 2352 | + for (const [hookName, rawHook] of Object.entries(asRecord(rawData.hooks))) { |
| 2353 | + const hookPath = `${base}.hooks.${hookName}`; |
| 2354 | + const declared = universe.hooks.get(hookName); |
| 2355 | + if (!declared) { |
| 2356 | + orphan( |
| 2357 | + `${inLocale} · hook "${hookName}"`, |
| 2358 | + hookPath, |
| 2359 | + `Translations are keyed to hook "${hookName}", which this stack does not define, so its ` + |
| 2360 | + `refusals keep their declared messages.` + |
| 2361 | + suggest(hookName, universe.hooks.keys()), |
| 2362 | + `Match the key to a hook's \`name\`, or drop it.`, |
| 2363 | + ); |
| 2364 | + continue; |
| 2365 | + } |
| 2366 | + if (!isRec(rawHook)) continue; |
| 2367 | + for (const code of Object.keys(asRecord(rawHook.refusals))) { |
| 2368 | + if (declared.has(code)) continue; |
| 2369 | + orphan( |
| 2370 | + `${inLocale} · hook "${hookName}" · refusal "${code}"`, |
| 2371 | + `${hookPath}.refusals.${code}`, |
| 2372 | + declared.size === 0 |
| 2373 | + ? `Translations are keyed to refusal "${code}", but hook "${hookName}" declares no ` + |
| 2374 | + `\`refusals\`, so nothing resolves this key.` |
| 2375 | + : `Translations are keyed to refusal "${code}", a code hook "${hookName}" does not declare ` + |
| 2376 | + `under \`refusals\`, so nothing resolves this key.` + |
| 2377 | + suggest(code, declared), |
| 2378 | + `Refusal translations are keyed by a code the hook's \`refusals\` declares; declare it there, ` + |
| 2379 | + `or drop the key.`, |
| 2380 | + ); |
| 2381 | + } |
| 2382 | + } |
2318 | 2383 | } |
2319 | 2384 | } |
2320 | 2385 |
|
|
0 commit comments