Builds the decidable schema for selecting among UI options.
'one' produces a single enumeration (pick) carrying each option's
description; { max } produces one boolean per option id. This is the
schema useUiDecision and uiDecisionResource ask, so a server can pass
it to a decision adapter's schema option to pin UI selection questions.
Pass the same entries, in the same order, as the hook or resource, with
the same select, and the server asks byte-identical questions.
Each entry is one of:
- a candidate item
{ id, description }, used as is; - a component
{ name, description, children? }, such as anexposeComponentresult or a definition without an implementation, whose option id is itsname; - a UI kit, flattened into its members;
- a plain group
{ components, selectable? }, which mirrors a UI kit without importing component implementations. Its members are structural{ name, description, children? }objects and are flattened exactly like a kit's.
Members of a kit or group that is not selectable (selectable: false)
are never options. A name that appears in both a selectable and a
non-selectable kit or group is non-selectable.
An entry with an id is always a candidate item, even when it also has a
name. Components and kits are flattened as the hooks flatten them:
declared children are included depth first, components are deduped by
name (the first wins) and cycles terminate. Candidate items are not
deduped, so a candidate id that repeats another option id throws.
API
export declare function createSelectionSchema(
options: ReadonlyArray <
| {
id: string;
description: string;
}
| {
name: string;
description: string;
children?: unknown;
}
| UiKit <any>
| SelectionGroup
>,
select: Select ,
): DecidableSchema; @paramoptions:ReadonlyArray<{
id: string;
description: string;
} | {
name: string;
description: string;
children?: unknown;
} | UiKit<any> | SelectionGroup>Candidate items, components and/or UI kits, in order.
How many options may be selected.
@returnsExamples
// Candidates mode:
createSelectionSchema(
[
{ id: 'flight', description: 'The user asks about one aircraft' },
{ id: 'airport', description: 'The user asks about an airport' },
],
'one',
);
// Narrowing mode, with the components (or kits) passed to the hook:
HashbrownTypeSafe.decide({
...,
schema: createSelectionSchema([flightCard, cardsKit], { max: 2 }),
});