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

@companyio/inventory

v0.3.1

Published

Universal inventory package for multi-tenant CompanyIO products

Readme

@companyio/inventory

Universal stock balances, movements, transfers, adjustments, and counts for CompanyIO products.

Inventory is the authoritative source of truth for physical stock quantities and movements.

Sales and Purchasing describe commercial events. Inventory records the stock effect. Accounting owns financial truth. Fuel tank/dip/meter stock stays in @companyio/fuel.

Inventory does not own:

  • product/SKU master (@companyio/catalog)
  • purchase orders or supplier bills (@companyio/purchasing)
  • sales invoices (@companyio/sales)
  • journals (@companyio/accounting)
  • fuel tanks, dips, litres, pumps (@companyio/fuel)

productRef stores a @companyio/catalog variant id. locationRef is an opaque location id from the host (warehouse, store, back room — not a Fuel tank).

pnpm exec inventory init --schema apps/api/prisma/schema.prisma
pnpm exec inventory status
pnpm --filter @companyio/api exec prisma migrate deploy --config prisma7.config.ts

inventory init copies prisma/migrations/0001_inventory_baseline when the host does not already have it (20260926000700_inventory_baseline). Host migration 20260930120000_inventory_movement_idempotency adds idempotencyKey. Inventory does not connect to PostgreSQL. Tenant columns are main_business_id and branch_id.

Fastify + commerce wiring

const inventory = attachInventory(app, {
  store: createPrismaInventoryStore(prisma),
  catalog: createCatalogInventoryAdapter(catalog),
  prefix: '/api/v1/inventory',
  authenticate,
  getContext,
});

attachPurchasing(app, {
  // ...
  inventory: createPurchasingInventoryAdapter(inventory.inventory, {
    defaultLocationRef: 'main',
  }),
});

attachSales(app, {
  // ...
  inventory: createSalesInventoryAdapter(inventory.inventory, {
    defaultLocationRef: 'main',
  }),
});

Line or document attributes.locationRef overrides the default location.

API Routes

Mounted at /api/v1/inventory. Full detail: docs/API_ROUTE_INVENTORY.md.

| Method | Route | Auth | Purpose | | -------- | ----------------------- | ------- | --------------- | | GET | /inventory/health | Public | Health | | GET | /inventory/stock | Session | Stock levels | | GET | /inventory/movements | Session | Movements | | POST | /inventory/receipts | Session | Receipt | | POST | /inventory/issues | Session | Issue | | POST/GET | /inventory/transfers… | Session | Transfers | | POST/GET | /inventory/adjustments… | Session | Adjustments | | POST | /inventory/counts… | Session | Counts (+ post) |

Known gaps

  • COGS / COGS-return / shortage / gain journals: optional host wiring via createAccountingInventoryAdapter. Accounts resolve through Accounting resolveInventoryPostingAccounts (seeded STANDARD_CHART_CODES + optional OperationalAccountMapping). Verified zero WAC skips journals (skippedZeroCostIds); invalid valuation fails. Pass books into createSalesInventoryAdapter (and Fuel inventoryBooks) so costs post once per movement id.
  • locationRef is opaque — hosts own warehouses/stores; vertical tank/dip stock stays in product packages.
  • No lot/serial tracking yet.

Frontend (/client + /react)

Browser hosts should import from the dedicated entries — never the package root:

import { createInventoryApi } from '@companyio/inventory/client';
import {
  InventoryProvider,
  InventoryStockPage,
  inventoryQueryKeys,
} from '@companyio/inventory/react';

InventoryStockPage covers stock on hand, recent movements, receive stock, and physical count. Product pickers come from @companyio/catalog/react. Host-specific workflows (e.g. ContractFlow issue-to-project via contractor material-issues) stay in thin product adapters.

Fixed assets are not stock inventory — use @companyio/assets. Fuel tank/dip stock stays in @companyio/fuel. Purchasing receipts that affect stock go through purchasing → inventory adapters, not duplicated UI in this package.

Build / test

pnpm --filter @companyio/inventory test
pnpm --filter @companyio/inventory build
pnpm --filter @companyio/inventory typecheck

Package tests cover CLI init, stock movements integration, HTTP routes, client contracts, format helpers, and browser-boundary guards for /client and /react.