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

@haneinfo/spaces

v0.2.8

Published

Spaces and folders for StateMachine instances with inherited access materialized into the instance access list.

Readme

@haneinfo/spaces

Optional backend for spaces and folders that StateMachine instances are placed in, with access inherited down the tree. Implements approved decision 202610-b1d6. No frontend is included.

Inherited access is materialized as rows of the instance access list (state_machine_instance_readers, source = 'INHERITED', via_node_id = the granting node), so detail reads, lists, exports, search, reports and references apply it through their existing readership rules without any change.

Tree

A SPACE is a top-level container; a FOLDER always has a parent. Names are trimmed NFC text of 1–200 code points without control or format characters, unique among siblings without regard to case (top-level spaces are siblings of each other). The tree is at most 8 levels deep (a space is level 1) and a node has at most 500 direct children. inheritAccess defaults to true; archivedAt is reserved and has no operation yet.

Access entries and inheritance

An entry is { principalType: USER | ROLE, principalId, level: READ | WRITE | MANAGE }, unique per node and principal. A node's effective access is its own entries plus the effective access of its parent while inheritAccess is true; a node with inheritAccess = false has only its own entries. The highest level per principal wins; there are no deny entries. effectiveSpaceAccess, spaceAccessLevelFor, inheritedInstanceAccess and the shared SPACE_ACCESS_TEST_VECTORS live in @haneinfo/plugin-api.

Placed instances inherit READ as READ and both WRITE and MANAGE as WRITE. USER principals must be active users and ROLE principals existing role names (the instance access list rules). The creator of a node receives MANAGE on it.

| Action | Rule | | --- | --- | | See a node, its children, its access list and its instances | Any effective level on the node, or spaces:space:admin; otherwise SPACE_NODE_NOT_FOUND | | Create a top-level space | spaces:space:create | | Create a folder, rename, change inheritAccess, delete, change access entries | MANAGE on the node (effective), or spaces:space:admin | | Move a folder | MANAGE on the folder and on the new parent | | Place or move an instance | Write the instance and WRITE (or MANAGE) on the target node | | Take an instance out | Write the instance, or MANAGE on its node |

A node must keep at least one effective MANAGE entry: removing or downgrading the last one, or turning off inheritance when MANAGE was only inherited, is SPACE_INVALID (administrators are bound by this rule too, although they can always manage). A folder cannot move under itself or its descendants, and a space cannot move.

Children lists contain only visible children. Breadcrumbs list the visible ancestors above the node up to the first one the caller cannot see; parentId is null when the parent is not visible. In the access list, effective[].viaNodeId is null when the caller cannot see that node.

Inherited rows

Every trigger rewrites the affected instances' INHERITED rows in its own transaction, so revocation takes effect as soon as it commits, exactly like a grant:

| Trigger | Instances rewritten | | --- | --- | | Place, move or take out an instance | That instance | | Set or remove an access entry | Instances in the node and in descendants that inherit from it | | Change a folder's inheritAccess | Same | | Move a folder | Same, from its new position | | Delete a node | None (only empty nodes can be deleted) | | Permanent purge of an instance | Placement and rows removed in the purge transaction |

Only rows with source = 'INHERITED' of those instances are read and written. GRANTED, ASSIGNED and DELEGATED rows of the same principal are separate rows and are never changed or removed; a person with a manual grant and an inherited row keeps reading through whichever remains. Unchanged rows are not rewritten.

Before writing anything, a change counts the placements it would rewrite; more than maxAffectedInstances (default 5,000) is SPACE_TOO_LARGE and nothing changes. Every change takes transaction-scoped advisory locks on the trees (top-level spaces) involved, in sorted order, then re-reads the tree; placement changes additionally lock the instance row. Rewrites read placed instances with FOR KEY SHARE so a concurrent purge either waits or is already visible. If a node or placement moved to an unlocked tree meanwhile, the transaction rolls back and retries discovery (at most six attempts), keeping every tree lock before the instance lock.

Soft deletion and archiving do not change placements (soft-deleted instances are unreadable anyway); a node manager can still take a soft-deleted instance out.

HTTP

All routes use InteractiveAuthGuard.

