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

@oa-sdk/ast-sync

v0.2.0

Published

V3 Unified Architecture: Zero-loss bidirectional TypeScript AST synchronization and standalone guard generation

Readme

@oa-sdk/ast-sync

V3 Unified Architecture: Zero-loss bidirectional TypeScript AST synchronization, type shape taxonomy analysis, and standalone pre-compiled guard generation.

Features

  • Bidirectional AST Sync: Seamless synchronization between EntitySpec (OpenAPI 3.2 schema representations) and TypeScript AST with reverse-offset patch engine preserving comments, formatting, and custom statements.
  • Pluggable Type Adapters: Pluggable adapters for Typia AOT type tags, Zod schemas, and raw TypeScript AST types.
  • Type Shape Taxonomy & Feasibility Diagnostics: Classifies TypeScript syntax into 24 distinct syntax features with 3-tier projection feasibility:
    • direct: Clean 1:1 mapping to OpenAPI 3.2 / TypeSpec.
    • policy-required: Requires an explicit authoring policy (e.g. record, utility types).
    • unsupported: Complex dynamic constructs (conditional types, mapped types, indexed access).
  • Checker-Resolved Symbol Cycle Detection: Graph DFS cycle detector using canonical TypeScript TypeChecker symbol IDs (symbol.id), resolving through aliased imports and multi-file re-export chains.
  • Standalone Pre-compiled Type Guards: Generates self-contained, zero-dependency validation functions using AJV standalone code generation, fully conforming to strict CSP (zero eval, zero new Function).
  • Tiered AOT Fast-Path Guards: Inlines zero-overhead (O(1)) structural checks (is<Name>Fast) for high-frequency loops (e.g. 60fps/120fps UI streams or network packet loops), short-circuiting before deep Ajv validation.
  • Polymorphic oneOf O(1) Dispatcher: Resolves discriminator.propertyName into compile-time hash tables (__dispatch_is<Name>) for (O(1)) branch lookup instead of sequential array scans.

Install

pnpm add -D @oa-sdk/ast-sync

Requires Node.js 22 or later and TypeScript 5.0 or later.

Minimal ESM Example

import ts from 'typescript'
import { extractDeclarationShape, detectSymbolCycles } from '@oa-sdk/ast-sync'

// Analyze declaration feasibility:
const shape = extractDeclarationShape(typeNode)
console.log(shape.feasibility) // 'direct' | 'policy-required' | 'unsupported'

// Detect cyclic dependencies using TypeChecker symbol IDs:
const cycleResult = detectSymbolCycles(program)
if (cycleResult.hasCycles) {
  console.warn('Cycles detected:', cycleResult.cycles)
}

Standalone Guard Generation with Tiered Fast-Path & Polymorphic Dispatch

import { generateStandaloneGuards } from '@oa-sdk/ast-sync/guards'

const artifacts = await generateStandaloneGuards({
  schemaDocument: openApiDoc,
  outDir: './src/guards',
  tiered: true,               // Generates is<Name>Fast(data) and tiered wrappers
  polymorphicDispatch: true,  // Generates O(1) discriminator dispatch tables
  guards: [
    { name: 'isActionPayload', schema: '#/$defs/ActionPayload', typeName: 'ActionPayload' },
    { name: 'isTimeSeriesPayload', schema: '#/$defs/TimeSeriesPayload', typeName: 'TimeSeriesPayload' },
    { name: 'isStreamItem', schema: '#/$defs/StreamItem', typeName: 'StreamItem' },
  ],
})

Generated code exports:

  1. isActionPayloadFast(data: unknown): boolean — High-speed inline (O(1)) check.
  2. isActionPayload(data: unknown): data is ActionPayload — Tiered composite guard with full Draft 2020-12 accuracy.
  3. const __dispatch_isStreamItem = { "ui-action@v1": isActionPayload, "time-series@v1": isTimeSeriesPayload } — Instant (O(1)) discriminator routing.

CLI Audit

Use the oa-gen CLI from @oa-sdk/codegen to audit TypeScript files for type shape feasibility:

pnpm exec oa-gen audit:shape --source src/models/user.ts