1- import { PostgrestClient } from '../src/index'
2- import { Database } from './types.override'
3- import { TypeEqual , expectType } from './types'
4- import { SelectQueryError } from '../src/select-query-parser/utils'
1+ import type { RequiredDeep } from 'type-fest'
52import { z } from 'zod'
6- import { RequiredDeep } from 'type-fest'
3+ import { PostgrestClient } from '../src/index'
4+ import type { SelectQueryError } from '../src/select-query-parser/utils'
5+ import { expectType , type TypeEqual } from './types'
6+ import type { Database } from './types.override'
77
88const REST_URL = 'http://localhost:3000'
99const postgrest = new PostgrestClient < Database > ( REST_URL )
@@ -442,8 +442,7 @@ describe('advanced rpc', () => {
442442 . select ( 'channel_id, message, users(username, catchphrase)' )
443443 let result : Exclude < typeof res . data , null >
444444 let expected : RequiredDeep < z . infer < typeof SelectWithUsersSchema > > [ ]
445- // TODO: works with latest postgrest-meta type introspection
446- // expectType<TypeEqual<typeof result, typeof expected>>(true)
445+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
447446 expect ( res ) . toMatchInlineSnapshot ( `
448447 Object {
449448 "count": null,
@@ -503,8 +502,7 @@ describe('advanced rpc', () => {
503502 . select ( 'id, username, users(username, catchphrase)' )
504503 let result : Exclude < typeof res . data , null >
505504 let expected : RequiredDeep < z . infer < typeof SelectWithUsersProfileSchema > >
506- // TODO: works with latest postgrest-meta type introspection
507- // expectType<TypeEqual<typeof result, typeof expected>>(true)
505+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
508506 expect ( res ) . toMatchInlineSnapshot ( `
509507 Object {
510508 "count": null,
@@ -547,8 +545,7 @@ describe('advanced rpc', () => {
547545 let result : Exclude < typeof res . data , null >
548546 // Should be an error response due to ambiguous function resolution
549547 let expected : SelectQueryError < 'Could not choose the best candidate function between: public.postgrest_unresolvable_function(a => int4), public.postgrest_unresolvable_function(a => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved' >
550- // TODO: works with latest postgrest-meta type introspection
551- // expectType<TypeEqual<typeof result, typeof expected>>(true)
548+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
552549 expect ( res ) . toMatchInlineSnapshot ( `
553550 Object {
554551 "count": null,
@@ -572,8 +569,7 @@ describe('advanced rpc', () => {
572569 let result : Exclude < typeof res . data , null >
573570 // Should be an error response due to ambiguous function resolution
574571 let expected : SelectQueryError < 'Could not choose the best candidate function between: public.postgrest_unresolvable_function(a => int4), public.postgrest_unresolvable_function(a => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved' >
575- // TODO: works with latest postgrest-meta type introspection
576- // expectType<TypeEqual<typeof result, typeof expected>>(true)
572+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
577573 expect ( res ) . toMatchInlineSnapshot ( `
578574 Object {
579575 "count": null,
@@ -612,8 +608,7 @@ describe('advanced rpc', () => {
612608 } )
613609 let result : Exclude < typeof res . data , null >
614610 let expected : number
615- // TODO: works with latest postgrest-meta type introspection
616- // expectType<TypeEqual<typeof result, typeof expected>>(true)
611+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
617612 expect ( res ) . toMatchInlineSnapshot ( `
618613 Object {
619614 "count": null,
@@ -631,8 +626,7 @@ describe('advanced rpc', () => {
631626 } )
632627 let result : Exclude < typeof res . data , null >
633628 let expected : string
634- // TODO: works with latest postgrest-meta type introspection
635- // expectType<TypeEqual<typeof result, typeof expected>>(true)
629+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
636630 expect ( res ) . toMatchInlineSnapshot ( `
637631 Object {
638632 "count": null,
@@ -650,8 +644,7 @@ describe('advanced rpc', () => {
650644 } )
651645 let result : Exclude < typeof res . data , null >
652646 let expected : z . infer < typeof UserProfileSchema > [ ]
653- // TODO: works with latest postgrest-meta type introspection
654- // expectType<TypeEqual<typeof result, typeof expected>>(true)
647+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
655648 expect ( res ) . toMatchInlineSnapshot ( `
656649 Object {
657650 "count": null,
@@ -677,8 +670,7 @@ describe('advanced rpc', () => {
677670 let result : Exclude < typeof res . data , null >
678671 const ExpectedSchema = z . array ( MessagesWithoutBlurbSchema )
679672 let expected : RequiredDeep < z . infer < typeof ExpectedSchema > >
680- // TODO: works with latest postgrest-meta type introspection
681- // expectType<TypeEqual<typeof result, typeof expected>>(true)
673+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
682674 expect ( res ) . toMatchInlineSnapshot ( `
683675 Object {
684676 "count": null,
@@ -712,8 +704,7 @@ describe('advanced rpc', () => {
712704 let result : Exclude < typeof res . data , null >
713705 const ExpectedSchema = z . array ( MessagesWithoutBlurbSchema )
714706 let expected : RequiredDeep < z . infer < typeof ExpectedSchema > >
715- // TODO: works with latest postgrest-meta type introspection
716- // expectType<TypeEqual<typeof result, typeof expected>>(true)
707+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
717708 expect ( res ) . toMatchInlineSnapshot ( `
718709 Object {
719710 "count": null,
@@ -761,8 +752,7 @@ describe('advanced rpc', () => {
761752 } )
762753 let result : Exclude < typeof res . data , null >
763754 let expected : string
764- // TODO: works with latest postgrest-meta type introspection
765- // expectType<TypeEqual<typeof result, typeof expected>>(true)
755+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
766756 expect ( res ) . toMatchInlineSnapshot ( `
767757 Object {
768758 "count": null,
@@ -776,12 +766,9 @@ describe('advanced rpc', () => {
776766
777767 test ( 'polymorphic function with bool param' , async ( ) => {
778768 const res = await postgrest . rpc ( 'polymorphic_function_with_different_return' , {
779- // TODO: works with latest postgrest-meta type introspection
780- ////@ts -expect-error Type 'boolean' is not assignable to type 'string'
769+ // @ts -expect-error Type 'boolean' is not assignable to type 'string'
781770 '' : true ,
782771 } )
783- // TODO: works with latest postgrest-meta type introspection
784- // expectType<TypeEqual<typeof result, typeof expected>>(true)
785772 expect ( res ) . toMatchInlineSnapshot ( `
786773 Object {
787774 "count": null,
@@ -795,8 +782,7 @@ describe('advanced rpc', () => {
795782
796783 test ( 'polymorphic function with unnamed int param' , async ( ) => {
797784 const res = await postgrest . rpc (
798- // TODO: works with latest postgrest-meta type introspection
799- ////@ts -expect-error Argument of type '"polymorphic_function_with_unnamed_integer"' is not assignable to parameter of type '"blurb_message" | "function_returning_row" | "function_returning_set_of_rows"
785+ // @ts -expect-error Argument of type '"polymorphic_function_with_unnamed_integer"' is not assignable to parameter of type '"blurb_message" | "function_returning_row" | "function_returning_set_of_rows"
800786 'polymorphic_function_with_unnamed_integer' ,
801787 {
802788 '' : 1 ,
@@ -894,8 +880,7 @@ describe('advanced rpc', () => {
894880 } )
895881 let result : Exclude < typeof res . data , null >
896882 let expected : string
897- // TODO: works with latest postgrest-meta type introspection
898- // expectType<TypeEqual<typeof result, typeof expected>>(true)
883+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
899884 expect ( res ) . toMatchInlineSnapshot ( `
900885 Object {
901886 "count": null,
@@ -913,8 +898,7 @@ describe('advanced rpc', () => {
913898 } )
914899 let result : Exclude < typeof res . data , null >
915900 let expected : string
916- // TODO: works with latest postgrest-meta type introspection
917- // expectType<TypeEqual<typeof result, typeof expected>>(true)
901+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
918902 expect ( res ) . toMatchInlineSnapshot ( `
919903 Object {
920904 "count": null,
@@ -930,8 +914,7 @@ describe('advanced rpc', () => {
930914 const res = await postgrest . rpc ( 'polymorphic_function_with_unnamed_default' )
931915 let result : Exclude < typeof res . data , null >
932916 let expected : SelectQueryError < 'Could not choose the best candidate function between: public.polymorphic_function_with_unnamed_default(), public.polymorphic_function_with_unnamed_default( => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved' >
933- // TODO: works with latest postgrest-meta type introspection
934- // expectType<TypeEqual<typeof result, typeof expected>>(true)
917+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
935918 expect ( res ) . toMatchInlineSnapshot ( `
936919 Object {
937920 "count": null,
@@ -977,8 +960,7 @@ describe('advanced rpc', () => {
977960 } )
978961 let result : Exclude < typeof res . data , null >
979962 let expected : string
980- // TODO: works with latest postgrest-meta type introspection
981- // expectType<TypeEqual<typeof result, typeof expected>>(true)
963+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
982964 expect ( res ) . toMatchInlineSnapshot ( `
983965 Object {
984966 "count": null,
@@ -994,8 +976,7 @@ describe('advanced rpc', () => {
994976 const res = await postgrest . rpc ( 'polymorphic_function_with_unnamed_default_overload' )
995977 let result : Exclude < typeof res . data , null >
996978 let expected : SelectQueryError < 'Could not choose the best candidate function between: public.polymorphic_function_with_unnamed_default_overload(), public.polymorphic_function_with_unnamed_default_overload( => text). Try renaming the parameters or the function itself in the database so function overloading can be resolved' >
997- // TODO: works with latest postgrest-meta type introspection
998- // expectType<TypeEqual<typeof result, typeof expected>>(true)
979+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
999980 expect ( res ) . toMatchInlineSnapshot ( `
1000981 Object {
1001982 "count": null,
@@ -1041,8 +1022,7 @@ describe('advanced rpc', () => {
10411022 } )
10421023 let result : Exclude < typeof res . data , null >
10431024 let expected : string
1044- // TODO: works with latest postgrest-meta type introspection
1045- // expectType<TypeEqual<typeof result, typeof expected>>(true)
1025+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
10461026 expect ( res ) . toMatchInlineSnapshot ( `
10471027 Object {
10481028 "count": null,
@@ -1056,14 +1036,12 @@ describe('advanced rpc', () => {
10561036
10571037 test ( 'polymorphic function with unnamed default overload bool param' , async ( ) => {
10581038 const res = await postgrest . rpc ( 'polymorphic_function_with_unnamed_default_overload' , {
1059- // TODO: works with latest postgrest-meta type introspection
1060- ////@ts -expect-error Type 'boolean' is not assignable to type 'string'
1039+ // @ts -expect-error Type 'boolean' is not assignable to type 'string'
10611040 '' : true ,
10621041 } )
10631042 let result : Exclude < typeof res . data , null >
10641043 let expected : string
1065- // TODO: works with latest postgrest-meta type introspection
1066- // expectType<TypeEqual<typeof result, typeof expected>>(true)
1044+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
10671045 expect ( res ) . toMatchInlineSnapshot ( `
10681046 Object {
10691047 "count": null,
@@ -1078,9 +1056,8 @@ describe('advanced rpc', () => {
10781056 test ( 'function with blurb_message' , async ( ) => {
10791057 const res = await postgrest . rpc ( 'blurb_message' )
10801058 let result : Exclude < typeof res . data , null >
1081- let expected : never
1082- // TODO: works with latest postgrest-meta type introspection
1083- // expectType<TypeEqual<typeof result, typeof expected>>(true)
1059+ let expected : SelectQueryError < 'the function public.blurb_message with parameter or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache' >
1060+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
10841061 expect ( res ) . toMatchInlineSnapshot ( `
10851062 Object {
10861063 "count": null,
@@ -1110,8 +1087,7 @@ describe('advanced rpc', () => {
11101087 } )
11111088 let result : Exclude < typeof res . data , null >
11121089 let expected : SelectQueryError < 'the function public.blurb_message with parameter or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache' >
1113- // TODO: works with latest postgrest-meta type introspection
1114- // expectType<TypeEqual<typeof result, typeof expected>>(true)
1090+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
11151091 expect ( res ) . toMatchInlineSnapshot ( `
11161092 Object {
11171093 "count": null,
@@ -1275,7 +1251,7 @@ describe('advanced rpc', () => {
12751251test ( 'should be able to filter before and after select rpc' , async ( ) => {
12761252 const res = await postgrest
12771253 . rpc ( 'get_user_profile' , {
1278- //@ts -expect-error Type '{ username: string; }' is missing the following properties from type '{ age_range: unknown; catchphrase: unknown; data: unknown; status: "ONLINE" | "OFFLINE" | null; username: string; }': age_range, catchphrase, data, status
1254+ // @ts -expect-error Type '{ username: string; }' is missing the following properties from type '{ age_range: unknown; catchphrase: unknown; data: unknown; status: "ONLINE" | "OFFLINE" | null; username: string; }': age_range, catchphrase, data, status
12791255 user_row : { username : 'supabot' } ,
12801256 } )
12811257 . select ( 'id, username, users(username, catchphrase)' )
@@ -1292,7 +1268,7 @@ test('should be able to filter before and after select rpc', async () => {
12921268 ` )
12931269 const res2 = await postgrest
12941270 . rpc ( 'get_user_profile' , {
1295- //@ts -expect-error Type '{ username: string; }' is missing the following properties from type
1271+ // @ts -expect-error Type '{ username: string; }' is missing the following properties from type
12961272 user_row : { username : 'supabot' } ,
12971273 } )
12981274 // should also be able to fitler before the select
@@ -1310,7 +1286,7 @@ test('should be able to filter before and after select rpc', async () => {
13101286 ` )
13111287 const res3 = await postgrest
13121288 . rpc ( 'get_user_profile' , {
1313- //@ts -expect-error Type '{ username: string; }' is missing the following properties from type
1289+ // @ts -expect-error Type '{ username: string; }' is missing the following properties from type
13141290 user_row : { username : 'supabot' } ,
13151291 } )
13161292 // should also be able to fitler before the select
@@ -1374,7 +1350,6 @@ test('RPC call with subselect and computed field', async () => {
13741350 } )
13751351 )
13761352 let expected : z . infer < typeof ExpectedSchema >
1377- // TODO: works with latest postgrest-meta type introspection
1378- // expectType<TypeEqual<typeof result, typeof expected>>(true)
1353+ expectType < TypeEqual < typeof result , typeof expected > > ( true )
13791354 ExpectedSchema . parse ( res . data )
13801355} )
0 commit comments