Entity / foldkit-entity
Summary of exports
Entities, relations, and selections
| Call | Meaning |
|---|---|
Entity.define(name, struct) | Declare an Entity with a Field per struct property |
Entity.defineVariants(name, cases) | Experimental: tagged-union Entity (variants, fields) |
Entity.relate(entities, relations) | Declare Relation.one / Relation.many edges between Entities |
Entity.select(entity, spec) | Declare a Selection carrying members and schema |
Entity.page(selection, window) | Select a many relation as a cursor-paginated page |
Entity.selectionSchema(entity, schemas) | Build a Selection schema from per-member schemas |
Entity.variantsOf(entity) | Read variant union, case fields, and stored-row codec |
Entity.fields(entity, ...keys) | Extract field schemas by key for spreading into inputs |
Entity.derived({ key: spec }) | Attach Derived.make, Derived.count, or Derived.exists |
Entity.annotate(meta) / annotateMembers | Attach foldkit-metadata entries to Entity or members |
Entity.same(a, b) / Entity.is(value) | Check shared Entity identity or descriptor shape |
Selected<typeof selection> | Result TypeScript type of a Selection |
Words.of(schema) | Read title and description Options across checks |
Inputs, writes, invariants, and states
| Call | Meaning |
|---|---|
Entity.input(entity, struct, mapping?) | Experimental: map operation input keys to Entity members |
Relation.nested(relation, input) | Map an input key to a nested target input |
Entity.selectFor(input, { also? }) | Derive a Selection for loading an edit screen |
Entity.valuesFor(input, value) | Convert a loaded row back into input form values |
Write.update(input, options) | Declare an update (id, expect?, when?, from?, becomes?) |
Write.insert / Write.delete | Declare an insert or delete over an operation input |
Write.writes / reads / bind / apply | Inspect footprints, encode patches, and compute resulting rows |
Write.ensured / footprint / boundReads | Read postcondition invariants and bound read/write footprints |
Entity.sets({ member: term }, { on }) | Set Expr.viewer or Expr.now automatically on create/write |
Entity.invariant / Entity.transition | Attach state (after) or transition (before/after) rules |
Entity.judge / Entity.check | Evaluate invariants (Valid, Invalid, Undecided) or Schema |
Entity.invariants / Entity.readsBefore | List attached invariants and whether they inspect before |
Entity.refine / states / inState | Declare named row states and test stored rows against them |
Laws.check / show / facts / lawFactsOf | Verify writes against invariants and emit graph facts |
Footprint.declared / Footprint.unknown | Declare write footprints for non-Write transitions |
Expressions and queries
| Call | Meaning |
|---|---|
Query.from(entityOrState) | Start a query over all rows or a named state |
Query.where(...predicates) | Conjoin predicates onto a query |
Query.orderBy(...terms) | Append Order.asc / Order.desc / Order.chosen terms |
Query.orderFor(query, input) | Resolve fixed ordering terms ending on id |
Query.placement(query, input, options) | Check if a query orders identically on the client |
Query.dependencies / unsupported / show | Inspect read fields, missing ops, and readable text |
Expr.eq / isNull / isNotNull / in | Equality, null checks, and list membership predicates |
Expr.lt / lte / gt / gte | Ordering comparisons (binary or asciiFold for text) |
Expr.contains / Text.startsWith | Case-insensitive substring and collation-aware prefix match |
Expr.and / or / not / implies | Three-valued SQL boolean connectives |
Expr.add / Expr.sub | Portable numeric addition and subtraction (number.add/subtract) |
Expr.path / Expr.exists / Expr.is | Traverse one relations, check many pointers, narrow variants |
Expr.whenGiven(input, fn) | Apply a predicate only when a nullable input is non-null |
Expr.field / input / literal / show | Explicit scalar nodes and readable expression formatting |
Judges, operators, and conformance
| Call | Meaning |
|---|---|
evaluate / evaluateEach | Run a Query over in-memory rows |
Judge.predicate / Judge.query | Evaluate three-valued truth over partial HeldRow caches |
Held.rows / Held.fromRefs / isLink | Build HeldRow caches and normalize relation ref keys |
Judge.pins | Extract fixed field values from a conjunction for pointing |
Expr.operator(id, options) | Define a reusable macro (definedAs) or primitive operator |
Expr.expanded / unsupported / dependenciesOf | Expand operator macros and inspect expression dependencies |
Operators.memory / implement / kernel | Build and compose in-memory primitive operator tables |
Operators.merge / override / checked | Combine operator tables and validate outputs in tests |
Law.* (associative, monotonic, …) | Algebraic laws declared on primitive operators |
Conformance.laws / lawsBy / operator | Test operator implementations against laws and each other |
Operators.withEvidence / describeTable | Record conformance evidence and serialize table capabilities |
Collation.* / ReadFilter.* | Collation metadata and server-filtered member metadata |
valueOfOperand(node, { operators }) | Evaluate a row-independent scalar expression |
Next
- Walk through one domain end to end: One domain declaration
- Serve Entities over HTTP, SQLite, and Postgres:
foldkit-remoteandfoldkit-remote-drizzle - Build forms and permissions from your Entities:
foldkit-formandfoldkit-guard - See a full application built on one domain:
examples/entity