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

@sethucms/core

v0.1.0

Published

Core types, content model, portable query AST, capabilities, permissions and errors for SethuCMS

Readme

@sethucms/core

Dependency-free core of SethuCMS (Node 20+, Web Crypto only). Every adapter and the API build on it.

| Module | Responsibility | |---|---| | errors | Error codes, HTTP mapping, toApiError (never leaks INTERNAL details) | | field-types | Canonical types, operators per type, value checks | | content-model | defineCollection, ContentModel, validateRecord | | capabilities | Capability matrix, restrictive defaults, per-database presets | | query-ast | parseQuery for untrusted input, builders, hard limits | | query-validate | Validate against introspected metadata; planQuery refuses unsupported queries | | pagination | HMAC-signed, query-bound, expiring, rotatable cursors | | permissions | Role merge, row filters, field mask/hide, anti-probing restrictQuery | | redact | Secret redaction for logs and audit diffs |

Security properties (tested)

  • Field and collection names come only from the introspected definition; user strings are never interpolated.
  • Object-valued filter values ({"$ne": null}) and unknown keys are rejected.
  • Offset pagination is refused; cursors are tamper-proof and bound to the query that produced them.
  • Row filters are ANDed onto every query; masked or hidden fields cannot be filtered, sorted or projected.
  • Unsupported capabilities raise CAPABILITY_UNSUPPORTED instead of degrading silently.
pnpm --filter @sethucms/core test

Quick example

import {
  defineCollection, parseQuery, planQuery, resolveAccess, restrictQuery, PRESETS,
} from '@sethucms/core';

// 1. Describe a collection (normally produced by introspecting the database).
const posts = defineCollection({
  name: 'posts',
  fields: [
    { name: 'id', type: 'integer', primaryKey: true, generated: true },
    { name: 'title', type: 'string', required: true },
    { name: 'authorEmail', type: 'string' },
  ],
  relations: [],
});

// 2. Parse the untrusted request body. Throws VALIDATION_FAILED if anything looks wrong.
const query = parseQuery({ collection: 'posts', filter: { field: 'title', op: 'startsWith', value: 'Hello' } });

// 3. Apply what this user may see, then check the database can run it.
const access = resolveAccess([{ action: 'read', fieldRules: { authorEmail: { read: 'hide' } } }], posts, 'read');
const safeQuery = restrictQuery(query, access);
planQuery(safeQuery, posts, PRESETS.sql); // throws CAPABILITY_UNSUPPORTED if it cannot run

How to read the code

Start with the file headers; each one explains its module in plain words. A good reading order: errors.ts -> field-types.ts -> content-model.ts -> query-ast.ts -> query-validate.ts -> permissions.ts -> pagination.ts. Tests in tests/ double as examples of what is accepted and what is rejected.