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

@axiomdb/schema

v0.1.1

Published

Schema introspection and type generation for AxiomDB

Readme

@axiomdb/schema

Schema introspection and type generation CLI for AxiomDB.

Installation

npm install @axiomdb/schema

Overview

Introspects your database schema and generates TypeScript types for use with AxiomDB queries. Supports PostgreSQL, MySQL, and MSSQL connections as schema sources.

CLI Usage

npx axiomdb-schema generate [options]

Options

| Flag | Default | Description | |------|---------|-------------| | --adapter <name> | postgres | Schema adapter to use (postgres, mysql, mssql, or a custom adapter) | | --out <path> | axiomdb-schema.d.ts | Output file path for the generated type declarations | | --cwd <path> | . | Working directory for the adapter | | --connection-string <url> | — | Database connection string (required for built-in adapters) | | --schema <name> | public / dbo | Database schema to introspect | | --no-relations | — | Exclude foreign key relation metadata from output | | -h, --help | — | Show help |

Examples

# PostgreSQL
npx axiomdb-schema generate --adapter postgres \
  --connection-string postgres://user:pass@localhost:5432/mydb

# MySQL
npx axiomdb-schema generate --adapter mysql \
  --connection-string mysql://user:pass@localhost:3306/mydb

# MSSQL
npx axiomdb-schema generate --adapter mssql \
  --connection-string mssql://user:pass@localhost:1433/mydb

# Custom output path and schema
npx axiomdb-schema generate --adapter postgres \
  --connection-string postgres://localhost/mydb \
  --out src/generated/axiomdb-schema.d.ts \
  --schema my_schema

Generated output

The CLI generates two files:

  1. axiomdb-schema.d.ts — TypeScript type declarations used by the TypeScript plugin and your IDE for type inference.
  2. axiomdb-schema.json — JSON schema metadata used by @axiomdb/babel-plugin for runtime validation and the TypeScript language service plugin.

Generated type structure

The .d.ts file declares a module with the following interfaces:

declare module '@axiomdb/schema' {
  // Row types for each table (all columns required)
  export interface Tables {
    users: {
      id: number;
      name: string;
      email: string;
      active: boolean;
      created_at: Date;
    };
    orders: {
      id: number;
      user_id: number;
      total: number;
      status: string;
      created_at: Date;
    };
  }

  // Insert types (columns with defaults or nullable are optional)
  export interface InsertTypes {
    users: {
      id?: number;          // has default (serial/autoincrement)
      name: string;
      email: string;
      active?: boolean;     // has default
      created_at?: Date;    // has default
    };
    orders: {
      id?: number;
      user_id: number;
      total: number;
      status?: string;      // has default
      created_at?: Date;
    };
  }

  // Foreign key relationships (omitted with --no-relations)
  export interface Relations {
    orders: {
      user_id: { references: 'users'; column: 'id' };
    };
  }

  // Type helpers
  export type TableName = keyof Tables;
  export type ColumnsOf<T extends TableName> = keyof Tables[T];
  export type RowType<T extends TableName> = Tables[T];
}

Adapters

Built-in adapters:

  • @axiomdb/schema/adapters/postgres — Direct PostgreSQL introspection
  • @axiomdb/schema/adapters/mysql — Direct MySQL introspection
  • @axiomdb/schema/adapters/mssql — Direct MSSQL introspection

Custom adapters

If --adapter <name> is not a built-in, the CLI tries to import @axiomdb/schema-<name> and calls its default export (or <name>Adapter named export) as a factory function. The factory must return a SchemaAdapter:

interface SchemaAdapter {
  name: string;
  introspect(options: {
    cwd: string;
    connectionString?: string;
    schema?: string;
  }): Promise<IntrospectedSchema>;
}

Install a custom adapter as a package (e.g., npm install @axiomdb/schema-sqlite) and use it with --adapter sqlite.

License

MIT