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

@morphdb/ast

v1.1.0

Published

MorphDB Abstract Syntax Tree (AST) nodes and dialect visitor interfaces

Readme

@morphdb/ast

Abstract Syntax Tree (AST) Nodes, Visitor Compiler Interfaces, and Structural Hash Normalizer.


1. Responsibility

The @morphdb/ast package contains the immutable intermediate syntax representations for MorphDB. It is responsible for:

  • Defining compiler AST nodes (SelectQueryNode, FilterExpressionNode, JoinNode, SortNode, PaginationNode).
  • Providing the ASTVisitor<R> interface contract for target dialect compilers.
  • Normalizing dynamic parameter scalars into structural AST hashes for LRU compilation plan caching (ASTNormalizer).

2. Public API

export interface ASTVisitor<R> {
  visitSelectQuery(node: SelectQueryNode): R;
  visitFilterExpression(node: FilterExpressionNode): R;
  visitJoinExpression(node: JoinNode): R;
  visitSortExpression(node: SortNode): R;
  visitPagination(node: PaginationNode): R;
}

export interface ASTNode {
  readonly kind: ASTNodeKind;
  accept<R>(visitor: ASTVisitor<R>): R;
}

export class ASTNormalizer {
  static normalize(node: SelectQueryNode): NormalizedASTResult;
}

3. Folder Structure

packages/ast/
├── package.json
├── tsconfig.json
├── README.md
├── src/
│   ├── index.ts               # Barrel exports
│   ├── ast-node.ts            # Base ASTNode & ASTVisitor definitions
│   ├── select-query-node.ts   # Root SelectQueryNode
│   ├── filter-node.ts         # FilterExpressionNode
│   ├── join-node.ts           # JoinNode
│   ├── sort-node.ts           # SortNode
│   ├── pagination-node.ts     # PaginationNode
│   └── normalizer.ts          # ASTNormalizer structural hash engine
└── tests/
    └── ast.test.ts            # Vitest unit tests

4. Internal Components

  • SelectQueryNode: Root AST node aggregating projections, filter expressions, joins, sort nodes, and pagination bounds.
  • ASTNormalizer: Extracts dynamic filter values into parameter arrays while computing a structural hash signature for execution plan caching.

5. Interfaces

export enum ASTNodeKind {
  SELECT_QUERY = 'SELECT_QUERY',
  FILTER_EXPRESSION = 'FILTER_EXPRESSION',
  JOIN_EXPRESSION = 'JOIN_EXPRESSION',
  SORT_EXPRESSION = 'SORT_EXPRESSION',
  PAGINATION = 'PAGINATION',
}

export interface NormalizedASTResult {
  readonly structuralHash: string;
  readonly extractedParameters: ReadonlyArray<unknown>;
}

6. Dependency Graph

graph TD
    AST["@morphdb/ast"] --> CoreEngine["Compiler Architecture"]

7. Extension Points

  • New AST Node Kinds: Add InsertNode, UpdateNode, DeleteNode, GroupByNode for DML extensions.
  • Custom Visitor Compiler Passes: External authors implement ASTVisitor<R> to compile query ASTs to Cypher, SQLite, or Redis.

8. Design Patterns Used

  • Visitor Pattern: Double dispatch compiler traversal (node.accept(visitor)).
  • Composite Pattern: Tree structures of nested AST nodes.
  • Immutable Object Pattern: All AST nodes are frozen (Object.freeze()).