Remote / API

foldkit-remote-drizzle

foldkit-remote-drizzle — provisional compiler from Remote Entity/Selection/Query to Drizzle's typed query graph.

It captures no connection and re-plans nothing: Remote.plan already produces entity + id + field batches, so this maps a Selection's fields to Drizzle columns. Each entity is declared once with entity(name, table), which is both the Drizzle binding and the Remote EntityDescriptor.

Keyset pagination and required-column projection are adapted from fate's Drizzle integration (MIT); see THIRD_PARTY_NOTICES.md.

Namespaces

DrizzleOperatorsThe SQL compiler's implementations, by operator.

Functions

applyEditsA journal's apply for foldkit-sync's editsJournal: one committed cell edit, written to its column with the sequence it committed at as the row's revision,…
bindBinds every Entity of an Entity.relate result to its table in one step, so a relation's target binding can be one that is declared after its owner.
buildPage
checkConstraintsThe CHECKs a binding's Entity implies, as clauses for a migration written in SQL, and the rules no CHECK holds, which only the server's writes do:
checkFieldsEvery field the body reads has a column here, every operation it needs is one this compiler runs, and every order it may take (each Order.chosen alternative…
collatedColumnThe column under the term's collation, and a cursor value made comparable to it; none when the column compares as it is (no collation, or binary on a…
compileCallOne call of a primitive operator as SQL, by the binding's table, its arguments compiled and cast as in a body: what a conformance check selects to ask the…
compileCheckPredicatescompilePredicates for a CHECK: its literals are inlined, so they are not cast.
compileOrderByThe body's ordering for one input, as this package's order terms: a chosen order resolved to the field or call the input names, a call compiled to its SQL…
compilePredicatesPredicates with no body around them, as SQL fragments: an invariant's, say. entity is the Entity the row is, where a predicate goes through a relation.
compileWhereThe body's predicates, as the SQL fragments this request needs. Each is separate: the caller conjoins them with whatever else applies, so a body cannot…
computationSqlA computed assignment, as data, as the SQL that writes it: a field its column, a value a parameter, a call by the binding's SQL operators. What writer sets,…
contextOverwritesWhy write cannot land through binding: each member it writes that is stored on the column of a member its Entity sets from the context. The Entity refuses…
contextSharersEach member stored on the column of a member Entity.sets names, that is not set itself: the server writes the context's value to that column, and a write of…
cursorSelectionbase and each term's key under an alias of its own, to select beside a row: an expression has no name, and two columns may share one. A key already in base,…
databaseLayerProvides a Drizzle database as the DrizzleDatabase service. Any Drizzle database qualifies; the cast is confined here because its builder is generic over…
entity
entityChecksThe CHECKs an Entity implies, as Drizzle check()s for its table's own definition, so drizzle-kit writes them into the migration that makes it:
idColumn
idCursorA cursor naming the row a page ended on by its id, for an order whose key values JSON cannot carry: keyed as keyCursor's are, so an id beginning as a keyed…
keyCursorA cursor holding the order's key values at the row a page ended on, the id among them: where the page ended, whatever that row does after. None when a value…
keysetWhere(a CMP A) OR (a = A AND b CMP B) OR ... — the lexicographic predicate that keeps a page contiguous under a multi-column order. forward selects rows after…
keysOfThe values a row selected with cursorSelection holds, in the terms' order.
lockParentsLock parentIds on table in ascending id order using SELECT ... FOR UPDATE. Returns the sorted ids that were locked.
many
manyToMany
normalizeMaps rows a mutation returned (e.g. Drizzle returning) to entity patches, rewriting a one relation's foreign key to its ref key. fields is the set of…
operatorProblemsAs requireOperators, each problem a sentence, for a check that gathers them.
operatorsFrom
orderByTermsThe ORDER BY for a traversal, nulls placed as the term says: backward reverses each term, its nulls with it.
pollLiveA live source that polls from inside the subscriber's own request. Each tick reads the subscribed rows again through the entity's source as a read answers…
projectsAnyWhether at least one requested field maps to a column, relation, or computed value.
queryA RemoteServer.query source over a keyset-paginated table. The connection's cursor is the row identity; a requested cursor's ordering tuple is re-read…
queryPlansEach page the sources read for these inputs, a first and a later one, as the database plans it, for every order a body offers its reader. Run it in a test…
reachedEntitiesEvery Entity a body's paths and exists reach, once each: the tables whose visible a request resolves for its reader before compiling (visibleOf).
readCursorWhat a cursor says: the key values a keyed one holds, checked against the order it pages (a client sends it, so nothing is trusted that is not one of these…
readerA pruned reader backed by an injected executor. Use it when the database is not an Effect service, or to test the projection without one.
requireOperatorsRefuses expressions needing an operation or operator the binding cannot run: in SQL, or in memory, where a predicate over the input alone is decided and a…
revisionTriggerThe SQL that makes a database move binding's revision on every update that does not move it itself: a handler's, applyEdits', raw SQL. A guarded writer…
rowChangeLogThe SQLite statements (D1's dialect) that keep a log of the rows each write to binding's table touched, in order, for rowLog to read: a table, and triggers…
rowLogThe log rowChangeLog keeps for binding, read through DrizzleDatabase, at most batch entries a tick (default 500); the rest wait for the next.
runStatementA statement, failing as a RemoteServerError whose message is failed and whose cause is the driver's error. That error carries the SQL and its parameters: it…
selectColumnsThe column map for the requested scalar and relation fields. The primary key is always selected: normalization needs it even when the client did not ask for…
shapeWindow
sortParentIdsDeduplicate and sort parent ids in deterministic ascending code-unit order.
sortTermsThe order a client asked for, as order terms. sort names one of the orders the server offers, never a column: columns is the server's say in what each name…
sourceA RemoteServer.entity source backed by the DrizzleDatabase service. It selects the requested columns in one batch, then resolves each selected relation: a…
toQueryPage
whereIdsA whole id batch as one IN (...) — the normalized-store advantage.
withParentLockRun body inside a Postgres transaction that first locks parentIds on table in ascending id order (SELECT ... FOR UPDATE), preventing deadlocks across…
writer

Values

bodyOperationsWhat a query body, and a guard's Read rule, may use besides: paths and exists, which read other tables. A rule judged elsewhere (an invariant, a when) does…
CursorReadWhat a cursor says: where its page ended, an id from before keys, or nothing this server minted.
drizzleWritesThe provided database's writes. DrizzleDatabaseService names only the reads a source makes, so a test can fake it with select; a Drizzle database has these…
kernelOperators
oneA ref field; with nullable: true the ref may be null, as the column may.
returningThe returning columns for fields and the normalization of the rows they yield, paired so a mutation cannot select one set of columns and normalize another.
supportedThe operations this compiler turns into SQL. Declared rather than implied by which cases predicate happens to handle, so a body needing something else is…

Classes

Interfaces

BindingOperatorsWhat a binding runs its expressions' primitive operators by, in SQL and in memory.
CascadeEdgeOne relation a delete cascades through: the pointing binding, and the column its link is on.
CompileTargetWhat a binding has to offer to be compiled against: a column per field key, and the table, whose dialect decides how text folds.
ComputedConfigAn aggregate over a collection relation, attached to each owning row.
CountDerivedA Derived.make member counted over a many relation of its owner: what a join table with no Entity is counted by. A count the Entity can say (Derived.count)…
DrizzleDatabaseService
DrizzleSelect
DrizzleStatement
DrizzleWriteA write statement: awaited for its effect, or asked for the columns it wrote.
DrizzleWritesThe writes any Drizzle database for SQLite or Postgres offers, typed by each table's columns.
EntityBinding
EntityCheckOptionsOptions for entityChecks, matching what bind is given for the same table.
InsertSelectThe select an insert hands its callback: values by the table's keys, from a table, while a condition holds.
InverseOneStorageA one relation from the other side: the foreign key is a column of the target's table, as a user's profile points at its user. One-to-one only holds if that…
ManyRelationThe foreign key lives on the target table.
ManyStorageA many relation whose foreign key is a column of the target's table.
ManyToManyRelationJoined through a table: localColumn references the owner's id.
OneRelationThe foreign key lives on the owning table.
OneStorageA one relation: the foreign key is a column of the owner's table.
OrderTerm
Page
ParentLockOptions for locking parent rows on Postgres during child writes.
ParentLockTransactionA Drizzle transaction handle exposed inside withParentLock / ParentLock.onWrite.
PointerEdgeOne relation pointing at a row that a delete of it restricts or clears: its Entity and key, for what a refusal names, and where its link is stored.
QueryEdge
QueryPage
QueryPlan
ReturningThe returning columns for fields and the normalization of the rows they yield. columns are the table's own dialect's, so Drizzle's returning takes them as…
RowLogWhat a log of written rows says: its newest entry, and what changed after an entry.
ServerOnlyRulesRules of the bound Entity no CHECK can hold (checkConstraints(...).serverOnly), reported on the binding's first write: the server's declared writes hold…
SourceQuery
SqlContextWhat an implementation is handed to build its SQL.
SqlImplementationOne operator's SQL implementation.
StatementFailedThe driver failed a statement; the caller was answered failed and nothing of why.
SuppliedDerivedA derived member this package does not compute: the application supplies it, by wrapping the source and answering for the field itself. bind registers the…
ThroughStorageA many relation joined through a table: localColumn references the owner's id.
WindowOptions
WindowShape
WriteLedgerWhere a writer records each update and insert it lands, by the operation that asked for it, so a retry of that operation is answered from the record rather…

Types

AnyEntityBindingA binding with its derived field map erased. The field map is invariant through EntityDescriptor.ref, so a concrete binding is not assignable to…
EntityStorage
PlanVerdictHow the database orders one page: served reads it in order from an index and stops at the page's end; sorted reads every matching row and sorts them first…
RelationBinding
RemoteDrizzleDiagnosticEvery diagnostic foldkit-remote-drizzle reports.
StoredRelationHow a relation is stored, as far as compiling reads it: a one by the column it is stored on.
Traversal
VisibleThe rows of a table a principal may see, as a condition over that table's columns, or an Effect of one for a rule that must ask something first. It is given…