export interface ResolvedOption { /** Canonical id (server-side primary key). */ id: string | number; /** Same as `id` — preserved for legacy frontend parity. */ value: string | number; /** Display string. */ label: string; /** Same as `label` — preserved for legacy frontend parity. */ name: string; description?: string | null; image?: string | null; color?: string | null; icon?: string | null; } export interface OptionsMeta { /** 'static' for inline options, 'dynamic' for FK-resolved lists. */ type: 'static' | 'dynamic' | string; /** Number of options the server returned in this batch. */ count: number; } export interface UseOptionsResolverArgs { /** * The owning model whose options endpoint is queried. Pass the model * key (e.g. 'sales_orders'). Required — passing an empty string puts * the hook in idle mode and no fetch fires. */ modelKey: string; /** * Field on `modelKey` to resolve. Maps to `?field=`. */ fieldKey: string; /** * Optional FK target. When set the hook resolves against * `/api/options/?field=id` instead of `/api/options/`. * This is the canonical path the kernel auto-derives from * `ColumnDef.Ref`. Prefer this over `endpoint`. */ ref?: string; /** * Free-text query forwarded as `?q=`. Empty values are skipped so the * server returns the first page unfiltered. */ query?: string; /** * Cascade scope forwarded as `?filter_value=`. Set by a dependent picker * from the current value of the field it `dependsOn` (e.g. a product * picker scoped to the header's `source_warehouse_id`). When empty/undefined * the param is omitted (no scope — the picker lists everything). Changing it * re-fetches; an empty string is treated as "not set" so a cleared parent * does not query for the empty-string scope. */ filterValue?: string; /** * Server-side pagination cap. Defaults to 50 (kernel * DefaultOptionsLimit) if omitted. */ limit?: number; /** * Toggle to disable fetching entirely (e.g. while a parent row is * still loading). Defaults to true. */ enabled?: boolean; /** * Escape hatch for callers that need a non-canonical URL — e.g. * legacy `/options/?...`. When set it overrides `ref` and * `modelKey` for the fetch path. The query string is built from * `fieldKey` / `query` / `limit` exactly the same way. */ endpoint?: string; } export interface UseOptionsResolverResult { options: ResolvedOption[]; meta: OptionsMeta | null; loading: boolean; error: Error | null; /** Forces a refetch. Useful after a parent record updates. */ refetch: () => void; } /** * Resolves select options for a field via the canonical * `/api/options/:model?field=…` endpoint. Returns the v0.9.0 envelope * `{ data, meta: { type, count } }` projected into a stable shape. * * The hook is intentionally minimal: it does NOT debounce `query` * (callers should hold the controlled value and pass it post-debounce) * and does NOT cache across hook instances (apps that need shared state * compose this with TanStack Query in their own layer). */ export declare function useOptionsResolver(args: UseOptionsResolverArgs): UseOptionsResolverResult; /** * Normalizes the wire shape into ResolvedOption. The kernel returns dual * id/value and label/name fields for legacy parity — we accept either * and surface a stable shape downstream. */ export declare function projectOption(raw: any): ResolvedOption; //# sourceMappingURL=use-options-resolver.d.ts.map