@stepbook/query
v0.2.0
Published
stepbook query language — the JSONata engine plus a structured query AST that compiles to JSONata.
Readme
@stepbook/query
The query engine for stepbook. Evaluate JSONata over any value, or compile StepQL (a YAML query AST) down to JSONata.
Install
npm install @stepbook/queryUsage
Three exports cover most uses:
import { runQuery, compileQuery, toRows } from '@stepbook/query'
// Evaluate a JSONata expression against a value.
runQuery('$.longWords[$length($) > 8]', data)
// → { kind: 'value', value: [...] } | { kind: 'error', message }
// Compile a StepQL source string (YAML AST, or pass 'jsonata' to passthrough).
compileQuery(source, 'yaml')
// → { kind: 'ok', jsonata } | { kind: 'error', message }
// Coerce a result into a table for rendering. Presentation, not execution.
toRows(value)
// → { rows, total, columns }The Zod schema for the structured AST (QueryAst) is also exported, so tools that generate or validate queries don't need the JSON Schema separately.
