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

@prometheus-ags/entity-graph-alpine

v3.0.0-alpha.0

Published

Alpine.js plugin exposing $entity(type,id) and $entityList(type,query) magics — wires @prometheus-ags/entity-graph-core into Alpine.effect().

Downloads

77

Readme

@prometheus-ags/entity-graph-alpine

Alpine.js plugin for the Prometheus entity graph. Registers $entity(type, id) and $entityList(type, query) magics that wire the framework-agnostic @prometheus-ags/entity-graph-core Zustand store into Alpine's reactive system via Alpine.reactive().

Installation

pnpm add @prometheus-ags/entity-graph-alpine alpinejs

Quick Start

import Alpine from "alpinejs";
import {
  EntityGraphAlpinePlugin,
} from "@prometheus-ags/entity-graph-alpine";
import {
  registerEntityTransport,
  makeRestTransport,
} from "@prometheus-ags/entity-graph-core";

// 1. Register entity transports at app boot (once per entity type).
registerEntityTransport(
  "Invoice",
  makeRestTransport({ supabase, table: "invoice" }),
);

// 2. Install the plugin before Alpine.start().
Alpine.plugin(EntityGraphAlpinePlugin);

// 3. Start Alpine.
Alpine.start();

Magics

$entity(type, id)

Returns an AlpineEntitySnapshot whose properties update automatically when the underlying graph slice changes.

<div x-data="{ inv: $entity('Invoice', invoiceId) }">
  <p x-show="inv.isLoading">Loading…</p>
  <p x-show="inv.error" x-text="'Error: ' + inv.error"></p>
  <div x-show="inv.isReady">
    <h2 x-text="inv.data.title"></h2>
    <span x-text="inv.data.amount"></span>
  </div>
  <button @click="inv.refetch()">Refresh</button>
</div>

| Property | Type | Description | |----------|------|-------------| | data | T \| null | Merged entity (canonical + patches), or null if not loaded | | isLoading | boolean | true while a fetch is in flight | | error | string \| null | Last fetch error message | | isReady | boolean | true when data is present and not loading | | refetch() | () => void | Invalidate and re-fetch | | destroy() | () => void | Release graph subscription (called automatically on component destroy) |

$entityList(type, query)

Returns an AlpineEntityList whose items update automatically when any entity in the list changes anywhere in the app.

<div x-data="{ list: $entityList('Invoice', { queryKey: ['invoices'], limit: 20 }) }">
  <p x-show="list.isLoading">Loading…</p>
  <ul>
    <template x-for="item in list.items" :key="item.id">
      <li x-text="item.title"></li>
    </template>
  </ul>
  <p x-show="list.total !== null" x-text="list.items.length + ' / ' + list.total"></p>
  <button @click="list.loadMore()" x-show="list.hasNextPage" :disabled="list.isLoadingMore">
    Load more
  </button>
</div>

| Property | Type | Description | |----------|------|-------------| | items | T[] | Resolved entities in list order | | isLoading | boolean | true while the first page loads | | isLoadingMore | boolean | true while loading additional pages | | error | string \| null | Last fetch error | | hasNextPage | boolean | true when more pages are available | | total | number \| null | Server-reported total row count | | loadMore() | () => void | Fetch the next page | | refetch() | () => void | Reset and re-fetch from page one | | destroy() | () => void | Release graph subscription |

Query Options

interface AlpineListQuery {
  queryKey: unknown[] | string; // Stable cache key
  filter?: Record<string, unknown>; // Transport-agnostic filter
  search?: string;               // Free-text search
  limit?: number;                // Page size
  enabled?: boolean;             // Default true
  staleTime?: number;            // ms; overrides engine default
}

Custom Magic Names

Use createEntityGraphPlugin when another plugin already claims $entity:

import { createEntityGraphPlugin } from "@prometheus-ags/entity-graph-alpine";

Alpine.plugin(
  createEntityGraphPlugin({ entityMagicName: "$ent", listMagicName: "$entList" })
);

How It Works

  1. The plugin calls Alpine.magic(name, factory) for each magic.
  2. Each factory creates an internal reactive cell via Alpine.reactive({}).
  3. The cell subscribes to useGraphStore from @prometheus-ags/entity-graph-core using Zustand's subscribe with a selector. When the graph slice changes, the cell properties are updated — Alpine's reactivity system detects the mutation and schedules re-renders for any template expression that read them.
  4. On component destroy() (or when Alpine calls the registered cleanup fn), the Zustand subscription is torn down and the engine subscriber token is released (enabling garbage collection of idle entities).

Prerequisites

  • alpinejs >= 3.13
  • @prometheus-ags/entity-graph-core at the same version (already a dependency)

Entity fetching requires at least one transport registered via registerEntityTransport(type, transport) before Alpine starts. See entity-graph-core README for transport setup.

License

MIT