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

@ossy/policies

v1.13.3

Published

Policy domain — aggregate and events for the Ossy policy model

Readme

@ossy/policies

Policy domain package for the Ossy platform — access policies as event-sourced entities with create/revoke actions, queries, and an ADR 0006 schema.

What this package provides

| Primitive | File | Id / export | |---|---|---| | Schema | policy.schema.js | @ossy/policies/schema/policy | | Schema ids | schema-ids.js | PolicySchema | | Aggregate | policy.aggregate.js | Policy (kind: 'entity') | | Events | policies.events.js | PoliciesEvents.Created, PoliciesEvents.Revoked | | Queries | policies.queries.js | PoliciesQueries.GetPoliciesForUser | | Action | create.action.js | @ossy/policies/actions/create (CreatePolicy) | | Task | create.task.js | @ossy/policies/tasks/create | | Action | revoke.action.js | @ossy/policies/actions/revoke (RevokePolicy) | | Task | revoke.task.js | @ossy/policies/tasks/revoke |

@ossy/platform loads policies for authenticated users via PoliciesQueries.GetPoliciesForUser and attaches them to req.user.policies.

Policy schema (ADR 0006)

| Schema | Id | Purpose | |---|---|---| | Policy | @ossy/policies/schema/policy | Access rule metadata (effect, assignedTo) |

Policy state is primarily driven by aggregate events; the schema supports manifest discovery and document tooling.

Creating a policy

Call POST /actions with:

{
  "action": "@ossy/policies/actions/create",
  "payload": {
    "belongsTo": "ws-1",
    "assignedTo": "user-2",
    "effect": "allow",
    "actions": ["resource:read"],
    "where": {
      "workspace": "ws-1",
      "location": "/uploads/**",
      "type": "image/*"
    }
  }
}

Required fields: belongsTo, assignedTo, actions, where. effect defaults to allow.

Revoking a policy

Call POST /actions with:

{
  "action": "@ossy/policies/actions/revoke",
  "payload": {
    "policyId": "policy-abc"
  }
}

Server usage

import { Policy, PoliciesEvents, PoliciesQueries, PolicySchema } from '@ossy/policies/server'

PolicySchema.policy
// => '@ossy/policies/schema/policy'

const policies = await PoliciesQueries.GetPoliciesForUser('user-2')

Client usage

import { CreatePolicy, RevokePolicy } from '@ossy/policies'

CreatePolicy.id
// => '@ossy/policies/actions/create'

Event model (ADR 0008)

Policies are event-sourced entities. Policy.View folds:

| Event | Effect | |---|---| | Created | Sets id, belongsTo, assignedTo, effect, actions, where, status: 'active' | | Revoked | Sets status: 'revoked' |

PoliciesEvents.Created emits type: '@ossy/policies/schema/policy', event: 'Created', and resourceId for the policy id.

Migration

| Before | After | |---|---| | policies/actions/create | @ossy/policies/actions/create | | policies/actions/revoke | @ossy/policies/actions/revoke | | (task shared action id) | @ossy/policies/tasks/create | | (task shared action id) | @ossy/policies/tasks/revoke | | PoliciesEvents.PolicyCreated | PoliciesEvents.Created | | PoliciesEvents.PolicyRevoked | PoliciesEvents.Revoked | | Aggregate query type: 'Policy' | type: '@ossy/policies/schema/policy' | | Event field type: 'PolicyCreated' | event: 'Created' with schema type |