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/compiler

v2.1.0

Published

Dialect-neutral TypeScript source compilation, query evidence, and migration compatibility.

Readme

@typed-sql/compiler

The stable, grammar-neutral TypeScript source compiler behind typed-sql. It finds static SQL templates, asks the configured grammar for row and parameter shapes, creates an in-memory TypeScript overlay, preserves source mappings, emits deterministic query manifests, and compares them with grammar-owned native database evidence for CI and production correlation. It also compares before/after snapshots and manifests to find query-level migration breaks in both rolling-deployment directions, and captures fingerprint-keyed structured plans for explicit regression review.

pnpm add @typed-sql/compiler
import { compileSource } from "@typed-sql/compiler";
import { postgres } from "@typed-sql/postgres";

const result = compileSource({
  source: 'import { sql } from "@typed-sql/postgres"; const q = sql`SELECT 1 AS value`;',
  dialect: postgres(),
  schema: { formatVersion: 1, dialect: "postgres", tables: {} },
});

For batch/editor parity and incremental consumers, createSourceAnalysisService() accepts a serializable SourceAnalysisRequest and returns a versioned SourceAnalysisResult. The result contains the same transform and diagnostics as compileSource, plus source/project, grammar and capability, schema, type-policy, compiler-option, and revision identities. checkFile() uses this service and exposes its result as analysis.

compileSource consumes only DialectPlugin; it does not branch on a database, grammar package, or driver. Compiled queries expose path-independent SHA-256 fingerprints, variant fingerprints, variant descriptions, and source-mapped semantics merged conservatively across conditional structure. buildQueryManifest turns the same evidence into canonical, secret-free JSON without generating an application API. Its public options include the structural-variant bound used for conditional fragments. Application projects normally use the compiler through typed-sql check or the language server.

Source bytes, static query count, structural variants, and generated declaration bytes have finite defaults and explicit overrides. Exceeding a limit returns TSQ006, the unchanged source overlay, and no inferred query contract. Cancellation raises AbortError before a partial result is returned.

Native checkFile() verification executes only TypeScript 7.0.2. It reads tsc --version before writing a temporary overlay and throws TypeScriptCompilerCompatibilityError with remediation for an untested patch or another line.

Live verification APIs collect transient SQL only after sources still match the manifest, schedule grammar-owned adapters with bounded concurrency, compare native field evidence, and emit canonical proofs that contain no SQL, values, URLs, absolute paths, or driver errors.

Plan-governance APIs schedule grammar-owned inspectors, normalize redacted plan evidence, and apply absolute or environment-comparable relative budgets. Version, schema, settings, statistics, and sample changes remain explicit uncertainty instead of being treated as a pass.

Migration compatibility APIs consume deterministic artifacts only. They classify source, runtime, deployment-order, compatible, and unknown outcomes; link affected variants to source and dependency ranges; and emit canonical reports without SQL, default expressions, credentials, or absolute paths.

Read Architecture, Compose conditional SQL, Query manifests, and Live verification, Query plan governance, Migration compatibility, and Inference and safety.

MIT © typed-sql contributors