@prisma/orm-framework 8.0.0-rc.1-dev.41 → 8.0.0-rc.1-dev.43

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.
Files changed (62) hide show
  1. package/dist/authoring-B2H-9qCv.d.mts +1 -0
  2. package/dist/{codec-LWTqo1GG.d.mts → codec-Ce07W3Mz.d.mts} +2 -2
  3. package/dist/{codec-LWTqo1GG.d.mts.map → codec-Ce07W3Mz.d.mts.map} +1 -1
  4. package/dist/{codec-types-720XoDZ0-Br-QaYK3.d.mts → codec-types-D6VRj2RE-BLElXc-O.d.mts} +5 -5
  5. package/dist/{codec-types-720XoDZ0-Br-QaYK3.d.mts.map → codec-types-D6VRj2RE-BLElXc-O.d.mts.map} +1 -1
  6. package/dist/{components-CS6Hvdt6.d.mts → components-CGA_WwEG.d.mts} +4 -4
  7. package/dist/{components-CS6Hvdt6.d.mts.map → components-CGA_WwEG.d.mts.map} +1 -1
  8. package/dist/components.d.mts +15 -15
  9. package/dist/components.mjs +2 -2
  10. package/dist/components__authoring.d.mts +2 -2
  11. package/dist/components__codec.d.mts +2 -2
  12. package/dist/components__components.d.mts +3 -3
  13. package/dist/components__control.d.mts +2 -2
  14. package/dist/components__emission.d.mts +3 -3
  15. package/dist/components__execution.d.mts +1 -1
  16. package/dist/components__psl-ast.d.mts +3 -3
  17. package/dist/components__runtime.d.mts +2 -2
  18. package/dist/components__runtime.mjs +2 -2
  19. package/dist/{config-types-Dw7Nvsbm.d.mts → config-types-CW4PDwMC.d.mts} +6 -6
  20. package/dist/{config-types-Dw7Nvsbm.d.mts.map → config-types-CW4PDwMC.d.mts.map} +1 -1
  21. package/dist/config.d.mts +1 -1
  22. package/dist/config__config-types.d.mts +1 -1
  23. package/dist/contract-authoring.d.mts +3 -3
  24. package/dist/{control-2lID5ISA.d.mts → control-BF8qzdnM.d.mts} +7 -7
  25. package/dist/{control-2lID5ISA.d.mts.map → control-BF8qzdnM.d.mts.map} +1 -1
  26. package/dist/emission-CmUO03gQ.d.mts +2 -0
  27. package/dist/{emission-types-BY5gWxhC-DcGn4rl_.d.mts → emission-types-DLXP34Ki-CFms3VrX.d.mts} +4 -4
  28. package/dist/{emission-types-BY5gWxhC-DcGn4rl_.d.mts.map → emission-types-DLXP34Ki-CFms3VrX.d.mts.map} +1 -1
  29. package/dist/errors.d.mts +1 -1
  30. package/dist/errors__execution.d.mts +1 -1
  31. package/dist/{execution-j0w6KfPD.d.mts → execution-CSnQT8EX.d.mts} +2 -2
  32. package/dist/{execution-j0w6KfPD.d.mts.map → execution-CSnQT8EX.d.mts.map} +1 -1
  33. package/dist/{execution-D3yaOlOT.d.mts → execution-Cyl2dXxX.d.mts} +2 -2
  34. package/dist/{execution-D3yaOlOT.d.mts.map → execution-Cyl2dXxX.d.mts.map} +1 -1
  35. package/dist/{framework-authoring-CctmQY6c-DdJ4E7XK.d.mts → framework-authoring-BhctBwih-DQ_6noDM.d.mts} +3 -3
  36. package/dist/{framework-authoring-CctmQY6c-DdJ4E7XK.d.mts.map → framework-authoring-BhctBwih-DQ_6noDM.d.mts.map} +1 -1
  37. package/dist/{framework-components-p8N1lyvE-Cgl21LGI.d.mts → framework-components-hZ2tO-KH-CdRXBOYd.d.mts} +5 -5
  38. package/dist/{framework-components-p8N1lyvE-Cgl21LGI.d.mts.map → framework-components-hZ2tO-KH-CdRXBOYd.d.mts.map} +1 -1
  39. package/dist/ids.d.mts +1 -1
  40. package/dist/{parse-0ZJjj_2N-Ds7oY9eP.d.mts → parse-0ZJjj_2N-DhQpSVmQ.d.mts} +3 -3
  41. package/dist/{parse-0ZJjj_2N-Ds7oY9eP.d.mts.map → parse-0ZJjj_2N-DhQpSVmQ.d.mts.map} +1 -1
  42. package/dist/{psl-ast-Bxf2Zocj.d.mts → psl-ast-BXZoFQBk.d.mts} +4 -4
  43. package/dist/{psl-ast-Bxf2Zocj.d.mts.map → psl-ast-BXZoFQBk.d.mts.map} +1 -1
  44. package/dist/{psl-ast-GTXfHjAV-HsPDAkQr.d.mts → psl-ast-CWJQF8LA-Vr5JNPdn.d.mts} +4 -4
  45. package/dist/{psl-ast-GTXfHjAV-HsPDAkQr.d.mts.map → psl-ast-CWJQF8LA-Vr5JNPdn.d.mts.map} +1 -1
  46. package/dist/psl-parser.d.mts +8 -8
  47. package/dist/psl-parser__interpret.d.mts +3 -3
  48. package/dist/psl-parser__syntax.d.mts +1 -1
  49. package/dist/psl-printer.d.mts +6 -6
  50. package/dist/{runtime-DYTFHGwh.mjs → runtime-BqzioOmU.mjs} +241 -87
  51. package/dist/runtime-BqzioOmU.mjs.map +1 -0
  52. package/dist/{runtime-Cne6hBaG.d.mts → runtime-Cuxw8obj.d.mts} +326 -189
  53. package/dist/runtime-Cuxw8obj.d.mts.map +1 -0
  54. package/dist/{symbol-table-CZ7EVCTL-HNuzTvNC.d.mts → symbol-table-CZ7EVCTL-CR-ncCpD.d.mts} +5 -5
  55. package/dist/{symbol-table-CZ7EVCTL-HNuzTvNC.d.mts.map → symbol-table-CZ7EVCTL-CR-ncCpD.d.mts.map} +1 -1
  56. package/dist/{types-import-spec-C9FyCno_-CONzlg_q.d.mts → types-import-spec-3mjbVBhI-DQI6BvKU.d.mts} +3 -3
  57. package/dist/{types-import-spec-C9FyCno_-CONzlg_q.d.mts.map → types-import-spec-3mjbVBhI-DQI6BvKU.d.mts.map} +1 -1
  58. package/package.json +15 -15
  59. package/dist/authoring-D6-6Uhns.d.mts +0 -1
  60. package/dist/emission-aQb87dEn.d.mts +0 -2
  61. package/dist/runtime-Cne6hBaG.d.mts.map +0 -1
  62. package/dist/runtime-DYTFHGwh.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { U as PlanMeta } from "./domain-envelope-D6Wn9AmZ-BqZKTT9U.mjs";
