@prisma-next/sql-runtime 0.13.0-dev.3 → 0.13.0-dev.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,16 @@
1
- import { AfterExecuteResult, AfterExecuteResult as AfterExecuteResult$1, AsyncIterableResult, ExecutionPlan, RuntimeExecuteOptions, RuntimeLog, RuntimeLog as Log, RuntimeMiddleware, RuntimeMiddlewareContext } from "@prisma-next/framework-components/runtime";
2
- import { Adapter, AnyQueryAst, CodecRef, ContractCodecRegistry, LoweredParam, LoweredStatement, MarkerReadResult, MarkerReadResult as MarkerReadResult$1, SqlCodecCallContext, SqlDriver, SqlQueryable } from "@prisma-next/sql-relational-core/ast";
3
- import { ExecutionStack, ExecutionStackInstance, RuntimeAdapterDescriptor, RuntimeAdapterInstance, RuntimeDriverDescriptor, RuntimeDriverInstance, RuntimeExtensionDescriptor, RuntimeExtensionInstance, RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
4
- import { SqlStorage } from "@prisma-next/sql-contract/types";
1
+ import { AnyCodecDescriptor, CodecDescriptor } from "@prisma-next/framework-components/codec";
2
+ import { AfterExecuteResult, AsyncIterableResult, ExecutionPlan, RuntimeCore, RuntimeExecuteOptions, RuntimeLog, RuntimeMiddleware, RuntimeMiddlewareContext } from "@prisma-next/framework-components/runtime";
3
+ import { Adapter, AnyQueryAst, Codec, CodecRef, ContractCodecRegistry, LoweredParam, LoweredStatement, MarkerReadResult, SqlCodecCallContext, SqlConnection, SqlDriver, SqlQueryable } from "@prisma-next/sql-relational-core/ast";
4
+ import { ExecutionStack, RuntimeAdapterDescriptor, RuntimeAdapterInstance, RuntimeDriverDescriptor, RuntimeDriverInstance, RuntimeExtensionDescriptor, RuntimeExtensionInstance, RuntimeTargetDescriptor, RuntimeTargetInstance } from "@prisma-next/framework-components/execution";
5
5
  import { SqlOperationDescriptors } from "@prisma-next/sql-operations";
6
6
  import { SqlParamRefMutator } from "@prisma-next/sql-relational-core/middleware";
7
7
  import { Contract, JsonValue, PlanMeta } from "@prisma-next/contract/types";
8
- import { CodecDescriptorRegistry, ExecutionContext, TypeHelperRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
8
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
9
+ import { ExecutionContext, TypeHelperRegistry } from "@prisma-next/sql-relational-core/query-lane-context";
9
10
  import { SqlExecutionPlan, SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
10
11
  import { CodecTypesBase, CodecValue, Expression, RawCodecInferer } from "@prisma-next/sql-relational-core/expression";
11
12
  import { RuntimeScope } from "@prisma-next/sql-relational-core/types";
12
- import { AnyCodecDescriptor, CodecDescriptor } from "@prisma-next/framework-components/codec";
13
13
 
14
- //#region src/codecs/ast-codec-registry.d.ts
15
- /**
16
- * Build a contract-free {@link ContractCodecRegistry} that resolves codecs
17
- * purely from AST-supplied {@link import('@prisma-next/framework-components/codec').CodecRef}s
18
- * against a target's descriptor registry.
19
- *
20
- * Dispatch is driven entirely by `CodecRef`s embedded in AST nodes; no
21
- * contract walk is needed. `forColumn` always returns `undefined` — this
22
- * registry carries no column-to-codec mappings.
23
- */
24
- declare function createAstCodecRegistry(descriptors: CodecDescriptorRegistry): ContractCodecRegistry;
25
- //#endregion
26
14
  //#region src/codecs/encoding.d.ts
27
15
  interface ParamMetadata {
28
16
  readonly codec: CodecRef | undefined;
@@ -31,23 +19,6 @@ interface ParamMetadata {
31
19
  declare function deriveParamMetadata(ast: AnyQueryAst): readonly ParamMetadata[];
32
20
  declare function encodeParamsWithMetadata(values: readonly unknown[], metadata: readonly ParamMetadata[], ctx: SqlCodecCallContext, contractCodecs?: ContractCodecRegistry): Promise<readonly unknown[]>;
33
21
  //#endregion
34
- //#region src/codecs/validation.d.ts
35
- declare function extractCodecIds(contract: Contract<SqlStorage>): Set<string>;
36
- declare function validateContractCodecMappings(registry: CodecDescriptorRegistry, contract: Contract<SqlStorage>): void;
37
- declare function validateCodecRegistryCompleteness(registry: CodecDescriptorRegistry, contract: Contract<SqlStorage>): void;
38
- //#endregion
39
- //#region src/lower-sql-plan.d.ts
40
- /**
41
- * Lowers a SQL query plan to an executable Plan by calling the adapter's lower method.
42
- *
43
- * Ad-hoc lowerings produce only `{kind: 'literal'}` slots; this helper
44
- * unwraps them into the bare-value array `SqlExecutionPlan` exposes.
45
- * Encountering a `{kind: 'bind'}` slot here means the caller passed an
46
- * AST containing `PreparedParamRef` to the ad-hoc execute path — that's a
47
- * caller error, surfaced as `RUNTIME.PREPARE_BIND_ON_ADHOC`.
48
- */
49
- declare function lowerSqlPlan<Row>(adapter: Adapter<AnyQueryAst, Contract<SqlStorage>, LoweredStatement>, contract: Contract<SqlStorage>, queryPlan: SqlQueryPlan<Row>): SqlExecutionPlan<Row>;
50
- //#endregion
51
22
  //#region src/middleware/sql-middleware.d.ts
52
23
  interface SqlMiddlewareContext extends RuntimeMiddlewareContext {
53
24
  readonly contract: Contract<SqlStorage>;
@@ -111,46 +82,50 @@ interface SqlMiddleware<TCodecMap extends Record<string, unknown> = Record<strin
111
82
  afterExecute?(plan: SqlExecutionPlan, result: AfterExecuteResult, ctx: SqlMiddlewareContext): Promise<void>;
112
83
  }
113
84
  //#endregion
114
- //#region src/middleware/budgets.d.ts
115
- interface BudgetsOptions {
116
- readonly maxRows?: number;
117
- readonly defaultTableRows?: number;
118
- readonly tableRows?: Record<string, number>;
119
- readonly maxLatencyMs?: number;
120
- readonly severities?: {
121
- readonly rowCount?: 'warn' | 'error';
122
- readonly latency?: 'warn' | 'error';
123
- };
85
+ //#region src/codecs/decoding.d.ts
86
+ type ColumnRef = {
87
+ table: string;
88
+ column: string;
89
+ };
90
+ interface DecodeContext {
91
+ readonly aliases: ReadonlyArray<string> | undefined;
92
+ readonly codecs: ReadonlyMap<string, Codec>;
93
+ readonly columnRefs: ReadonlyMap<string, ColumnRef>;
94
+ readonly includeAliases: ReadonlySet<string>;
124
95
  }
125
- declare function budgets(options?: BudgetsOptions): SqlMiddleware;
126
96
  //#endregion
127
- //#region src/middleware/lints.d.ts
128
- interface LintsOptions {
129
- readonly severities?: {
130
- readonly selectStar?: 'warn' | 'error';
131
- readonly noLimit?: 'warn' | 'error';
132
- readonly deleteWithoutWhere?: 'warn' | 'error';
133
- readonly updateWithoutWhere?: 'warn' | 'error';
134
- readonly readOnlyMutation?: 'warn' | 'error';
135
- readonly unindexedPredicate?: 'warn' | 'error';
136
- };
137
- readonly fallbackWhenAstMissing?: 'raw' | 'skip';
97
+ //#region src/prepared/types.d.ts
98
+ type ParamSpec<CT extends CodecTypesBase = CodecTypesBase> = (keyof CT & string) | {
99
+ readonly codecId: keyof CT & string;
100
+ readonly typeParams?: JsonValue;
101
+ readonly nullable?: boolean;
102
+ };
103
+ type Declaration<CT extends CodecTypesBase = CodecTypesBase> = Readonly<Record<string, ParamSpec<CT>>>;
104
+ type DeclaredCodecId<S> = S extends string ? S : S extends {
105
+ readonly codecId: infer C extends string;
106
+ } ? C : never;
107
+ type DeclaredNullable<S> = S extends {
108
+ readonly nullable: true;
109
+ } ? true : false;
110
+ type BindSiteParams<D> = { readonly [K in keyof D]: Expression<{
111
+ codecId: DeclaredCodecId<D[K]>;
112
+ nullable: DeclaredNullable<D[K]>;
113
+ }> };
114
+ type ParamsFromDeclaration<D, CT extends CodecTypesBase> = { readonly [K in keyof D]: CodecValue<DeclaredCodecId<D[K]>, DeclaredNullable<D[K]>, CT> };
115
+ type PrepareCallback<D, Row> = (params: BindSiteParams<D>) => SqlQueryPlan<Row>;
116
+ interface PreparedStatement<Params, Row> {
117
+ readonly sql: string;
118
+ readonly ast: AnyQueryAst;
119
+ readonly meta: PlanMeta;
120
+ readonly slots: readonly LoweredParam[];
121
+ /**
122
+ * Run this prepared statement against the given target. The target carries
123
+ * the execution scope (top-level runtime, an explicit connection, an active
124
+ * transaction). It is required and explicit — there is no implicit binding
125
+ * back to the runtime that produced this statement.
126
+ */
127
+ execute(target: RuntimeQueryable, params: Params, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
138
128
  }
139
- /**
140
- * AST-first lint middleware for SQL plans. When `plan.ast` is a SQL QueryAst, inspects
141
- * the AST structurally. When `plan.ast` is missing, falls back to raw heuristic
142
- * guardrails or skips linting depending on `fallbackWhenAstMissing`.
143
- *
144
- * Rules (AST-based):
145
- * - DELETE without WHERE: blocks execution (configurable severity, default error)
146
- * - UPDATE without WHERE: blocks execution (configurable severity, default error)
147
- * - Unbounded SELECT: warn/error (severity from noLimit)
148
- * - SELECT * intent: warn/error (severity from selectStar)
149
- *
150
- * Fallback: When ast is missing, `fallbackWhenAstMissing: 'raw'` uses heuristic
151
- * SQL parsing; `'skip'` skips all lints. Default is `'raw'`.
152
- */
153
- declare function lints(options?: LintsOptions): SqlMiddleware;
154
129
  //#endregion
155
130
  //#region src/runtime-spi.d.ts
156
131
  /**
@@ -160,7 +135,7 @@ interface MarkerReader {
160
135
  readMarker(queryable: SqlQueryable): Promise<MarkerReadResult>;
161
136
  }
162
137
  /**
163
- * SQL family adapter SPI consumed by `SqlRuntime`. Encapsulates the
138
+ * SQL family adapter SPI consumed by `SqlRuntimeBase`. Encapsulates the
164
139
  * runtime contract, marker reader, and plan validation logic so the
165
140
  * runtime can be unit-tested without a concrete SQL adapter profile.
166
141
  *
@@ -275,16 +250,20 @@ declare function createExecutionContext<TContract extends Contract<SqlStorage> =
275
250
  }): ExecutionContext<TContract>;
276
251
  //#endregion
277
252
  //#region src/sql-runtime.d.ts
278
- type Log$1 = RuntimeLog;
279
- interface CreateRuntimeOptions<TContract extends Contract<SqlStorage> = Contract<SqlStorage>, TTargetId extends string = string> {
280
- readonly stackInstance: ExecutionStackInstance<'sql', TTargetId, SqlRuntimeAdapterInstance<TTargetId>, RuntimeDriverInstance<'sql', TTargetId>, SqlRuntimeExtensionInstance<TTargetId>>;
253
+ type Log = RuntimeLog;
254
+ interface RuntimeOptions<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> {
281
255
  readonly context: ExecutionContext<TContract>;
256
+ readonly adapter: Adapter<AnyQueryAst, Contract<SqlStorage>, LoweredStatement>;
282
257
  readonly driver: SqlDriver<unknown>;
283
258
  readonly verifyMarker?: VerifyMarkerOption;
284
259
  readonly middleware?: readonly SqlMiddleware[];
285
260
  readonly mode?: 'strict' | 'permissive';
286
- readonly log?: Log$1;
261
+ readonly log?: Log;
287
262
  }
263
+ /**
264
+ * SQL-family runtime interface. Named `Runtime` (not `SqlRuntime`) by deliberate exception
265
+ * to avoid a repo-wide rename; see ADR 230 (runtime target layer) for the recorded decision.
266
+ */
288
267
  interface Runtime extends RuntimeQueryable {
289
268
  connection(): Promise<RuntimeConnection>;
290
269
  telemetry(): RuntimeTelemetryEvent | null;
@@ -327,41 +306,127 @@ interface RuntimeQueryable extends RuntimeScope {
327
306
  interface TransactionContext extends RuntimeQueryable {
328
307
  readonly invalidated: boolean;
329
308
  }
330
- declare function withTransaction<R>(runtime: Runtime, fn: (tx: TransactionContext) => PromiseLike<R>): Promise<R>;
331
- declare function createRuntime<TContract extends Contract<SqlStorage>, TTargetId extends string>(options: CreateRuntimeOptions<TContract, TTargetId>): Runtime;
309
+ /**
310
+ * Abstract family-layer base for SQL runtimes. Subclass to build a target runtime
311
+ * (e.g. `PostgresRuntimeImpl`); app code should consume the `Runtime` interface returned
312
+ * by the target factories, never this class directly.
313
+ */
314
+ declare abstract class SqlRuntimeBase<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> extends RuntimeCore<SqlQueryPlan, SqlExecutionPlan, SqlMiddleware> implements Runtime {
315
+ #private;
316
+ private readonly contract;
317
+ private readonly adapter;
318
+ private readonly driver;
319
+ private readonly familyAdapter;
320
+ private readonly contractCodecs;
321
+ private readonly codecDescriptors;
322
+ private readonly sqlCtx;
323
+ private readonly verifyMarkerOption;
324
+ private verifyMarkerPromise;
325
+ private codecRegistryValidated;
326
+ private _telemetry;
327
+ constructor(options: RuntimeOptions<TContract>);
328
+ /**
329
+ * Lower a `SqlQueryPlan` (AST + meta) into a `SqlExecutionPlan`
330
+ * with encoded parameters ready for the driver.
331
+ *
332
+ * Implementation note: SQL splits lower-then-encode across
333
+ * {@link lowerToDraft} + {@link encodeDraftParams} so the runtime
334
+ * can fire the `beforeExecute` middleware chain between them
335
+ * (cipherstash bulk-encrypt, for example, mutates pre-encode
336
+ * `ParamRef.value` slots). This protected hook composes the two
337
+ * back into the cross-family `lower()` shape `RuntimeCore.execute`
338
+ * expects, and is called from the no-middleware fast paths /
339
+ * fixtures that hit `RuntimeCore`'s default template directly.
340
+ * `execute()` overrides the template and uses the split form so
341
+ * `beforeExecute` lands between the two halves.
342
+ *
343
+ * `ctx: SqlCodecCallContext` is forwarded to `encodeParams` so
344
+ * per-query cancellation reaches every codec body during parameter
345
+ * encoding. SQL params do not populate `ctx.column` — encode-side
346
+ * column metadata is the middleware's domain.
347
+ */
348
+ protected lower(plan: SqlQueryPlan, ctx: SqlCodecCallContext): Promise<SqlExecutionPlan>;
349
+ /**
350
+ * AST → pre-encode draft. The returned plan has `sql` rendered and
351
+ * `params` populated with the user-domain values the lowering site
352
+ * collected from `ParamRef` nodes. No codec encode has happened
353
+ * yet; consumers can mutate `params` via the `SqlParamRefMutator`
354
+ * before {@link encodeDraftParams} runs.
355
+ */
356
+ private lowerToDraft;
357
+ /**
358
+ * Encode a draft plan's params through the per-column codecs and
359
+ * freeze the result into the final `SqlExecutionPlan` the driver
360
+ * sees. Errors surface as `RUNTIME.ENCODE_FAILED` envelopes from
361
+ * {@link encodeParams}.
362
+ */
363
+ private encodeDraftParams;
364
+ /**
365
+ * Default driver invocation required by the abstract `RuntimeCore` contract. Every production path overrides `execute()` and routes through `executeAgainstQueryable`, so this hook is defensive only — subclasses that delegate back to `super.execute()` would land here.
366
+ */
367
+ protected runDriver(exec: SqlExecutionPlan): AsyncIterable<Record<string, unknown>>;
368
+ /**
369
+ * SQL pre-compile hook. Runs the registered middleware `beforeCompile` chain over the plan's draft (AST + meta). Returns the original plan unchanged when no middleware rewrote the AST; otherwise returns a new plan carrying the rewritten AST and meta. The AST is the authoritative source of execution metadata, so a rewrite needs no sidecar reconciliation here — the lowering adapter and the encoder both walk the rewritten
370
+ * AST directly.
371
+ */
372
+ protected runBeforeCompile(plan: SqlQueryPlan): Promise<SqlQueryPlan>;
373
+ execute<Row>(plan: (SqlExecutionPlan<unknown> | SqlQueryPlan<unknown>) & {
374
+ readonly _row?: Row;
375
+ }, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
376
+ executePrepared<Params, Row>(ps: PreparedStatement<Params, Row>, params: Params, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
377
+ /**
378
+ * Returns the raw driver connection. The connection is a `SqlQueryable` — SQL
379
+ * issued on it runs below the middleware/codec/telemetry pipeline. It carries
380
+ * its own lifecycle (`release`/`destroy`/`beginTransaction`); the caller owns
381
+ * disposal.
382
+ */
383
+ protected acquireRawConnection(): Promise<SqlConnection>;
384
+ private streamRows;
385
+ /**
386
+ * Execute a plan against a caller-supplied queryable, running the full
387
+ * middleware/codec/telemetry pipeline. Use `acquireRawConnection` to obtain a
388
+ * queryable that subclasses can bind typed plans to.
389
+ */
390
+ protected executeAgainstQueryable<Row>(plan: SqlExecutionPlan<unknown> | SqlQueryPlan<unknown>, queryable: SqlQueryable, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
391
+ prepare<D extends Declaration<CT>, Row, CT extends CodecTypesBase = CodecTypesBase>(declaration: D, callback: PrepareCallback<D, Row>): Promise<PreparedStatement<ParamsFromDeclaration<D, CT>, Row>>;
392
+ /**
393
+ * Execute a prepared statement against a caller-supplied queryable, running
394
+ * the full middleware/codec/telemetry pipeline.
395
+ */
396
+ protected executePreparedAgainstQueryable<P, Row>(ps: PreparedStatementImpl<P, Row>, userParams: Record<string, unknown>, queryable: SqlQueryable, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
397
+ connection(): Promise<RuntimeConnection>;
398
+ private wrapTransaction;
399
+ telemetry(): RuntimeTelemetryEvent | null;
400
+ close(): Promise<void>;
401
+ private ensureCodecRegistryValidated;
402
+ private verifyMarker;
403
+ private recordTelemetry;
404
+ }
405
+ /** Minimal structural type `withTransaction` depends on — anything that can open a connection. */
406
+ interface ConnectionProvider {
407
+ connection(): Promise<RuntimeConnection>;
408
+ }
409
+ declare function withTransaction<R>(runtime: ConnectionProvider, fn: (tx: TransactionContext) => PromiseLike<R>): Promise<R>;
332
410
  //#endregion
333
- //#region src/prepared/types.d.ts
334
- type ParamSpec<CT extends CodecTypesBase = CodecTypesBase> = (keyof CT & string) | {
335
- readonly codecId: keyof CT & string;
336
- readonly typeParams?: JsonValue;
337
- readonly nullable?: boolean;
338
- };
339
- type Declaration<CT extends CodecTypesBase = CodecTypesBase> = Readonly<Record<string, ParamSpec<CT>>>;
340
- type DeclaredCodecId<S> = S extends string ? S : S extends {
341
- readonly codecId: infer C extends string;
342
- } ? C : never;
343
- type DeclaredNullable<S> = S extends {
344
- readonly nullable: true;
345
- } ? true : false;
346
- type BindSiteParams<D> = { readonly [K in keyof D]: Expression<{
347
- codecId: DeclaredCodecId<D[K]>;
348
- nullable: DeclaredNullable<D[K]>;
349
- }> };
350
- type ParamsFromDeclaration<D, CT extends CodecTypesBase> = { readonly [K in keyof D]: CodecValue<DeclaredCodecId<D[K]>, DeclaredNullable<D[K]>, CT> };
351
- type PrepareCallback<D, Row> = (params: BindSiteParams<D>) => SqlQueryPlan<Row>;
352
- interface PreparedStatement<Params, Row> {
411
+ //#region src/prepared/prepared-statement.d.ts
412
+ interface PreparedStatementInternals {
353
413
  readonly sql: string;
354
414
  readonly ast: AnyQueryAst;
355
415
  readonly meta: PlanMeta;
356
416
  readonly slots: readonly LoweredParam[];
357
- /**
358
- * Run this prepared statement against the given target. The target carries
359
- * the execution scope (top-level runtime, an explicit connection, an active
360
- * transaction). It is required and explicit there is no implicit binding
361
- * back to the runtime that produced this statement.
362
- */
417
+ readonly decodeContext: DecodeContext;
418
+ readonly paramMetadata: readonly ParamMetadata[];
419
+ }
420
+ declare class PreparedStatementImpl<Params, Row> implements PreparedStatement<Params, Row>, PreparedStatementInternals {
421
+ readonly sql: string;
422
+ readonly ast: AnyQueryAst;
423
+ readonly meta: PlanMeta;
424
+ readonly slots: readonly LoweredParam[];
425
+ readonly decodeContext: DecodeContext;
426
+ readonly paramMetadata: readonly ParamMetadata[];
427
+ constructor(internals: PreparedStatementInternals);
363
428
  execute(target: RuntimeQueryable, params: Params, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
364
429
  }
365
430
  //#endregion
366
- export { createAstCodecRegistry as $, SqlRuntimeExtensionInstance as A, VerifyMarkerOption as B, RuntimeParameterizedCodecDescriptor as C, SqlRuntimeAdapterInstance as D, SqlRuntimeAdapterDescriptor as E, createSqlExecutionStack as F, SqlMiddleware as G, lints as H, MarkerReader as I, extractCodecIds as J, SqlMiddlewareContext as K, RuntimeFamilyAdapter as L, SqlStaticContributions as M, TypeHelperRegistry as N, SqlRuntimeDriverInstance as O, createExecutionContext as P, encodeParamsWithMetadata as Q, RuntimeTelemetryEvent as R, RuntimeMutationDefaultGenerator as S, SqlExecutionStackWithDriver as T, BudgetsOptions as U, LintsOptions as V, budgets as W, validateContractCodecMappings as X, validateCodecRegistryCompleteness as Y, deriveParamMetadata as Z, TransactionContext as _, Declaration as a, ExecutionContext as b, ParamSpec as c, PreparedStatement as d, CreateRuntimeOptions as f, RuntimeTransaction as g, RuntimeQueryable as h, BindSiteParams as i, SqlRuntimeTargetDescriptor as j, SqlRuntimeExtensionDescriptor as k, ParamsFromDeclaration as l, RuntimeConnection as m, Log as n, DeclaredCodecId as o, Runtime as p, lowerSqlPlan as q, MarkerReadResult$1 as r, DeclaredNullable as s, AfterExecuteResult$1 as t, PrepareCallback as u, createRuntime as v, SqlExecutionStack as w, GeneratorStability as x, withTransaction as y, TelemetryOutcome as z };
367
- //# sourceMappingURL=index-JOQlRa75.d.mts.map
431
+ export { RuntimeTelemetryEvent as A, PreparedStatement as B, SqlRuntimeTargetDescriptor as C, createSqlExecutionStack as D, createExecutionContext as E, DeclaredCodecId as F, SqlMiddlewareContext as H, DeclaredNullable as I, ParamSpec as L, VerifyMarkerOption as M, BindSiteParams as N, MarkerReader as O, Declaration as P, ParamsFromDeclaration as R, SqlRuntimeExtensionInstance as S, TypeHelperRegistry as T, deriveParamMetadata as U, SqlMiddleware as V, encodeParamsWithMetadata as W, SqlExecutionStackWithDriver as _, RuntimeConnection as a, SqlRuntimeDriverInstance as b, RuntimeTransaction as c, withTransaction as d, ExecutionContext as f, SqlExecutionStack as g, RuntimeParameterizedCodecDescriptor as h, Runtime as i, TelemetryOutcome as j, RuntimeFamilyAdapter as k, SqlRuntimeBase as l, RuntimeMutationDefaultGenerator as m, PreparedStatementInternals as n, RuntimeOptions as o, GeneratorStability as p, ConnectionProvider as r, RuntimeQueryable as s, PreparedStatementImpl as t, TransactionContext as u, SqlRuntimeAdapterDescriptor as v, SqlStaticContributions as w, SqlRuntimeExtensionDescriptor as x, SqlRuntimeAdapterInstance as y, PrepareCallback as z };
432
+ //# sourceMappingURL=prepared-statement-FQyyQnkC.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepared-statement-FQyyQnkC.d.mts","names":[],"sources":["../src/codecs/encoding.ts","../src/middleware/sql-middleware.ts","../src/codecs/decoding.ts","../src/prepared/types.ts","../src/runtime-spi.ts","../src/sql-context.ts","../src/sql-runtime.ts","../src/prepared/prepared-statement.ts"],"mappings":";;;;;;;;;;;;;;UAgBiB,aAAA;EAAA,SACN,KAAA,EAAO,QAAQ;EAAA,SACf,IAAA;AAAA;AAAA,iBAeK,mBAAA,CAAoB,GAAA,EAAK,WAAA,YAAuB,aAAa;AAAA,iBA6GvD,wBAAA,CACpB,MAAA,sBACA,QAAA,WAAmB,aAAA,IACnB,GAAA,EAAK,mBAAA,EACL,cAAA,GAAiB,qBAAA,GAChB,OAAA;;;UCxIc,oBAAA,SAA6B,wBAAA;EAAA,SACnC,QAAA,EAAU,QAAA,CAAS,UAAA;AAAA;;;;;UAO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,GAAA;EA2EjB,UAAA,IAAc,OAAA,CAAQ,iBAAA;EAAA,QAyCpB,eAAA;EAiCR,SAAA,IAAa,qBAAA;EAIP,KAAA,IAAS,OAAA;EAAA,QAIP,4BAAA;EAAA,QAOM,YAAA;EAAA,QAkCN,eAAA;AAAA;;UAyBO,kBAAA;EACf,UAAA,IAAc,OAAO,CAAC,iBAAA;AAAA;AAAA,iBAGF,eAAA,IACpB,OAAA,EAAS,kBAAA,EACT,EAAA,GAAK,EAAA,EAAI,kBAAA,KAAuB,WAAA,CAAY,CAAA,IAC3C,OAAA,CAAQ,CAAA;;;UClvBM,0BAAA;EAAA,SACN,GAAA;EAAA,SACA,GAAA,EAAK,WAAA;EAAA,SACL,IAAA,EAAM,QAAA;EAAA,SACN,KAAA,WAAgB,YAAA;EAAA,SAChB,aAAA,EAAe,aAAA;EAAA,SACf,aAAA,WAAwB,aAAA;AAAA;AAAA,cAGtB,qBAAA,yBACA,iBAAA,CAAkB,MAAA,EAAQ,GAAA,GAAM,0BAAA;EAAA,SAElC,GAAA;EAAA,SACA,GAAA,EAAK,WAAA;EAAA,SACL,IAAA,EAAM,QAAA;EAAA,SACN,KAAA,WAAgB,YAAA;EAAA,SAChB,aAAA,EAAe,aAAA;EAAA,SACf,aAAA,WAAwB,aAAA;cAErB,SAAA,EAAW,0BAAA;EAUvB,OAAA,CACE,MAAA,EAAQ,gBAAA,EACR,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,qBAAA,GACT,mBAAA,CAAoB,GAAA;AAAA"}
@@ -1,23 +1,34 @@
1
- import { A as SqlRuntimeExtensionInstance, D as SqlRuntimeAdapterInstance, E as SqlRuntimeAdapterDescriptor, O as SqlRuntimeDriverInstance, b as ExecutionContext, j as SqlRuntimeTargetDescriptor, k as SqlRuntimeExtensionDescriptor, v as createRuntime } from "../index-JOQlRa75.mjs";
1
+ import { C as SqlRuntimeTargetDescriptor, S as SqlRuntimeExtensionInstance, b as SqlRuntimeDriverInstance, f as ExecutionContext, i as Runtime, o as RuntimeOptions, v as SqlRuntimeAdapterDescriptor, x as SqlRuntimeExtensionDescriptor, y as SqlRuntimeAdapterInstance } from "../prepared-statement-FQyyQnkC.mjs";
2
+ import { CodecDescriptor } from "@prisma-next/framework-components/codec";
2
3
  import { ResultType } from "@prisma-next/framework-components/runtime";
3
4
  import { Adapter, AnyQueryAst, Codec, ContractCodecRegistry, LoweredStatement, SelectAst } from "@prisma-next/sql-relational-core/ast";
4
5
  import { RuntimeDriverDescriptor } from "@prisma-next/framework-components/execution";
5
- import { SqlStorage, SqlStorageInput, StorageTableInput, buildSqlNamespace } from "@prisma-next/sql-contract/types";
6
6
  import { Contract, ContractModelBase } from "@prisma-next/contract/types";
7
+ import { SqlStorage, SqlStorageInput, StorageTableInput, buildSqlNamespace } from "@prisma-next/sql-contract/types";
7
8
  import { DevDatabase, collectAsync, createDevDatabase, teardownTestDatabase, withClient } from "@prisma-next/test-utils";
8
9
  import { SqlExecutionPlan, SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
9
- import { CodecDescriptor } from "@prisma-next/framework-components/codec";
10
10
  import { Client } from "pg";
11
11
 
12
12
  //#region test/utils.d.ts
13
+ type CreateTestRuntimeOptions<TContract extends Contract<SqlStorage>> = Omit<RuntimeOptions<TContract>, 'adapter'> & {
14
+ readonly stackInstance: {
15
+ readonly adapter: RuntimeOptions<TContract>['adapter'];
16
+ };
17
+ };
18
+ /**
19
+ * Test-only concrete runtime. Unpacks `stackInstance.adapter` and forwards
20
+ * the rest into `TestSqlRuntime`, a trivial concrete leaf of the abstract
21
+ * `SqlRuntimeBase`.
22
+ */
23
+ declare function createTestRuntime<TContract extends Contract<SqlStorage>>(options: CreateTestRuntimeOptions<TContract>): Runtime;
13
24
  /**
14
25
  * Executes a plan and collects all results into an array. This helper DRYs up the common pattern of executing plans in tests. The return type is inferred from the plan's type parameter.
15
26
  */
16
- declare function executePlanAndCollect<P extends SqlExecutionPlan<ResultType<P>> | SqlQueryPlan<ResultType<P>>>(runtime: ReturnType<typeof createRuntime>, plan: P): Promise<ResultType<P>[]>;
27
+ declare function executePlanAndCollect<P extends SqlExecutionPlan<ResultType<P>> | SqlQueryPlan<ResultType<P>>>(runtime: Runtime, plan: P): Promise<ResultType<P>[]>;
17
28
  /**
18
29
  * Drains a plan execution, consuming all results without collecting them. Useful for testing side effects without memory overhead.
19
30
  */
20
- declare function drainPlanExecution(runtime: ReturnType<typeof createRuntime>, plan: SqlExecutionPlan | SqlQueryPlan<unknown>): Promise<void>;
31
+ declare function drainPlanExecution(runtime: Runtime, plan: SqlExecutionPlan | SqlQueryPlan<unknown>): Promise<void>;
21
32
  /**
22
33
  * Sets up database schema and data, then writes the contract marker. This helper DRYs up the common pattern of database setup in tests.
23
34
  *
@@ -99,5 +110,5 @@ declare function createTestContract(contract: Partial<Omit<Contract<SqlStorage>,
99
110
  }): Contract<SqlStorage>;
100
111
  declare function stubAst(): AnyQueryAst;
101
112
  //#endregion
102
- export { type DevDatabase, SeedMarkerInput, StubAdapter, buildTestContractCodecs, collectAsync, createDevDatabase, createStubAdapter, createTestAdapterDescriptor, createTestContext, createTestContract, createTestStackInstance, createTestTargetDescriptor, descriptorsFromCodecs, drainPlanExecution, emptySqlTestDomain, executePlanAndCollect, seedTestMarker, setupTestDatabase, stubAst, teardownTestDatabase, unboundNamespaceWithTables, withClient, writeTestContractMarker };
113
+ export { type DevDatabase, SeedMarkerInput, StubAdapter, buildTestContractCodecs, collectAsync, createDevDatabase, createStubAdapter, createTestAdapterDescriptor, createTestContext, createTestContract, createTestRuntime, createTestStackInstance, createTestTargetDescriptor, descriptorsFromCodecs, drainPlanExecution, emptySqlTestDomain, executePlanAndCollect, seedTestMarker, setupTestDatabase, stubAst, teardownTestDatabase, unboundNamespaceWithTables, withClient, writeTestContractMarker };
103
114
  //# sourceMappingURL=utils.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","names":[],"sources":["../../test/utils.ts"],"mappings":";;;;;;;;;;;;;;AAmEA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oBAAA,yBAAA,cAAA,wBAAA,cAAA,2BAAA;AArOD;;;AAAA,KAmPY,WAAA,GAAc,OAAA,CAAQ,SAAA,EAAW,QAAA,CAAS,UAAA,GAAa,gBAAA;EAAA,SACxD,QAAA,EAAU,aAAA,CAAc,KAAA;AAAA;;;;;;iBAQnB,iBAAA,IAAqB,WAAW;AAAA,iBA0FhC,0BAAA,CACd,MAAA,EAAQ,MAAA,SAAe,iBAAA,IACtB,UAAA,QAAkB,iBAAA;AAAA,iBAIL,kBAAA,0CAAkB,iBAAA;AAAA,iBAIlB,kBAAA,CACd,QAAA,EAAU,OAAA,CAAQ,IAAA,CAAK,QAAA,CAAS,UAAA;EAC9B,WAAA;EACA,WAAA;EACA,MAAA,GAAS,MAAA,SAAe,iBAAA;EACxB,MAAA,GAAS,QAAA,CAAS,UAAA;EAClB,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,eAAA;AAAA,IAExB,QAAA,CAAS,UAAA;AAAA,iBA2BI,OAAA,IAAW,WAAW"}
@@ -1,14 +1,15 @@
1
- import { i as createSqlExecutionStack, r as createExecutionContext } from "../exports-DDqF-xmg.mjs";
1
+ import { i as createSqlExecutionStack, r as createExecutionContext, t as SqlRuntimeBase } from "../exports-DJWGwqMq.mjs";
2
2
  import { runtimeError } from "@prisma-next/framework-components/runtime";
3
3
  import { canonicalizeJson } from "@prisma-next/framework-components/utils";
4
4
  import { SelectAst, TableSource } from "@prisma-next/sql-relational-core/ast";
5
+ import { ifDefined } from "@prisma-next/utils/defined";
5
6
  import { instantiateExecutionStack } from "@prisma-next/framework-components/execution";
6
- import { SqlStorage, SqlUnboundNamespace, buildSqlNamespace } from "@prisma-next/sql-contract/types";
7
7
  import { coreHash, profileHash } from "@prisma-next/contract/types";
8
8
  import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
9
9
  import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
10
10
  import { builtinGeneratorIds } from "@prisma-next/ids";
11
11
  import { generateId } from "@prisma-next/ids/runtime";
12
+ import { SqlStorage, SqlUnboundNamespace, buildSqlNamespace } from "@prisma-next/sql-contract/types";
12
13
  import { applicationDomainOf, collectAsync, collectAsync as collectAsync$1, createDevDatabase, drainAsyncIterable, teardownTestDatabase, withClient } from "@prisma-next/test-utils";
13
14
  //#region test/test-codec.ts
14
15
  function defineTestCodec(config) {
@@ -48,6 +49,24 @@ function createTestMutationDefaultGenerators() {
48
49
  stability: "field"
49
50
  }));
50
51
  }
52
+ var TestSqlRuntime = class extends SqlRuntimeBase {};
53
+ /**
54
+ * Test-only concrete runtime. Unpacks `stackInstance.adapter` and forwards
55
+ * the rest into `TestSqlRuntime`, a trivial concrete leaf of the abstract
56
+ * `SqlRuntimeBase`.
57
+ */
58
+ function createTestRuntime(options) {
59
+ const { stackInstance, context, driver, verifyMarker, middleware, mode, log } = options;
60
+ return new TestSqlRuntime({
61
+ context,
62
+ adapter: stackInstance.adapter,
63
+ driver,
64
+ ...ifDefined("verifyMarker", verifyMarker),
65
+ ...ifDefined("middleware", middleware),
66
+ ...ifDefined("mode", mode),
67
+ ...ifDefined("log", log)
68
+ });
69
+ }
51
70
  /**
52
71
  * Executes a plan and collects all results into an array. This helper DRYs up the common pattern of executing plans in tests. The return type is inferred from the plan's type parameter.
53
72
  */
@@ -343,6 +362,6 @@ function stubAst() {
343
362
  return SelectAst.from(TableSource.named("stub"));
344
363
  }
345
364
  //#endregion
346
- export { buildTestContractCodecs, collectAsync, createDevDatabase, createStubAdapter, createTestAdapterDescriptor, createTestContext, createTestContract, createTestStackInstance, createTestTargetDescriptor, descriptorsFromCodecs, drainPlanExecution, emptySqlTestDomain, executePlanAndCollect, seedTestMarker, setupTestDatabase, stubAst, teardownTestDatabase, unboundNamespaceWithTables, withClient, writeTestContractMarker };
365
+ export { buildTestContractCodecs, collectAsync, createDevDatabase, createStubAdapter, createTestAdapterDescriptor, createTestContext, createTestContract, createTestRuntime, createTestStackInstance, createTestTargetDescriptor, descriptorsFromCodecs, drainPlanExecution, emptySqlTestDomain, executePlanAndCollect, seedTestMarker, setupTestDatabase, stubAst, teardownTestDatabase, unboundNamespaceWithTables, withClient, writeTestContractMarker };
347
366
 
348
367
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["collectAsync","SelectAstCtor"],"sources":["../../test/test-codec.ts","../../test/utils.ts"],"sourcesContent":["/**\n * Test-only helper that constructs a SQL-family `Codec` instance from author-side encode/decode functions. Replaces the legacy public `mkCodec()` factory (deleted under TML-2357); tests that need a stub codec for behavioural assertions instantiate one through this helper rather than going through `descriptor.factory(...)`.\n *\n * The body is identical in spirit to the retired `mkCodec`: promise-lift sync author functions onto the framework-required `Promise<…>` boundary, default `encodeJson`/`decodeJson` to identity when `TInput` is JSON-safe, fail loudly otherwise.\n */\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { Codec, SqlCodecCallContext } from '@prisma-next/sql-relational-core/ast';\n\ntype JsonRoundTripConfig<TInput> = [TInput] extends [JsonValue]\n ? {\n encodeJson?: (value: TInput) => JsonValue;\n decodeJson?: (json: JsonValue) => TInput;\n }\n : {\n encodeJson: (value: TInput) => JsonValue;\n decodeJson: (json: JsonValue) => TInput;\n };\n\nexport function defineTestCodec<\n Id extends string,\n const TTraits extends readonly CodecTrait[] = readonly [],\n TWire = unknown,\n TInput = unknown,\n>(\n config: {\n typeId: Id;\n targetTypes?: readonly string[];\n encode: (value: TInput, ctx: SqlCodecCallContext) => TWire | Promise<TWire>;\n decode: (wire: TWire, ctx: SqlCodecCallContext) => TInput | Promise<TInput>;\n traits?: TTraits;\n } & JsonRoundTripConfig<TInput>,\n): Codec<Id, TTraits, TWire, TInput> {\n const identity = (v: unknown) => v;\n const userEncode = config.encode;\n const userDecode = config.decode;\n const widenedConfig = config as {\n encodeJson?: (value: TInput) => JsonValue;\n decodeJson?: (json: JsonValue) => TInput;\n };\n return {\n id: config.typeId,\n encode: (value, ctx) => {\n try {\n return Promise.resolve(userEncode(value, ctx));\n } catch (error) {\n return Promise.reject(error);\n }\n },\n decode: (wire, ctx) => {\n try {\n return Promise.resolve(userDecode(wire, ctx));\n } catch (error) {\n return Promise.reject(error);\n }\n },\n encodeJson: (widenedConfig.encodeJson ?? identity) as (value: TInput) => JsonValue,\n decodeJson: (widenedConfig.decodeJson ?? identity) as (json: JsonValue) => TInput,\n } as Codec<Id, TTraits, TWire, TInput>;\n}\n","import {\n type Contract,\n type ContractModelBase,\n coreHash,\n profileHash,\n} from '@prisma-next/contract/types';\nimport type {\n CodecDescriptor,\n CodecMeta,\n CodecTrait,\n} from '@prisma-next/framework-components/codec';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport {\n instantiateExecutionStack,\n type RuntimeDriverDescriptor,\n} from '@prisma-next/framework-components/execution';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { ResultType } from '@prisma-next/framework-components/runtime';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport { canonicalizeJson } from '@prisma-next/framework-components/utils';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport {\n buildSqlNamespace,\n SqlStorage,\n type SqlStorageInput,\n SqlUnboundNamespace,\n type StorageTableInput,\n} from '@prisma-next/sql-contract/types';\nimport type {\n Adapter,\n AnyQueryAst,\n Codec,\n ContractCodecRegistry,\n LoweredStatement,\n SelectAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { SelectAst as SelectAstCtor, TableSource } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlExecutionPlan, SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport { applicationDomainOf, collectAsync, drainAsyncIterable } from '@prisma-next/test-utils';\nimport type { Client } from 'pg';\nimport {\n createExecutionContext,\n type createRuntime,\n createSqlExecutionStack,\n} from '../src/exports';\nimport type {\n ExecutionContext,\n SqlRuntimeAdapterDescriptor,\n SqlRuntimeAdapterInstance,\n SqlRuntimeDriverInstance,\n SqlRuntimeExtensionDescriptor,\n SqlRuntimeTargetDescriptor,\n} from '../src/sql-context';\nimport { defineTestCodec } from './test-codec';\n\nfunction createTestMutationDefaultGenerators() {\n return builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => generateId(params ? { id, params } : { id }),\n stability: 'field' as const,\n }));\n}\n\n/**\n * Executes a plan and collects all results into an array. This helper DRYs up the common pattern of executing plans in tests. The return type is inferred from the plan's type parameter.\n */\nexport async function executePlanAndCollect<\n P extends SqlExecutionPlan<ResultType<P>> | SqlQueryPlan<ResultType<P>>,\n>(runtime: ReturnType<typeof createRuntime>, plan: P): Promise<ResultType<P>[]> {\n type Row = ResultType<P>;\n return collectAsync<Row>(runtime.execute<Row>(plan));\n}\n\n/**\n * Drains a plan execution, consuming all results without collecting them. Useful for testing side effects without memory overhead.\n */\nexport async function drainPlanExecution(\n runtime: ReturnType<typeof createRuntime>,\n plan: SqlExecutionPlan | SqlQueryPlan<unknown>,\n): Promise<void> {\n return drainAsyncIterable(runtime.execute(plan));\n}\n\n/**\n * Sets up database schema and data, then writes the contract marker. This helper DRYs up the common pattern of database setup in tests.\n *\n * Callers must supply `bootstrapMarkerTables` (typically\n * `bootstrapPostgresSignMarkerTables` from integration `postgres-bootstrap.ts`)\n * so this package does not depend on the postgres adapter/target packs.\n */\nexport async function setupTestDatabase(\n client: Client,\n contract: Contract<SqlStorage>,\n setupFn: (client: Client) => Promise<void>,\n bootstrapMarkerTables: (client: Client) => Promise<void>,\n): Promise<void> {\n await client.query('drop schema if exists prisma_contract cascade');\n await client.query('create schema if not exists public');\n\n await setupFn(client);\n\n await bootstrapMarkerTables(client);\n await writeTestContractMarker(client, contract);\n}\n\nexport interface SeedMarkerInput {\n /** Logical space for the marker row; defaults to {@link APP_SPACE_ID}. */\n readonly space?: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number;\n readonly invariants?: readonly string[];\n}\n\n/**\n * Seeds a contract marker row directly via raw SQL. Test-only: the production\n * write path goes through the control adapter SPI (`initMarker`/`updateMarker`),\n * which needs a `ControlDriverInstance`; these fixtures hold a raw `pg.Client`,\n * so they perform a minimal `INSERT` over the columns the runtime reads back.\n */\nexport async function seedTestMarker(client: Client, input: SeedMarkerInput): Promise<void> {\n await client.query(\n `insert into prisma_contract.marker\n (space, core_hash, profile_hash, contract_json, canonical_version, invariants, updated_at)\n values ($1, $2, $3, $4::jsonb, $5, $6::text[], now())`,\n [\n input.space ?? APP_SPACE_ID,\n input.storageHash,\n input.profileHash,\n input.contractJson === undefined ? null : JSON.stringify(input.contractJson),\n input.canonicalVersion ?? null,\n input.invariants ?? [],\n ],\n );\n}\n\n/**\n * Seeds the app-space marker for a contract. Thin wrapper over\n * {@link seedTestMarker} for the common \"write the marker for this contract\" case.\n */\nexport async function writeTestContractMarker(\n client: Client,\n contract: Contract<SqlStorage>,\n): Promise<void> {\n await seedTestMarker(client, {\n storageHash: contract.storage.storageHash,\n profileHash: contract.profileHash,\n contractJson: contract,\n canonicalVersion: 1,\n });\n}\n\n/**\n * Creates a test adapter descriptor from a raw adapter. Wraps the adapter in an SqlRuntimeAdapterDescriptor with static contributions derived from the adapter's codec registry.\n */\n/**\n * Build a {@link ContractCodecRegistry} from a codec array for tests that exercise `encodeParam(s)` / `decodeRow` in isolation. The production runtime builds `ContractCodecRegistry` from contract walk + descriptor list and never goes through this helper; tests use it to wire a hand-built codec set into the surface those functions consume in production.\n */\nexport function buildTestContractCodecs(\n codecs: ReadonlyArray<Codec<string>>,\n): ContractCodecRegistry {\n const byId = new Map<string, Codec<string>>();\n for (const codec of codecs) {\n byId.set(codec.id, codec);\n }\n // Canonical-key cache: production `forCodecRef` memoizes per `(codecId, canonicalize(typeParams))`. Tests resolve by codecId, but key the cache on the canonical pair so callers passing distinct typeParams get distinct (still codec-id-templated) entries — and so this helper cannot silently coalesce them.\n const byCanonicalKey = new Map<string, Codec<string>>();\n return {\n forColumn: () => undefined,\n forCodecRef: (ref) => {\n const canonicalKey = canonicalizeJson({\n codecId: ref.codecId,\n ...(ref.typeParams !== undefined ? { typeParams: ref.typeParams } : {}),\n });\n const cached = byCanonicalKey.get(canonicalKey);\n if (cached) return cached;\n const template = byId.get(ref.codecId);\n if (!template) {\n throw runtimeError(\n 'RUNTIME.CODEC_DESCRIPTOR_MISSING',\n `Test ContractCodecRegistry has no codec for codecId '${ref.codecId}'.`,\n {\n codecId: ref.codecId,\n ...(ref.typeParams !== undefined ? { typeParams: ref.typeParams } : {}),\n },\n );\n }\n byCanonicalKey.set(canonicalKey, template);\n return template;\n },\n };\n}\n\n/**\n * Synthesize `CodecDescriptor`s from a codec array of non-parameterized codec instances. Test-only: the production synthesis bridge was retired under TML-2357. Lets the existing `createTestAdapterDescriptor` pattern keep wrapping a stub `Adapter` (whose `__codecs` slot still exposes the codec set) into the descriptor-list shape that `SqlStaticContributions.codecs:` now expects. The `Codec` instances carry\n * `traits`/`targetTypes`/`meta` via the SQL family extension; the structural narrow reads those fields directly.\n */\nexport function descriptorsFromCodecs(\n codecs: ReadonlyArray<Codec<string>>,\n): ReadonlyArray<CodecDescriptor> {\n // Permissive paramsSchema for synthesized test descriptors: accepts any\n // shape (incl. undefined) and passes it through. Stubs do not encode\n // parameterization, so marking them `isParameterized: true` with this\n // schema lets the runtime integrity check tolerate columns that legitimately\n // carry typeParams (e.g. `sql/char@1` length=36) without re-introducing\n // the legacy \"non-parameterized + typeParams\" silent skip.\n // Permissive schema for synthesized test descriptors. `validate()` always\n // succeeds and discards input, narrowed to `void` to match the\n // `paramsSchema: StandardSchemaV1<void, void>` slot on the descriptor.\n // The factory ignores typeParams, so typing the validated output as `void`\n // is honest about what the stub does with the value.\n const acceptAnyParamsSchema = {\n '~standard': {\n version: 1 as const,\n vendor: 'sql-runtime/test-utils',\n validate: (_value: unknown) => ({ value: undefined }),\n },\n };\n const descriptors: CodecDescriptor[] = [];\n for (const instance of codecs) {\n const legacy = instance as {\n readonly traits?: readonly CodecTrait[];\n readonly targetTypes?: readonly string[];\n readonly meta?: CodecMeta;\n };\n descriptors.push({\n codecId: instance.id,\n traits: legacy.traits ?? [],\n targetTypes: legacy.targetTypes ?? [],\n paramsSchema: acceptAnyParamsSchema,\n isParameterized: true,\n factory: () => () => instance,\n ...(legacy.meta !== undefined ? { meta: legacy.meta } : {}),\n });\n }\n return descriptors;\n}\n\nexport function createTestAdapterDescriptor(\n adapter: StubAdapter,\n): SqlRuntimeAdapterDescriptor<'postgres'> {\n const descriptors = descriptorsFromCodecs(adapter.__codecs);\n return {\n kind: 'adapter' as const,\n rawCodecInferer: { inferCodec: () => 'pg/text' },\n id: 'test-adapter',\n version: '0.0.1',\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n codecs: () => descriptors,\n mutationDefaultGenerators: createTestMutationDefaultGenerators,\n create(_stack): SqlRuntimeAdapterInstance<'postgres'> {\n return Object.assign({ familyId: 'sql' as const, targetId: 'postgres' as const }, adapter);\n },\n };\n}\n\n/**\n * Creates a test target descriptor with empty static contributions.\n */\nexport function createTestTargetDescriptor(): SqlRuntimeTargetDescriptor<'postgres'> {\n return {\n kind: 'target' as const,\n id: 'postgres',\n version: '0.0.1',\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n codecs: () => [],\n create() {\n return { familyId: 'sql' as const, targetId: 'postgres' as const };\n },\n };\n}\n\n/**\n * Creates an ExecutionContext for testing. This helper DRYs up the common pattern of context creation in tests.\n *\n * Accepts a raw adapter and optional extension descriptors, wrapping the adapter in a descriptor internally for descriptor-first context creation.\n */\nexport function createTestContext<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n adapter: StubAdapter,\n options?: {\n extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;\n },\n): ExecutionContext<TContract> {\n return createExecutionContext({\n contract,\n stack: {\n target: createTestTargetDescriptor(),\n adapter: createTestAdapterDescriptor(adapter),\n extensionPacks: options?.extensionPacks ?? [],\n },\n });\n}\n\nexport function createTestStackInstance(options?: {\n extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;\n driver?: RuntimeDriverDescriptor<\n 'sql',\n 'postgres',\n unknown,\n SqlRuntimeDriverInstance<'postgres'>\n >;\n}) {\n const stack = createSqlExecutionStack({\n target: createTestTargetDescriptor(),\n adapter: createTestAdapterDescriptor(createStubAdapter()),\n driver: options?.driver,\n extensionPacks: options?.extensionPacks ?? [],\n });\n\n return instantiateExecutionStack(stack);\n}\n\n/**\n * Stub-adapter type augments the public {@link Adapter} surface with a `__codecs` slot that exposes the test stub's runtime codec set to descriptor-shaping helpers (`createTestAdapterDescriptor`). Production adapters do not declare this slot — runtime codecs flow through the descriptor list from `SqlRuntimeAdapterDescriptor.codecs()` — so the augmentation is intentionally test-only.\n */\nexport type StubAdapter = Adapter<SelectAst, Contract<SqlStorage>, LoweredStatement> & {\n readonly __codecs: ReadonlyArray<Codec<string>>;\n};\n\n/**\n * Creates a stub adapter for testing. This helper DRYs up the common pattern of adapter creation in tests.\n *\n * The stub adapter includes simple codecs for common test types (pg/int4@1, pg/text@1, pg/timestamptz@1) to enable type inference in tests without requiring the postgres adapter package.\n */\nexport function createStubAdapter(): StubAdapter {\n // Stub codecs for codec IDs that test contracts may reference. The set must\n // be complete enough to satisfy `assertColumnCodecIntegrity` against any\n // emitted test contract; the encode/decode bodies are passthrough since\n // the stub adapter never executes against a real driver.\n // The encode/decode bodies pass through; widen TInput to a JSON-safe type\n // so `defineTestCodec` does not require explicit JSON round-trip helpers.\n const passthroughCodec = (typeId: string, targetType: string): Codec<string> =>\n defineTestCodec({\n typeId,\n targetTypes: [targetType],\n encode: (value: string | number | boolean | null) => value,\n decode: (wire: string | number | boolean | null) => wire,\n });\n const codecs: ReadonlyArray<Codec<string>> = [\n passthroughCodec('pg/bit@1', 'bit'),\n passthroughCodec('pg/bool@1', 'bool'),\n passthroughCodec('pg/bytea@1', 'bytea'),\n passthroughCodec('pg/float4@1', 'float4'),\n passthroughCodec('pg/float8@1', 'float8'),\n passthroughCodec('pg/int2@1', 'int2'),\n defineTestCodec({\n typeId: 'pg/int4@1',\n targetTypes: ['int4'],\n encode: (value: number) => value,\n decode: (wire: number) => wire,\n }),\n passthroughCodec('pg/int8@1', 'int8'),\n passthroughCodec('pg/interval@1', 'interval'),\n passthroughCodec('pg/json@1', 'json'),\n passthroughCodec('pg/jsonb@1', 'jsonb'),\n passthroughCodec('pg/numeric@1', 'numeric'),\n defineTestCodec({\n typeId: 'pg/text@1',\n targetTypes: ['text'],\n encode: (value: string) => value,\n decode: (wire: string) => wire,\n }),\n passthroughCodec('pg/time@1', 'time'),\n defineTestCodec({\n typeId: 'pg/timestamp@1',\n targetTypes: ['timestamp'],\n encode: (value: Date) => value,\n decode: (wire: Date) => wire,\n encodeJson: (value: Date) => value.toISOString(),\n decodeJson: (json) => {\n if (typeof json !== 'string') throw new Error('expected ISO date string');\n return new Date(json);\n },\n }),\n defineTestCodec({\n typeId: 'pg/timestamptz@1',\n targetTypes: ['timestamptz'],\n encode: (value: Date) => value,\n decode: (wire: Date) => wire,\n // Date is not assignable to JsonValue, so the JSON round-trip pair must be supplied explicitly.\n encodeJson: (value: Date) => value.toISOString(),\n decodeJson: (json) => {\n if (typeof json !== 'string') throw new Error('expected ISO date string');\n return new Date(json);\n },\n }),\n passthroughCodec('pg/timetz@1', 'timetz'),\n passthroughCodec('pg/varbit@1', 'varbit'),\n passthroughCodec('pg/uuid@1', 'uuid'),\n passthroughCodec('sql/char@1', 'char'),\n passthroughCodec('sql/varchar@1', 'varchar'),\n ];\n\n return {\n __codecs: codecs,\n profile: {\n id: 'stub-profile',\n target: 'postgres',\n capabilities: {},\n readMarker: async () => ({ kind: 'absent' as const }),\n },\n lower(ast: SelectAst, _ctx: { contract: Contract<SqlStorage>; params?: readonly unknown[] }) {\n const sqlText = JSON.stringify(ast);\n const refs = ast.collectParamRefs();\n const params = refs.map((ref) =>\n ref.kind === 'prepared-param-ref'\n ? ({ kind: 'bind' as const, name: ref.name } as const)\n : ({ kind: 'literal' as const, value: ref.value } as const),\n );\n return Object.freeze({ sql: sqlText, params });\n },\n };\n}\n\nexport function unboundNamespaceWithTables(\n tables: Record<string, StorageTableInput>,\n): ReturnType<typeof buildSqlNamespace> {\n return buildSqlNamespace({ id: UNBOUND_NAMESPACE_ID, entries: { table: tables } });\n}\n\nexport function emptySqlTestDomain() {\n return applicationDomainOf({ models: {} });\n}\n\nexport function createTestContract(\n contract: Partial<Omit<Contract<SqlStorage>, 'profileHash' | 'storage' | 'domain'>> & {\n storageHash?: string;\n profileHash?: string;\n models?: Record<string, ContractModelBase>;\n domain?: Contract<SqlStorage>['domain'];\n storage?: Partial<Omit<SqlStorageInput, 'storageHash'>>;\n },\n): Contract<SqlStorage> {\n const { execution, ...rest } = contract;\n const storageHashValue = coreHash(rest['storageHash'] ?? 'sha256:testcore');\n\n return {\n target: rest['target'] ?? 'postgres',\n targetFamily: rest['targetFamily'] ?? 'sql',\n storage: rest['storage']\n ? new SqlStorage({\n ...rest['storage'],\n storageHash: storageHashValue,\n namespaces: rest['storage'].namespaces ?? { __unbound__: SqlUnboundNamespace.instance },\n })\n : new SqlStorage({\n storageHash: storageHashValue,\n namespaces: { __unbound__: SqlUnboundNamespace.instance },\n }),\n domain: rest['domain'] ?? applicationDomainOf({ models: rest['models'] ?? {} }),\n roots: rest['roots'] ?? {},\n capabilities: rest['capabilities'] ?? {},\n extensionPacks: rest['extensionPacks'] ?? {},\n meta: rest['meta'] ?? {},\n ...(execution ? { execution } : {}),\n profileHash: profileHash(rest['profileHash'] ?? 'sha256:testprofile'),\n };\n}\n\nexport function stubAst(): AnyQueryAst {\n return SelectAstCtor.from(TableSource.named('stub'));\n}\n\n// Re-export generic utilities from test-utils\nexport {\n collectAsync,\n createDevDatabase,\n type DevDatabase,\n teardownTestDatabase,\n withClient,\n} from '@prisma-next/test-utils';\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAg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ils.ts"],"sourcesContent":["/**\n * Test-only helper that constructs a SQL-family `Codec` instance from author-side encode/decode functions. Replaces the legacy public `mkCodec()` factory (deleted under TML-2357); tests that need a stub codec for behavioural assertions instantiate one through this helper rather than going through `descriptor.factory(...)`.\n *\n * The body is identical in spirit to the retired `mkCodec`: promise-lift sync author functions onto the framework-required `Promise<…>` boundary, default `encodeJson`/`decodeJson` to identity when `TInput` is JSON-safe, fail loudly otherwise.\n */\nimport type { JsonValue } from '@prisma-next/contract/types';\nimport type { CodecTrait } from '@prisma-next/framework-components/codec';\nimport type { Codec, SqlCodecCallContext } from '@prisma-next/sql-relational-core/ast';\n\ntype JsonRoundTripConfig<TInput> = [TInput] extends [JsonValue]\n ? {\n encodeJson?: (value: TInput) => JsonValue;\n decodeJson?: (json: JsonValue) => TInput;\n }\n : {\n encodeJson: (value: TInput) => JsonValue;\n decodeJson: (json: JsonValue) => TInput;\n };\n\nexport function defineTestCodec<\n Id extends string,\n const TTraits extends readonly CodecTrait[] = readonly [],\n TWire = unknown,\n TInput = unknown,\n>(\n config: {\n typeId: Id;\n targetTypes?: readonly string[];\n encode: (value: TInput, ctx: SqlCodecCallContext) => TWire | Promise<TWire>;\n decode: (wire: TWire, ctx: SqlCodecCallContext) => TInput | Promise<TInput>;\n traits?: TTraits;\n } & JsonRoundTripConfig<TInput>,\n): Codec<Id, TTraits, TWire, TInput> {\n const identity = (v: unknown) => v;\n const userEncode = config.encode;\n const userDecode = config.decode;\n const widenedConfig = config as {\n encodeJson?: (value: TInput) => JsonValue;\n decodeJson?: (json: JsonValue) => TInput;\n };\n return {\n id: config.typeId,\n encode: (value, ctx) => {\n try {\n return Promise.resolve(userEncode(value, ctx));\n } catch (error) {\n return Promise.reject(error);\n }\n },\n decode: (wire, ctx) => {\n try {\n return Promise.resolve(userDecode(wire, ctx));\n } catch (error) {\n return Promise.reject(error);\n }\n },\n encodeJson: (widenedConfig.encodeJson ?? identity) as (value: TInput) => JsonValue,\n decodeJson: (widenedConfig.decodeJson ?? identity) as (json: JsonValue) => TInput,\n } as Codec<Id, TTraits, TWire, TInput>;\n}\n","import {\n type Contract,\n type ContractModelBase,\n coreHash,\n profileHash,\n} from '@prisma-next/contract/types';\nimport type {\n CodecDescriptor,\n CodecMeta,\n CodecTrait,\n} from '@prisma-next/framework-components/codec';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport {\n instantiateExecutionStack,\n type RuntimeDriverDescriptor,\n} from '@prisma-next/framework-components/execution';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { ResultType } from '@prisma-next/framework-components/runtime';\nimport { runtimeError } from '@prisma-next/framework-components/runtime';\nimport { canonicalizeJson } from '@prisma-next/framework-components/utils';\nimport { builtinGeneratorIds } from '@prisma-next/ids';\nimport { generateId } from '@prisma-next/ids/runtime';\nimport {\n buildSqlNamespace,\n SqlStorage,\n type SqlStorageInput,\n SqlUnboundNamespace,\n type StorageTableInput,\n} from '@prisma-next/sql-contract/types';\nimport type {\n Adapter,\n AnyQueryAst,\n Codec,\n ContractCodecRegistry,\n LoweredStatement,\n SelectAst,\n} from '@prisma-next/sql-relational-core/ast';\nimport { SelectAst as SelectAstCtor, TableSource } from '@prisma-next/sql-relational-core/ast';\nimport type { SqlExecutionPlan, SqlQueryPlan } from '@prisma-next/sql-relational-core/plan';\nimport { applicationDomainOf, collectAsync, drainAsyncIterable } from '@prisma-next/test-utils';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Client } from 'pg';\nimport { createExecutionContext, createSqlExecutionStack } from '../src/exports';\nimport type {\n ExecutionContext,\n SqlRuntimeAdapterDescriptor,\n SqlRuntimeAdapterInstance,\n SqlRuntimeDriverInstance,\n SqlRuntimeExtensionDescriptor,\n SqlRuntimeTargetDescriptor,\n} from '../src/sql-context';\nimport { type Runtime, type RuntimeOptions, SqlRuntimeBase } from '../src/sql-runtime';\nimport { defineTestCodec } from './test-codec';\n\nfunction createTestMutationDefaultGenerators() {\n return builtinGeneratorIds.map((id) => ({\n id,\n generate: (params?: Record<string, unknown>) => generateId(params ? { id, params } : { id }),\n stability: 'field' as const,\n }));\n}\n\nclass TestSqlRuntime extends SqlRuntimeBase {}\n\ntype CreateTestRuntimeOptions<TContract extends Contract<SqlStorage>> = Omit<\n RuntimeOptions<TContract>,\n 'adapter'\n> & {\n readonly stackInstance: { readonly adapter: RuntimeOptions<TContract>['adapter'] };\n};\n\n/**\n * Test-only concrete runtime. Unpacks `stackInstance.adapter` and forwards\n * the rest into `TestSqlRuntime`, a trivial concrete leaf of the abstract\n * `SqlRuntimeBase`.\n */\nexport function createTestRuntime<TContract extends Contract<SqlStorage>>(\n options: CreateTestRuntimeOptions<TContract>,\n): Runtime {\n const { stackInstance, context, driver, verifyMarker, middleware, mode, log } = options;\n return new TestSqlRuntime({\n context,\n adapter: stackInstance.adapter,\n driver,\n ...ifDefined('verifyMarker', verifyMarker),\n ...ifDefined('middleware', middleware),\n ...ifDefined('mode', mode),\n ...ifDefined('log', log),\n });\n}\n\n/**\n * Executes a plan and collects all results into an array. This helper DRYs up the common pattern of executing plans in tests. The return type is inferred from the plan's type parameter.\n */\nexport async function executePlanAndCollect<\n P extends SqlExecutionPlan<ResultType<P>> | SqlQueryPlan<ResultType<P>>,\n>(runtime: Runtime, plan: P): Promise<ResultType<P>[]> {\n type Row = ResultType<P>;\n return collectAsync<Row>(runtime.execute<Row>(plan));\n}\n\n/**\n * Drains a plan execution, consuming all results without collecting them. Useful for testing side effects without memory overhead.\n */\nexport async function drainPlanExecution(\n runtime: Runtime,\n plan: SqlExecutionPlan | SqlQueryPlan<unknown>,\n): Promise<void> {\n return drainAsyncIterable(runtime.execute(plan));\n}\n\n/**\n * Sets up database schema and data, then writes the contract marker. This helper DRYs up the common pattern of database setup in tests.\n *\n * Callers must supply `bootstrapMarkerTables` (typically\n * `bootstrapPostgresSignMarkerTables` from integration `postgres-bootstrap.ts`)\n * so this package does not depend on the postgres adapter/target packs.\n */\nexport async function setupTestDatabase(\n client: Client,\n contract: Contract<SqlStorage>,\n setupFn: (client: Client) => Promise<void>,\n bootstrapMarkerTables: (client: Client) => Promise<void>,\n): Promise<void> {\n await client.query('drop schema if exists prisma_contract cascade');\n await client.query('create schema if not exists public');\n\n await setupFn(client);\n\n await bootstrapMarkerTables(client);\n await writeTestContractMarker(client, contract);\n}\n\nexport interface SeedMarkerInput {\n /** Logical space for the marker row; defaults to {@link APP_SPACE_ID}. */\n readonly space?: string;\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson?: unknown;\n readonly canonicalVersion?: number;\n readonly invariants?: readonly string[];\n}\n\n/**\n * Seeds a contract marker row directly via raw SQL. Test-only: the production\n * write path goes through the control adapter SPI (`initMarker`/`updateMarker`),\n * which needs a `ControlDriverInstance`; these fixtures hold a raw `pg.Client`,\n * so they perform a minimal `INSERT` over the columns the runtime reads back.\n */\nexport async function seedTestMarker(client: Client, input: SeedMarkerInput): Promise<void> {\n await client.query(\n `insert into prisma_contract.marker\n (space, core_hash, profile_hash, contract_json, canonical_version, invariants, updated_at)\n values ($1, $2, $3, $4::jsonb, $5, $6::text[], now())`,\n [\n input.space ?? APP_SPACE_ID,\n input.storageHash,\n input.profileHash,\n input.contractJson === undefined ? null : JSON.stringify(input.contractJson),\n input.canonicalVersion ?? null,\n input.invariants ?? [],\n ],\n );\n}\n\n/**\n * Seeds the app-space marker for a contract. Thin wrapper over\n * {@link seedTestMarker} for the common \"write the marker for this contract\" case.\n */\nexport async function writeTestContractMarker(\n client: Client,\n contract: Contract<SqlStorage>,\n): Promise<void> {\n await seedTestMarker(client, {\n storageHash: contract.storage.storageHash,\n profileHash: contract.profileHash,\n contractJson: contract,\n canonicalVersion: 1,\n });\n}\n\n/**\n * Creates a test adapter descriptor from a raw adapter. Wraps the adapter in an SqlRuntimeAdapterDescriptor with static contributions derived from the adapter's codec registry.\n */\n/**\n * Build a {@link ContractCodecRegistry} from a codec array for tests that exercise `encodeParam(s)` / `decodeRow` in isolation. The production runtime builds `ContractCodecRegistry` from contract walk + descriptor list and never goes through this helper; tests use it to wire a hand-built codec set into the surface those functions consume in production.\n */\nexport function buildTestContractCodecs(\n codecs: ReadonlyArray<Codec<string>>,\n): ContractCodecRegistry {\n const byId = new Map<string, Codec<string>>();\n for (const codec of codecs) {\n byId.set(codec.id, codec);\n }\n // Canonical-key cache: production `forCodecRef` memoizes per `(codecId, canonicalize(typeParams))`. Tests resolve by codecId, but key the cache on the canonical pair so callers passing distinct typeParams get distinct (still codec-id-templated) entries — and so this helper cannot silently coalesce them.\n const byCanonicalKey = new Map<string, Codec<string>>();\n return {\n forColumn: () => undefined,\n forCodecRef: (ref) => {\n const canonicalKey = canonicalizeJson({\n codecId: ref.codecId,\n ...(ref.typeParams !== undefined ? { typeParams: ref.typeParams } : {}),\n });\n const cached = byCanonicalKey.get(canonicalKey);\n if (cached) return cached;\n const template = byId.get(ref.codecId);\n if (!template) {\n throw runtimeError(\n 'RUNTIME.CODEC_DESCRIPTOR_MISSING',\n `Test ContractCodecRegistry has no codec for codecId '${ref.codecId}'.`,\n {\n codecId: ref.codecId,\n ...(ref.typeParams !== undefined ? { typeParams: ref.typeParams } : {}),\n },\n );\n }\n byCanonicalKey.set(canonicalKey, template);\n return template;\n },\n };\n}\n\n/**\n * Synthesize `CodecDescriptor`s from a codec array of non-parameterized codec instances. Test-only: the production synthesis bridge was retired under TML-2357. Lets the existing `createTestAdapterDescriptor` pattern keep wrapping a stub `Adapter` (whose `__codecs` slot still exposes the codec set) into the descriptor-list shape that `SqlStaticContributions.codecs:` now expects. The `Codec` instances carry\n * `traits`/`targetTypes`/`meta` via the SQL family extension; the structural narrow reads those fields directly.\n */\nexport function descriptorsFromCodecs(\n codecs: ReadonlyArray<Codec<string>>,\n): ReadonlyArray<CodecDescriptor> {\n // Permissive paramsSchema for synthesized test descriptors: accepts any\n // shape (incl. undefined) and passes it through. Stubs do not encode\n // parameterization, so marking them `isParameterized: true` with this\n // schema lets the runtime integrity check tolerate columns that legitimately\n // carry typeParams (e.g. `sql/char@1` length=36) without re-introducing\n // the legacy \"non-parameterized + typeParams\" silent skip.\n // Permissive schema for synthesized test descriptors. `validate()` always\n // succeeds and discards input, narrowed to `void` to match the\n // `paramsSchema: StandardSchemaV1<void, void>` slot on the descriptor.\n // The factory ignores typeParams, so typing the validated output as `void`\n // is honest about what the stub does with the value.\n const acceptAnyParamsSchema = {\n '~standard': {\n version: 1 as const,\n vendor: 'sql-runtime/test-utils',\n validate: (_value: unknown) => ({ value: undefined }),\n },\n };\n const descriptors: CodecDescriptor[] = [];\n for (const instance of codecs) {\n const legacy = instance as {\n readonly traits?: readonly CodecTrait[];\n readonly targetTypes?: readonly string[];\n readonly meta?: CodecMeta;\n };\n descriptors.push({\n codecId: instance.id,\n traits: legacy.traits ?? [],\n targetTypes: legacy.targetTypes ?? [],\n paramsSchema: acceptAnyParamsSchema,\n isParameterized: true,\n factory: () => () => instance,\n ...(legacy.meta !== undefined ? { meta: legacy.meta } : {}),\n });\n }\n return descriptors;\n}\n\nexport function createTestAdapterDescriptor(\n adapter: StubAdapter,\n): SqlRuntimeAdapterDescriptor<'postgres'> {\n const descriptors = descriptorsFromCodecs(adapter.__codecs);\n return {\n kind: 'adapter' as const,\n rawCodecInferer: { inferCodec: () => 'pg/text' },\n id: 'test-adapter',\n version: '0.0.1',\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n codecs: () => descriptors,\n mutationDefaultGenerators: createTestMutationDefaultGenerators,\n create(_stack): SqlRuntimeAdapterInstance<'postgres'> {\n return Object.assign({ familyId: 'sql' as const, targetId: 'postgres' as const }, adapter);\n },\n };\n}\n\n/**\n * Creates a test target descriptor with empty static contributions.\n */\nexport function createTestTargetDescriptor(): SqlRuntimeTargetDescriptor<'postgres'> {\n return {\n kind: 'target' as const,\n id: 'postgres',\n version: '0.0.1',\n familyId: 'sql' as const,\n targetId: 'postgres' as const,\n codecs: () => [],\n create() {\n return { familyId: 'sql' as const, targetId: 'postgres' as const };\n },\n };\n}\n\n/**\n * Creates an ExecutionContext for testing. This helper DRYs up the common pattern of context creation in tests.\n *\n * Accepts a raw adapter and optional extension descriptors, wrapping the adapter in a descriptor internally for descriptor-first context creation.\n */\nexport function createTestContext<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n adapter: StubAdapter,\n options?: {\n extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;\n },\n): ExecutionContext<TContract> {\n return createExecutionContext({\n contract,\n stack: {\n target: createTestTargetDescriptor(),\n adapter: createTestAdapterDescriptor(adapter),\n extensionPacks: options?.extensionPacks ?? [],\n },\n });\n}\n\nexport function createTestStackInstance(options?: {\n extensionPacks?: ReadonlyArray<SqlRuntimeExtensionDescriptor<'postgres'>>;\n driver?: RuntimeDriverDescriptor<\n 'sql',\n 'postgres',\n unknown,\n SqlRuntimeDriverInstance<'postgres'>\n >;\n}) {\n const stack = createSqlExecutionStack({\n target: createTestTargetDescriptor(),\n adapter: createTestAdapterDescriptor(createStubAdapter()),\n driver: options?.driver,\n extensionPacks: options?.extensionPacks ?? [],\n });\n\n return instantiateExecutionStack(stack);\n}\n\n/**\n * Stub-adapter type augments the public {@link Adapter} surface with a `__codecs` slot that exposes the test stub's runtime codec set to descriptor-shaping helpers (`createTestAdapterDescriptor`). Production adapters do not declare this slot — runtime codecs flow through the descriptor list from `SqlRuntimeAdapterDescriptor.codecs()` — so the augmentation is intentionally test-only.\n */\nexport type StubAdapter = Adapter<SelectAst, Contract<SqlStorage>, LoweredStatement> & {\n readonly __codecs: ReadonlyArray<Codec<string>>;\n};\n\n/**\n * Creates a stub adapter for testing. This helper DRYs up the common pattern of adapter creation in tests.\n *\n * The stub adapter includes simple codecs for common test types (pg/int4@1, pg/text@1, pg/timestamptz@1) to enable type inference in tests without requiring the postgres adapter package.\n */\nexport function createStubAdapter(): StubAdapter {\n // Stub codecs for codec IDs that test contracts may reference. The set must\n // be complete enough to satisfy `assertColumnCodecIntegrity` against any\n // emitted test contract; the encode/decode bodies are passthrough since\n // the stub adapter never executes against a real driver.\n // The encode/decode bodies pass through; widen TInput to a JSON-safe type\n // so `defineTestCodec` does not require explicit JSON round-trip helpers.\n const passthroughCodec = (typeId: string, targetType: string): Codec<string> =>\n defineTestCodec({\n typeId,\n targetTypes: [targetType],\n encode: (value: string | number | boolean | null) => value,\n decode: (wire: string | number | boolean | null) => wire,\n });\n const codecs: ReadonlyArray<Codec<string>> = [\n passthroughCodec('pg/bit@1', 'bit'),\n passthroughCodec('pg/bool@1', 'bool'),\n passthroughCodec('pg/bytea@1', 'bytea'),\n passthroughCodec('pg/float4@1', 'float4'),\n passthroughCodec('pg/float8@1', 'float8'),\n passthroughCodec('pg/int2@1', 'int2'),\n defineTestCodec({\n typeId: 'pg/int4@1',\n targetTypes: ['int4'],\n encode: (value: number) => value,\n decode: (wire: number) => wire,\n }),\n passthroughCodec('pg/int8@1', 'int8'),\n passthroughCodec('pg/interval@1', 'interval'),\n passthroughCodec('pg/json@1', 'json'),\n passthroughCodec('pg/jsonb@1', 'jsonb'),\n passthroughCodec('pg/numeric@1', 'numeric'),\n defineTestCodec({\n typeId: 'pg/text@1',\n targetTypes: ['text'],\n encode: (value: string) => value,\n decode: (wire: string) => wire,\n }),\n passthroughCodec('pg/time@1', 'time'),\n defineTestCodec({\n typeId: 'pg/timestamp@1',\n targetTypes: ['timestamp'],\n encode: (value: Date) => value,\n decode: (wire: Date) => wire,\n encodeJson: (value: Date) => value.toISOString(),\n decodeJson: (json) => {\n if (typeof json !== 'string') throw new Error('expected ISO date string');\n return new Date(json);\n },\n }),\n defineTestCodec({\n typeId: 'pg/timestamptz@1',\n targetTypes: ['timestamptz'],\n encode: (value: Date) => value,\n decode: (wire: Date) => wire,\n // Date is not assignable to JsonValue, so the JSON round-trip pair must be supplied explicitly.\n encodeJson: (value: Date) => value.toISOString(),\n decodeJson: (json) => {\n if (typeof json !== 'string') throw new Error('expected ISO date string');\n return new Date(json);\n },\n }),\n passthroughCodec('pg/timetz@1', 'timetz'),\n passthroughCodec('pg/varbit@1', 'varbit'),\n passthroughCodec('pg/uuid@1', 'uuid'),\n passthroughCodec('sql/char@1', 'char'),\n passthroughCodec('sql/varchar@1', 'varchar'),\n ];\n\n return {\n __codecs: codecs,\n profile: {\n id: 'stub-profile',\n target: 'postgres',\n capabilities: {},\n readMarker: async () => ({ kind: 'absent' as const }),\n },\n lower(ast: SelectAst, _ctx: { contract: Contract<SqlStorage>; params?: readonly unknown[] }) {\n const sqlText = JSON.stringify(ast);\n const refs = ast.collectParamRefs();\n const params = refs.map((ref) =>\n ref.kind === 'prepared-param-ref'\n ? ({ kind: 'bind' as const, name: ref.name } as const)\n : ({ kind: 'literal' as const, value: ref.value } as const),\n );\n return Object.freeze({ sql: sqlText, params });\n },\n };\n}\n\nexport function unboundNamespaceWithTables(\n tables: Record<string, StorageTableInput>,\n): ReturnType<typeof buildSqlNamespace> {\n return buildSqlNamespace({ id: UNBOUND_NAMESPACE_ID, entries: { table: tables } });\n}\n\nexport function emptySqlTestDomain() {\n return applicationDomainOf({ models: {} });\n}\n\nexport function createTestContract(\n contract: Partial<Omit<Contract<SqlStorage>, 'profileHash' | 'storage' | 'domain'>> & {\n storageHash?: string;\n profileHash?: string;\n models?: Record<string, ContractModelBase>;\n domain?: Contract<SqlStorage>['domain'];\n storage?: Partial<Omit<SqlStorageInput, 'storageHash'>>;\n },\n): Contract<SqlStorage> {\n const { execution, ...rest } = contract;\n const storageHashValue = coreHash(rest['storageHash'] ?? 'sha256:testcore');\n\n return {\n target: rest['target'] ?? 'postgres',\n targetFamily: rest['targetFamily'] ?? 'sql',\n storage: rest['storage']\n ? new SqlStorage({\n ...rest['storage'],\n storageHash: storageHashValue,\n namespaces: rest['storage'].namespaces ?? { __unbound__: SqlUnboundNamespace.instance },\n })\n : new SqlStorage({\n storageHash: storageHashValue,\n namespaces: { __unbound__: SqlUnboundNamespace.instance },\n }),\n domain: rest['domain'] ?? applicationDomainOf({ models: rest['models'] ?? {} }),\n roots: rest['roots'] ?? {},\n capabilities: rest['capabilities'] ?? {},\n extensionPacks: rest['extensionPacks'] ?? {},\n meta: rest['meta'] ?? {},\n ...(execution ? { execution } : {}),\n profileHash: profileHash(rest['profileHash'] ?? 'sha256:testprofile'),\n };\n}\n\nexport function stubAst(): AnyQueryAst {\n return SelectAstCtor.from(TableSource.named('stub'));\n}\n\n// Re-export generic utilities from test-utils\nexport {\n collectAsync,\n createDevDatabase,\n type DevDatabase,\n teardownTestDatabase,\n withClient,\n} from '@prisma-next/test-utils';\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,gBAMd,QAOmC;CACnC,MAAM,YAAY,MAAe;CACjC,MAAM,aAAa,OAAO;CAC1B,MAAM,aAAa,OAAO;CAC1B,MAAM,gBAAgB;CAItB,OAAO;EACL,IAAI,OAAO;EACX,SAAS,OAAO,QAAQ;GACtB,IAAI;IACF,OAAO,QAAQ,QAAQ,WAAW,OAAO,GAAG,CAAC;GAC/C,SAAS,OAAO;IACd,OAAO,QAAQ,OAAO,KAAK;GAC7B;EACF;EACA,SAAS,MAAM,QAAQ;GACrB,IAAI;IACF,OAAO,QAAQ,QAAQ,WAAW,MAAM,GAAG,CAAC;GAC9C,SAAS,OAAO;IACd,OAAO,QAAQ,OAAO,KAAK;GAC7B;EACF;EACA,YAAa,cAAc,cAAc;EACzC,YAAa,cAAc,cAAc;CAC3C;AACF;;;ACLA,SAAS,sCAAsC;CAC7C,OAAO,oBAAoB,KAAK,QAAQ;EACtC;EACA,WAAW,WAAqC,WAAW,SAAS;GAAE;GAAI;EAAO,IAAI,EAAE,GAAG,CAAC;EAC3F,WAAW;CACb,EAAE;AACJ;AAEA,IAAM,iBAAN,cAA6B,eAAe,CAAC;;;;;;AAc7C,SAAgB,kBACd,SACS;CACT,MAAM,EAAE,eAAe,SAAS,QAAQ,cAAc,YAAY,MAAM,QAAQ;CAChF,OAAO,IAAI,eAAe;EACxB;EACA,SAAS,cAAc;EACvB;EACA,GAAG,UAAU,gBAAgB,YAAY;EACzC,GA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