pg-prisma package
Prisma and Postgres building blocks for @imqueue services.
Two kinds of thing live here, and they are used at different times.
Query extensions wrap a PrismaClient and change what queries do: softDelete turns deletes into deletedAt stamps and hides stamped rows, accessScope narrows every read to the records the caller is allowed to see, authorship stamps who created, updated or deleted a row, audit writes a trail of every write to a table you nominate, and isoDates serializes Date values so they survive the RPC wire as ISO strings. Each is independent; each is driven by a per-model config the code generator emits from your Prisma schema.
Installers and tools run once at startup or by hand rather than per query: installArchiving moves aged rows into a mirror archive schema on a pg_cron schedule, installChangeTriggers makes Postgres NOTIFY on every row change, migrateDown rolls applied migrations back (Prisma has no native "down"), and prettifySql/silently/isSqlLogSuppressed are query-logging helpers.
Ordering matters when extensions are combined, because Prisma runs the first-added query hook outermost. audit has to be added first if it is to see operations that softDelete reroutes; the individual pages say so where it applies.
The Prisma generator that emits typed @imqueue/rpc models from your schema ships separately at @imqueue/pg-prisma/codegen and is invoked by Prisma, not imported — it is deliberately absent from this barrel.
Functions
|
Function |
Description |
|---|---|
|
Build the query extension that restricts queries to the records the active access levels allow. | |
|
Compose the access-scope | |
|
Build the query extension that records every write to an audited model. | |
|
Build the query extension that stamps who created, updated or deleted a row. | |
|
Install the row-archiving machinery: a mirror | |
|
Install Postgres triggers that | |
|
Build the query extension that serializes every | |
|
Whether SQL logging is currently suppressed. | |
|
Roll back the most recently applied Prisma migrations. | |
|
Format a one-line SQL string so it is readable in a log. | |
|
Run | |
|
Build the query extension that turns deletes into |
Interfaces
|
Interface |
Description |
|---|---|
|
Everything accessScope() needs to build its extension. | |
|
One watched table to seed into the archive settings table. | |
|
The raw-SQL surface this installer needs (a Prisma client or its | |
|
Column names in the audit target table. | |
|
Where the audit trail is written, and under which column names. | |
|
Everything audit() needs to build its extension. | |
|
Which columns on one model carry authorship, and which one triggers a delete stamp. | |
|
Everything authorship() needs to build its extension. | |
|
Which tables notify, and under which Postgres object names. | |
|
Everything installArchiving() needs. | |
|
Everything migrateDown() needs: no globals and no environment are read. | |
|
What migrateDown() did. | |
|
A RawExecutor that can also open a transaction. | |
|
The raw-SQL surface used to install triggers (a Prisma client or its | |
|
Everything softDelete() needs to build its extension. |
Variables
|
Variable |
Description |
|---|---|
|
The three kinds of write recorded in the audit trail. | |
|
Default Postgres NOTIFY channel the change triggers emit on. | |
|
Default name of the trigger's plpgsql notify function. | |
|
Default name of the per-table change trigger. |
Type Aliases
|
Type Alias |
Description |
|---|---|
|
Per-model access-scope config: | |
|
Resolves the current request's value for one access level: - | |
|
Which models carry authorship, keyed by Prisma model name. | |
|
Which models are soft-deleted, and which column carries the stamp. |
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.