2
- import { r as CodecCallContext } from "./codec-types-720XoDZ0-Br-QaYK3.mjs";
2
+ import { r as CodecCallContext } from "./codec-types-D6VRj2RE-BLElXc-O.mjs";
3
3
  //#region ../../../1-framework/1-core/framework-components/dist/runtime.d.mts
4
4
  //#region src/annotations.d.ts
5
5
  /**
@@ -302,23 +302,22 @@ interface RuntimeLog {
302
302
  debug?(event: unknown): void;
303
303
  }
304
304
  /**
305
- * Per-execute context threaded through every middleware phase
306
- * (`beforeExecute`, `onRow`, `afterExecute`). Allocated once per
307
- * `runtime.execute()` call and shared by reference across all
308
- * middleware in the chain.
309
- *
310
- * - `signal` carries the per-query `AbortSignal` -- the same
311
- * reference that `runtime.execute(plan, { signal })` was invoked
312
- * with, and the same reference threaded into the per-call
313
- * `CodecCallContext` (ADR 207). Middleware that wraps a
314
- * network-backed SDK forwards `ctx.signal` into that SDK to
315
- * propagate caller cancellation; pure-CPU middleware ignores it.
316
- *
317
- * Symmetric plumbing across all middleware phases (rather than only
318
- * `beforeExecute`) is a deliberate choice: a middleware that wraps a
319
- * downstream observability hook or post-processor in `afterExecute` /
320
- * `onRow` needs the same cancellation reach as its `beforeExecute`
321
- * counterpart.
305
+ * Per-operation context threaded through every middleware phase
306
+ * (`beforeQuery`, `interceptQuery`, `onRow`, `afterQuery` for queries, and
307
+ * `beforeExecute`, `interceptExecute`, `afterExecute` for executes). Allocated
308
+ * once per runtime operation and shared by reference across all middleware in
309
+ * the chain.
310
+ *
311
+ * - `signal` carries the per-operation `AbortSignal` -- the same reference
312
+ * passed to the runtime call and the same reference threaded into the
313
+ * per-call `CodecCallContext` (ADR 207). Middleware that wraps a
314
+ * network-backed SDK forwards `ctx.signal` into that SDK to propagate caller
315
+ * cancellation; pure-CPU middleware ignores it.
316
+ *
317
+ * Symmetric plumbing across all middleware phases is a deliberate choice: a
318
+ * middleware that wraps a downstream observability hook or post-processor in
319
+ * `afterQuery` / `afterExecute`, `interceptQuery` / `interceptExecute`, or
320
+ * `onRow` needs the same cancellation reach as its before hook.
322
321
  */
