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

@typed-sql/core

v2.1.0

Published

Driver- and dialect-neutral typed SQL query contracts.

Readme

@typed-sql/core

The stable, driver- and grammar-neutral foundation of typed-sql. It defines queries, fragments, rendering, database adapters, diagnostics, schema contracts, and the interface implemented by every SQL grammar.

pnpm add @typed-sql/core @typed-sql/postgres pg

Application queries import sql from the selected grammar so the compiler can associate each template with its dialect:

import { sql } from "@typed-sql/postgres";
import type { QueryParameters, QueryRow } from "@typed-sql/core";

const query = sql`
  SELECT account.id, account.email
  FROM accounts AS account
  WHERE account.id = ${42n}
`;

type Account = QueryRow<typeof query>;
type Parameters = QueryParameters<typeof query>;

Runtime adapters share grammar-neutral result and control contracts: all, one, and maybeOne preserve the inferred row, accept optional signals or absolute deadlines, and expose stable cardinality and cancellation errors. Adapter capabilities are explicit; unsupported controls are never silently ignored.

Optional adapter services use namespaced capability tokens rather than widening the common Database interface. getAdapterCapability and requireAdapterCapability preserve the service type without adding a protocol or driver dependency to core.

DatabaseObserver provides redacted query, batch, pipeline, stream, cancellation, and nested transaction lifecycles. It is disabled by default and does not add a telemetry dependency to core.

sql.validateResult(query, schema) optionally validates decoded rows through the structural Standard Schema V1 interface. Validator output must agree with the inferred row; core does not install Zod, Valibot, or another validator package.

createRoutedDatabase provides conservative, grammar-neutral primary/replica selection and bounded explicit-transaction retries from semantic evidence. Dialect packages supply the semantic resolver; applications continue owning every database adapter and topology decision.

Grammar and adapter authors can use DialectPlugin, DIALECT_CONTRACT_VERSION, assertDialectPlugin, defineQuerySemantics, mergeQuerySemantics, createDatabase, renderQuery, the prepared-query skeleton helpers, and the neutral resolver primitives from the package root. The package has no parser, grammar, database driver, TypeScript compiler, or editor dependency.

Read the query API, architecture, routing and retry guide, bulk data guide, result validation guide, and custom grammar guide.

MIT © typed-sql contributors