by Haru S.

Prisma ORM is a next-generation database toolkit for Node.js and TypeScript, featuring an auto-generated type-safe query builder, declarative migrations, and a visual data editor for SQL and NoSQL databases.
This block provides the Prisma Client runtime source from packages/client/src, the core engine that powers query execution, extension handling, engine communication, and client instantiation for Prisma ORM. It is intended for teams embedding or customizing Prisma Client generation and runtime behavior in TypeScript/Node.js backend projects.
generation/ - Code generation utilities; generator.ts orchestrates client code emission from DMMFruntime/ - Core runtime: client factory, request handling, engine adapters, extensions, tracing, transactionsruntime/getPrismaClient.ts - Main factory that constructs the PrismaClient class at runtimeruntime/RequestHandler.ts - Handles query dispatch, middleware execution, and result deserializationruntime/DataLoader.ts - Batches database requests to reduce round-tripsruntime/index.ts - Primary public entry point; re-exports all public symbolsruntime/index-browser.ts - Browser-safe subset of the runtime exportsruntime/strictEnum.ts - Runtime enforcement helper for Prisma enum valuesruntime/mergeBy.ts - Utility for merging arrays by a key functionruntime/getLogLevel.ts - Maps log event strings to severity levelsruntime/core/extensions/ - Extension definition and context helpers (defineExtension, getExtensionContext)runtime/core/public/ - User-facing utilities (validator)runtime/core/engines/ - Engine abstraction layer: ClientEngine, AccelerateEngine, common typesruntime/core/compositeProxy/ - Proxy helpers for building model and extension objectsruntime/core/jsonProtocol/ - JSON query serialization (serializeJsonQuery)runtime/core/model/ - Model parameter helpers (createParam)runtime/core/runtimeDataModel.ts - Converts DMMF to the lean RuntimeDataModel used at runtimeruntime/core/types/ - Core TypeScript type exports (exported types, Skip, TypedSql, ITX deny list)Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript cli / script completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 f938d6073cdcc552…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
runtime/core/tracing/runtime/core/transaction/ - Interactive transaction coordinationruntime/core/raw-query/ - Raw SQL query helpersscripts/ - Build and postinstall scriptstestUtils/ - Internal test helpers (not for production use)utils/ - Shared utilities: deserializeRawResults, getRuntimenpm install @prisma/client
npm install @prisma/client-common @prisma/client-engine-runtime @prisma/client-runtime-utils
npm install @prisma/debug @prisma/dmmf @prisma/driver-adapter-utils @prisma/internals
npm install @prisma/json-protocol
npm install decimal.js
No native build steps are required for pure TypeScript/Node.js use. If you are using the Wasm-based query compiler (WasmQueryCompilerLoader), ensure your bundler supports .wasm imports. For edge runtimes, use runtime/index-browser.ts as the entry point.
Copy the source/ directory into your project, e.g. src/prisma-runtime/.
In tsconfig.json, ensure paths resolves the internal package aliases if you are not running inside the Prisma monorepo:
{
"compilerOptions": {
"moduleResolution": "bundler",
"paths": {
"@prisma/client-common": ["./node_modules/@prisma/client-common"],
"@prisma/client-runtime-utils": ["./node_modules/@prisma/client-runtime-utils"],
"@prisma/client-engine-runtime": ["./node_modules/@prisma/client-engine-runtime"]
}
}
}
DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"
# For Prisma Accelerate:
PRISMA_ACCELERATE_API_KEY="your-accelerate-key"
import { getPrismaClient } from './prisma-runtime/runtime/getPrismaClient'
prisma.schema generator output to your app directory and run prisma generate — the generated client will call getPrismaClient from this runtime.getPrismaClientimport { getPrismaClient, type GetPrismaClientConfig } from './runtime/index'
function getPrismaClient(config: GetPrismaClientConfig): new (options?: PrismaClientOptions) => any
The central factory. Pass it a GetPrismaClientConfig (produced by the generator) to receive a fully-typed PrismaClient constructor. Use this when building custom generators or embedding Prisma in a framework where you control client instantiation.
defineExtensionimport { Extensions } from './runtime/index'
Extensions.defineExtension(ext: ExtensionArgs): ExtensionArgs
Defines a Prisma Client extension (model methods, result fields, query middleware, client-level methods). Use this to package reusable extension logic as an npm library or internal utility without referencing a concrete generated client.
serializeJsonQueryimport { serializeJsonQuery } from './runtime/index'
function serializeJsonQuery(query: JsonQuery): string
Serializes a structured JsonQuery object into the wire format expected by Prisma engines. Useful when building custom query pipelines or testing engine communication directly without going through the full PrismaClient call stack.
skipimport { skip } from './runtime/index'
// type: unique symbol used as a sentinel for "omit this field"
A typed sentinel value used in Prisma's conditional select/omit API. Pass skip instead of undefined to explicitly exclude a field from a query result type while keeping TypeScript inference correct.
makeStrictEnumimport { makeStrictEnum } from './runtime/index'
function makeStrictEnum<T extends Record<string, string | number>>(obj: T): T
Freezes an enum-like object and throws at runtime if an unknown value is accessed. Use this in generated code or custom enums where silent undefined access would be a silent bug.
Demonstrates using getPrismaClient with a minimal config to create a client instance outside of prisma generate.
import { getPrismaClient, type GetPrismaClientConfig } from './prisma-runtime/runtime/index'
import { dmmfToRuntimeDataModel } from './prisma-runtime/runtime/index'
// Normally produced by prisma generate; shown here for illustration
const config: GetPrismaClientConfig = {
runtimeDataModel: dmmfToRuntimeDataModel(someDmmf.datamodel),
generator: undefined,
dirname: __dirname,
filename: __filename,
relativePath: '../',
clientVersion: '5.0.0',
engineVersion: 'abc123',
datasourceNames: ['db'],
activeProvider: 'postgresql',
}
const PrismaClient = getPrismaClient(config)
const prisma = new PrismaClient({ datasources: { db: { url: process.env.DATABASE_URL } } })
async function main() {
// prisma is now fully operational
await prisma.$disconnect()
}
main()
Packages a soft-delete extension that intercepts findMany on any model.
import { Extensions } from './prisma-runtime/runtime/index'
const softDeleteExtension = Extensions.defineExtension({
name: 'softDelete',
model: {
$allModels: {
async findManyActive<T>(
this: T,
args?: Parameters<T extends { findMany: (...a: any) => any } ? T['findMany'] : never>[0],
) {
const context = Extensions.getExtensionContext(this)
return (context as any).findMany({ ...args, where: { ...args?.where, deletedAt: null } })
},
},
},
})
export { softDeleteExtension }
// In your application:
// const prisma = new PrismaClient().$extends(softDeleteExtension)
// await prisma.user.findManyActive()
Useful for debugging or building a query logger that captures wire-format queries.
import { serializeJsonQuery, type JsonQuery } from './prisma-runtime/runtime/index'
const query: JsonQuery = {
modelName: 'User',
action: 'findMany',
query: {
arguments: { where: { email: { equals: 'alice@example.com' } } },
selection: { $scalars: true },
},
}
const wire = serializeJsonQuery(query)
console.log('Wire format:', wire)
// Send to engine for debugging or replay
skip for conditional field selectionimport { skip } from './prisma-runtime/runtime/index'
function buildSelect(includeEmail: boolean) {
return {
id: true,
name: true,
email: includeEmail ? true : skip,
}
}
// With a real prisma client:
// const user = await prisma.user.findFirst({ select: buildSelect(false) })
// TypeScript correctly narrows the result type based on skip vs true
generation/generator.ts - Entry point for the Prisma code generator; reads DMMF and emits TypeScript client files.runtime/getPrismaClient.ts - Defines getPrismaClient, the factory that wires engines, middleware, and extensions into a usable client class.runtime/RequestHandler.ts - Owns the request lifecycle: applies query middleware stack, dispatches to the engine, deserializes responses.runtime/DataLoader.ts - Implements request batching; coalesces concurrent queries into single engine round-trips.runtime/index.ts - Barrel export; the sole import target for downstream consumers of this package.runtime/index-browser.ts - Browser/edge-compatible subset; omits Node.js-only engine binaries.runtime/strictEnum.ts - makeStrictEnum implementation using a Proxy trap.runtime/mergeBy.ts - Generic array merge utility keyed by a selector function.runtime/getLogLevel.ts - Maps log event names to ordered severity levels for filtering.runtime/core/engines/ - Abstracts over binary, Wasm, and Accelerate query engines behind a unified Engine interface.runtime/core/extensions/ - defineExtension and getExtensionContext implementations.runtime/core/public/ - validator helper exposed directly to end users.runtime/core/compositeProxy/ - Low-level Proxy-based building blocks for model and extension object construction.runtime/core/jsonProtocol/ - serializeJsonQuery converts high-level query objects to engine wire format.runtime/core/model/ - createParam builds typed parameter descriptors for model fields.runtime/core/runtimeDataModel.ts - Converts verbose DMMF datamodel to the lean RuntimeDataModel structure used at query time.runtime/core/types/ - Shared TypeScript types: Skip, TypedSql, ITXClientDenyList, and all re-exported user-facing types.runtime/core/tracing/ - OpenTelemetry span creation and propagation hooks.runtime/core/transaction/ - Interactive transaction ($transaction) state machine and coordination logic.runtime/core/raw-query/ - Helpers for $queryRaw / $executeRaw argument handling.utils/ - deserializeRawResults for raw query result parsing; getRuntime for environment detection.@prisma/client-common not found at runtime: Install @prisma/client-common explicitly; it is a peer of the client source and not auto-hoisted in all monorepo setups.Cannot find module '@prisma/dmmf': This package ships separately from @prisma/client; add it explicitly with npm install @prisma/dmmf.serverComponentsExternalPackages: ['@prisma/client'] (Next.js 14) or switch to runtime/index-browser.ts as the entry; do not import the Node.js binary engine path.skip sentinel causes undefined at runtime instead of omission: skip is a unique symbol, not undefined; ensure you are on Prisma 5.x where the runtime checks === skip rather than === undefined.Decimal: @prisma/client-runtime-utils re-exports Decimal from decimal.js; if you get dual-package hazard errors, pin decimal.js to a single version in your lockfile.$extends: defineExtension must be called before passing to $extends; calling it inline as a plain object literal bypasses the type narrowing and causes never result types.I have dropped the Prisma Client runtime source into `src/prisma-runtime/` in my project.
The block comes from the upstream package `prisma_prisma` (domain: backend), specifically
`packages/client/src`. A USAGE.md file is in the same directory as this prompt.
Please integrate the Prisma Client runtime into my existing Node.js / TypeScript / Express project by:
1. Reading USAGE.md in full to understand available exports and setup steps.
2. Installing all required dependencies listed in the "Required dependencies" section.
3. Updating my tsconfig.json paths as described in "Project setup".
4. Replacing any existing `import { PrismaClient } from '@prisma/client'` with a call to
`getPrismaClient` from `src/prisma-runtime/runtime/index.ts`, passing the generated config.
5. Adding the soft-delete extension from the "Working examples" section to `src/extensions/softDelete.ts`.
6. Wiring the extension into the PrismaClient instance in `src/db.ts`.
7. Ensuring all environment variables (DATABASE_URL, etc.) are read from `.env` via `dotenv`.
8. Running the TypeScript compiler (`tsc --noEmit`) and fixing any type errors before finishing.
Do not invent any API names; use only the exports documented in USAGE.md.
Prisma is licensed under the Apache License 2.0. See source/LICENSE if present, or refer to the official Prisma repository for the full license text. This block is derived from the prisma/prisma monorepo, packages/client/src.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
Automation, Utilities & Developer Tools
Free