npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vireocodedev/query

v0.2.2

Published

Framework-free Vireo query schemas, transport ports, and parameterized SQLite execution.

Readme

@vireocodedev/query

Framework-free query metadata, transport ports, filter compilation, and parameterized SQLite execution for Vireo Starter.

The package owns reusable query contracts. An application still owns its entity-key vocabulary, HTTP implementation, database schema, SQL expressions, authorization, cache lifecycle, and product UI.

Install

npm install @vireocodedev/query zod

The package is published publicly on npm; installation requires no registry authentication. TypeScript declarations are verified from the packed artifact with TypeScript 6, moduleResolution: "Bundler", and skipLibCheck: false. Relative source maps with embedded source content are published intentionally for debugging.

The sole peer dependency is zod >=4.4 <5. The root entry point is React-free, browser-global-free, and worker-safe.

React Query integration lives in @vireocodedev/ui/tanstack-query:

npm install @vireocodedev/ui @tanstack/react-query

Public architecture

application transport
  -> createQueryEngineApi
  -> Zod-validated entity metadata
  -> application cache or createVireoQueryEngineQueries
  -> query-filter JSON
  -> compileQueryFilterWhere / compileSearchTextWhere
  -> createSqliteQueryExecutor
  -> application-owned SQLite worker port

There are no package-global signals or caches. Every API, executor, and config client is instance-scoped.

Entity metadata and API

createQueryEngineEntitySchemas builds recursive Zod schemas from an optional application-owned entity-key schema. The default accepts any non-empty string, keeping this package generic while rejecting unusable identifiers.

createQueryEngineApi accepts a minimal get(path, options) port. It validates all responses, encodes dynamic path segments, forwards abort signals, preserves transport and Zod failures, and can optionally retry an application-provided legacy entity key.

import { createQueryEngineApi } from "@vireocodedev/query";
import z from "zod";

const api = createQueryEngineApi(fetchAdapter, {
  entityKeySchema: z.enum(["CUSTOMER", "ORDER"]),
  legacyEntityKey: key => (key === "CUSTOMER" ? "customer" : undefined),
});

Filter compilation

bindSqliteSearchColumns creates one explicit registry for selectable columns, filter fields, and sort expressions. compileQueryFilterWhere compiles supported operators into SQL placeholders plus bound values. compileSearchTextWhere does the same for free-text search.

The compiler fails closed. Malformed JSON, a mismatched entity, unknown fields, duplicate bindings, and invalid typed values throw instead of silently removing restrictions.

Application-authored SQL expressions remain trusted configuration. Runtime filter/search values are always returned separately as parameters.

SQLite execution

createSqliteQueryExecutor provides paged searches, optional count probing, concurrent-request deduplication, matching-key lookup, timing hooks, and deterministic row mapping over injected execution ports.

executeParameterizedSqliteQuery and executeParameterizedSqlitePagedQuery are worker-side helpers. Pagination is normalized to whole rows before transport and validated again before interpolation into SQL.

Config persistence

createQueryEngineConfigClient owns instance-local in-memory fallback state and an injected request transport. createQueryEngineConfigSqliteRequestHandlers, replaceQueryEngineConfig, and getQueryEngineConfig provide the worker-side persistence boundary.

Table identifiers, singleton keys, request names, snapshot shape, and persisted JSON are validated. Corrupt storage is reported explicitly and never replaced with an empty configuration.

React Query integration

The optional React adapter belongs to Starter UI because it imports React Query:

import { createVireoQueryEngineQueries } from "@vireocodedev/ui/tanstack-query";

export const QueryEngineQueries = createVireoQueryEngineQueries(api);

The adapter creates stable query options without mutating global signals. Applications remain free to use another cache or the framework-free API directly.

Failure semantics

  • Invalid API response data raises the original Zod error.
  • Transport failures remain transport failures when no legacy retry applies.
  • Aborted requests are never retried.
  • Invalid filter contracts fail closed before SQL execution.
  • Invalid pagination fails before a statement is prepared.
  • Invalid SQLite config identifiers fail synchronously.
  • Malformed or shape-incompatible persisted config raises an error.
  • Duplicate request and filter registrations are rejected.

Verification and live documentation

Package tests cover public schemas, API paths and failures, filter compilation, pagination, config persistence, concurrency, and framework boundaries. The unified Vireo Storybook contains executable examples under Query Engine; every displayed source file is the same TypeScript module Storybook executes.