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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@drizzle-lab/api

v0.30.2

Published

Drizzle Lab API - Fork of Drizzle Kit API

Readme

@drizzle-lab/api

Fork of Drizzle Kit API - Enhanced with features for schema documentation and visualization.

[!IMPORTANT] This package is a community project based on Drizzle Kit.

I recommend using Drizzle Kit as much as possible.

Installation

npm install @drizzle-lab/api

Features

  • 🔄 Import schema from files or database
  • 📝 Document your schema with JSDoc-like syntax
  • 📸 Generate snapshot from Drizzle objects
  • 🎨 Generate SQL from schema
  • 📊 Generate TypeScript from schema
  • 🎯 Support for PostgreSQL, MySQL and SQLite

API Reference

Extensions

Document your schema with the explain function.

Works for tables and views.

import { explain } from "@drizzle-lab/api/extensions";
import { pgTable, text, jsonb } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
  id: text("id").primaryKey(),
  name: text("name").notNull(),
  metadata: jsonb("metadata").$type<{ role: string }>(),
});

explain(users, {
  description: "Users table storing core user information",
  columns: {
    id: "Unique identifier for the user",
    name: "User's full name",
    metadata: "Additional user metadata stored as JSON",
  },
  jsonShapes: {
    metadata: {
      role: "string",
    },
  },
});

PostgreSQL API

Import and transform PostgreSQL schemas:

import { importDrizzleConfig } from "@drizzle-lab/api/config/node";
import { importFromFiles } from "@drizzle-lab/api/pg/node";
import { 
  importFromDatabase, 
  schemaToSql, 
  snapshotToTypeScript,
  drizzleObjectsToSnapshot
} from "@drizzle-lab/api/pg";

// Import schema from config
const config = await importDrizzleConfig();
const drizzleObjects = await importFromFiles(config.schema);

// Import schema from database
const snapshot = drizzleObjectsToSnapshot(drizzleObjects, config);

// Generate SQL
const sql = schemaToSql(schema);

// Generate TypeScript
const ts = snapshotToTypeScript(snapshot, "preserve");

MySQL API

Import and transform MySQL schemas:

import { importDrizzleConfig } from "@drizzle-lab/api/config/node";
import { importFromFiles } from "@drizzle-lab/api/mysql/node";
import { 
  importFromDatabase, 
  schemaToSql, 
  snapshotToTypeScript,
  drizzleObjectsToSnapshot
} from "@drizzle-lab/api/mysql";

// Import schema from config
const config = await importDrizzleConfig();
const drizzleObjects = await importFromFiles(config.schema);

// Generate snapshot
const snapshot = drizzleObjectsToSnapshot(drizzleObjects, config);
    
// Generate SQL
const sql = schemaToSql(schema);

// Generate TypeScript
const ts = snapshotToTypeScript(snapshot, "preserve");

SQLite API

Import and transform SQLite schemas:

import { importDrizzleConfig } from "@drizzle-lab/api/config/node";
import { importFromFiles } from "@drizzle-lab/api/sqlite/node";
import { 
  importFromDatabase, 
  schemaToSql, 
  snapshotToTypeScript,
  drizzleObjectsToSnapshot
} from "@drizzle-lab/api/sqlite";

// Import schema from config
const config = await importDrizzleConfig();
const drizzleObjects = await importFromFiles(config.schema);

// Generate snapshot
const snapshot = drizzleObjectsToSnapshot(drizzleObjects, config);

// Generate SQL
const sql = schemaToSql(schema);

// Generate TypeScript
const ts = snapshotToTypeScript(snapshot, "preserve");

(Optional) Extended Config

export default defineConfig({
  // ...
  lab: {
    projectId: "drizzle-lab", // optional, defaults to "drizzle-lab". Used to identify the project in json output
  },
});

Environment Variables

They are all optional.

| Variable | Description | Default | |----------|-------------|---------| | DRIZZLE_LAB_DEBUG | Enable debug logging | false | | DRIZZLE_LAB_CWD | Working directory | "" | | DRIZZLE_LAB_CONFIG_PATH | Path to config file | drizzle.config.ts | | DRIZZLE_LAB_SAVE_DIR | Directory to save output | ./drizzle | | DRIZZLE_LAB_PROJECT_ID | Project ID to identify the project in json output | drizzle-lab | | TS_CONFIG_PATH | Path to tsconfig.json | ./tsconfig.json | | DRIZZLE_LAB_ENV_FILE_PATH | Path to env file | undefined |

License

MIT