turbine-orm 0.28.2 → 0.28.3

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.
@@ -523,7 +523,7 @@ function generateIndex(schema) {
523
523
  const lines = [
524
524
  ...generatedFileHeader(),
525
525
  "import { TurbineClient as BaseTurbineClient, TransactionClient as BaseTransactionClient, QueryInterface } from 'turbine-orm';",
526
- "import type { TurbineConfig, TransactionOptions } from 'turbine-orm';",
526
+ "import type { TurbineConfig, TransactionOptions, DeferredQuery, PipelineResults } from 'turbine-orm';",
527
527
  "import { SCHEMA } from './metadata.js';",
528
528
  ];
529
529
  // Import all entity types and relations maps
@@ -607,9 +607,13 @@ function generateIndex(schema) {
607
607
  lines.push('');
608
608
  // Augment TurbineClient via interface merging with a typed $transaction
609
609
  // overload. The callback parameter is narrowed to `TypedTransactionClient`
610
- // so users get autocomplete on `tx.users`, `tx.posts`, etc. The base
611
- // signature (callback parameter `BaseTransactionClient`) remains valid as
612
- // an overload, so prior usage continues to typecheck.
610
+ // so users get autocomplete on `tx.users`, `tx.posts`, etc.
611
+ //
612
+ // IMPORTANT: the merged member must be compatible with the base class's
613
+ // $transaction ON ITS OWN (TS2415) — since v0.26 the base method also has a
614
+ // batch-array overload (`$transaction([...queries])`), so the merged
615
+ // interface must redeclare BOTH signatures. Emitting only the callback form
616
+ // makes every generated client fail `tsc` with "incorrectly extends".
613
617
  lines.push('export interface TurbineClient {');
614
618
  lines.push(' /**');
615
619
  lines.push(' * Run a callback inside a transaction. The callback receives a typed');
@@ -619,6 +623,13 @@ function generateIndex(schema) {
619
623
  lines.push(' fn: (tx: TypedTransactionClient) => Promise<R>,');
620
624
  lines.push(' options?: TransactionOptions,');
621
625
  lines.push(' ): Promise<R>;');
626
+ lines.push(' /**');
627
+ lines.push(' * Batch form: run several deferred queries in one transaction and get');
628
+ lines.push(' * their results as a tuple (same as the base client).');
629
+ lines.push(' */');
630
+ lines.push(' $transaction<T extends readonly DeferredQuery<unknown>[]>(');
631
+ lines.push(' queries: readonly [...T],');
632
+ lines.push(' ): Promise<PipelineResults<T>>;');
622
633
  lines.push('}');
623
634
  lines.push('');
624
635
  // Factory function with JSDoc
package/dist/generate.js CHANGED
@@ -516,7 +516,7 @@ export function generateIndex(schema) {
516
516
  const lines = [
517
517
  ...generatedFileHeader(),
518
518
  "import { TurbineClient as BaseTurbineClient, TransactionClient as BaseTransactionClient, QueryInterface } from 'turbine-orm';",
519
- "import type { TurbineConfig, TransactionOptions } from 'turbine-orm';",
519
+ "import type { TurbineConfig, TransactionOptions, DeferredQuery, PipelineResults } from 'turbine-orm';",
520
520
  "import { SCHEMA } from './metadata.js';",
521
521
  ];
522
522
  // Import all entity types and relations maps
@@ -600,9 +600,13 @@ export function generateIndex(schema) {
600
600
  lines.push('');
601
601
  // Augment TurbineClient via interface merging with a typed $transaction
602
602
  // overload. The callback parameter is narrowed to `TypedTransactionClient`
603
- // so users get autocomplete on `tx.users`, `tx.posts`, etc. The base
604
- // signature (callback parameter `BaseTransactionClient`) remains valid as
605
- // an overload, so prior usage continues to typecheck.
603
+ // so users get autocomplete on `tx.users`, `tx.posts`, etc.
604
+ //
605
+ // IMPORTANT: the merged member must be compatible with the base class's
606
+ // $transaction ON ITS OWN (TS2415) — since v0.26 the base method also has a
607
+ // batch-array overload (`$transaction([...queries])`), so the merged
608
+ // interface must redeclare BOTH signatures. Emitting only the callback form
609
+ // makes every generated client fail `tsc` with "incorrectly extends".
606
610
  lines.push('export interface TurbineClient {');
607
611
  lines.push(' /**');
608
612
  lines.push(' * Run a callback inside a transaction. The callback receives a typed');
@@ -612,6 +616,13 @@ export function generateIndex(schema) {
612
616
  lines.push(' fn: (tx: TypedTransactionClient) => Promise<R>,');
613
617
  lines.push(' options?: TransactionOptions,');
614
618
  lines.push(' ): Promise<R>;');
619
+ lines.push(' /**');
620
+ lines.push(' * Batch form: run several deferred queries in one transaction and get');
621
+ lines.push(' * their results as a tuple (same as the base client).');
622
+ lines.push(' */');
623
+ lines.push(' $transaction<T extends readonly DeferredQuery<unknown>[]>(');
624
+ lines.push(' queries: readonly [...T],');
625
+ lines.push(' ): Promise<PipelineResults<T>>;');
615
626
  lines.push('}');
616
627
  lines.push('');
617
628
  // Factory function with JSDoc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbine-orm",
3
- "version": "0.28.2",
3
+ "version": "0.28.3",
4
4
  "description": "Postgres-native TypeScript ORM — runs on Neon, Vercel Postgres, Cloudflare, Supabase. Streaming cursors, typed errors, single-query nested relations. One dependency, no WASM engine",
5
5
  "type": "module",
6
6
  "exports": {