
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
@prisma-next/sql-relational-core
Advanced tools
AST types, query lane context, and type utilities for Prisma Next SQL lanes
Schema and column builders, operation attachment, and AST types for Prisma Next.
The relational core package provides the foundational primitives for building relational SQL queries. It includes table/column builders, parameter helpers, operation attachment logic, and type definitions that are shared across SQL query lanes (DSL, ORM, Raw).
This package is part of the SQL lanes layer and provides the relational primitives that both the SQL DSL and ORM builder depend on.
Provide shared relational primitives (schema builders, column builders, parameter helpers, operations registry) that can be consumed by multiple SQL query lanes without code duplication.
Non-goals:
flowchart TD
subgraph "Relational Core"
SCHEMA[Schema Builder]
COL[Column Builders]
PARAM[Parameter Helpers]
OPS[Operations Registry]
TYPES[Type Definitions]
AST[AST Types]
end
subgraph "Consumers"
SQL[SQL Lane]
ORM[ORM Lane]
end
SCHEMA --> SQL
SCHEMA --> ORM
COL --> SQL
COL --> ORM
PARAM --> SQL
PARAM --> ORM
OPS --> SQL
OPS --> ORM
TYPES --> SQL
TYPES --> ORM
AST --> SQL
AST --> ORM
schema.ts)tables.user.id in addition to tables.user.columns.id)types.ts)ColumnBuilder type with operation methods based on column typeIdparam.ts)operations-registry.ts)ColumnBuilder instancestypeId and contract capabilitiesplan.ts)SqlQueryPlan<Row> interface for SQL query plans produced by lanes before loweringParamRef.codec (parameters) and ProjectionItem.codec (output) as a CodecRef on the AST itself, not on plan-level descriptor lists. See DEVELOPING.md for the CodecRef invariant.Codec authors extend the framework CodecImpl (and pair the codec with a CodecDescriptorImpl registration) per ADR 208 — Higher-order codecs for parameterized types. Each codec class declares the four conversion methods (encode, decode, encodeJson, decodeJson); the descriptor class declares static metadata (codecId, traits, targetTypes, meta, paramsSchema, optional renderOutputType) and a factory returning a per-instance codec.
encode / decode) are typed as Promise<…>-returning at the public boundary; sync method bodies are accepted via TypeScript bivariance and the runtime always awaits.encodeJson / decodeJson / renderOutputType?) stay synchronous so contract validation and client construction stay synchronous.encode and decode must be implemented — there is no identity-default fallback.// Non-parameterized codec (P = void) — see packages/3-targets/3-targets/postgres/src/core/codecs.ts
// for the production form.
import {
CodecDescriptorImpl,
CodecImpl,
voidParamsSchema,
type CodecCallContext,
type CodecInstanceContext,
} from '@prisma-next/framework-components/codec';
class PgTextCodec extends CodecImpl<'pg/text@1', readonly ['equality'], string, string> {
override readonly id = 'pg/text@1';
override readonly traits = ['equality'] as const;
encode(v: string, _ctx: CodecCallContext): Promise<string> { return Promise.resolve(v); }
decode(w: string, _ctx: CodecCallContext): Promise<string> { return Promise.resolve(w); }
encodeJson(v: string) { return v; }
decodeJson(j: unknown) { return j as string; }
}
class PgTextDescriptor extends CodecDescriptorImpl<void> {
override readonly codecId = 'pg/text@1';
override readonly traits = ['equality'] as const;
override readonly targetTypes = ['text'] as const;
override readonly paramsSchema = voidParamsSchema;
override readonly factory = () => (_ctx: CodecInstanceContext) => new PgTextCodec();
}
ctx)Codecs receive a second ctx options argument; you may ignore it. The runtime allocates one SqlCodecCallContext per runtime.execute(plan, { signal }) call and threads the same reference to every codec dispatch site as a non-optional argument — when no signal is supplied the runtime still threads an empty {}, never undefined. The internal Codec interface declares the parameter as required (encode(value, ctx: SqlCodecCallContext) / decode(wire, ctx: SqlCodecCallContext)); single-arg method bodies continue to compile via TypeScript's bivariance for trailing parameters, so codec ergonomics are unchanged.
ctx.signal — the same AbortSignal reference at every codec call in one execute. Forward it to network SDKs so aborted queries stop talking to the underlying service.ctx.column (decode-side only) — { table, name } for cells the runtime can resolve to a single column ref; undefined for aggregate aliases, computed projections, and other unresolvable cells. Encode-side ctx.column is always undefined (encode-time column enrichment is the middleware's domain).// Forward ctx.signal to a network call so aborted queries stop the SDK.
class PgKmsSecretCodec extends CodecImpl<'pg/kms-secret@1', readonly [], string, string> {
override readonly id = 'pg/kms-secret@1';
override readonly traits = [] as const;
override async encode(v: string, ctx: SqlCodecCallContext): Promise<string> {
return kms.encrypt({ plaintext: v }, { signal: ctx.signal });
}
override async decode(w: string, ctx: SqlCodecCallContext): Promise<string> {
return kms.decrypt({ ciphertext: w }, { signal: ctx.signal });
}
encodeJson(v: string) { return v; }
decodeJson(j: unknown) { return j as string; }
}
Codec bodies that ignore ctx.signal complete in the background (cooperative cancellation); aborts still surface to the caller as RUNTIME.ABORTED with details.phase ∈ { 'encode', 'decode', 'stream' }.
See ADR 204 — Single-Path Async Codec Runtime and ADR 207 — Codec call context: per-query AbortSignal and column metadata.
ast/* via exports/ast.ts)SelectAst, InsertAst, UpdateAst, DeleteAstColumnRef, ParamRef, LiteralExpr, OperationExpr, ListExpressionBinaryExpr (ops: eq, neq, gt, lt, gte, lte, like, ilike, in, notIn), AndExpr, OrExpr, ExistsExpr, NullCheckExprWhereArg and ToWhereExpr for passing filter payloads without lane-specific typesJoinAst, JoinOnExpr (eqCol or WhereExpr)InsertAst.rows is row-based and uses InsertValue cells (ColumnRef, ParamRef, or the insert-only DefaultValueExpr sentinel for SQL DEFAULT) for batched insertsSelectAst.selectAllIntent — preserves select-all intent when normalized to explicit columnsDeleteAst.where and UpdateAst.where optional for mutation-without-WHERE lint supporttypes.ts)ExtractJsTypeFromColumnBuilder)AnyColumnBuilder helper type for accepting column builders with any operation types@prisma-next/contract: Core contract types@prisma-next/operations: Operation registry used by schema builders@prisma-next/sql-contract: SQL contract types (via @prisma-next/sql-contract/types)arktype: Parameter schema typing for codec definitionsNote: This package does not depend on specific adapters (e.g., @prisma-next/adapter-postgres). Test fixtures define CodecTypes inline to remain adapter-agnostic and avoid cyclic dependencies.
This package follows the standard exports/ directory pattern:
src/exports/schema.ts - Re-exports schema buildersrc/exports/param.ts - Re-exports parameter helperssrc/exports/types.ts - Re-exports type definitionssrc/exports/operations-registry.ts - Re-exports operations registrysrc/exports/plan.ts - Re-exports plan types and helperssrc/exports/ast.ts - Re-exports SQL AST typessrc/exports/errors.ts - Re-exports error helpers (planInvalid, planUnsupported)src/index.ts - Main entry point that re-exports from exports/This enables subpath imports like @prisma-next/sql-relational-core/schema, @prisma-next/sql-relational-core/param, @prisma-next/sql-relational-core/plan, etc.
FAQs
AST types, query lane context, and type utilities for Prisma Next SQL lanes
We found that @prisma-next/sql-relational-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.