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

@commonpub/schema

v0.7.0

Published

Drizzle ORM tables and Zod validators for CommonPub

Readme

@commonpub/schema

Drizzle ORM table definitions and Zod validators for the CommonPub data model.

Overview

This package is the single source of truth for CommonPub's database schema. Every table, enum, relation, and validator lives here. All other packages depend on @commonpub/schema.

Installation

pnpm add @commonpub/schema

Usage

import { users, contentItems, contentTypeEnum } from '@commonpub/schema';
import { createContentItemSchema, updateUserProfileSchema } from '@commonpub/schema';

Schema Modules

| Module | Tables | Purpose | | ------------ | -------------------------------------------------------------------------------------------- | ------------------------------------------ | | auth | users, sessions, accounts, organizations, members, federatedAccounts, oauthClients, oauthCodes, verifications | User identity, auth sessions, OAuth, SSO | | content | contentItems, contentVersions, contentForks, contentBuilds, tags, contentTags | Articles, projects, blog posts, explainers | | social | likes, comments, follows, bookmarks, notifications, reports, conversations, messages | Social interactions, messaging, reports | | hub | hubs, hubMembers, hubPosts, hubPostReplies, hubBans, hubInvites, hubShares | Hub spaces (community/product/company) with moderation | | product | products, contentProducts | Product catalog and BOM linking | | learning | learningPaths, learningModules, learningLessons, enrollments, lessonProgress, certificates | Learning paths, progress, certificates | | docs | docsSites, docsVersions, docsPages, docsNav | Versioned documentation sites | | federation | remoteActors, activities, followRelationships, actorKeypairs | ActivityPub federation state | | admin | instanceSettings, auditLogs | Admin panel and instance config | | video | videos, videoCategories | Video content and categories | | contest | contests, contestEntries | Contest/competition system | | files | files | File upload tracking | | enums | (none) | Shared PostgreSQL enums | | validators | (none) | Zod schemas for input validation |

Enums

All enums are defined as PostgreSQL enum types via Drizzle's pgEnum:

  • userRoleEnum: member, moderator, admin
  • userStatusEnum: active, suspended, banned
  • profileVisibilityEnum: public, private
  • contentTypeEnum: project, article, blog, explainer
  • contentStatusEnum: draft, published, archived
  • contentVisibilityEnum: public, unlisted, private
  • difficultyEnum: beginner, intermediate, advanced
  • Additional enums for communities, learning, federation, etc.

Conventions

  • UUID primary keys on all tables (uuid().defaultRandom().primaryKey())
  • Timestamps with timezone (timestamp('created_at', { withTimezone: true }))
  • Cascade deletes on foreign keys where appropriate
  • JSONB columns for flexible structured data (social links, parts lists, sections)
  • Denormalized counters for read performance (view/like/comment/fork counts)
  • Relations defined via Drizzle's relations() for type-safe joins

Validators

Zod schemas for validating user input at API boundaries:

import { createContentItemSchema, updateUserProfileSchema } from '@commonpub/schema';

const result = createContentItemSchema.safeParse(userInput);
if (!result.success) {
  // Handle validation errors
}

Development

pnpm build        # Compile TypeScript
pnpm test         # Run tests
pnpm typecheck    # Type-check without emitting

Dependencies

  • drizzle-orm: ORM and query builder
  • zod: Runtime validation