323
322
  interface RuntimeMiddlewareContext {
324
323
  readonly contract: unknown;
@@ -344,21 +343,22 @@ interface RuntimeMiddlewareContext {
344
343
  */
345
344
  contentHash(exec: ExecutionPlan): Promise<string>;
346
345
  /**
347
- * Per-execute cancellation signal threaded through every middleware
348
- * phase. Middleware that wraps async work or downstream cancellable
349
- * primitives should observe this and abort early when the consumer
350
- * cancels.
346
+ * Per-operation cancellation signal threaded through every selected
347
+ * middleware phase. Middleware that wraps async work or downstream
348
+ * cancellable primitives should observe this and abort early when the
349
+ * consumer cancels.
351
350
  */
352
351
  readonly signal?: AbortSignal;
353
352
  /**
354
- * Identifies the queryable scope this execution is running under.
353
+ * Identifies the queryable scope this operation is running under.
355
354
  *
356
- * - `'runtime'` — top-level `runtime.execute(plan)`. The default scope
357
- * used by the standard read/write paths.
358
- * - `'connection'` — `connection.execute(plan)` after
359
- * `runtime.connection()` checked out a connection from the pool.
360
- * - `'transaction'` — `transaction.execute(plan)` inside an explicit
361
- * transaction, or a query routed through `withTransaction`.
355
+ * - `'runtime'` — top-level `runtime.query(plan)` or `runtime.execute(plan)`.
356
+ * The default scope used by the standard read/write paths.
357
+ * - `'connection'` — `connection.query(plan)` or `connection.execute(plan)`
358
+ * after `runtime.connection()` checked out a connection from the pool.
359
+ * - `'transaction'` — `transaction.query(plan)` or
360
+ * `transaction.execute(plan)` inside an explicit transaction, or an
361
+ * operation routed through `withTransaction`.
362
362
  *
363
363
  * Middleware that should only act at the top level read this field to
364
364
  * bypass non-runtime scopes. The cache middleware uses it to skip
@@ -372,28 +372,28 @@ interface RuntimeMiddlewareContext {
372
372
  */
373
373
  readonly scope: 'runtime' | 'connection' | 'transaction';
374
374
  /**
375
- * Identity for one `execute()` call. The runtime mints a fresh value via
376
- * `crypto.randomUUID()` when it constructs the per-execute context, and
377
- * the same context reference is threaded through every middleware phase
378
- * (`beforeExecute`, `intercept`, `onRow`, `afterExecute`). Every hook in
379
- * one execute call therefore observes the same `planExecutionId`; two
380
- * executions of the same plan observe distinct values. Use this to
381
- * correlate observations across the lifecycle of a single execute call
375
+ * Identity for one `query()` or `execute()` call. The runtime mints a fresh
376
+ * value via `crypto.randomUUID()` when it constructs the per-operation
377
+ * context, then threads that context through every hook in the selected
378
+ * query or execute lifecycle. Every hook in one call therefore observes
379
+ * the same `planExecutionId`; two calls for the same plan observe distinct
380
+ * values. Use this to correlate observations across a single operation
382
381
  * (tracing, timing, audit). See ADR 220.
383
382
  */
384
383
  readonly planExecutionId: string;
385
384
  }
386
- interface AfterExecuteResult {
387
- readonly rowCount: number;
385
+ interface AfterResultBase {
388
386
  readonly latencyMs: number;
389
- readonly completed: boolean;
390
387
  /**
391
- * Indicates where the rows observed during this execution came from.
388
+ * Indicates which execution path was selected.
392
389
  *
393
- * - `'driver'` — the default. Rows came from the underlying driver via
394
- * `runDriver` / `runWithMiddleware`'s normal path.
395
- * - `'middleware'` a `RuntimeMiddleware.intercept` hook short-circuited
396
- * execution and supplied the rows directly. The driver was not invoked.
390
+ * - `'driver'` — the default. The result came from the underlying driver via
391
+ * `runDriver` / `runQueryWithMiddleware` or
392
+ * `runExecuteWithMiddleware`'s normal path.
393
+ * - `'middleware'` a `RuntimeMiddleware.interceptQuery` or
394
+ * `RuntimeMiddleware.interceptExecute` hook selected the middleware
395
+ * interception path. This includes both supplying the result directly and
396
+ * completing with an interceptor error; the driver was not invoked.
397
397
  *
398
398
  * Observers (telemetry, lints, budgets) that need to distinguish between
399
399
  * driver-served and middleware-served executions read this field.
@@ -401,37 +401,30 @@ interface AfterExecuteResult {
401
401
  */
402
402
  readonly source: 'driver' | 'middleware';
403
403
  }
404
- /**
405
- * Result of a successful `RuntimeMiddleware.intercept` hook.
406
- *
407
- * Carries the rows that the middleware wishes to return in place of
408
- * invoking the driver. The runtime iterates `rows` in order and yields
409
- * each row to the consumer; `beforeExecute`, `runDriver`, and `onRow` are
410
- * all skipped on the hit path. `afterExecute` still fires with
411
- * `source: 'middleware'`.
412
- *
413
- * `rows` accepts both `Iterable` (arrays, sync generators) and
414
- * `AsyncIterable` (async generators). `for await` natively handles both
415
- * via `Symbol.asyncIterator` / `Symbol.iterator` fallback, so the
416
- * orchestrator does not need to branch on the variant. Cached arrays in
417
- * the cache middleware are the common case; streaming variants support
418
- * future use cases like mock layers replaying recordings.
419
- *
420
- * Row shape is `Record<string, unknown>` — the same untyped shape
421
- * `onRow` receives. The SQL runtime decodes intercepted rows through its
422
- * normal codec pass, so interceptors cache and return raw (undecoded)
423
- * rows.
424
- */
425
- interface InterceptResult {
404
+ interface AfterQueryResult extends AfterResultBase {
405
+ readonly rowCount: number;
406
+ readonly completed: boolean;
407
+ }
408
+ type AfterExecuteResult = AfterResultBase & ({
409
+ readonly stats: RuntimeStatementStats;
410
+ readonly completed: true;
411
+ } | {
412
+ readonly completed: false;
413
+ });
414
+ interface QueryInterceptResult {
426
415
  readonly rows: AsyncIterable<Record<string, unknown>> | Iterable<Record<string, unknown>>;
427
416
  }
417
+ interface ExecuteInterceptResult {
418
+ readonly stats: RuntimeStatementStats;
419
+ }
428
420
  /**
429
421
  * Marker interface for family-specific param-ref mutators threaded into
430
- * `beforeExecute` as the third argument. The framework treats the mutator
431
- * opaquely — it allocates and forwards the family's mutator instance so
432
- * `runWithMiddleware` can stay family-agnostic. SQL extends this with
433
- * `SqlParamRefMutator` (over `ParamRef`); Mongo extends with
434
- * `MongoParamRefMutator` (over `MongoParamRef`).
422
+ * `beforeQuery` or `beforeExecute` as the third argument. The framework treats
423
+ * the mutator opaquely — it allocates and forwards the family's mutator
424
+ * instance so the operation-specific middleware runners can stay
425
+ * family-agnostic. SQL extends this with `SqlParamRefMutator` (over
426
+ * `ParamRef`); Mongo extends this with `MongoParamRefMutator` (over
427
+ * `MongoParamRef`).
435
428
  *
436
429
  * Extension authors target the family-specific mutator type, not this
437
430
  * marker.
@@ -449,66 +442,124 @@ type ParamRefMutator = {
449
442
  * `MongoMiddleware`) narrow `TPlan` to their concrete plan type.
450
443
  *
451
444
  * `TMutator` is the family-specific {@link ParamRefMutator} the runtime
452
- * threads into `beforeExecute(plan, ctx, params)` as a third argument.
453
- * Existing `(plan)` / `(plan, ctx)` middleware bodies continue to compile
454
- * TypeScript permits assigning a function with fewer parameters to a
455
- * function-typed slot that declares more. The third arg is additive.
445
+ * threads into `beforeQuery(plan, ctx, params)` or
446
+ * `beforeExecute(plan, ctx, params)` as a third argument. Existing
447
+ * `(plan)` / `(plan, ctx)` middleware bodies continue to compile TypeScript
448
+ * permits assigning a function with fewer parameters to a function-typed slot
449
+ * that declares more. The third arg is additive.
456
450
  */
457
451
  interface RuntimeMiddleware<TPlan extends QueryPlan = QueryPlan, TMutator extends ParamRefMutator = ParamRefMutator> {
458
452
  readonly name: string;
459
453
  readonly familyId?: string;
460
454
  readonly targetId?: string;
461
455
  /**
462
- * Optional short-circuit hook. Runs inside `runWithMiddleware`, after
463
- * the orchestrator receives the lowered plan and before any
464
- * `beforeExecute` hook fires. Middleware run in registration order; the
465
- * first to return a non-`undefined` `InterceptResult` wins, and
466
- * subsequent middleware's `intercept` does not fire.
456
+ * Fires after the family runtime has produced a draft execution plan from
457
+ * the AST, but before the family encodes parameter values to driver wire
458
+ * format. Mutations applied via the family-specific `params` mutator are
459
+ * visible to the subsequent encode step.
460
+ *
461
+ * Lifecycle position (SQL example):
462
+ * `runBeforeCompile → lowerSqlPlan → beforeQuery → encodeParams → interceptQuery → driver query`.
463
+ *
464
+ * The `params` argument is a family-specific {@link ParamRefMutator}
465
+ * scoped to the value slots of `ParamRef` nodes in the plan's AST.
466
+ * Middleware that doesn't need to mutate params can ignore the argument;
467
+ * existing `(plan)` / `(plan, ctx)` bodies stay compatible.
468
+ *
469
+ * `ctx.signal` carries the per-operation `AbortSignal`; middleware that
470
+ * wraps a network SDK forwards it. Cooperative cancellation surfaces a
471
+ * `RUNTIME.ABORTED { phase: 'beforeQuery' }` envelope promptly even when the
472
+ * body ignores the signal.
473
+ *
474
+ * Intercept ordering: `interceptQuery` runs *after* this hook; an
475
+ * interceptor that short-circuits the driver path still observes the
476
+ * post-`beforeQuery`, fully-encoded plan. The trade-off is that any
477
+ * `beforeQuery` SDK round-trips happen even when a downstream interceptor
478
+ * would have skipped the driver entirely.
479
+ */
480
+ beforeQuery?(plan: TPlan, ctx: RuntimeMiddlewareContext, params?: TMutator): void | Promise<void>;
481
+ /**
482
+ * Optional short-circuit hook for query executions. Runs inside
483
+ * `runQueryWithMiddleware`, after the orchestrator receives the lowered plan
484
+ * and after the `beforeQuery` hook fires. Middleware run in registration
485
+ * order; the first to return a non-`undefined` `QueryInterceptResult` wins,
486
+ * and subsequent middleware's `interceptQuery` does not fire.
467
487
  *
468
- * On a hit, `beforeExecute`, `runDriver`, and `onRow` are all skipped.
469
- * `afterExecute` still fires with `source: 'middleware'`.
488
+ * On a hit, `beforeQuery` has already fired; `runDriver` and `onRow` are
489
+ * skipped. `afterQuery` still fires with `source: 'middleware'`.
470
490
  *
471
- * Returning `undefined` (or omitting the hook entirely) signals
472
- * passthrough — execution proceeds through the normal driver path.
491
+ * Returning `undefined` (or omitting the hook entirely) signals passthrough
492
+ * — execution proceeds through the normal driver path.
473
493
  *
474
- * Errors thrown inside `intercept` are rethrown by `runWithMiddleware`
475
- * as the original `Error` — no envelope is guaranteed at this layer.
476
- * Before rethrowing, `afterExecute` fires with `completed: false` and
477
- * `source: 'middleware'`. Errors thrown by `afterExecute` during the
478
- * error path remain swallowed (existing semantics, unchanged).
494
+ * Errors thrown inside `interceptQuery` are rethrown by
495
+ * `runQueryWithMiddleware` as the original `Error` — no envelope is
496
+ * guaranteed at this layer. Before rethrowing, `afterQuery` fires with
497
+ * `completed: false` and `source: 'middleware'`. Errors thrown by
498
+ * `afterQuery` during the error path remain swallowed (existing semantics,
499
+ * unchanged).
479
500
  *
480
- * Used by middleware that need to short-circuit execution and supply
501
+ * Used by middleware that need to short-circuit query execution and supply
481
502
  * rows directly: caching, mocks, rate limiting, circuit breaking.
503
+ *
504
+ * `rows` accepts both `Iterable` (arrays, sync generators) and `AsyncIterable`
505
+ * (async generators). `for await` natively handles both via
506
+ * `Symbol.asyncIterator` / `Symbol.iterator` fallback, so the orchestrator
507
+ * does not need to branch on the variant. Cached arrays in the cache
508
+ * middleware are the common case; streaming variants support future use
509
+ * cases like mock layers replaying recordings.
510
+ *
511
+ * Row shape is `Record<string, unknown>` — the same untyped shape `onRow`
512
+ * receives. The SQL runtime decodes intercepted rows through its normal
513
+ * codec pass, so interceptors cache and return raw (undecoded) rows.
482
514
  */
483
- intercept?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<InterceptResult | undefined>;
515
+ interceptQuery?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<QueryInterceptResult | undefined>;
516
+ onRow?(row: Record<string, unknown>, plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<void>;
517
+ afterQuery?(plan: TPlan, result: AfterQueryResult, ctx: RuntimeMiddlewareContext): Promise<void>;
484
518
  /**
485
- * Fires after the family runtime has produced a draft execution
486
- * plan from the AST, but before the family encodes parameter values
487
- * to driver wire format. Mutations applied via the
488
- * family-specific `params` mutator are visible to the subsequent
489
- * encode step.
519
+ * Fires after the family runtime has produced a draft execution plan from
520
+ * the AST, but before the family encodes parameter values to driver wire
521
+ * format. Mutations applied via the family-specific `params` mutator are
522
+ * visible to the subsequent encode step.
490
523
  *
491
524
  * Lifecycle position (SQL example):
492
- * `runBeforeCompile → lowerSqlPlan → beforeExecute → encodeParams → intercept → driver`.
525
+ * `runBeforeCompile → lowerSqlPlan → beforeExecute → encodeParams → interceptExecute → driver execute`.
493
526
  *
494
527
  * The `params` argument is a family-specific {@link ParamRefMutator}
495
528
  * scoped to the value slots of `ParamRef` nodes in the plan's AST.
496
- * Middleware that doesn't need to mutate params can ignore the
497
- * argument; existing `(plan)` / `(plan, ctx)` bodies stay compatible.
529
+ * Middleware that doesn't need to mutate params can ignore the argument;
530
+ * existing `(plan)` / `(plan, ctx)` bodies stay compatible.
498
531
  *
499
- * `ctx.signal` carries the per-query `AbortSignal`; middleware that
500
- * wraps a network SDK forwards it. Cooperative cancellation
501
- * surfaces a `RUNTIME.ABORTED { phase: 'beforeExecute' }` envelope
502
- * promptly even when the body ignores the signal.
532
+ * `ctx.signal` carries the per-operation `AbortSignal`; middleware that
533
+ * wraps a network SDK forwards it. Cooperative cancellation surfaces a
534
+ * `RUNTIME.ABORTED { phase: 'beforeExecute' }` envelope promptly even when
535
+ * the body ignores the signal.
503
536
  *
504
- * Intercept ordering: `intercept` runs *after* this hook; an
505
- * interceptor that short-circuits the driver path still observes
506
- * the post-`beforeExecute`, fully-encoded plan. The trade-off is
507
- * that any `beforeExecute` SDK round-trips happen even when a
508
- * downstream interceptor would have skipped the driver entirely.
537
+ * Intercept ordering: `interceptExecute` runs *after* this hook; an
538
+ * interceptor that short-circuits the driver path still observes the
539
+ * post-`beforeExecute`, fully-encoded plan. The trade-off is that any
540
+ * `beforeExecute` SDK round-trips happen even when a downstream interceptor
541
+ * would have skipped the driver entirely.
509
542
  */
510
543
  beforeExecute?(plan: TPlan, ctx: RuntimeMiddlewareContext, params?: TMutator): void | Promise<void>;
511
- onRow?(row: Record<string, unknown>, plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<void>;
544
+ /**
545
+ * Optional short-circuit hook for execute operations. Middleware run in
546
+ * registration order; the first to return a non-`undefined`
547
+ * `ExecuteInterceptResult` wins, and subsequent middleware's
548
+ * `interceptExecute` does not fire.
549
+ *
550
+ * On a hit, `beforeExecute` has already fired; only the driver execute is
551
+ * skipped. The statistics supplied in `stats` are returned eagerly; there is
552
+ * no row stream and `onRow` is not fired. `afterExecute` still fires with
553
+ * `source: 'middleware'`.
554
+ *
555
+ * Returning `undefined` (or omitting the hook entirely) signals passthrough
556
+ * — execution proceeds through the normal driver path. Errors thrown inside
557
+ * `interceptExecute` are rethrown by `runExecuteWithMiddleware` as the
558
+ * original `Error`. Before rethrowing, `afterExecute` fires with
559
+ * `completed: false`; errors thrown by `afterExecute` during the error path
560
+ * remain swallowed.
561
+ */
562
+ interceptExecute?(plan: TPlan, ctx: RuntimeMiddlewareContext): Promise<ExecuteInterceptResult | undefined>;
512
563
  afterExecute?(plan: TPlan, result: AfterExecuteResult, ctx: RuntimeMiddlewareContext): Promise<void>;
513
564
  }
514
565
  /**
@@ -537,47 +588,100 @@ type CrossFamilyMiddleware<TPlan extends QueryPlan = QueryPlan> = RuntimeMiddlew
537
588
  readonly targetId?: undefined;
538
589
  };
539
590
  /**
540
- * Optional per-`execute` options accepted by every family runtime.
591
+ * Optional per-operation options accepted by every family runtime.
541
592
  *
542
- * `signal` is the per-query cancellation signal. The runtime threads the
543
- * signal through to every codec call for the query and uses it to short-
544
- * circuit the row stream with `RUNTIME.ABORTED` when the caller aborts.
545
- * Omitting the option (or passing `undefined`) preserves today's behavior
546
- * bit-for-bit.
593
+ * `signal` is the per-operation cancellation signal. The runtime threads it
594
+ * through middleware and codec calls; query row streams stop with
595
+ * `RUNTIME.ABORTED` when the caller aborts. Omitting the option (or passing
596
+ * `undefined`) preserves today's behavior bit-for-bit.
547
597
  */
548
598
  interface RuntimeExecuteOptions {
549
599
  readonly signal?: AbortSignal;
550
600
  readonly scope?: 'runtime' | 'connection' | 'transaction';
551
601
  }
552
602
  /**
553
- * Cross-family SPI for any runtime that can execute plans and be shut down.
603
+ * Cross-family SPI for any runtime that can query or execute plans and be shut down.
554
604
  * Each family runtime (SQL, Mongo) satisfies this interface — SQL nominally,
555
605
  * Mongo structurally (due to its phantom Row parameter using a unique symbol).
556
606
  *
557
- * The `_row` intersection on `execute` connects the `Row` type parameter to the
607
+ * The `_row` intersection on `query` connects the `Row` type parameter to the
558
608
  * plan, mirroring how `QueryPlan<Row>` carries a phantom `_row?: Row`.
559
609
  */
610
+ interface RuntimeStatementStats {
611
+ readonly affectedRows: number;
612
+ }
560
613
  interface RuntimeExecutor<TPlan extends QueryPlan> {
561
- execute<Row>(plan: TPlan & {
614
+ query<Row>(plan: TPlan & {
562
615
  readonly _row?: Row;
563
616
  }, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
617
+ execute(plan: TPlan, options?: RuntimeExecuteOptions): Promise<RuntimeStatementStats>;
564
618
  close(): Promise<void>;
565
619
  }
566
620
  declare function checkMiddlewareCompatibility(middleware: RuntimeMiddleware, runtimeFamilyId: string, runtimeTargetId: string): void;
567
621
  //#endregion
568
622
  //#region src/execution/before-execute-chain.d.ts
623
+ /**
624
+ * Runs every middleware's `beforeQuery` hook in registration order,
625
+ * threading through the (optional) family-specific `paramsMutator`.
626
+ *
627
+ * Why this lives outside {@link runQueryWithMiddleware}: middleware that
628
+ * mutates parameter values (e.g. cipherstash's bulk-encrypt SDK
629
+ * round-trip) must run *before* the family runtime encodes those
630
+ * parameters to driver wire format. Family runtimes call
631
+ * `runBeforeQueryChain` between the AST → plan lowering step and
632
+ * the parameter encode step; the encode then observes the mutator's
633
+ * `currentParams()` view. `runQueryWithMiddleware` retains the rest of
634
+ * the query lifecycle (`interceptQuery`, driver/row source loop, `onRow`,
635
+ * `afterQuery`) but no longer fires `beforeQuery` itself.
636
+ *
637
+ * Lifecycle within this helper:
638
+ *
639
+ * 1. For each middleware in registration order, if `beforeQuery`
640
+ * is implemented:
641
+ * - `checkAborted(ctx, 'beforeQuery')` short-circuits if the
642
+ * caller already aborted at entry.
643
+ * - The hook is invoked with `(plan, ctx, paramsMutator)`. A
644
+ * middleware body that ignores the mutator stays compatible —
645
+ * JavaScript allows extra positional arguments.
646
+ * - If the hook returns a Promise, it is raced against
647
+ * `ctx.signal` via {@link raceAgainstAbort} so cooperative
648
+ * cancellation surfaces a `RUNTIME.ABORTED { phase:
649
+ * 'beforeQuery' }` envelope even when the body itself
650
+ * ignores the signal.
651
+ *
652
+ * Error propagation: any error thrown by a `beforeQuery` body
653
+ * (or surfaced by the abort race) propagates out of this helper
654
+ * unchanged. Family runtime entry points await this helper before invoking
655
+ * `runQueryWithMiddleware`, so a rejection prevents the runner and its
656
+ * `afterQuery` hook from running.
657
+ *
658
+ * Relationship to {@link runQueryWithMiddleware}: the framework's
659
+ * `RuntimeCore.query` template calls this helper between
660
+ * `lower(plan)` and `runQueryWithMiddleware(...)`. Family runtimes that
661
+ * override query preparation (e.g. SQL, which inlines lower + encode for
662
+ * direct mutator threading) call this helper themselves at the
663
+ * equivalent point — between the family's AST → draft-plan
664
+ * lowering and the parameter-encode step.
665
+ *
666
+ * Intercept ordering: this helper fires unconditionally before
667
+ * `runQueryWithMiddleware`. `interceptQuery` (inside
668
+ * `runQueryWithMiddleware`) therefore observes the post-`beforeQuery`
669
+ * plan — mutator mutations are visible in the params interceptors see.
670
+ * The trade-off is documented on `RuntimeMiddleware.interceptQuery`.
671
+ */
672
+ declare function runBeforeQueryChain<TExec extends ExecutionPlan, TMutator extends ParamRefMutator = ParamRefMutator>(plan: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec, TMutator>>, ctx: RuntimeMiddlewareContext, paramsMutator?: TMutator): Promise<void>;
569
673
  /**
570
674
  * Runs every middleware's `beforeExecute` hook in registration order,
571
675
  * threading through the (optional) family-specific `paramsMutator`.
572
676
  *
573
- * Why this lives outside {@link runWithMiddleware}: middleware that
677
+ * Why this lives outside {@link runExecuteWithMiddleware}: middleware that
574
678
  * mutates parameter values (e.g. cipherstash's bulk-encrypt SDK
575
679
  * round-trip) must run *before* the family runtime encodes those
576
680
  * parameters to driver wire format. Family runtimes call
577
681
  * `runBeforeExecuteChain` between the AST → plan lowering step and
578
682
  * the parameter encode step; the encode then observes the mutator's
579
- * `currentParams()` view. `runWithMiddleware` retains the rest of
580
- * the lifecycle (`intercept`, driver/row source loop, `onRow`,
683
+ * `currentParams()` view. `runExecuteWithMiddleware` retains the rest of
684
+ * the execute lifecycle (`interceptExecute`, driver statistics execution,
581
685
  * `afterExecute`) but no longer fires `beforeExecute` itself.
582
686
  *
583
687
  * Lifecycle within this helper:
@@ -597,23 +701,23 @@ declare function checkMiddlewareCompatibility(middleware: RuntimeMiddleware, run
597
701
  *
598
702
  * Error propagation: any error thrown by a `beforeExecute` body
599
703
  * (or surfaced by the abort race) propagates out of this helper
600
- * unchanged. The family runtime is responsible for converting it
601
- * into the appropriate `afterExecute(completed: false)` notification
602
- * once `runWithMiddleware` runs.
704
+ * unchanged. Family runtime entry points await this helper before invoking
705
+ * `runExecuteWithMiddleware`, so a rejection prevents the runner and its
706
+ * `afterExecute` hook from running.
603
707
  *
604
- * Relationship to {@link runWithMiddleware}: the framework's
708
+ * Relationship to {@link runExecuteWithMiddleware}: the framework's
605
709
  * `RuntimeCore.execute` template calls this helper between
606
- * `lower(plan)` and `runWithMiddleware(...)`. Family runtimes that
607
- * override `execute` (e.g. SQL, which inlines lower + encode for
710
+ * `lower(plan)` and `runExecuteWithMiddleware(...)`. Family runtimes that
711
+ * override execute (e.g. SQL, which inlines lower + encode for
608
712
  * direct mutator threading) call this helper themselves at the
609
713
  * equivalent point — between the family's AST → draft-plan
610
714
  * lowering and the parameter-encode step.
611
715
  *
612
716
  * Intercept ordering: this helper fires unconditionally before
613
- * `runWithMiddleware`. `intercept` (inside `runWithMiddleware`)
614
- * therefore observes the post-`beforeExecute` plan — mutator
615
- * mutations are visible in the params interceptors see. The
616
- * trade-off is documented on `RuntimeMiddleware.intercept`.
717
+ * `runExecuteWithMiddleware`. `interceptExecute` (inside
718
+ * `runExecuteWithMiddleware`) therefore observes the post-`beforeExecute`
719
+ * plan — mutator mutations are visible in the params interceptors see.
720
+ * The trade-off is documented on `RuntimeMiddleware.interceptExecute`.
617
721
  */
618
722
  declare function runBeforeExecuteChain<TExec extends ExecutionPlan, TMutator extends ParamRefMutator = ParamRefMutator>(plan: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec, TMutator>>, ctx: RuntimeMiddlewareContext, paramsMutator?: TMutator): Promise<void>;
619
723
  //#endregion
@@ -644,17 +748,18 @@ declare function runtimeError(code: string, message: string, details?: Record<st
644
748
  * - `'decode'` — abort fired during `decodeRow` / `decodeField`.
645
749
  * - `'stream'` — abort fired between rows or before any codec call
646
750
  * (already-aborted at entry).
647
- * - `'beforeExecute'` / `'afterExecute'` / `'onRow'` — abort fired
648
- * on entry to or during the corresponding middleware phase
751
+ * - `'beforeQuery'` / `'beforeExecute'` / `'afterQuery'` /
752
+ * `'afterExecute'` / `'onRow'` — abort fired on entry to or during
753
+ * the corresponding middleware phase
649
754
  * (cooperative cancellation per the param-transform seam).
650
755
  */
651
756
  declare const RUNTIME_ABORTED: "RUNTIME.ABORTED";
652
757
  /** Discriminator placed in `details.phase` of a `RUNTIME.ABORTED` envelope. */
653
- type RuntimeAbortedPhase = 'encode' | 'decode' | 'stream' | 'beforeExecute' | 'afterExecute' | 'onRow';
758
+ type RuntimeAbortedPhase = 'encode' | 'decode' | 'stream' | 'beforeQuery' | 'beforeExecute' | 'afterQuery' | 'afterExecute' | 'onRow';
654
759
  /**
655
760
  * Construct a `RUNTIME.ABORTED` envelope. Phase distinguishes where the
656
761
  * abort was observed — codec call sites (`encode` / `decode` / `stream`)
657
- * or middleware seams (`beforeExecute` / `afterExecute` / `onRow`), as
762
+ * or operation-specific middleware seams, as
658
763
  * enumerated on {@link RuntimeAbortedPhase}. Cause carries
659
764
  * `signal.reason` verbatim from the platform — native abort produces a
660
765
  * `DOMException`, explicit `controller.abort(reason)` produces whatever
@@ -710,49 +815,84 @@ declare function raceAgainstAbort<T>(work: Promise<T>, signal: AbortSignal | und
710
815
  //#endregion
711
816
  //#region src/execution/run-with-middleware.d.ts
712
817
  /**
713
- * Drives a single execution of `runDriver()` through the middleware
714
- * lifecycle's intercept + row-source + termination phases.
818
+ * Drives a single query execution of `runDriver()` through the middleware
819
+ * lifecycle's `interceptQuery` + row-source + termination phases.
715
820
  *
716
821
  * Lifecycle, in order:
717
- * 1. For each middleware in registration order: `intercept(exec, ctx)`. The
718
- * first non-`undefined` result wins; subsequent middleware's `intercept`
719
- * does not fire. On a hit, the runtime emits a `middleware.intercept`
720
- * debug event naming the winning middleware, switches the row source to
721
- * the intercepted rows, and proceeds with `source: 'middleware'`. On
722
- * all-passthrough (every `intercept` returns `undefined` or is omitted),
723
- * `source: 'driver'` is used and the row source is `runDriver()`.
822
+ * 1. For each middleware in registration order: `interceptQuery(exec, ctx)`.
823
+ * The first non-`undefined` result wins; subsequent middleware's
824
+ * `interceptQuery` does not fire. On a hit, the runtime emits a
825
+ * `middleware.interceptQuery` debug event naming the winning middleware,
826
+ * switches the row source to the intercepted rows, and proceeds with
827
+ * `source: 'middleware'`. On all-passthrough (every `interceptQuery`
828
+ * returns `undefined` or is omitted), `source: 'driver'` is used and the
829
+ * row source is `runDriver()`.
724
830
  * 2. Iterate the row source. On the driver path, for each row, for each
725
831
  * middleware in registration order: `onRow(row, exec, ctx)`; then yield
726
832
  * the row. On the intercepted hit path, `onRow` is skipped — intercepted
727
833
  * rows did not originate from a driver row stream — but rows are still
728
834
  * yielded to the consumer in order.
729
835
  * 3. On successful completion: for each middleware in registration order:
730
- * `afterExecute(exec, { rowCount, latencyMs, completed: true, source },
836
+ * `afterQuery(exec, { rowCount, latencyMs, completed: true, source },
731
837
  * ctx)`.
732
838
  * 4. On any error thrown during steps 1–2: for each middleware in
733
- * registration order: `afterExecute(exec, { rowCount, latencyMs,
734
- * completed: false, source }, ctx)`. Errors thrown by `afterExecute`
839
+ * registration order: `afterQuery(exec, { rowCount, latencyMs,
840
+ * completed: false, source }, ctx)`. Errors thrown by `afterQuery`
735
841
  * during the error path are swallowed so they do not mask the original
736
842
  * error. The original error is then rethrown.
737
843
  *
738
- * `beforeExecute` is **not** fired here — see
739
- * {@link runBeforeExecuteChain} in `before-execute-chain.ts`. Family
740
- * runtimes call that helper between the AST → plan lowering step and
741
- * the parameter encode step so middleware that mutates ParamRef
742
- * values (e.g. cipherstash bulk-encrypt) can have its mutations
743
- * visible to encode. `runWithMiddleware` operates on the fully-
744
- * encoded plan; interceptors therefore observe a fully-mutated,
844
+ * `beforeQuery` is **not** fired here — see
845
+ * {@link runBeforeQueryChain} in `before-execute-chain.ts`. Family runtimes
846
+ * call that helper between the AST → plan lowering step and the parameter
847
+ * encode step so middleware that mutates ParamRef values can have its
848
+ * mutations visible to encode. `runQueryWithMiddleware` operates on the
849
+ * fully-encoded plan; interceptors therefore observe a fully-mutated,
745
850
  * encoded plan.
746
851
  *
747
- * The `source` field on `AfterExecuteResult` lets observers (telemetry,
748
- * lints, budgets) distinguish driver-served from middleware-served
749
- * executions without needing their own out-of-band signal.
852
+ * The `source` field on `AfterQueryResult` lets observers (telemetry, lints,
853
+ * budgets) distinguish driver-served from middleware-served executions
854
+ * without needing their own out-of-band signal.
750
855
  *
751
856
  * This helper is the single canonical implementation of the
752
- * intercept-and-row-source loop; family runtimes should not
753
- * reimplement it.
857
+ * intercept-and-row-source loop; family runtimes should not reimplement it.
858
+ */
859
+ declare function runQueryWithMiddleware<TExec extends ExecutionPlan, Row>(exec: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec>>, ctx: RuntimeMiddlewareContext, runDriver: () => AsyncIterable<Row>): AsyncIterableResult<Row>;
860
+ /**
861
+ * Drives a single execute operation through the middleware
862
+ * `interceptExecute` + statistics + termination phases.
863
+ *
864
+ * Lifecycle, in order:
865
+ * 1. For each middleware in registration order: `interceptExecute(exec, ctx)`.
866
+ * The first non-`undefined` result wins; subsequent middleware's
867
+ * `interceptExecute` does not fire. On a hit, the runtime emits a
868
+ * `middleware.interceptExecute` debug event naming the winning middleware,
869
+ * uses the returned `stats`, and proceeds with `source: 'middleware'`.
870
+ * On all-passthrough (every `interceptExecute` returns `undefined` or is
871
+ * omitted), `source: 'driver'` is used and `runDriver()` supplies the
872
+ * statistics.
873
+ * 2. Execute operations return eager statistics. There is no row stream and
874
+ * `onRow` does not fire.
875
+ * 3. On successful completion: for each middleware in registration order:
876
+ * `afterExecute(exec, { stats, latencyMs, completed: true, source }, ctx)`.
877
+ * 4. On any error thrown during steps 1–2: for each middleware in
878
+ * registration order: `afterExecute(exec, { latencyMs, completed: false,
879
+ * source }, ctx)`. Errors thrown by `afterExecute` during the error path
880
+ * are swallowed so they do not mask the original error. The original
881
+ * error is then rethrown.
882
+ *
883
+ * `beforeExecute` is **not** fired here — see
884
+ * {@link runBeforeExecuteChain} in `before-execute-chain.ts`. Family runtimes
885
+ * call that helper between the AST → plan lowering step and the parameter
886
+ * encode step so middleware that mutates ParamRef values can have its
887
+ * mutations visible to encode. `runExecuteWithMiddleware` operates on the
888
+ * fully-encoded plan; interceptors therefore observe a fully-mutated,
889
+ * encoded plan.
890
+ *
891
+ * The `source` field on `AfterExecuteResult` lets observers (telemetry, lints,
892
+ * budgets) distinguish driver-served from middleware-served executions
893
+ * without needing their own out-of-band signal.
754
894
  */
755
- declare function runWithMiddleware<TExec extends ExecutionPlan, Row>(exec: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec>>, ctx: RuntimeMiddlewareContext, runDriver: () => AsyncIterable<Row>): AsyncIterableResult<Row>;
895
+ declare function runExecuteWithMiddleware<TExec extends ExecutionPlan>(exec: TExec, middleware: ReadonlyArray<RuntimeMiddleware<TExec>>, ctx: RuntimeMiddlewareContext, runDriver: () => Promise<RuntimeStatementStats>): Promise<RuntimeStatementStats>;
756
896
  //#endregion
757
897
  //#region src/execution/runtime-core.d.ts
758
898
  /**
@@ -769,34 +909,30 @@ interface RuntimeCoreOptions<TMiddleware extends RuntimeMiddleware<ExecutionPlan
769
909
  /**
770
910
  * Family-agnostic abstract runtime base.
771
911
  *
772
- * Defines the entire `execute(plan)` template in one place:
912
+ * Defines the shared operation-specific middleware lifecycles:
773
913
  *
774
914
  * 1. `runBeforeCompile(plan)` — concrete; defaults to identity. SQL overrides
775
- * this to run its `beforeCompile` middleware-hook chain.
915
+ * this to run its shared `beforeCompile` middleware-hook chain.
776
916
  * 2. `lower(plan)` — abstract. Each family produces its `*ExecutionPlan`
777
917
  * (SQL via `lowerSqlPlan`, Mongo via `adapter.lower`).
778
- * 3. `runBeforeExecuteChain(exec, this.middleware, this.ctx)` concrete;
779
- * runs every middleware's `beforeExecute` hook after lowering but
780
- * before the row source is opened. Family runtimes that need a
781
- * params mutator visible to a downstream encode step (SQL) override
782
- * `execute` and call this helper themselves at the equivalent
783
- * pre-encode point.
784
- * 4. `runWithMiddleware(exec, this.middleware, this.ctx,
785
- * () => runDriver(exec))` — concrete; runs the intercept chain,
786
- * drives the row source, fires `onRow` / `afterExecute`. Does
787
- * **not** fire `beforeExecute` — see step 3.
788
- *
789
- * Concrete subclasses must implement `lower`, `runDriver`, and `close`.
918
+ * 3. Queries run `beforeQuery`; statements run `beforeExecute`. Both chains
919
+ * run after lowering and before their matching driver terminal. Family
920
+ * runtimes that expose a params mutator to downstream encoding override
921
+ * the operation and call the matching helper at the pre-encode point.
922
+ * 4. The matching runner processes `interceptQuery` or `interceptExecute`
923
+ * before invoking the driver. Queries then fire `onRow` and `afterQuery`;
924
+ * statements fire `afterExecute`.
925
+ *
926
+ * Concrete subclasses must implement `lower`, `runDriver`, `runExecute`, and
927
+ * `close`.
790
928
  *
791
929
  * The class is generic over:
792
930
  * - `TPlan` — the family's pre-lowering plan type.
793
931
  * - `TExec` — the family's post-lowering (executable) plan type.
794
932
  * - `TMiddleware` — the family's middleware type. Constrained to
795
- * `RuntimeMiddleware<TExec>` because `runWithMiddleware` invokes the
796
- * `beforeExecute` / `onRow` / `afterExecute` hooks with the lowered
797
- * `TExec`. (The spec/plan wording "RuntimeMiddleware<TPlan>" is
798
- * tightened to `<TExec>` here so the helper call typechecks; the
799
- * intent is unchanged — middleware sees the post-lowering plan.)
933
+ * `RuntimeMiddleware<TExec>` because the operation-specific runners invoke
934
+ * hooks with the lowered `TExec`. Middleware therefore sees the
935
+ * post-lowering plan.
800
936
  */
801
937
  declare abstract class RuntimeCore<TPlan extends QueryPlan, TExec extends ExecutionPlan, TMiddleware extends RuntimeMiddleware<TExec>> implements RuntimeExecutor<TPlan> {
802
938
  protected readonly middleware: ReadonlyArray<TMiddleware>;
@@ -813,11 +949,10 @@ declare abstract class RuntimeCore<TPlan extends QueryPlan, TExec extends Execut
813
949
  * Family-specific: SQL produces `{ sql, params, ast?, ... }`; Mongo
814
950
  * produces `{ command, ... }`.
815
951
  *
816
- * `ctx` carries per-query cancellation (and any future fields on
817
- * `CodecCallContext`); concrete subclasses forward it to the
818
- * encode-side codec dispatch site (e.g. SQL's `encodeParams` in m2,
819
- * Mongo's `resolveValue` in m3). The runtime allocates one ctx per
820
- * `execute()` call and threads the same reference everywhere; the
952
+ * `ctx` carries per-operation cancellation (and any future fields on
953
+ * `CodecCallContext`); concrete subclasses forward it to the encode-side
954
+ * codec dispatch site. The runtime allocates one ctx per operation call
955
+ * and threads the same reference everywhere; the
821
956
  * `signal` field inside may be `undefined`, but the ctx object itself
822
957
  * is always present.
823
958
  */
@@ -826,17 +961,19 @@ declare abstract class RuntimeCore<TPlan extends QueryPlan, TExec extends Execut
826
961
  * Drive the underlying transport for a lowered `TExec`. Yields raw rows
827
962
  * directly from the driver as `Record<string, unknown>`; codec decoding
828
963
  * (if any) is the subclass's responsibility, applied by wrapping
829
- * `execute()` rather than living inside this hook.
964
+ * `query()` rather than living inside this hook.
830
965
  *
831
- * The `Row` type parameter on `execute()` is satisfied by the caller via
966
+ * The `Row` type parameter on `query()` is satisfied by the caller via
832
967
  * the plan's phantom `_row`; the runtime treats rows as opaque records
833
968
  * here and trusts the caller's row typing.
834
969
  */
835
970
  protected abstract runDriver(exec: TExec): AsyncIterable<Record<string, unknown>>;
971
+ protected abstract runExecute(exec: TExec): Promise<RuntimeStatementStats>;
836
972
  abstract close(): Promise<void>;
837
- execute<Row>(plan: TPlan & {
973
+ query<Row>(plan: TPlan & {
838
974
  readonly _row?: Row;
839
975
  }, options?: RuntimeExecuteOptions): AsyncIterableResult<Row>;
976
+ execute(plan: TPlan, options?: RuntimeExecuteOptions): Promise<RuntimeStatementStats>;
840
977
  }
841
978
  //#endregion
842
979
  //#region src/meta-builder.d.ts
@@ -897,5 +1034,5 @@ interface LaneMetaBuilder<K extends OperationKind> extends MetaBuilder<K> {
897
1034
  */
898
1035
  declare function createMetaBuilder<K extends OperationKind>(kind: K, terminalName: string): LaneMetaBuilder<K>;
899
1036
  //#endregion
900
- export { defineAnnotation as A, RuntimeMiddleware as C, checkAborted as D, assertAnnotationsApplicable as E, runtimeAborted as F, runtimeError as I, raceAgainstAbort as M, runBeforeExecuteChain as N, checkMiddlewareCompatibility as O, runWithMiddleware as P, RuntimeLog as S, ValidAnnotations as T, RuntimeCore as _, CrossFamilyMiddleware as a, RuntimeExecuteOptions as b, InterceptResult as c, OperationKind as d, ParamRefMutator as f, RuntimeAbortedPhase as g, ResultType as h, AsyncIterableResult as i, isRuntimeError as j, createMetaBuilder as k, LaneMetaBuilder as l, RUNTIME_ABORTED as m, AnnotationHandle as n, DefineAnnotationOptions as o, QueryPlan as p, AnnotationValue as r, ExecutionPlan as s, AfterExecuteResult as t, MetaBuilder as u, RuntimeCoreOptions as v, RuntimeMiddlewareContext as w, RuntimeExecutor as x, RuntimeErrorEnvelope as y };
901
- //# sourceMappingURL=runtime-Cne6hBaG.d.mts.map
1037
+ export { checkAborted as A, runtimeAborted as B, RuntimeExecutor as C, RuntimeStatementStats as D, RuntimeMiddlewareContext as E, raceAgainstAbort as F, runBeforeExecuteChain as I, runBeforeQueryChain as L, createMetaBuilder as M, defineAnnotation as N, ValidAnnotations as O, isRuntimeError as P, runExecuteWithMiddleware as R, RuntimeExecuteOptions as S, RuntimeMiddleware as T, runtimeError as V, ResultType as _, AsyncIterableResult as a, RuntimeCoreOptions as b, ExecuteInterceptResult as c, MetaBuilder as d, OperationKind as f, RUNTIME_ABORTED as g, QueryPlan as h, AnnotationValue as i, checkMiddlewareCompatibility as j, assertAnnotationsApplicable as k, ExecutionPlan as l, QueryInterceptResult as m, AfterQueryResult as n, CrossFamilyMiddleware as o, ParamRefMutator as p, AnnotationHandle as r, DefineAnnotationOptions as s, AfterExecuteResult as t, LaneMetaBuilder as u, RuntimeAbortedPhase as v, RuntimeLog as w, RuntimeErrorEnvelope as x, RuntimeCore as y, runQueryWithMiddleware as z };
1038
+ //# sourceMappingURL=runtime-Cuxw8obj.d.mts.map