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

@cossackframework/studio

v0.9.6

Published

A local, browser-based database inspector for Cossack applications

Readme

Cossack Studio

@cossackframework/studio is the Node-only database inspector bundled with the Cossack CLI. It loads orm.config.ts through the application's installed ORM tooling.

cossack add studio
pnpm install
pnpm studio

The default command opens a loopback-only Studio session for the configured local adapter:

cossack studio
cossack studio --no-open --port 4983
cossack studio --driver postgres

The printed launch URL contains a one-time token. The first visit exchanges it for an HttpOnly, SameSite=Strict session cookie and the token stops working; later visits from the same browser use the cookie. To open Studio in another browser or profile, restart it to get a new launch URL.

Remote D1 uses the project's authenticated Wrangler installation:

cossack studio --remote
cossack studio --remote --database DB --env production

Studio supports Cloudflare D1, SQLite, Turso, PostgreSQL, and MySQL schema inspection. It shows exact row counts and adjustable pagination, with 100 rows by default. It supports inline and JSON-aware keyed row editing. It runs one arbitrary SQL statement per execution. Its SQL editor includes syntax highlighting plus table and column completion. Remote D1 changes affect deployed data immediately. The console shows up to 1,000 rows and asks the database for at most 1,001, so the extra row tells it that the result is truncated. Studio appends LIMIT 1001 to a SELECT or WITH query that has no top-level LIMIT, OFFSET or FETCH, and wraps other queries in SELECT * FROM (…) AS __q LIMIT 1001.

Batch delete and batch update apply all or nothing on SQLite, Turso, PostgreSQL and MySQL: Studio runs them in one transaction and rolls back if a selected row is stale or a statement fails. D1 (local and remote) has no interactive transactions, so batches there are best-effort. Rows changed before the failure stay changed, and the error reports how many. Remote D1 sends up to 50 statements in one Wrangler call, as one D1 batch: a failing statement rolls back the rows of its own call, but a stale row does not stop the other rows in the same call.

Studio groups remote D1 statements into few Wrangler calls, because each call starts a Wrangler process. A schema load takes three or four calls, whatever the number of tables. A browse takes one call, and the Pragmas tab takes one call after the first visit.

For local connections, Studio detects the ORM driver's dialect. DB_CONNECTION or COSSACK_STUDIO_DRIVER can distinguish SQLite-family adapters. PostgreSQL and MySQL drivers remain project dependencies. Studio executes through the ORM driver and never exposes credentials to browser code. Project .env and .dev.vars files are loaded into the Studio server process before orm.config.ts is imported. Existing shell variables keep precedence.

On PostgreSQL and MySQL, a schema load runs four queries whatever the number of tables: the table and view list, then the columns, indexes and foreign keys of the whole schema. The first load also reads the server version. On PostgreSQL, keys, foreign keys and view definitions come from pg_catalog, so a role that can only SELECT the tables sees the same schema as their owner. MySQL keeps each object's CREATE statement in SHOW CREATE, one query per object, so the Structure tab loads it when it shows that object. Programmatic callers use StudioDatabase.getDefinition(name); objects whose definition is not loaded yet have sqlDeferred: true.

Studio merges physical introspection with orm.schema(), displays logical types and relation provenance, surfaces drift, and hides migration bookkeeping. The introspected schema is cached. Studio invalidates it after SQL console statements that may change the schema (DDL, writes, SELECT … INTO, PRAGMA writes) and after pragma edits. The Browse tab's refresh button re-introspects to pick up changes made outside Studio.

The "Database capabilities and migrations" panel loads inspection on demand when it is opened: the shared read-only database facts used by cossack orm schema inspect --json. Programmatic callers use StudioDatabase.getInspection(); getSchema() includes inspection only after it has been loaded. These facts include the selected target and environment, driver/dialect capabilities, physical and model schema, known relationships, and applied, pending or changed migrations. Inspection does not create migration bookkeeping tables or apply migrations. Credential fields and temporary connection identities are excluded.

For programmatic inspection of a configured project:

import { inspectStudioProject } from '@cossackframework/studio';

const facts = await inspectStudioProject({
  projectRoot: process.cwd(),
  environment: 'staging',
  target: 'local',
  binding: 'STAGING_DB',
});

The project adapter receives the selected environment and target with readOnly: true. The optional binding must match the inspected target. Named environments must select their own configured binding. An absent binding must fail rather than use an unrelated top-level database. Temporary inspection connections close after success or failure. An existing local Studio connection keeps ownership of its borrowed ORM until Studio closes it.

Storage-oriented SQLite declarations can retain richer application semantics through model decorators:

@Column({ type: 'json', name: 'meta', nullable: true })
declare meta: Record<string, unknown> | null;

@CreateDateColumn({ name: 'created_at' })
declare createdAt: Date;

The Structure tab shows both the ORM type (json, datetime) and physical database type (TEXT, VARCHAR(32)). The Browse tab adds relation-property columns for navigable ORM relations. Selecting one toggles a read-only related table directly below that row, loaded through the corresponding foreign-key filter. Relation data is fetched lazily and capped at 50 rows per expansion. The panel's new-tab action opens the fully browsable filtered relation.

For programmatic startup:

import { runStudio } from '@cossackframework/studio';

await runStudio({
  projectRoot: process.cwd(),
  // Optional when a custom dialect wrapper cannot be detected:
  // provider: 'postgres',
  remote: false,
  port: 4983,
  open: true,
});