Skip to content

What is Pragma? ​

Pragma is a natural-language query layer for data tables. Describe your table once; your users type what they want to see; Pragma returns a validated, library-agnostic TableQuery (search, filters, sort and pagination) that any table, API or database can run.

Pragma answering an instruction: filter chips, an explanation and the filtered table

The problem ​

Every table library has its own state model for search, filtering, sorting and paging. Turning “enterprise customers in India who joined this year, biggest first” into that state means hand-written translation code, and asking a language model to do it directly gives you output you cannot trust: invented fields, wrong operators, values in the wrong format, or fields users were never meant to see.

The approach ​

Natural language is an input, not the source of truth. The source of truth is a typed query checked against your schema.

The model proposes; the engine decidesParsers and models only propose changes. Every field, operator and value is validated before anything is applied.
Local firstExplicit instructions are answered in the browser in about a millisecond. A model is called only for what the parser can't fully understand.
Safe by constructionHidden fields behave like fields that don't exist. Model output can never widen the schema. Row data never reaches a model.
Stateful“Now sort by revenue” keeps your filters. “Remove the country filter” removes only that one.
Asks, never guessesAmbiguous requests return a question with ready-made options. Impossible combinations return warnings.
Always explainedChips and explanations are generated from the validated query, so they always match what runs.

Packages ​

Most apps install one package and import by subpath:

bash
npm install @avinash-baraiya/pragma
Import pathWhat you get
@avinash-baraiya/pragmadefineSchema, createEngine, the TableQuery protocol, validation, dates
…/reactAccessible AskBar with @ autocomplete, QueryChips, Explanation, ClarificationPrompt, Feedback
…/tanstack, …/tanstack/reactTanStack Table v9 adapter and the usePragmaTable hook
…/serverWeb-standard HTTP handler plus a Node/Express adapter; keeps model keys on the server
…/providers/<name>openai-compatible, anthropic, gemini, ai-sdk, mock, remote
…/styles.cssOptional default styles
Prefer minimal installs?

The same code is published as individual packages: @avinash-baraiya/pragma-core, -interpreter, -providers, -server, -react and -tanstack. Core has no framework or vendor dependencies.

Where things run ​

StepWhereNetwork
@ autocomplete, chip removal, clarification choices, table sort and pagingBrowserNone
Explicit instructions (deterministic parser)BrowserNone
Everything elseYour server, then the model you configuredOne request to your endpoint, one to the model
Filtering, sorting and paging the rowsBrowser (TanStack) or your backendYour choice

Released under the MIT License.