|
| 1 | +import { app } from './utils' |
| 2 | + |
| 3 | +test('typegen', async () => { |
| 4 | + const { body } = await app.inject({ method: 'GET', path: '/generators/typescript' }) |
| 5 | + // This is expected to be very brittle, as generated types can change a lot |
| 6 | + // without being breaking changes. Use `npm run test:update` to make life |
| 7 | + // easier. |
| 8 | + expect(body).toMatchInlineSnapshot(` |
| 9 | + "export type Json = |
| 10 | + | string |
| 11 | + | number |
| 12 | + | boolean |
| 13 | + | null |
| 14 | + | { [key: string]: Json } |
| 15 | + | Json[] |
| 16 | +
|
| 17 | + export interface Database { |
| 18 | + public: { |
| 19 | + Tables: { |
| 20 | + category: { |
| 21 | + Row: { |
| 22 | + id: number |
| 23 | + name: string |
| 24 | + } |
| 25 | + Insert: { |
| 26 | + id?: number |
| 27 | + name: string |
| 28 | + } |
| 29 | + Update: { |
| 30 | + id?: number |
| 31 | + name?: string |
| 32 | + } |
| 33 | + } |
| 34 | + memes: { |
| 35 | + Row: { |
| 36 | + category: number | null |
| 37 | + created_at: string |
| 38 | + id: number |
| 39 | + metadata: Json | null |
| 40 | + name: string |
| 41 | + status: Database["public"]["Enums"]["meme_status"] | null |
| 42 | + } |
| 43 | + Insert: { |
| 44 | + category?: number | null |
| 45 | + created_at: string |
| 46 | + id?: number |
| 47 | + metadata?: Json | null |
| 48 | + name: string |
| 49 | + status?: Database["public"]["Enums"]["meme_status"] | null |
| 50 | + } |
| 51 | + Update: { |
| 52 | + category?: number | null |
| 53 | + created_at?: string |
| 54 | + id?: number |
| 55 | + metadata?: Json | null |
| 56 | + name?: string |
| 57 | + status?: Database["public"]["Enums"]["meme_status"] | null |
| 58 | + } |
| 59 | + } |
| 60 | + todos: { |
| 61 | + Row: { |
| 62 | + details: string | null |
| 63 | + id: number |
| 64 | + "user-id": number |
| 65 | + blurb: string | null |
| 66 | + } |
| 67 | + Insert: { |
| 68 | + details?: string | null |
| 69 | + id?: number |
| 70 | + "user-id": number |
| 71 | + } |
| 72 | + Update: { |
| 73 | + details?: string | null |
| 74 | + id?: number |
| 75 | + "user-id"?: number |
| 76 | + } |
| 77 | + } |
| 78 | + users: { |
| 79 | + Row: { |
| 80 | + id: number |
| 81 | + name: string | null |
| 82 | + status: Database["public"]["Enums"]["user_status"] | null |
| 83 | + } |
| 84 | + Insert: { |
| 85 | + id?: number |
| 86 | + name?: string | null |
| 87 | + status?: Database["public"]["Enums"]["user_status"] | null |
| 88 | + } |
| 89 | + Update: { |
| 90 | + id?: number |
| 91 | + name?: string | null |
| 92 | + status?: Database["public"]["Enums"]["user_status"] | null |
| 93 | + } |
| 94 | + } |
| 95 | + users_audit: { |
| 96 | + Row: { |
| 97 | + created_at: string | null |
| 98 | + id: number |
| 99 | + previous_value: Json | null |
| 100 | + user_id: number | null |
| 101 | + } |
| 102 | + Insert: { |
| 103 | + created_at?: string | null |
| 104 | + id?: number |
| 105 | + previous_value?: Json | null |
| 106 | + user_id?: number | null |
| 107 | + } |
| 108 | + Update: { |
| 109 | + created_at?: string | null |
| 110 | + id?: number |
| 111 | + previous_value?: Json | null |
| 112 | + user_id?: number | null |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + Views: { |
| 117 | + todos_view: { |
| 118 | + Row: { |
| 119 | + details: string | null |
| 120 | + id: number | null |
| 121 | + "user-id": number | null |
| 122 | + } |
| 123 | + Insert: { |
| 124 | + details?: string | null |
| 125 | + id?: number | null |
| 126 | + "user-id"?: number | null |
| 127 | + } |
| 128 | + Update: { |
| 129 | + details?: string | null |
| 130 | + id?: number | null |
| 131 | + "user-id"?: number | null |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + Functions: { |
| 136 | + blurb: { |
| 137 | + Args: { |
| 138 | + "": unknown |
| 139 | + } |
| 140 | + Returns: string |
| 141 | + } |
| 142 | + postgres_fdw_disconnect: { |
| 143 | + Args: { |
| 144 | + "": string |
| 145 | + } |
| 146 | + Returns: boolean |
| 147 | + } |
| 148 | + postgres_fdw_disconnect_all: { |
| 149 | + Args: Record<PropertyKey, never> |
| 150 | + Returns: boolean |
| 151 | + } |
| 152 | + postgres_fdw_get_connections: { |
| 153 | + Args: Record<PropertyKey, never> |
| 154 | + Returns: Record<string, unknown>[] |
| 155 | + } |
| 156 | + postgres_fdw_handler: { |
| 157 | + Args: Record<PropertyKey, never> |
| 158 | + Returns: unknown |
| 159 | + } |
| 160 | + } |
| 161 | + Enums: { |
| 162 | + meme_status: "new" | "old" | "retired" |
| 163 | + user_status: "ACTIVE" | "INACTIVE" |
| 164 | + } |
| 165 | + CompositeTypes: { |
| 166 | + [_ in never]: never |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + " |
| 171 | + `) |
| 172 | +}) |
0 commit comments