Skip to content

Commit 8399574

Browse files
supabase types added
1 parent 29b0b3c commit 8399574

File tree

10 files changed

+351
-27
lines changed

10 files changed

+351
-27
lines changed

src/app/shared/_models/post.interface.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/app/supabase-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file re-exports all types from the new structure
2+
// This allows existing code to continue working without changes
3+
export * from './types/supabase';
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// export type Json =
2+
// | string
3+
// | number
4+
// | boolean
5+
// | null
6+
// | { [key: string]: Json | undefined }
7+
// | Json[]
8+
//
9+
// export type Database = {
10+
// public: {
11+
// Tables: {
12+
// comments: {
13+
// Row: CommentRow
14+
// Insert: CommentInsert
15+
// Update: CommentUpdate
16+
// Relationships: CommentRelationships
17+
// }
18+
// post_tags: {
19+
// Row: PostTagRow
20+
// Insert: PostTagInsert
21+
// Update: PostTagUpdate
22+
// Relationships: PostTagRelationships
23+
// }
24+
// posts: {
25+
// Row: PostRow
26+
// Insert: PostInsert
27+
// Update: PostUpdate
28+
// Relationships: PostRelationships
29+
// }
30+
// profiles: {
31+
// Row: ProfileRow
32+
// Insert: ProfileInsert
33+
// Update: ProfileUpdate
34+
// Relationships: ProfileRelationships
35+
// }
36+
// tags: {
37+
// Row: TagRow
38+
// Insert: TagInsert
39+
// Update: TagUpdate
40+
// Relationships: TagRelationships
41+
// }
42+
// }
43+
// Views: {
44+
// [_ in never]: never
45+
// }
46+
// Functions: {
47+
// [_ in never]: never
48+
// }
49+
// Enums: {
50+
// [_ in never]: never
51+
// }
52+
// CompositeTypes: {
53+
// [_ in never]: never
54+
// }
55+
// }
56+
// }
57+
//
58+
// export type DefaultSchema = Database[Extract<keyof Database, "public">]

src/app/types/supabase/comments.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export type Comment = {
2+
content: string;
3+
created_at: string | null;
4+
id: string;
5+
is_deleted: boolean | null;
6+
is_reported: boolean | null;
7+
post_id: string;
8+
user_id: string | null;
9+
};
10+
11+
export type CommentInsert = {
12+
content: string;
13+
created_at?: string | null;
14+
id?: string;
15+
is_deleted?: boolean | null;
16+
is_reported?: boolean | null;
17+
post_id: string;
18+
user_id?: string | null;
19+
};
20+
21+
export type CommentUpdate = {
22+
content?: string;
23+
created_at?: string | null;
24+
id?: string;
25+
is_deleted?: boolean | null;
26+
is_reported?: boolean | null;
27+
post_id?: string;
28+
user_id?: string | null;
29+
};
30+
31+
export type CommentRelationships = [
32+
{
33+
foreignKeyName: 'comments_post_id_fkey';
34+
columns: ['post_id'];
35+
isOneToOne: false;
36+
referencedRelation: 'posts';
37+
referencedColumns: ['id'];
38+
},
39+
{
40+
foreignKeyName: 'comments_user_id_fkey';
41+
columns: ['user_id'];
42+
isOneToOne: false;
43+
referencedRelation: 'profiles';
44+
referencedColumns: ['id'];
45+
},
46+
];

src/app/types/supabase/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Re-export all types from the individual files
2+
// export * from './base-types';
3+
export * from './comments';
4+
export * from './post-tags';
5+
export * from './posts';
6+
export * from './profiles';
7+
export * from './tags';
8+
// export * from './utility-types';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Tag } from './tags';
2+
3+
export type PostTag = {
4+
post_id: string;
5+
tag_id: number;
6+
};
7+
8+
export type PostTagList = {
9+
tags: Tag;
10+
};
11+
12+
export type PostTagInsert = {
13+
post_id: string;
14+
tag_id: number;
15+
};
16+
17+
export type PostTagUpdate = {
18+
post_id?: string;
19+
tag_id?: number;
20+
};
21+
22+
export type PostTagRelationships = [
23+
{
24+
foreignKeyName: 'post_tags_post_id_fkey';
25+
columns: ['post_id'];
26+
isOneToOne: false;
27+
referencedRelation: 'posts';
28+
referencedColumns: ['id'];
29+
},
30+
{
31+
foreignKeyName: 'post_tags_tag_id_fkey';
32+
columns: ['tag_id'];
33+
isOneToOne: false;
34+
referencedRelation: 'tags';
35+
referencedColumns: ['id'];
36+
},
37+
];

