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

@schema-first/core

v0.3.2

Published

A comprehensive spec framework for describing resources used by frontends as a foundation for meta-driven UIs.

Readme

@schema-first/core

A strictly typed, framework-agnostic data specification engine. Define your domain logic, permissions, and API actions once; render them anywhere.

🎯 Goals

  • Single Source of Truth: Define labels, validation, and API logic in the "Spec," not the UI.
  • Strict Framework Interop: Use the TypeRegistry to swap React components for Vue/Svelte nodes without losing type safety.
  • Convention over Configuration: Automatically infer labels and URLs while allowing deep overrides.
  • Zero UI Dependency: The core package manages the logic of data; your UI package manages the pixels.

⚙️ Configuration & Customization

1. The Type Registry (Framework Interop)

If you are using something other than React, or want to lock down your API paths, use Declaration Merging in a spec.d.ts file:

import "@schema-first/core";

declare module "@schema-first/core" {
  interface TypeRegistry {
    element: MyVueVNode; // Swap ReactNode
    icon: MyIconComponent;
    resource_key: "User" | "Project" | "Invoice"; // Strict keys
  }

  interface ColumnMetadataRegistry {
    isInternal: boolean; // Add custom column props
  }
}

2. Initializing Conventions

Initialize the engine at your app's entry point to inject icons and fetch logic.

import {
  initializeConventions,
  labels,
  urls,
  auto_pages,
} from "@schema-first/core";
import { FiPlus, FiTrash } from "react-icons/fi";

initializeConventions({
  UNIMPLEMENTED_PLACEHOLDER: <i>Not yet implemented</i>,
  actions: {
    create: { label: "Add {resource}", icon: FiPlus },
    delete: { label: "Remove", icon: FiTrash, color: "red" },
  },
  fetch: async (url, method, body) => {
    const res = await fetch(url, { method, body: JSON.stringify(body) });
    return res.json();
  },
  labels,
  urls,
  auto_pages,
  loadSpec: (name) => myCachedSpecs[name],
  SORTABLE_FIELDS: ["string", "number", "datetime"],
});

🎨 The Renderer System

The RegisteredRenderer system is the bridge between your Spec and your UI Library. It allows you to register components for specific data types and view modes (Table, Form, etc.).

Registering a Custom Renderer

If you have a custom "Markdown" type or want to override how "Currency" looks in a table:

import { registerRenderer } from "@schema-first/core";

// Register a custom table renderer for currency
registerRenderer("number", {
  view: "table",
  test: (spec) => spec.numberType === "currency",
  renderer: ({ data, meta }) => (
    <span className="font-mono">
      {meta.currency} {data.toLocaleString()}
    </span>
  ),
});

Consuming Renderers in UI

In your components, use getRenderer to resolve the correct component based on the spec.

const ColumnCell = ({ spec, data }) => {
  // Finds the best match in the Registry (or returns the Placeholder)
  const Renderer = getRenderer(spec, "table");

  return <Renderer data={data} spec={spec} meta={spec.meta} />;
};

📊 Using in Tables

The Spec provides everything needed to build high-performance data tables. Use tableColumns to iterate through keys.

const { tableColumns, columns } = UserSpec;

return (
  <table>
    <thead>
      <tr>
        {tableColumns.map((key) => (
          <th key={key}>{columns[key].label}</th>
        ))}
      </tr>
    </thead>
    <tbody>
      {data.map((row) => (
        <tr key={row.id}>
          {tableColumns.map((key) => (
            <td key={key}>
              <ColumnCell spec={columns[key]} data={row[key]} />
            </td>
          ))}
        </tr>
      ))}
    </tbody>
  </table>
);

📝 Using in Forms

The RawColumnSpec handles validation and field types. Use the form property on Actions to render dynamic modals or pages.

const CreateUserAction = new APIAction({
  method: "POST",
  form: UserSpec, // The form is driven by the UserSpec columns
  label: "Create User",
  execute: async (data) => {
    /* ... */
  },
});

// In your Form Component:
{
  Object.entries(UserSpec.columns).map(([key, col]) => {
    if (!col.showOnForm) return null;
    const Input = getRenderer(col, "form");
    return <Input key={key} spec={col} />;
  });
}

License

This project is licensed under the Apache License 2.0 - see the LICENSE and NOTICE files for details.