Skip to content

@btravstack/prisma


@btravstack/prisma / index

index ​

Classes ​

DatabaseUnreachable ​

Defined in: packages/prisma/src/prisma.ts:117

The database did not answer when the scope opened. Carries the database's name and the driver's own failure, never the URL, which holds credentials.

Extends ​

  • TaggedErrorInstance<"DatabaseUnreachable", { cause: unknown; database: string; }>

Constructors ​

Constructor ​
ts
new DatabaseUnreachable(args): DatabaseUnreachable;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

DatabaseUnreachable

Inherited from ​

TaggedError("DatabaseUnreachable")<{ readonly database: string; readonly cause: unknown; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"DatabaseUnreachable"TaggedError("DatabaseUnreachable")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
causepublicunknownRowSecurityBypassed.causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
databasereadonlystringTaggedError("DatabaseUnreachable").databasepackages/prisma/src/prisma.ts:118
messagepublicstringTaggedError("DatabaseUnreachable").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("DatabaseUnreachable").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
stack?publicstringTaggedError("DatabaseUnreachable").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

RowSecurityBypassed ​

Defined in: packages/prisma/src/prisma.ts:106

The role the client connected as is exempt from row-level security on a table that has it enabled: a superuser, a role with BYPASSRLS, or the owner of a table whose security is not FORCEd — which Prisma 8 cannot declare, so every table a migration created qualifies for the role that ran it. Every policy would admit every row, so the boot is refused rather than served without isolation. tables are the ones it would bypass; the URL is never carried.

Extends ​

  • TaggedErrorInstance<"RowSecurityBypassed", { bypass: RowSecurityBypass; database: string; role: string; tables: readonly string[]; }>

Constructors ​

Constructor ​
ts
new RowSecurityBypassed(args): RowSecurityBypassed;

Defined in: node_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2386

Parameters ​
ParameterType
argsobject & object
Returns ​

RowSecurityBypassed

Inherited from ​

TaggedError("RowSecurityBypassed")<{ readonly database: string; readonly role: string; readonly bypass: RowSecurityBypass; readonly tables: readonly string[]; }>.constructor

Properties ​

PropertyModifierTypeInherited fromDefined in
_tagreadonly"RowSecurityBypassed"TaggedError("RowSecurityBypassed")._tagnode_modules/.pnpm/unthrown@5.12.1/node_modules/unthrown/dist/index.d.mts:2363
bypassreadonlyRowSecurityBypassTaggedError("RowSecurityBypassed").bypasspackages/prisma/src/prisma.ts:109
cause?publicunknownTaggedError("RowSecurityBypassed").causenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24
databasereadonlystringTaggedError("RowSecurityBypassed").databasepackages/prisma/src/prisma.ts:107
messagepublicstringTaggedError("RowSecurityBypassed").messagenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075
namepublicstringTaggedError("RowSecurityBypassed").namenode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1074
rolereadonlystringTaggedError("RowSecurityBypassed").rolepackages/prisma/src/prisma.ts:108
stack?publicstringTaggedError("RowSecurityBypassed").stacknode_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076
tablesreadonlyreadonly string[]TaggedError("RowSecurityBypassed").tablespackages/prisma/src/prisma.ts:110

Type Aliases ​

PrismaBinding ​

ts
type PrismaBinding = object;

Defined in: packages/prisma/src/prisma.ts:123

What the starter hands PrismaOptions.client.

Properties ​

PropertyModifierTypeDescriptionDefined in
middlewarereadonlyreadonly SqlMiddlewareLike[]The starter's own middleware — the statement hooks of every supported Prisma train, reporting every query to Observers. Spread it into the client's middleware array beside any of the application's own.packages/prisma/src/prisma.ts:131
urlreadonlystringDATABASE_URL, read through Config rather than by the application.packages/prisma/src/prisma.ts:125

PrismaLike ​

ts
type PrismaLike = object;

Defined in: packages/prisma/src/prisma.ts:24

All this starter needs of a client: a raw lane to probe with, and a runtime to run the probe on and to close.

A Prisma 8 client satisfies it structurally. Both members are part of the contract rather than optional because every client has them, and a probe that has to feature-detect its own client cannot report the difference between "the database is down" and "this client cannot be asked".

Properties ​

PropertyModifierTypeDescriptionDefined in
rawreadonlyobjectThe raw lane, required to EXIST and deliberately not described further. Spelling its signature out here would refuse every real client: a parameter is contravariant, and the genuine raw.sql takes the target's own interpolation union and its own row-spec type, both of which are narrower than anything this package — which cannot see a contract — could name. unknown on the property still requires it to be there, which is what makes a client with no raw lane a compile error.packages/prisma/src/prisma.ts:35
raw.sqlreadonlyunknown-packages/prisma/src/prisma.ts:35
runtimereadonlyunknownRequired to exist, and read through the same cast for the same reason: the real execute takes the contract's own plan type.packages/prisma/src/prisma.ts:40

PrismaOptions ​

ts
type PrismaOptions<C> = object;

Defined in: packages/prisma/src/prisma.ts:135

What prismaDatabase is handed.

Type Parameters ​

Type Parameter
C extends PrismaLike

Properties ​

PropertyModifierTypeDescriptionDefined in
clientreadonly(binding) => CBuilds the client from what the starter bound. This is the one thing the starter cannot own: a Prisma 8 client is typed by the application's own emitted Contract and constructed from its own contract.json, so there is no client type to ship. Building it here is what makes the returned type exactly the one the application will hold. Example import { contractFromJson } from "@prisma/orm-postgres/static"; const contract = contractFromJson<Contract>(contractJson); prismaDatabase("OrderDatabase")({ client: ({ url, middleware }) => postgres({ contract, url, middleware }), });packages/prisma/src/prisma.ts:155

RowSecurityBypass ​

ts
type RowSecurityBypass = "superuser" | "bypassrls" | "owner";

Defined in: packages/prisma/src/prisma.ts:76

Why row-level security does not apply to the role, as RowSecurityBypassed names it.


SqlMiddlewareLike ​

ts
type SqlMiddlewareLike = object;

Defined in: packages/prisma/src/instrument.ts:14

A Prisma 8 SQL middleware, structurally, with the hooks of BOTH release trains the peer range admits.

Prisma 8.0.0-rc.18 replaced the per-statement hooks: beforeQuery and beforeExecute became beforeEncode, afterQuery and afterExecute became activityEnded. The two sets are disjoint and neither runtime refuses a hook it does not know, so one object serves both: each runtime calls its own pair and never the other's. Declared here rather than imported so the option's type drags no target package into a consumer.

Properties ​

PropertyModifierTypeDescriptionDefined in
activityEndedreadonly(activity, result, ctx) => Promise<void>rc.18 and later: a statement, transaction or client activity ended.packages/prisma/src/instrument.ts:20
afterExecutereadonly(plan, result, ctx) => Promise<void>-packages/prisma/src/instrument.ts:30
afterQueryreadonly(plan, result, ctx) => Promise<void>-packages/prisma/src/instrument.ts:27
beforeEncodereadonly(plan, ctx) => Promise<void>rc.18 and later: before the statement's parameters are encoded, on both lanes.packages/prisma/src/instrument.ts:18
beforeExecutereadonly(plan, ctx) => Promise<void>rc.11 to rc.17: a statement run for its statistics, such as a write with no RETURNING.packages/prisma/src/instrument.ts:29
beforeQueryreadonly(plan, ctx) => Promise<void>rc.11 to rc.17: a statement read for its rows.packages/prisma/src/instrument.ts:26
familyIdreadonly"sql"-packages/prisma/src/instrument.ts:16
namereadonlystring-packages/prisma/src/instrument.ts:15

Functions ​

prismaDatabase() ​

ts
function prismaDatabase<N>(name): <C>(__namedParameters) => Module<ResolvedExports<readonly [PortClassOf<N, C>, typeof HealthChecks]>, 
  | DatabaseUnreachable
  | RowSecurityBypassed
  | ConfigInvalid, Exclude<EnvReading<"DATABASE_URL", never>, Available<[], readonly [Provider<PortInstance<`${N}Config`, {
  url: string;
}>, ConfigInvalid, EnvReading<"DATABASE_URL", never>> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, 
  | DatabaseUnreachable
  | RowSecurityBypassed, 
  | Scope
  | PortInstance<`${(...)}Config`, {
  url: ...;
}>
  | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object]>>> & object;

Defined in: packages/prisma/src/prisma.ts:188

A Prisma client whose pool is the application scope's.

Returns a module carrying the three pieces a composition root needs and nothing more: the config provider binding the connection string, the port the client is reached through, and the resourceful provider that opens it and closes it again.

The database answers before the scope is handed out: opening runs the health check's probe, so a pool is verified before any unit uses it, and a database that does not answer fails the boot with DatabaseUnreachable.

Row-level security has to apply to the role it connected as. Where any table has it enabled, a role that is a superuser, has BYPASSRLS, or owns such a table without FORCE fails the boot with RowSecurityBypassed. A database with no row-secured table passes as it is. The health check does not repeat it: a role does not change under a running pool.

The pool closes on every exit path, including a boot that fails after this provider ran — that is what makes it resourceful rather than a plain value. runtime().close() ends the pool; Prisma dials again lazily on the next statement, which is why no spec asserts that a released client refuses to query.

Migrations are not run here. A deployment runs prisma db migrate against this same URL before the process starts; an application that migrates itself at boot races every other replica.

Type Parameters ​

Type Parameter
N extends string

Parameters ​

ParameterType
nameN

Returns ​

<C>(__namedParameters) => Module<ResolvedExports<readonly [PortClassOf<N, C>, typeof HealthChecks]>, | DatabaseUnreachable | RowSecurityBypassed | ConfigInvalid, Exclude<EnvReading<"DATABASE_URL", never>, Available<[], readonly [Provider<PortInstance<`${N}Config`, { url: string; }>, ConfigInvalid, EnvReading<"DATABASE_URL", never>> & object, Provider<Observers, never, never> & object, Provider<PortInstance<string, C>, | DatabaseUnreachable | RowSecurityBypassed, | Scope | PortInstance<`${(...)}Config`, { url: ...; }> | Observers> & object, Provider<HealthChecks, never, PortInstance<string, C>> & object]>>> & object

Released under the MIT License.