src/app/types/supabase/posts.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Profile } from './profiles';
2+
import { PostTagList } from './post-tags';
3+
4+
export type Post = {
5+
content: string;
6+
created_at: string | null;
7+
description: string;
8+
id: string;
9+
is_draft: boolean;
10+
title: string;
11+
user_id: string;
12+
author?: Profile;
13+
post_tags?: PostTagList[];
14+
comments?: Comment[];
15+
};
16+
17+
export type PostInsert = {
18+
content: string;
19+
created_at?: string | null;
20+
description: string;
21+
id?: string;
22+
is_draft?: boolean;
23+
title: string;
24+
user_id: string;
25+
};
26+
27+
export type PostUpdate = {
28+
content?: string;
29+
created_at?: string | null;
30+
description?: string;
31+
id?: string;
32+
is_draft?: boolean;
33+
title?: string;
34+
user_id?: string;
35+
};
36+
37+
export type PostRelationships = [
38+
{
39+
foreignKeyName: 'posts_user_id_fkey';
40+
columns: ['user_id'];
41+
isOneToOne: false;
42+
referencedRelation: 'profiles';
43+
referencedColumns: ['id'];
44+
},
45+
];

src/app/types/supabase/profiles.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export type Profile = {
2+
avatar_url: string | null
3+
created_at: string | null
4+
id: string
5+
username: string
6+
}
7+
8+
export type ProfileInsert = {
9+
avatar_url?: string | null
10+
created_at?: string | null
11+
id: string
12+
username: string
13+
}
14+
15+
export type ProfileUpdate = {
16+
avatar_url?: string | null
17+
created_at?: string | null
18+
id?: string
19+
username?: string
20+
}
21+
22+
export type ProfileRelationships = []

src/app/types/supabase/tags.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export type Tag = {
2+
color: string;
3+
icon: string;
4+
id: number;
5+
name: string;
6+
};
7+
8+
export type TagInsert = {
9+
color: string;
10+
icon: string;
11+
id?: number;
12+
name: string;
13+
};
14+
15+
export type TagUpdate = {
16+
color?: string;
17+
icon?: string;
18+
id?: number;
19+
name?: string;
20+
};
21+
22+
export type TagRelationships = [];
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// import { Database, DefaultSchema } from './base-types';
2+
//
3+
// export type Tables<
4+
// DefaultSchemaTableNameOrOptions extends
5+
// | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
6+
// | { schema: keyof Database },
7+
// TableName extends DefaultSchemaTableNameOrOptions extends {
8+
// schema: keyof Database
9+
// }
10+
// ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
11+
// Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
12+
// : never = never,
13+
// > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
14+
// ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
15+
// Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
16+
// Row: infer R
17+
// }
18+
// ? R
19+
// : never
20+
// : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
21+
// DefaultSchema["Views"])
22+
// ? (DefaultSchema["Tables"] &
23+
// DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
24+
// Row: infer R
25+
// }
26+
// ? R
27+
// : never
28+
// : never
29+
//
30+
// export type TablesInsert<
31+
// DefaultSchemaTableNameOrOptions extends
32+
// | keyof DefaultSchema["Tables"]
33+
// | { schema: keyof Database },
34+
// TableName extends DefaultSchemaTableNameOrOptions extends {
35+
// schema: keyof Database
36+
// }
37+
// ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
38+
// : never = never,
39+
// > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
40+
// ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
41+
// Insert: infer I
42+
// }
43+
// ? I
44+
// : never
45+
// : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
46+
// ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
47+
// Insert: infer I
48+
// }
49+
// ? I
50+
// : never
51+
// : never
52+
//
53+
// export type TablesUpdate<
54+
// DefaultSchemaTableNameOrOptions extends
55+
// | keyof DefaultSchema["Tables"]
56+
// | { schema: keyof Database },
57+
// TableName extends DefaultSchemaTableNameOrOptions extends {
58+
// schema: keyof Database
59+
// }
60+
// ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
61+
// : never = never,
62+
// > = DefaultSchemaTableNameOrOptions extends { schema: keyof Database }
63+
// ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
64+
// Update: infer U
65+
// }
66+
// ? U
67+
// : never
68+
// : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
69+
// ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
70+
// Update: infer U
71+
// }
72+
// ? U
73+
// : never
74+
// : never
75+
//
76+
// export type Enums<
77+
// DefaultSchemaEnumNameOrOptions extends
78+
// | keyof DefaultSchema["Enums"]
79+
// | { schema: keyof Database },
80+
// EnumName extends DefaultSchemaEnumNameOrOptions extends {
81+
// schema: keyof Database
82+
// }
83+
// ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
84+
// : never = never,
85+
// > = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database }
86+
// ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
87+
// : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
88+
// ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
89+
// : never
90+
//
91+
// export type CompositeTypes<
92+
// PublicCompositeTypeNameOrOptions extends
93+
// | keyof DefaultSchema["CompositeTypes"]
94+
// | { schema: keyof Database },
95+
// CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
96+
// schema: keyof Database
97+
// }
98+
// ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
99+
// : never = never,
100+
// > = PublicCompositeTypeNameOrOptions extends { schema: keyof Database }
101+
// ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
102+
// : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
103+
// ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
104+
// : never
105+
//
106+
// export const Constants = {
107+
// public: {
108+
// Enums: {},
109+
// },
110+
// } as const

0 commit comments

Comments
 (0)