@@ -28,6 +28,7 @@ import {
2828 generateSingleQueryHook ,
2929} from '../../core/codegen/queries' ;
3030import { generateSchemaTypesFile } from '../../core/codegen/schema-types-generator' ;
31+ import { generateTypesFile } from '../../core/codegen/types' ;
3132import type {
3233 CleanFieldType ,
3334 CleanOperation ,
@@ -335,6 +336,53 @@ describe('Query Hook Generators', () => {
335336 } ) ;
336337} ) ;
337338
339+ describe ( 'Regression: FindManyArgs TCondition type arg' , ( ) => {
340+ // Bug: queries.ts passed 3 type args to FindManyArgs (TSelect, TWhere, TOrderBy),
341+ // but the template defines 4 params: FindManyArgs<TSelect, TWhere, TCondition = never, TOrderBy = never>.
342+ // This caused TOrderBy to land in the TCondition slot, defaulting TOrderBy to `never`
343+ // and breaking all hook orderBy params.
344+
345+ it ( 'includes Condition type in imports and re-exports when condition is enabled' , ( ) => {
346+ const result = generateListQueryHook ( simpleUserTable , {
347+ reactQueryEnabled : true ,
348+ useCentralizedKeys : true ,
349+ condition : true ,
350+ } ) ;
351+ expect ( result . content ) . toContain ( 'UserCondition' ) ;
352+ expect ( result . content ) . toMatch (
353+ / i m p o r t t y p e \{ [ ^ } ] * U s e r C o n d i t i o n [ ^ } ] * \} f r o m " \. \. \/ \. \. \/ o r m \/ i n p u t - t y p e s " / ,
354+ ) ;
355+ expect ( result . content ) . toMatch (
356+ / e x p o r t t y p e \{ [ ^ } ] * U s e r C o n d i t i o n [ ^ } ] * \} f r o m " \. \. \/ \. \. \/ o r m \/ i n p u t - t y p e s " / ,
357+ ) ;
358+ } ) ;
359+
360+ it ( 'includes Condition type in FindManyArgs type arguments' , ( ) => {
361+ const result = generateListQueryHook ( simpleUserTable , {
362+ reactQueryEnabled : true ,
363+ useCentralizedKeys : false ,
364+ condition : true ,
365+ } ) ;
366+ // FindManyArgs should have 4 type args: unknown, UserFilter, UserCondition, UsersOrderBy
367+ expect ( result . content ) . toMatch (
368+ / F i n d M a n y A r g s < u n k n o w n , U s e r F i l t e r , U s e r C o n d i t i o n , U s e r s O r d e r B y > / ,
369+ ) ;
370+ } ) ;
371+
372+ it ( 'omits Condition type when condition is disabled' , ( ) => {
373+ const result = generateListQueryHook ( simpleUserTable , {
374+ reactQueryEnabled : true ,
375+ useCentralizedKeys : false ,
376+ condition : false ,
377+ } ) ;
378+ // FindManyArgs should have 3 type args: unknown, UserFilter, UsersOrderBy
379+ expect ( result . content ) . toMatch (
380+ / F i n d M a n y A r g s < u n k n o w n , U s e r F i l t e r , U s e r s O r d e r B y > / ,
381+ ) ;
382+ expect ( result . content ) . not . toContain ( 'UserCondition' ) ;
383+ } ) ;
384+ } ) ;
385+
338386describe ( 'Mutation Hook Generators' , ( ) => {
339387 describe ( 'generateCreateMutationHook' , ( ) => {
340388 it ( 'generates create mutation hook for simple table' , ( ) => {
@@ -644,3 +692,27 @@ describe('Barrel File Generators', () => {
644692 } ) ;
645693 } ) ;
646694} ) ;
695+
696+ describe ( 'Regression: VectorFilter in types.ts' , ( ) => {
697+ // Bug: VectorFilter was generated in ORM input-types-generator.ts but was missing
698+ // from the React types.ts FILTER_CONFIGS. schema-types.ts imports VectorFilter
699+ // from types.ts, so the missing export caused build failures.
700+
701+ it ( 'exports VectorFilter interface from types.ts' , ( ) => {
702+ const result = generateTypesFile ( [ simpleUserTable ] ) ;
703+ expect ( result ) . toContain ( 'export interface VectorFilter {' ) ;
704+ } ) ;
705+
706+ it ( 'VectorFilter has equality and distinct operators with number[] type' , ( ) => {
707+ const result = generateTypesFile ( [ simpleUserTable ] ) ;
708+ expect ( result ) . toContain ( 'export interface VectorFilter {' ) ;
709+ // equality operators
710+ expect ( result ) . toMatch ( / i s N u l l \? : \s * b o o l e a n / ) ;
711+ // VectorFilter uses number[] type
712+ expect ( result ) . toMatch ( / e q u a l T o \? : \s * n u m b e r \[ \] / ) ;
713+ expect ( result ) . toMatch ( / n o t E q u a l T o \? : \s * n u m b e r \[ \] / ) ;
714+ // distinct operators
715+ expect ( result ) . toMatch ( / d i s t i n c t F r o m \? : \s * n u m b e r \[ \] / ) ;
716+ expect ( result ) . toMatch ( / n o t D i s t i n c t F r o m \? : \s * n u m b e r \[ \] / ) ;
717+ } ) ;
718+ } ) ;
0 commit comments