CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-supabase--supabase-js

Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.

89

0.95x
Overview
Eval results
Files

task.mdevals/scenario-9/

Type-Safe Task Manager

A task management system that leverages database schema types to ensure type safety across all database operations.

Capabilities

Fetch tasks with type safety

  • When fetching all tasks from the database, the result should be properly typed based on the database schema, allowing TypeScript to provide autocomplete for fields like id, title, description, status, and created_at. @test

Insert tasks with type inference

  • When inserting a new task with required fields (title 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. @test

Update tasks with type constraints

  • When updating an existing task by its ID, TypeScript should enforce that only valid table columns can be updated and the status field should be constrained to valid enum values if defined in the schema. @test

Query with custom return types

  • When performing a select query that returns only specific columns (e.g., just id and title), the return type should reflect only those selected fields rather than the full table type. @test

Implementation

@generates

API

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 }>;

Dependencies { .dependencies }

@supabase/supabase-js { .dependency }

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-js

tile.json