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

@velastack/schema

v0.3.0

Published

PocketBase schema engine: canonical collection model, id-based diff, lint, two-phase migration ordering, and layout.

Readme

@velastack/schema

The PocketBase schema engine behind VelaStack's visual schema viewer and editor.

import {
	schemaFromPocketBase,
	collectionToPocketBase,
	diff,
	lint,
	hasErrors,
	plan,
	materialize,
	layout
} from '@velastack/schema';

// The database as it is, from GET /api/collections.
const base = schemaFromPocketBase(items);

// The database as the user wants it (edited copy of `base`).
const next = edit(base);

const changes = diff(base, next); // typed ops, matched by id
const issues = lint(base, next, changes); // errors, warnings, infos
if (!hasErrors(issues)) {
	for (const step of plan(base, next, changes).steps) {
		// create → POST /api/collections, update → PATCH, delete → DELETE,
		// each with collectionToPocketBase(step.collection); PocketBase's
		// automigrate writes one migration file per save.
	}
	const target = materialize(next, changes); // `next` with the ids the plan used
	// Re-read GET /api/collections afterwards for the stored form: PocketBase
	// fills in defaults for options you left out.
}

const positions = layout(next); // dagre, for SVG or the editor

What it knows about PocketBase

Verified against pocketbase-server 0.40.6, not just read from the docs:

  • Fields and collections are matched by id. A kept id with a new name is a rename; a missing id is a drop. Field ids are user-settable.
  • A field's id is type + crc32(name) (text3208210256 is text + crc32("id")). pocketbaseFieldId mints the same, so new fields look native in a migration file.
  • A relation's target must already be saved. Self-relations and mutual references take two saves, which the planner defers to its fourth phase.
  • A collection that others relate to cannot be deleted. The planner strips the referring fields first.
  • A field's type and a relation's target cannot change in place. The diff emits replaceField with a fresh id, the lint calls it destructive, and materialize gives you next with that id in place.
  • One save writes one migration file, timestamped to the second. Wait for the clock to advance between saves.

Modules

| Module | Purpose | | ---------------------- | ----------------------------------------------------------------- | | types | Schema, Collection, Field (14 PocketBase types), Rules | | ids | pocketbaseFieldId, randomIds, seededIds, crc32 | | normalize/pocketbase | schemaFromPocketBase, collectionToPocketBase | | normalize/builtins | usersCollection, completeCollection (adds system fields) | | normalize/patterns | applyPatternResult for @velastack/patterns generate() results | | diff | diff, summarize, destructiveOps | | lint | lintSchema, lintChangeSet, lint, hasErrors | | plan | plan (four phases), materialize | | layout | layout with dagre; card metrics shared with the UI |