Package overview
@query-farm/vgi is one package with four entry points. Everything below is generated from the
source, so a symbol’s page is the authority for its exact shape.
Entry points
Section titled “Entry points”| Import | For |
|---|---|
@query-farm/vgi | Node / Bun workers. The function factories, Worker, catalogs, the client. |
@query-farm/vgi/serve | serveVgiWorker and createVgiWorkerFetch — an HTTP worker on Bun. |
@query-farm/vgi/worker-cf | Cloudflare Workers. createVgiFetch plus the factories, on the flechette Arrow backend. |
@query-farm/vgi/client | Browser client only — no server-side code in the bundle. |
The entry point changes what some names mean
int, int32, float32 and bool are type instances on the package root (re-exported from
vgi-rpc) but factory functions on /worker-cf. int64(), float64() and the rest of the
explicit factory set are functions on both, so prefer those in portable code. See
Runtimes.
The five factories
Section titled “The five factories”import {
defineScalarFunction, // 1 row → 1 value
defineTableFunction, // args → N rows
defineTableInOutFunction, // N rows → M rows, streaming
defineAggregate, // N rows → 1 value per group
defineTableBufferingFunction // N rows → M rows, after seeing all input
} from "@query-farm/vgi";
Each returns a VgiFunction, which is what a Worker or a FunctionRegistry accepts. There is also
defineRowTransformFunction for the blended UNNEST-style table-in-out, and defineCopyFromFunction
/ defineCopyToFunction for custom COPY formats.
Reference
Section titled “Reference”
Scalar functions
defineScalarFunction and its config.
Table functions
Producers, plus the optimizer hooks.
Table-in-out functions
Streaming a relation through.
Buffering functions
Sink, combine, source.
Aggregate functions
Per-group accumulation.
COPY formats
Your own format through COPY … FROM / TO.
Worker & serving
Worker, serveVgiWorker, the fetch handlers.
Catalogs
Descriptors, CatalogInterface, and the wire shapes.
Arguments
Declaring a signature, reading the values.
Arrow types
Type factories, facade shapes, predicates.
Value representations
rich vs raw, branded units, the codec.
Batch helpers
Building, reading, projecting, serializing batches.
Cache control
Advertising a result as reusable.
Filter pushdown
The predicates DuckDB pushed toward the scan.
State storage
State across calls and across processes.
Client
VgiClient and its transports.
Errors
The typed errors a worker raises.
Protocol & metadata
Enums, protocol shapes, secrets, function metadata.
Re-exported from vgi-rpc
Names that live in the transport layer.