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-2/

Product Inventory Query System

Build a product inventory query system that retrieves products based on various filter criteria.

Overview

You need to implement a module that queries a products database table and returns filtered results based on price ranges, stock levels, and rating thresholds. The database connection is already configured.

Database Schema

The products table has the following structure:

  • id (integer): Unique product identifier
  • name (string): Product name
  • price (decimal): Product price in dollars
  • stock (integer): Quantity in stock
  • rating (decimal): Product rating (0-5 scale)
  • category (string): Product category

Requirements

Find products by exact match

  • Return all products with a specific rating value @test
  • Return all products in a specific price point @test

Find products by price range

  • Return all products priced above a minimum threshold @test
  • Return all products priced at or below a maximum threshold @test
  • Return all products within a price range (inclusive bounds) @test

Find products by stock levels

  • Return all products with stock greater than a threshold @test
  • Return all products that are out of stock @test

Find products by rating

  • Return all products with rating less than a threshold @test
  • Return all products with rating at or above a threshold @test

Implementation

@generates

API

import { SupabaseClient } from '@supabase/supabase-js';

/**
 * Get products with exact rating
 * @param supabase - Supabase client instance
 * @param rating - Rating to match exactly
 * @returns Promise with products matching the rating
 */
export async function getProductsByRating(
  supabase: SupabaseClient,
  rating: number
): Promise<any[]>;

/**
 * Get products with exact price
 * @param supabase - Supabase client instance
 * @param price - Price to match exactly
 * @returns Promise with products matching the price
 */
export async function getProductsByPrice(
  supabase: SupabaseClient,
  price: number
): Promise<any[]>;

/**
 * Get products above minimum price
 * @param supabase - Supabase client instance
 * @param minPrice - Minimum price threshold (exclusive)
 * @returns Promise with products priced above the threshold
 */
export async function getProductsAbovePrice(
  supabase: SupabaseClient,
  minPrice: number
): Promise<any[]>;

/**
 * Get products at or below maximum price
 * @param supabase - Supabase client instance
 * @param maxPrice - Maximum price threshold (inclusive)
 * @returns Promise with products at or below the threshold
 */
export async function getProductsBelowOrAtPrice(
  supabase: SupabaseClient,
  maxPrice: number
): Promise<any[]>;

/**
 * Get products within price range
 * @param supabase - Supabase client instance
 * @param minPrice - Minimum price (inclusive)
 * @param maxPrice - Maximum price (inclusive)
 * @returns Promise with products in the price range
 */
export async function getProductsInPriceRange(
  supabase: SupabaseClient,
  minPrice: number,
  maxPrice: number
): Promise<any[]>;

/**
 * Get products with stock above threshold
 * @param supabase - Supabase client instance
 * @param threshold - Stock threshold (exclusive)
 * @returns Promise with products having stock above threshold
 */
export async function getProductsWithStockAbove(
  supabase: SupabaseClient,
  threshold: number
): Promise<any[]>;

/**
 * Get out of stock products
 * @param supabase - Supabase client instance
 * @returns Promise with products that have zero stock
 */
export async function getOutOfStockProducts(
  supabase: SupabaseClient
): Promise<any[]>;

/**
 * Get products with low ratings
 * @param supabase - Supabase client instance
 * @param threshold - Rating threshold (exclusive)
 * @returns Promise with products rated below the threshold
 */
export async function getLowRatedProducts(
  supabase: SupabaseClient,
  threshold: number
): Promise<any[]>;

/**
 * Get highly rated products
 * @param supabase - Supabase client instance
 * @param threshold - Rating threshold (inclusive)
 * @returns Promise with products rated at or above the threshold
 */
export async function getHighlyRatedProducts(
  supabase: SupabaseClient,
  threshold: number
): Promise<any[]>;

Dependencies { .dependencies }

@supabase/supabase-js { .dependency }

Provides database query capabilities for interacting with Supabase backend.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-supabase--supabase-js

tile.json