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/reporting

v0.3.0

Published

Universal report engine for multi-tenant CompanyIO products

Readme

@companyio/reporting

Universal report engine for CompanyIO hosts and verticals.

Fuel / Hospitality / ContractFlow / …
        ↓ registerReport(definition, runner, { pdfExporter? })
@companyio/reporting
        ↓ run / export (csv|json|pdf) / enqueueExport
JobsPort (@companyio/jobs)  →  async artifacts
Host pdfRenderer / pdfExporter → PDF bytes (pdfkit, etc.)

Verticals register opaque ReportDefinition ids and runners. This package never imports Fuel/Hospitality/ContractFlow types and does not ship a PDF engine — hosts plug in pdfRenderer (tabular) or per-report pdfExporter (full layout).

Install

pnpm add @companyio/reporting

Optional peer: fastify (for attachReporting). Async export requires a host JobsPort from @companyio/jobs.

Usage

import {
  createReporting,
  PLATFORM_SAMPLE_REPORT_ID,
  createPlatformSampleRunner,
  platformSampleReportDefinition,
} from '@companyio/reporting';

const reporting = createReporting({
  getContext: (_req, user) => ({
    main_business_id: user.main_business_id,
    branch_id: user.branch_id,
    user_id: user.id,
  }),
  jobs, // optional JobsPort
});

reporting.registerReport(platformSampleReportDefinition, createPlatformSampleRunner());

const result = await reporting.reporting.run(ctx, PLATFORM_SAMPLE_REPORT_ID, {
  filters: { label: { op: 'contains', value: 'a' } },
  sort: [{ key: 'value', direction: 'desc' }],
});

Host attach

import { attachReporting } from '@companyio/reporting';

attachReporting(app, {
  authenticate,
  getContext,
  jobs,
  prefix: '/api/v1/reports',
});

Routes:

| Method | Path | Purpose | | ------ | ---------------------------------------------- | ------------------------------------------------------ | | GET | /api/v1/reports | List definitions (permission-filtered) | | GET | /api/v1/reports/:id | Definition metadata | | GET | /api/v1/reports/:id/pdf | Stream PDF download (query filters / date range) | | POST | /api/v1/reports/:id/run | Sync run | | POST | /api/v1/reports/:id/export | Sync export (csv | json | pdf, optional async) | | GET | /api/v1/reports/exports/:artifactId | Fetch export artifact (PDF body is base64) | | GET | /api/v1/reports/exports/:artifactId/download | Stream artifact bytes |

PDF

const reporting = attachReporting(app, {
  authenticate,
  getContext,
  pdfRenderer: async (_ctx, { definition, result }) => {
    // Host wraps pdfkit / Puppeteer — package stays engine-agnostic.
    return { buffer: await renderTablePdf(definition, result), filename: `${definition.id}.pdf` };
  },
});

// Full-control layout (financial statements, multi-section packs):
reporting.registerReport(def, runner, {
  pdfExporter: async (ctx, query, definition) => ({
    buffer: await renderCustomPdf(ctx, query, definition),
    filename: `${definition.id}.pdf`,
  }),
});

Set exportFormats: ['pdf'] (or include pdf alongside csv/json) on the definition.

Boundaries

| Owns | Does not own | | ------------------------------------------------ | ------------------------------------ | | Registry, run pipeline, filters/sort/paging MVP | Vertical report SQL / domain queries | | CSV/JSON/PDF export contract + async job payload | PDF rendering libraries (host) | | Permission-key gate on definitions | SaaS entitlements package | | In-memory export artifact store (default) | Long-term object storage |

Architecture

Provisional storage model: handler-backed on-demand (ADR-PLAT-004). See DEVELOPER_GUIDE.md.