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

@devx-retailos/core

v0.0.2

Published

Shared types, interfaces, and errors for retailOS packages.

Readme

@devx-retailos/core

Shared types, interfaces, and errors for retailOS packages: the Subject identity model, Logger, RetailOSError, IdentityResolver, and the permission/flag registries.

Part of retailOS, a Medusa v2 SDK for offline-store POS systems. Packages are installed independently and composed in a brand's Medusa backend; core is the dependency-free foundation every other @devx-retailos/* package builds on.

Installation

npm install @devx-retailos/core

Pure TypeScript, zero runtime dependencies, no Medusa requirement. Ships CJS + ESM with type declarations.

Key exports

Identity types

RBAC in retailOS is subject-agnostic: anything with an id and a type can hold roles.

import type { Subject, PermissionScope, IdentityContext } from "@devx-retailos/core"

const subject: Subject = { id: "user_123", type: "medusa_user" }
const scope: PermissionScope = { organization_id: "org_01", store_id: "store_01" }

IdentityResolver

The seam that maps an incoming request to a subject. Implement it to plug a new auth mechanism (PIN, SSO, badge) into RBAC without schema changes.

import type { IdentityResolver, IdentityContext } from "@devx-retailos/core"

const pinResolver: IdentityResolver<MyRequest> = {
  name: "pin",
  async resolve(req): Promise<IdentityContext | null> {
    const employee = await lookupByPin(req.headers["x-pin"])
    if (!employee) return null
    return {
      subject: { id: employee.id, type: "employee" },
      scope: { organization_id: employee.organization_id },
    }
  },
}

Logger and withScope

All retailos packages log through this interface instead of console.*.

import { withScope, createNoopLogger, type Logger } from "@devx-retailos/core"

const log = withScope(injectedLogger, "discount")
log.info("discount applied", { discount_id, order_id }) // -> "[discount] discount applied"

createNoopLogger() returns a silent logger, useful as a default in tests.

RetailOSError

Base class for every domain error in the SDK, with a stable code consumers can switch on.

import { RetailOSError, PermissionDeniedError } from "@devx-retailos/core"

class StockMismatchError extends RetailOSError {
  constructor(readonly sku: string) {
    super("RETAILOS_INVENTORY_STOCK_MISMATCH", `Stock mismatch for ${sku}.`)
    this.name = "StockMismatchError"
  }
}

try {
  await doPosThing()
} catch (err) {
  if (err instanceof RetailOSError) handle(err.code)
}

Built-in subclasses: PermissionDeniedError (RETAILOS_PERMISSION_DENIED, carries subject + permission), UnknownPermissionError (RETAILOS_UNKNOWN_PERMISSION), IdentityResolutionError (RETAILOS_IDENTITY_RESOLUTION_FAILED).

PermissionRegistry

Permission keys are plain strings registered at boot. Modules export a PermissionRegistration[]; syncAllPermissions collects them and pushes them into a sync target (in practice the @devx-retailos/rbac module service).

import {
  createInMemoryPermissionRegistry,
  syncAllPermissions,
  type PermissionRegistration,
} from "@devx-retailos/core"

const MY_PERMISSIONS: PermissionRegistration[] = [
  { key: "report.read", description: "View reports", registered_by: "reports" },
]

await syncAllPermissions(rbacService, MY_PERMISSIONS)

FlagRegistry

Same pattern for boolean feature flags: FlagRegistration, createInMemoryFlagRegistry, syncAllFlags, each flag carrying a default_value.

DTOs

Plain data shapes shared across packages: OrganizationDTO, StoreDTO, PermissionDTO, RoleDTO, UserRoleDTO.

Related packages

  • @devx-retailos/rbac — org/store/role/permission RBAC Medusa module that consumes these types.
  • @devx-retailos/employee — employee entity + an IdentityResolver implementation for Medusa users.
  • @devx-retailos/sdk-client — typed frontend client and React hooks.

License

MIT