| Route | Description | | --- | --- | | GET /spaces | Visible top-level spaces | | POST /spaces | { name } → the space (201) | | GET /spaces/nodes/:id | { node, breadcrumbs } | | GET /spaces/nodes/:id/children | Visible children by name | | POST /spaces/nodes/:id/folders | { name, inheritAccess? } → the folder (201) | | PATCH /spaces/nodes/:id | { name?, inheritAccess?, parentId? } → the node | | DELETE /spaces/nodes/:id | 204; only an empty node | | GET /spaces/nodes/:id/access | { canManage, inheritAccess, items, effective } | | PUT /spaces/nodes/:id/access | { principalType, principalId, level } → the entry | | DELETE /spaces/nodes/:id/access/:principalType/:principalId | { removed } | | GET /spaces/nodes/:id/instances?offset=&limit= | { items: [{ instanceId, placedBy, placedAt, card }], total, offset, limit }; readable instances only, newest placement first, 50 per page, at most 200 | | PUT /spaces/placements/:instanceId | { nodeId } → { object: { type, id }, nodeId, placedBy, placedAt } | | DELETE /spaces/placements/:instanceId | 204; idempotent |

A node is { id, kind, parentId, name, inheritAccess, createdBy, createdAt, archivedAt, access, canManage }, where access is the caller's effective level (null when visible only through spaces:space:admin). Names, principal names and card texts are user content: render them as text. The instance list uses list-view's readableInstancePredicates, and cards come from the state-machine-instance preview provider.

| Code | Status | When | | --- | --- | --- | | SPACE_NODE_NOT_FOUND | 404 | The node does not exist or the caller cannot see it | | SPACE_INVALID | 400 | Malformed body or query, invalid name or principal, cycle, moving a space, losing the last MANAGE | | SPACE_NAME_TAKEN | 409 | A sibling has the name (case-insensitive) | | SPACE_NOT_EMPTY | 409 | Deleting a node with children or placed instances | | SPACE_TOO_LARGE | 409 | More affected instances than allowed, or the parent has the maximum number of children | | SPACE_DEPTH_EXCEEDED | 409 | The node (or a moved subtree) would be too deep | | FORBIDDEN | 403 | Visible, but the level or permission is missing | | INSTANCE_NOT_FOUND | 404 | The instance does not exist or the caller cannot read it |

Timeline and events

Placing, moving and taking out an instance add a SPACE history entry (shown as SPACE in the collaboration timeline) with decision.space = { action: PLACED | MOVED | REMOVED, nodeId, previousNodeId } (ids only, no names), and publish the runtime transactional event spaces.placed (instanceId, action, nodeId, previousNodeId, historyId, userId, ISO at). Access changes (entry set or removed, folder inheritance changed, folder moved) record the domain event spaces.access-changed of aggregate SpaceNode when @haneinfo/domain-events is installed, with nodeId, change, affectedInstances, actorId and at in its metadata and no principals. No notification is sent.

MCP

| Tool | Scope | Description | | --- | --- | --- | | list_spaces | <namespace>:spaces:read | {} → visible top-level spaces | | get_space_node | <namespace>:spaces:read | { nodeId } → node, breadcrumbs and visible children | | list_space_instances | <namespace>:spaces:read | { nodeId, offset?, limit? } → readable placed instances |

Every tool needs a user-bound credential and returns only what that user sees over HTTP. Names and card texts are wrapped as $userContent. Agents cannot change nodes, access entries or placements.

Configuration

runtime.spaces (no secrets). The defaults are the decision's limits; an App may only lower them.

| Key | Default | Range | | --- | --- | --- | | maxDepth | 8 | 1–8 | | maxChildren | 500 | 1–500 | | maxAffectedInstances | 5,000 | 1–5,000 | | maxNameLength | 200 | 1–200 | | defaultPageSize | 50 | 1–200, ≤ maxPageSize | | maxPageSize | 200 | 1–200 |

Database

Apply @haneinfo/state-machine/prisma/inherited-access.sql first (nullable via_node_id, the INHERITED source and its CHECK constraints) and update the App's state-machine fragment, then include prisma/spaces.prisma and apply prisma/spaces.sql. space_nodes has unique (parent_id, name_key) plus a partial unique index on name_key for top-level spaces (not expressible in Prisma), space_access cascades with its node, and space_placements has primary key (object_type, object_id) and no foreign key to the instance (purge removes it). Nothing needs a backfill.

Grant spaces:space:create to people who may create spaces and spaces:space:admin only to operators, enable spaces() with configRef spaces, and register SpacesMcpTools.