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

@xemahq/org-erasure-nest

v1.0.2

Published

The org-erasure participant contract, its fenced internal endpoint, and the protected-organization guard for Xema services.

Downloads

7,229

Readme

@xemahq/org-erasure-nest

The org-erasure participant contract, its fenced internal endpoint, and the protected-organization guard

Overview

An org-erasure participant is any service that holds an organisation's data and can be told to destroy it. An orchestrator discovers participants from the service registry by a declared capability and fans out to one internal route on each of them.

This package is the participant half of that contract, and nothing else:

  • the two protocol strings — the capability a participant declares, and the route path the orchestrator POSTs to;
  • OrgErasureController, the route, behind two independent fences;
  • OrgProtectionGuard and its identity probe, which answer may this organisation be destroyed at all? and fail closed on every uncertainty;
  • OrgErasureEndpointModule.forRunner(...), which mounts the route over an eraser you supply.

It deliberately knows nothing about storage. The Prisma-backed eraser — walk every model carrying the org column and delete its rows in an FK-safe order — lives in @xemahq/biome-database-nest, which composes this package.

Install

pnpm add @xemahq/org-erasure-nest

Peers: @nestjs/common, @nestjs/core, @nestjs/swagger, @xemahq/identity-client, @xemahq/kernel-contracts, @xemahq/platform-common, @xemahq/service-registry-nest, @xemahq/xema-decorators.

Usage

A participant whose data Prisma cannot reach supplies its own eraser:

import { OrgErasureEndpointModule } from '@xemahq/org-erasure-nest';

@Module({
  imports: [
    OrgErasureEndpointModule.forRunner({
      useFactory: (cache: CacheClient) => ({
        erase: async (orgId) => cache.dropOrgNamespace(orgId),
      }),
      inject: [CacheClient],
    }),
  ],
})
export class AppModule {}

A participant that stores rows in Postgres uses the Prisma binding instead:

import { OrgErasureModule } from '@xemahq/biome-database-nest';

imports: [OrgErasureModule.forRoot({ prismaServiceToken: PrismaService })];

Either way the service must declare ORG_DATA_ERASURE_CAPABILITY in its service descriptor, or the orchestrator will never find it.

Two fences, and why both

| guard | answers | | --- | --- | | ServiceActorGuard | is the caller a non-delegated service? | | OrgProtectionGuard | may this organisation be destroyed at all? |

Neither substitutes for the other. ServiceActorGuard proves a service token, not which service, so any service in the fleet reaches this route directly — which is why an orchestrator-side protection check cannot be the only one.

OrgProtectionGuard fails closed on every uncertainty: an unreachable or non-2xx identity service, a malformed body, a record without a boolean protection field, or an organisation that does not resolve in any realm this service can see. Erasure is irreversible; a wrongful refusal costs one retry.

The guard injects only tokens the platform bootstrap exports globally and builds its own probe, so it arms identically whether the endpoint is mounted through forRunner or declared in a module of your own. A service that has not wired the platform bootstrap refuses to start, with a named error, rather than serving an unfenced irreversible route.

Licence

Apache-2.0