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-remoteregisters Entities and reads Selections as they are.foldkit-remote-drizzlebinds a related set to tables withbind, andfoldkit-formbuilds a form fromEntity.input, andfoldkit-crudjoins 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.schemais an ordinary EffectSchema.Structand 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, metadataEach 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
pnpm add effect foldkit-entity