# @imqueue/pg-prisma 1.0.1 · API reference

Source: https://imqueue.org/api/pg-prisma/latest/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-prisma 1.0.1 — generated reference, not hand-written

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 |
| --- | --- |
| [accessScope(input)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscope/) | Build the query extension that restricts queries to the records the active access levels allow. |
| [accessWhere(where, config, resolvers)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accesswhere/) | Compose the access-scope `where` clause for a single model. |
| [audit(input)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.audit/) | Build the query extension that records every write to an audited model. |
| [authorship(input)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorship/) | Build the query extension that stamps who created, updated or deleted a row. |
| [installArchiving(options)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.installarchiving/) | Install the row-archiving machinery: a mirror `archive` schema, its settings table, the sweep function, and — best effort — a pg\_cron schedule to run it. |
| [installChangeTriggers(client, input)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.installchangetriggers/) | Install Postgres triggers that `NOTIFY` on every row change in the given tables. |
| [isoDates()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.isodates/) | Build the query extension that serializes every `Date` in a query result to an ISO-8601 string. |
| [isSqlLogSuppressed()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.issqllogsuppressed/) | Whether SQL logging is currently suppressed. |
| [migrateDown(options)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.migratedown/) | Roll back the most recently applied Prisma migrations. |
| [prettifySql(sql)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.prettifysql/) | Format a one-line SQL string so it is readable in a log. |
| [silently(fn)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.silently/) | Run `fn` with SQL logging suppressed. |
| [softDelete(input)](https://imqueue.org/api/pg-prisma/latest/pg-prisma.softdelete/) | Build the query extension that turns deletes into `deletedAt` stamps and hides stamped rows from reads. |


## Interfaces


| Interface | Description |
| --- | --- |
| [AccessScopeOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscopeoptions/) | Everything [accessScope()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscope/) needs to build its extension. |
| [ArchivableModel](https://imqueue.org/api/pg-prisma/latest/pg-prisma.archivablemodel/) | One watched table to seed into the archive settings table. |
| [ArchiveClient](https://imqueue.org/api/pg-prisma/latest/pg-prisma.archiveclient/) | The raw-SQL surface this installer needs (a Prisma client or its `tx`). |
| [AuditColumns](https://imqueue.org/api/pg-prisma/latest/pg-prisma.auditcolumns/) | Column names in the audit target table. |
| [AuditConfig](https://imqueue.org/api/pg-prisma/latest/pg-prisma.auditconfig/) | Where the audit trail is written, and under which column names. |
| [AuditOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.auditoptions/) | Everything [audit()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.audit/) needs to build its extension. |
| [AuthorshipColumns](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorshipcolumns/) | Which columns on one model carry authorship, and which one triggers a delete stamp. |
| [AuthorshipOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorshipoptions/) | Everything [authorship()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorship/) needs to build its extension. |
| [ChangeTriggerConfig](https://imqueue.org/api/pg-prisma/latest/pg-prisma.changetriggerconfig/) | Which tables notify, and under which Postgres object names. |
| [InstallArchiveOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.installarchiveoptions/) | Everything [installArchiving()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.installarchiving/) needs. |
| [MigrateDownOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.migratedownoptions/) | Everything [migrateDown()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.migratedown/) needs: no globals and no environment are read. |
| [MigrateDownResult](https://imqueue.org/api/pg-prisma/latest/pg-prisma.migratedownresult/) | What [migrateDown()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.migratedown/) did. |
| [RawClient](https://imqueue.org/api/pg-prisma/latest/pg-prisma.rawclient/) | A [RawExecutor](https://imqueue.org/api/pg-prisma/latest/pg-prisma.rawexecutor/) that can also open a transaction. |
| [RawExecutor](https://imqueue.org/api/pg-prisma/latest/pg-prisma.rawexecutor/) | The raw-SQL surface used to install triggers (a Prisma client or its `tx`). |
| [SoftDeleteOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.softdeleteoptions/) | Everything [softDelete()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.softdelete/) needs to build its extension. |


## Variables


| Variable | Description |
| --- | --- |
| [AuditAction](https://imqueue.org/api/pg-prisma/latest/pg-prisma.auditaction/) | The three kinds of write recorded in the audit trail. |
| [CHANGE\_NOTIFY\_CHANNEL](https://imqueue.org/api/pg-prisma/latest/pg-prisma.change_notify_channel/) | Default Postgres NOTIFY channel the change triggers emit on. |
| [CHANGE\_NOTIFY\_FUNCTION\_NAME](https://imqueue.org/api/pg-prisma/latest/pg-prisma.change_notify_function_name/) | Default name of the trigger's plpgsql notify function. |
| [CHANGE\_NOTIFY\_TRIGGER\_NAME](https://imqueue.org/api/pg-prisma/latest/pg-prisma.change_notify_trigger_name/) | Default name of the per-table change trigger. |


## Type Aliases


| Type Alias | Description |
| --- | --- |
| [AccessScopeModels](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscopemodels/) | Per-model access-scope config: `model → level → columns`. A record is in scope for a level when ANY of the level's columns matches (OR); a model is in scope when EVERY active level matches (AND). See the generated `ACCESS_SCOPE_MODELS`. |
| [AccessScopeResolver](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscoperesolver/) | Resolves the current request's value for one access level: - `undefined` — the level does not constrain this request (skip it), - `null` — active but there is no value → deny (match nothing), - a string — match rows where a scope column equals it, - an array — match rows where a scope column is `IN` it (empty → deny). |
| [AuthorshipModels](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorshipmodels/) | Which models carry authorship, keyed by Prisma model name. |
| [SoftDeleteModels](https://imqueue.org/api/pg-prisma/latest/pg-prisma.softdeletemodels/) | Which models are soft-deleted, and which column carries the stamp. |

