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

@imqueue/pg-prisma

v1.0.1

Published

Prisma/Postgres toolkit for Node.js & TypeScript microservices — query extensions (soft-delete, audit, authorship, access-scope), row archiving, change-notify triggers, down-migrations, and a Prisma generator for typed @imqueue/rpc models (the @imqueue fr

Readme

@imqueue/pg-prisma

License

A Prisma/Postgres toolkit for Node.js & TypeScript back-ends — the persistence helpers behind @imqueue framework services. It bundles a set of Prisma client extensions (soft-delete, audit trail, authorship stamping, row-level access scope), Postgres operational helpers (row archiving, change-notify triggers, down-migrations, SQL log formatting), and a Prisma generator that emits typed @imqueue/rpc model & repository classes.

Documentation: full guides, tutorial and API reference at imqueue.org. Commercial licensing & support for closed-source products at imqueue.com.

Using an AI assistant? Point it at imqueue.org/llms.txt for a machine-readable index of the docs, or see AGENTS.md.

Related packages:

  • @imqueue/core - Fast JSON message queue over Redis for inter-service communication.
  • @imqueue/rpc - RPC-like client/service implementation over @imqueue/core.
  • @imqueue/validation - Zod-backed decorator validation (used by the generated model classes).

Features

  • Soft-delete extension — transparently excludes soft-deleted rows and turns deletes into deletedAt stamps.
  • Audit extension — writes an append-only audit trail of INSERT/UPDATE/DELETE.
  • Authorship extension — stamps createdBy/updatedBy/deletedBy from a caller-supplied actor id.
  • Access-scope helperaccessWhere(...) composes row-level access filters (AND of per-level OR groups) onto any Prisma where.
  • Row archiving — moves aged rows out of hot tables into a mirror archive schema on a pg_cron schedule (idempotent DB setup).
  • Change-notify triggers — installs Postgres NOTIFY triggers for row changes.
  • Down-migrationsmigrateDown() undoes applied Prisma migrations (Prisma has no native "down").
  • SQL log helpersprettifySql() and cooperative log suppression.
  • Prisma generator — emits typed @imqueue/rpc models, inputs, query types and repositories from your schema.
  • TypeScript included!

Requirements

  • Node.js ≥ 22.12, PostgreSQL, and Prisma 7+.
  • @prisma/client is a peer dependency — the extensions import the Prisma namespace from @prisma/client/extension (the entry for shareable Client extensions), so they work whether you generate your client to the default @prisma/client output or to a custom path.
  • Some Postgres features are optional: row archiving schedules via pg_cron when available (it degrades gracefully when the extension is absent).

Install

npm i --save @imqueue/pg-prisma

Usage

Client extensions

import { PrismaClient } from '@prisma/client';
import { softDelete, audit, authorship } from '@imqueue/pg-prisma';

// The FIRST-added extension is the OUTERMOST — keep `audit` first so that
// soft-deletes are still recorded in the audit trail.
const prisma = new PrismaClient()
    .$extends(audit({ /* ...config... */ }))
    .$extends(authorship({ /* ...config... */ }))
    .$extends(softDelete({ /* ...config... */ }));

Access scope

import { accessWhere } from '@imqueue/pg-prisma';

const where = accessWhere(
    callerWhere,
    { user: ['createdBy'], portfolio: ['portfolioId'] },
    { user: () => currentUserId, portfolio: () => allowedPortfolioIds },
);

Prisma generator

The package ships a Prisma generator that emits typed @imqueue/rpc model and repository classes. Point a generator block at it in your schema.prisma:

generator imq {
  provider = "node ./node_modules/@imqueue/pg-prisma/src/codegen.js"
}

The generated code assumes your project defines the subpath import aliases #generated/* and #prisma (your PrismaClient instance), and imports validation decorators from @imqueue/validation and RPC decorators from @imqueue/rpc. Install those alongside this package if you use the generator.

Down-migrations

node --import tsx node_modules/@imqueue/pg-prisma/src/migrate-down.js \
  --database-url "$DATABASE_URL" --steps 1

Running Unit Tests

Tests run on the native Node.js test runner (node:test) with node:assert and no external test framework:

git clone [email protected]:imqueue/pg-prisma.git
cd pg-prisma
npm install
npm test

To produce a coverage report use:

npm run test-coverage        # prints coverage summary to the console
npm run test-lcov            # writes coverage/lcov.info

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE