diff --git a/packages/core/postgrest-js/test/advanced_rpc.test.ts b/packages/core/postgrest-js/test/advanced_rpc.test.ts index fbbc145b4..73942b131 100644 --- a/packages/core/postgrest-js/test/advanced_rpc.test.ts +++ b/packages/core/postgrest-js/test/advanced_rpc.test.ts @@ -1,9 +1,9 @@ -import { PostgrestClient } from '../src/index' -import { Database } from './types.override' -import { TypeEqual, expectType } from './types' -import { SelectQueryError } from '../src/select-query-parser/utils' +import type { RequiredDeep } from 'type-fest' import { z } from 'zod' -import { RequiredDeep } from 'type-fest' +import { PostgrestClient } from '../src/index' +import type { SelectQueryError } from '../src/select-query-parser/utils' +import { expectType, type TypeEqual } from './types' +import type { Database } from './types.override' const REST_URL = 'http://localhost:3000' const postgrest = new PostgrestClient(REST_URL) @@ -442,8 +442,7 @@ describe('advanced rpc', () => { .select('channel_id, message, users(username, catchphrase)') let result: Exclude let expected: RequiredDeep>[] - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -503,8 +502,7 @@ describe('advanced rpc', () => { .select('id, username, users(username, catchphrase)') let result: Exclude let expected: RequiredDeep> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -547,8 +545,7 @@ describe('advanced rpc', () => { let result: Exclude // Should be an error response due to ambiguous function resolution 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'> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -572,8 +569,7 @@ describe('advanced rpc', () => { let result: Exclude // Should be an error response due to ambiguous function resolution 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'> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -612,8 +608,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: number - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -631,8 +626,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -650,8 +644,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: z.infer[] - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -677,8 +670,7 @@ describe('advanced rpc', () => { let result: Exclude const ExpectedSchema = z.array(MessagesWithoutBlurbSchema) let expected: RequiredDeep> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -712,8 +704,7 @@ describe('advanced rpc', () => { let result: Exclude const ExpectedSchema = z.array(MessagesWithoutBlurbSchema) let expected: RequiredDeep> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -761,8 +752,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -776,12 +766,9 @@ describe('advanced rpc', () => { test('polymorphic function with bool param', async () => { const res = await postgrest.rpc('polymorphic_function_with_different_return', { - // TODO: works with latest postgrest-meta type introspection - ////@ts-expect-error Type 'boolean' is not assignable to type 'string' + // @ts-expect-error Type 'boolean' is not assignable to type 'string' '': true, }) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -795,8 +782,7 @@ describe('advanced rpc', () => { test('polymorphic function with unnamed int param', async () => { const res = await postgrest.rpc( - // TODO: works with latest postgrest-meta type introspection - ////@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" + // @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" 'polymorphic_function_with_unnamed_integer', { '': 1, @@ -894,8 +880,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -913,8 +898,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -930,8 +914,7 @@ describe('advanced rpc', () => { const res = await postgrest.rpc('polymorphic_function_with_unnamed_default') let result: Exclude 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'> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -977,8 +960,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -994,8 +976,7 @@ describe('advanced rpc', () => { const res = await postgrest.rpc('polymorphic_function_with_unnamed_default_overload') let result: Exclude 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'> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -1041,8 +1022,7 @@ describe('advanced rpc', () => { }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -1056,14 +1036,12 @@ describe('advanced rpc', () => { test('polymorphic function with unnamed default overload bool param', async () => { const res = await postgrest.rpc('polymorphic_function_with_unnamed_default_overload', { - // TODO: works with latest postgrest-meta type introspection - ////@ts-expect-error Type 'boolean' is not assignable to type 'string' + // @ts-expect-error Type 'boolean' is not assignable to type 'string' '': true, }) let result: Exclude let expected: string - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -1078,9 +1056,8 @@ describe('advanced rpc', () => { test('function with blurb_message', async () => { const res = await postgrest.rpc('blurb_message') let result: Exclude - let expected: never - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + 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'> + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -1110,8 +1087,7 @@ describe('advanced rpc', () => { }) let result: Exclude 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'> - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) expect(res).toMatchInlineSnapshot(` Object { "count": null, @@ -1275,7 +1251,7 @@ describe('advanced rpc', () => { test('should be able to filter before and after select rpc', async () => { const res = await postgrest .rpc('get_user_profile', { - //@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 + // @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 user_row: { username: 'supabot' }, }) .select('id, username, users(username, catchphrase)') @@ -1292,7 +1268,7 @@ test('should be able to filter before and after select rpc', async () => { `) const res2 = await postgrest .rpc('get_user_profile', { - //@ts-expect-error Type '{ username: string; }' is missing the following properties from type + // @ts-expect-error Type '{ username: string; }' is missing the following properties from type user_row: { username: 'supabot' }, }) // 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 () => { `) const res3 = await postgrest .rpc('get_user_profile', { - //@ts-expect-error Type '{ username: string; }' is missing the following properties from type + // @ts-expect-error Type '{ username: string; }' is missing the following properties from type user_row: { username: 'supabot' }, }) // should also be able to fitler before the select @@ -1374,7 +1350,6 @@ test('RPC call with subselect and computed field', async () => { }) ) let expected: z.infer - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) diff --git a/packages/core/postgrest-js/test/db/docker-compose.yml b/packages/core/postgrest-js/test/db/docker-compose.yml index c69a68e2e..7d2818653 100644 --- a/packages/core/postgrest-js/test/db/docker-compose.yml +++ b/packages/core/postgrest-js/test/db/docker-compose.yml @@ -39,7 +39,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres pgmeta: - image: supabase/postgres-meta:v0.91.5 + image: supabase/postgres-meta:v0.92.0 ports: - '8080:8080' environment: diff --git a/packages/core/postgrest-js/test/embeded_functions_join.test.ts b/packages/core/postgrest-js/test/embeded_functions_join.test.ts index 3c63b20fa..1a69cae91 100644 --- a/packages/core/postgrest-js/test/embeded_functions_join.test.ts +++ b/packages/core/postgrest-js/test/embeded_functions_join.test.ts @@ -1,8 +1,8 @@ -import { PostgrestClient } from '../src/index' -import { Database } from './types.override' -import { expectType, TypeEqual } from './types' +import type { RequiredDeep } from 'type-fest' import { z } from 'zod' -import { RequiredDeep } from 'type-fest' +import { PostgrestClient } from '../src/index' +import { expectType, type TypeEqual } from './types' +import type { Database } from './types.override' const REST_URL = 'http://localhost:3000' const postgrest = new PostgrestClient(REST_URL) @@ -75,8 +75,7 @@ describe('embeded functions select', () => { // Assert over the keys of the expected and result objects to ensure consistency between versions of types // should always fallback to a SelectQueryError if the relation cannot be found expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -135,8 +134,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -211,8 +209,7 @@ describe('embeded functions select', () => { ) let expected: RequiredDeep> expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -277,8 +274,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -347,8 +343,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -403,8 +398,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -469,8 +463,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -512,8 +505,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) // Can parse the data because the !inner ensure the join result from function is not nullable ExpectedSchema.parse(res.data) }) @@ -573,8 +565,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -649,8 +640,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -725,8 +715,7 @@ describe('embeded functions select', () => { ) let expected: RequiredDeep> expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -799,8 +788,7 @@ describe('embeded functions select', () => { ) let expected: RequiredDeep> expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -877,8 +865,7 @@ describe('embeded functions select', () => { ) let expected: RequiredDeep> expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -951,8 +938,7 @@ describe('embeded functions select', () => { ) let expected: RequiredDeep> expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -1021,8 +1007,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -1044,8 +1029,7 @@ describe('embeded functions select', () => { `) let result: Exclude let expected: never[] - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) }) test('embeded_function_returning_single_row - can embed single row returns function with row single param', async () => { @@ -1095,8 +1079,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -1120,8 +1103,7 @@ describe('embeded functions select', () => { `) let result: Exclude let expected: never[] - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) }) test('function_using_setof_rows_one', async () => { @@ -1185,8 +1167,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) @@ -1241,8 +1222,7 @@ describe('embeded functions select', () => { ) let expected: z.infer expectType>(true) - // TODO: works with latest postgrest-meta type introspection - // expectType>(true) + expectType>(true) ExpectedSchema.parse(res.data) }) }) diff --git a/packages/core/postgrest-js/test/types.generated.ts b/packages/core/postgrest-js/test/types.generated.ts index ea731f970..373ccea56 100644 --- a/packages/core/postgrest-js/test/types.generated.ts +++ b/packages/core/postgrest-js/test/types.generated.ts @@ -5,19 +5,19 @@ export type Database = { Tables: { users: { Row: { - age_range: unknown | null + age_range: unknown data: Json | null status: Database['personal']['Enums']['user_status'] | null username: string } Insert: { - age_range?: unknown | null + age_range?: unknown data?: Json | null status?: Database['personal']['Enums']['user_status'] | null username: string } Update: { - age_range?: unknown | null + age_range?: unknown data?: Json | null status?: Database['personal']['Enums']['user_status'] | null username?: string @@ -406,17 +406,17 @@ export type Database = { Row: { address: string | null id: number - shop_geom: unknown | null + shop_geom: unknown } Insert: { address?: string | null id: number - shop_geom?: unknown | null + shop_geom?: unknown } Update: { address?: string | null id?: number - shop_geom?: unknown | null + shop_geom?: unknown } Relationships: [] } @@ -466,22 +466,22 @@ export type Database = { } users: { Row: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string } Insert: { - age_range?: unknown | null - catchphrase?: unknown | null + age_range?: unknown + catchphrase?: unknown data?: Json | null status?: Database['public']['Enums']['user_status'] | null username: string } Update: { - age_range?: unknown | null - catchphrase?: unknown | null + age_range?: unknown + catchphrase?: unknown data?: Json | null status?: Database['public']['Enums']['user_status'] | null username?: string @@ -492,22 +492,22 @@ export type Database = { Views: { active_users: { Row: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string | null } Insert: { - age_range?: unknown | null - catchphrase?: unknown | null + age_range?: unknown + catchphrase?: unknown data?: Json | null status?: Database['public']['Enums']['user_status'] | null username?: string | null } Update: { - age_range?: unknown | null - catchphrase?: unknown | null + age_range?: unknown + catchphrase?: unknown data?: Json | null status?: Database['public']['Enums']['user_status'] | null username?: string | null @@ -585,44 +585,70 @@ export type Database = { Functions: { blurb_message: { Args: { '': Database['public']['Tables']['messages']['Row'] } - Returns: string + Returns: { + error: true + } & 'the function public.blurb_message with parameter or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache' } function_returning_row: { - Args: Record + Args: never Returns: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string } + SetofOptions: { + from: '*' + to: 'users' + isOneToOne: true + isSetofReturn: false + } } function_returning_set_of_rows: { - Args: Record + Args: never Returns: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string }[] + SetofOptions: { + from: '*' + to: 'users' + isOneToOne: false + isSetofReturn: true + } } function_returning_single_row: { Args: { messages: Database['public']['Tables']['messages']['Row'] } Returns: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string } + SetofOptions: { + from: 'messages' + to: 'users' + isOneToOne: true + isSetofReturn: false + } } function_using_setof_rows_one: { Args: { user_row: Database['public']['Tables']['users']['Row'] } Returns: { id: number username: string | null - }[] + } + SetofOptions: { + from: 'users' + to: 'user_profiles' + isOneToOne: true + isSetofReturn: true + } } function_using_table_returns: { Args: { user_row: Database['public']['Tables']['users']['Row'] } @@ -630,6 +656,12 @@ export type Database = { id: number username: string | null } + SetofOptions: { + from: 'users' + to: 'user_profiles' + isOneToOne: true + isSetofReturn: false + } } function_with_array_param: { Args: { param: string[] } @@ -640,19 +672,9 @@ export type Database = { Returns: string } get_active_user_messages: { - Args: { active_user_row: unknown } - Returns: { - channel_id: number - data: Json | null - id: number - message: string | null - username: string - }[] - } - get_messages: { - Args: - | { channel_row: Database['public']['Tables']['channels']['Row'] } - | { user_row: Database['public']['Tables']['users']['Row'] } + Args: { + active_user_row: Database['public']['Views']['active_users']['Row'] + } Returns: { channel_id: number data: Json | null @@ -660,7 +682,48 @@ export type Database = { message: string | null username: string }[] + SetofOptions: { + from: 'active_users' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } } + get_messages: + | { + Args: { user_row: Database['public']['Tables']['users']['Row'] } + Returns: { + channel_id: number + data: Json | null + id: number + message: string | null + username: string + }[] + SetofOptions: { + from: 'users' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } + } + | { + Args: { + channel_row: Database['public']['Tables']['channels']['Row'] + } + Returns: { + channel_id: number + data: Json | null + id: number + message: string | null + username: string + }[] + SetofOptions: { + from: 'channels' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } + } get_messages_by_username: { Args: { search_username: string } Returns: { @@ -670,6 +733,12 @@ export type Database = { message: string | null username: string }[] + SetofOptions: { + from: '*' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } } get_recent_messages_by_username: { Args: { search_username: string } @@ -680,20 +749,34 @@ export type Database = { message: string | null username: string | null }[] + SetofOptions: { + from: '*' + to: 'recent_messages' + isOneToOne: false + isSetofReturn: true + } } get_status: { Args: { name_param: string } Returns: Database['public']['Enums']['user_status'] } get_user_first_message: { - Args: { active_user_row: unknown } + Args: { + active_user_row: Database['public']['Views']['active_users']['Row'] + } Returns: { channel_id: number | null data: Json | null id: number | null message: string | null username: string | null - }[] + } + SetofOptions: { + from: 'active_users' + to: 'recent_messages' + isOneToOne: true + isSetofReturn: true + } } get_user_messages: { Args: { user_row: Database['public']['Tables']['users']['Row'] } @@ -704,6 +787,12 @@ export type Database = { message: string | null username: string }[] + SetofOptions: { + from: 'users' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } } get_user_profile: { Args: { user_row: Database['public']['Tables']['users']['Row'] } @@ -711,26 +800,61 @@ export type Database = { id: number username: string | null } + SetofOptions: { + from: 'users' + to: 'user_profiles' + isOneToOne: true + isSetofReturn: false + } } get_user_profile_non_nullable: { Args: { user_row: Database['public']['Tables']['users']['Row'] } Returns: { id: number username: string | null - }[] - } - get_user_recent_messages: { - Args: - | { active_user_row: unknown } - | { user_row: Database['public']['Tables']['users']['Row'] } - Returns: { - channel_id: number | null - data: Json | null - id: number | null - message: string | null - username: string | null - }[] + } + SetofOptions: { + from: 'users' + to: 'user_profiles' + isOneToOne: true + isSetofReturn: true + } } + get_user_recent_messages: + | { + Args: { user_row: Database['public']['Tables']['users']['Row'] } + Returns: { + channel_id: number | null + data: Json | null + id: number | null + message: string | null + username: string | null + }[] + SetofOptions: { + from: 'users' + to: 'recent_messages' + isOneToOne: false + isSetofReturn: true + } + } + | { + Args: { + active_user_row: Database['public']['Views']['active_users']['Row'] + } + Returns: { + channel_id: number | null + data: Json | null + id: number | null + message: string | null + username: string | null + }[] + SetofOptions: { + from: 'active_users' + to: 'recent_messages' + isOneToOne: false + isSetofReturn: true + } + } get_username_and_status: { Args: { name_param: string } Returns: { @@ -743,25 +867,28 @@ export type Database = { Returns: Database['public']['Enums']['user_status'] } polymorphic_function_with_different_return: { - Args: { '': boolean } | { '': number } | { '': string } - Returns: number - } - polymorphic_function_with_no_params_or_unnamed: { - Args: Record | { '': boolean } | { '': string } - Returns: number - } - polymorphic_function_with_unnamed_default: { - Args: Record | { ''?: number } | { ''?: string } - Returns: number - } - polymorphic_function_with_unnamed_default_overload: { - Args: Record | { ''?: boolean } | { ''?: number } | { ''?: string } - Returns: number - } - polymorphic_function_with_unnamed_integer: { - Args: { '': number } - Returns: number + Args: { '': string } + Returns: string } + polymorphic_function_with_no_params_or_unnamed: + | { Args: never; Returns: number } + | { Args: { '': string }; Returns: string } + polymorphic_function_with_unnamed_default: + | { + Args: never + Returns: { + error: true + } & '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' + } + | { Args: { ''?: string }; Returns: string } + polymorphic_function_with_unnamed_default_overload: + | { + Args: never + Returns: { + error: true + } & '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' + } + | { Args: { ''?: string }; Returns: string } polymorphic_function_with_unnamed_json: { Args: { '': Json } Returns: number @@ -774,34 +901,86 @@ export type Database = { Args: { '': string } Returns: number } - postgrest_resolvable_with_override_function: { - Args: - | Record - | { a: string } - | { b: number } - | { cid: number; search?: string } - | { profile_id: number } - | { user_row: Database['public']['Tables']['users']['Row'] } - Returns: undefined - } - postgrest_unresolvable_function: { - Args: Record | { a: number } | { a: string } - Returns: undefined - } + postgrest_resolvable_with_override_function: + | { Args: { a: string }; Returns: number } + | { Args: { b: number }; Returns: string } + | { + Args: { profile_id: number } + Returns: { + id: number + username: string | null + }[] + SetofOptions: { + from: '*' + to: 'user_profiles' + isOneToOne: false + isSetofReturn: true + } + } + | { + Args: { user_row: Database['public']['Tables']['users']['Row'] } + Returns: { + channel_id: number + data: Json | null + id: number + message: string | null + username: string + }[] + SetofOptions: { + from: 'users' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } + } + | { + Args: { cid: number; search?: string } + Returns: { + channel_id: number + data: Json | null + id: number + message: string | null + username: string + }[] + SetofOptions: { + from: '*' + to: 'messages' + isOneToOne: false + isSetofReturn: true + } + } + | { Args: never; Returns: undefined } + postgrest_unresolvable_function: + | { + Args: { a: string } + Returns: { + error: true + } & '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' + } + | { + Args: { a: number } + Returns: { + error: true + } & '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' + } + | { Args: never; Returns: undefined } set_users_offline: { Args: { name_param: string } Returns: { - age_range: unknown | null - catchphrase: unknown | null + age_range: unknown + catchphrase: unknown data: Json | null status: Database['public']['Enums']['user_status'] | null username: string }[] + SetofOptions: { + from: '*' + to: 'users' + isOneToOne: false + isSetofReturn: true + } } - void_func: { - Args: Record - Returns: undefined - } + void_func: { Args: never; Returns: undefined } } Enums: { user_status: 'ONLINE' | 'OFFLINE' diff --git a/packages/core/postgrest-js/tstyche.config.json b/packages/core/postgrest-js/tstyche.config.json index 1112968cc..489cfea96 100644 --- a/packages/core/postgrest-js/tstyche.config.json +++ b/packages/core/postgrest-js/tstyche.config.json @@ -1,4 +1,7 @@ { + "$schema": "https://tstyche.org/schemas/config.json", "tsconfig": "tsconfig.tstyche.json", - "testFileMatch": ["**/*.test-d.ts"] + "testFileMatch": ["./test/**/*.test.ts", "./test/**/*.test-d.ts"], + "checkSourceFiles": false, + "checkSuppressedErrors": true }