EntityType
type EntityType<TData, TSearchInput> = { data: TData; description: string; get: (context) => Promise<z.infer<TData> | undefined>; id: string; name: string; search: (context) => Promise<EntitySearchResult<TData>>; searchInput: TSearchInput;};Defined in: core/src/entity/entity.types.ts:39
A registered kind of entity: the data schema its records satisfy (always
carrying an id), a searchInput schema, and search/get resolvers. search
supports cursor-based pagination via the returned nextCursor.
searchInput must be an object schema, not any ZodType. Entity search is
exposed as a tool whose input is the search fields with cursor and limit
folded in alongside them, and that flattening is only possible over an object.
The alternative — nesting the caller’s fields under a wrapper key — reads
worse everywhere it surfaces, so the narrower contract is the better trade.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TData extends EntityBase |
EntityBase |
TSearchInput extends z.ZodObject |
z.ZodObject |
Properties
Section titled “Properties”data: TData;Defined in: core/src/entity/entity.types.ts:43
description
Section titled “description”description: string;Defined in: core/src/entity/entity.types.ts:42
get: (context) => Promise<z.infer<TData> | undefined>;Defined in: core/src/entity/entity.types.ts:46
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
EntityGetContext |
Returns
Section titled “Returns”Promise<z.infer<TData> | undefined>
id: string;Defined in: core/src/entity/entity.types.ts:40
name: string;Defined in: core/src/entity/entity.types.ts:41
search
Section titled “search”search: (context) => Promise<EntitySearchResult<TData>>;Defined in: core/src/entity/entity.types.ts:45
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
EntitySearchContext<TSearchInput> |
Returns
Section titled “Returns”Promise<EntitySearchResult<TData>>
searchInput
Section titled “searchInput”searchInput: TSearchInput;Defined in: core/src/entity/entity.types.ts:44