Since 0.1.0
Infer
Name the entry types a primitive produces, per view.
A type-only helper that describes a primitive's getter outputs.
import type { Infer } from "@qino/cms";
type PostTypes = Infer<typeof postCollection>;
type Post = PostTypes["output"];
type DetailPost = PostTypes["views"]["detail"];
Signature
type Infer<Primitive extends Collection | Tree | Item> = {
output: Entry; // default view
views: { [Name in ViewNames]: Entry };
};
Generics
| Parameter | Constraint | Description |
|---|---|---|
Primitive | a defineCollection, defineTree, or defineItem result | The primitive to describe |
Shape
outputis one entry as returned by the default view. UseArray<Post>for a list.viewshas one key per declared view, includingdefault, whose type equalsoutput. Without configured views,viewsis empty.
Outputs include schema transformations, resolved relations at the view's depth, awaited augment output, and _meta.
Notes
- A primitive that has been widened, such as one annotated as
AnyEntry-producing or passed through a generic that drops its inference metadata, resolves tonever. - Unknown view names are type errors.
- The descriptor exists only in TypeScript.