Entity / foldkit-entity

foldkit-entity

A domain entity declared once as a typed value: its intrinsic fields, its relations to other entities, and the derived values consumers may read. Other packages interpret that declaration; this one only describes.

Status: declaration and selection. foldkit-remote registers Entities and reads Selections as they are. foldkit-remote-drizzle binds a related set to tables with bind, and foldkit-form builds a form from Entity.input, and foldkit-crud joins one to a Remote operation.

For the whole path in one runnable trace, domain to client to SQL, see examples/entity.

What it owns

foldkit-entity owns domain structure: which members an entity has, what kind each is, and which entity a relation points to.

It does not own:

  • Validation. entity.schema is an ordinary Effect Schema.Struct and stays the only validity rule.
  • Storage or fetching. A relation says "one Author", not "a foreign key" or "a join table". How a derived value is computed is the interpreter's business.
  • Operations. An Entity implies no create, update, or delete.
  • Application state. Nothing here touches a Model or dispatches a Message.

Mental model

Entity
 ├── fields      intrinsic values: the properties of entity.schema
 ├── relations   navigation edges: one / many of another Entity (Entity.relate)
 ├── derived     readable values an interpreter supplies
 └── members     all three under one namespace; keys never collide

interpreter ──(foldkit-metadata)──► Entity / member        attaches what it needs
interpreter ◄── reads fields, relations, derived, metadata

Each pipe step, and Entity.relate, returns a new frozen descriptor with the same identity. Two descriptors are the same entity when Entity.same(a, b), not when a === b.

Install

sh
pnpm add effect foldkit-entity