Skip to content

Commit

Permalink
Merge pull request #490 from supabase/chore/update-generated-types
Browse files Browse the repository at this point in the history
chore: update generated types
  • Loading branch information
soedirgo authored Nov 22, 2023
2 parents 5e7dbdc + f0ec2e9 commit 56c39a5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
5 changes: 5 additions & 0 deletions test/db/00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ CREATE TABLE public.channels (
ALTER TABLE public.users REPLICA IDENTITY FULL; -- Send "previous data" to supabase
COMMENT ON COLUMN public.channels.data IS 'For unstructured data and prototyping.';

create table public.channel_details (
id bigint primary key references channels(id),
details text default null
);

-- MESSAGES
CREATE TABLE public.messages (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
Expand Down
5 changes: 4 additions & 1 deletion test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
if (error) {
throw new Error(error.message)
}
expectType<{ bar: Json; baz: string }>(data)
// getting this w/o the cast, not sure why:
// Parameter type Json is declared too wide for argument type Json
expectType<Json>(data.bar as Json)
expectType<string>(data.baz)
}

// rpc return type
Expand Down
47 changes: 42 additions & 5 deletions test/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Json = string | number | boolean | null | { [key: string]: Json } | Json[]
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]

export interface Database {
personal: {
Expand Down Expand Up @@ -45,6 +45,29 @@ export interface Database {
}
public: {
Tables: {
channel_details: {
Row: {
details: string | null
id: number
}
Insert: {
details?: string | null
id: number
}
Update: {
details?: string | null
id?: number
}
Relationships: [
{
foreignKeyName: 'channel_details_id_fkey'
columns: ['id']
isOneToOne: true
referencedRelation: 'channels'
referencedColumns: ['id']
}
]
}
channels: {
Row: {
data: Json | null
Expand Down Expand Up @@ -86,17 +109,29 @@ export interface Database {
username?: string
}
Relationships: [
{
foreignKeyName: 'messages_channel_id_fkey'
columns: ['channel_id']
referencedRelation: 'channels'
referencedColumns: ['id']
},
{
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'users'
referencedColumns: ['username']
},
{
foreignKeyName: 'messages_channel_id_fkey'
columns: ['channel_id']
referencedRelation: 'channels'
referencedColumns: ['id']
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'non_updatable_view'
referencedColumns: ['username']
},
{
foreignKeyName: 'messages_username_fkey'
columns: ['username']
referencedRelation: 'updatable_view'
referencedColumns: ['username']
}
]
}
Expand Down Expand Up @@ -148,6 +183,7 @@ export interface Database {
Row: {
username: string | null
}
Relationships: []
}
updatable_view: {
Row: {
Expand All @@ -162,6 +198,7 @@ export interface Database {
non_updatable_column?: never
username?: string | null
}
Relationships: []
}
}
Functions: {
Expand Down

0 comments on commit 56c39a5

Please sign in to comment.