Entity / foldkit-entity

Summary of exports

Entities, relations, and selections

CallMeaning
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) / annotateMembersAttach 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

CallMeaning
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.deleteDeclare an insert or delete over an operation input
Write.writes / reads / bind / applyInspect footprints, encode patches, and compute resulting rows
Write.ensured / footprint / boundReadsRead 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.transitionAttach state (after) or transition (before/after) rules
Entity.judge / Entity.checkEvaluate invariants (Valid, Invalid, Undecided) or Schema
Entity.invariants / Entity.readsBeforeList attached invariants and whether they inspect before
Entity.refine / states / inStateDeclare named row states and test stored rows against them
Laws.check / show / facts / lawFactsOfVerify writes against invariants and emit graph facts
Footprint.declared / Footprint.unknownDeclare write footprints for non-Write transitions

Expressions and queries

CallMeaning
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 / showInspect read fields, missing ops, and readable text
Expr.eq / isNull / isNotNull / inEquality, null checks, and list membership predicates
Expr.lt / lte / gt / gteOrdering comparisons (binary or asciiFold for text)
Expr.contains / Text.startsWithCase-insensitive substring and collation-aware prefix match
Expr.and / or / not / impliesThree-valued SQL boolean connectives
Expr.add / Expr.subPortable numeric addition and subtraction (number.add/subtract)
Expr.path / Expr.exists / Expr.isTraverse 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 / showExplicit scalar nodes and readable expression formatting

Judges, operators, and conformance

CallMeaning
evaluate / evaluateEachRun a Query over in-memory rows
Judge.predicate / Judge.queryEvaluate three-valued truth over partial HeldRow caches
Held.rows / Held.fromRefs / isLinkBuild HeldRow caches and normalize relation ref keys
Judge.pinsExtract fixed field values from a conjunction for pointing
Expr.operator(id, options)Define a reusable macro (definedAs) or primitive operator
Expr.expanded / unsupported / dependenciesOfExpand operator macros and inspect expression dependencies
Operators.memory / implement / kernelBuild and compose in-memory primitive operator tables
Operators.merge / override / checkedCombine operator tables and validate outputs in tests
Law.* (associative, monotonic, …)Algebraic laws declared on primitive operators
Conformance.laws / lawsBy / operatorTest operator implementations against laws and each other
Operators.withEvidence / describeTableRecord 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