Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.
89
A task management system that leverages database schema types to ensure type safety across all database operations.
id, title, description, status, and created_at. @testtitle and description), TypeScript should infer the correct types and the operation should return the inserted task with all fields including auto-generated ones like id and created_at. @testid and title), the return type should reflect only those selected fields rather than the full table type. @test@generates
import { createClient, SupabaseClient } from '@supabase/supabase-js';
// Database type definitions
export interface Database {
public: {
Tables: {
tasks: {
Row: {
id: number;
title: string;
description: string;
status: 'pending' | 'in_progress' | 'completed';
created_at: string;
};
Insert: {
id?: never;
title: string;
description: string;
status?: 'pending' | 'in_progress' | 'completed';
created_at?: never;
};
Update: {
id?: never;
title?: string;
description?: string;
status?: 'pending' | 'in_progress' | 'completed';
created_at?: never;
};
};
};
};
}
/**
* Creates a typed Supabase client for the task management system
* @param url - The Supabase project URL
* @param key - The Supabase anonymous key
* @returns A typed Supabase client
*/
export function createTaskClient(url: string, key: string): SupabaseClient<Database>;
/**
* Fetches all tasks from the database
* @param client - The typed Supabase client
* @returns Promise containing an array of tasks or an error
*/
export function fetchAllTasks(client: SupabaseClient<Database>): Promise<{ data: Database['public']['Tables']['tasks']['Row'][] | null; error: any }>;
/**
* Inserts a new task into the database
* @param client - The typed Supabase client
* @param task - The task data to insert
* @returns Promise containing the inserted task or an error
*/
export function insertTask(
client: SupabaseClient<Database>,
task: Database['public']['Tables']['tasks']['Insert']
): Promise<{ data: Database['public']['Tables']['tasks']['Row'] | null; error: any }>;
/**
* Updates an existing task by ID
* @param client - The typed Supabase client
* @param id - The task ID
* @param updates - The fields to update
* @returns Promise containing the updated task or an error
*/
export function updateTask(
client: SupabaseClient<Database>,
id: number,
updates: Database['public']['Tables']['tasks']['Update']
): Promise<{ data: Database['public']['Tables']['tasks']['Row'] | null; error: any }>;
/**
* Fetches tasks with only specific fields
* @param client - The typed Supabase client
* @returns Promise containing tasks with only id and title fields or an error
*/
export function fetchTaskSummaries(
client: SupabaseClient<Database>
): Promise<{ data: Array<{ id: number; title: string }> | null; error: any }>;Provides the Supabase JavaScript client with TypeScript support for database operations and schema type generation.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-supabase--supabase-jsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10