UNPKG

@adventurelabs/scout-core

Version:

Core utilities and helpers for Adventure Labs Scout applications

98 lines (97 loc) 5.03 kB
import { Database } from "../types/supabase"; import { IPart, PartInsert } from "../types/db"; import { IWebResponseCompatible } from "../types/requests"; import { SupabaseClient } from "@supabase/supabase-js"; /** * Retrieves all active parts for a specific device * @param client - Supabase client instance * @param device_id - ID of the device to get parts for */ export declare function get_parts_by_device_id(client: SupabaseClient<Database>, device_id: number): Promise<IWebResponseCompatible<IPart[]>>; /** * Retrieves a single active part by its ID * @param client - Supabase client instance * @param part_id - ID of the part to retrieve */ export declare function get_part_by_id(client: SupabaseClient<Database>, part_id: number): Promise<IWebResponseCompatible<IPart | null>>; /** * Retrieves all active parts with a specific serial number * @param client - Supabase client instance * @param serial_number - Serial number to search for */ export declare function get_parts_by_serial_number(client: SupabaseClient<Database>, serial_number: string): Promise<IWebResponseCompatible<IPart[]>>; /** * Retrieves all active parts with a specific product number * @param client - Supabase client instance * @param product_number - Product number to search for */ export declare function get_parts_by_product_number(client: SupabaseClient<Database>, product_number: string): Promise<IWebResponseCompatible<IPart[]>>; /** * Retrieves all active parts with a specific status * @param client - Supabase client instance * @param status - Component status to filter by */ export declare function get_parts_by_status(client: SupabaseClient<Database>, status: Database["public"]["Enums"]["component_status"]): Promise<IWebResponseCompatible<IPart[]>>; /** * Creates a new part with validation * @param client - Supabase client instance * @param newPart - Part data to create */ export declare function create_part(client: SupabaseClient<Database>, newPart: PartInsert): Promise<IWebResponseCompatible<IPart | null>>; /** * Updates an existing part * @param client - Supabase client instance * @param part_id - ID of the part to update * @param updatedPart - Partial part data to update */ export declare function update_part(client: SupabaseClient<Database>, part_id: number, updatedPart: Partial<PartInsert>): Promise<IWebResponseCompatible<IPart | null>>; /** * Soft deletes a part by setting deleted_at timestamp * @param client - Supabase client instance * @param part_id - ID of the part to delete */ export declare function delete_part(client: SupabaseClient<Database>, part_id: number): Promise<IWebResponseCompatible<IPart | null>>; /** * Updates the status of a specific part * @param client - Supabase client instance * @param part_id - ID of the part to update * @param status - New status to set */ export declare function update_part_status(client: SupabaseClient<Database>, part_id: number, status: Database["public"]["Enums"]["component_status"]): Promise<IWebResponseCompatible<IPart | null>>; /** * Retrieves all active parts associated with a certificate * @param client - Supabase client instance * @param certificate_id - ID of the certificate to search for */ export declare function get_parts_by_certificate_id(client: SupabaseClient<Database>, certificate_id: number): Promise<IWebResponseCompatible<IPart[]>>; /** * Retrieves all active parts for devices in a specific herd * @param client - Supabase client instance * @param herd_id - ID of the herd to get parts for */ export declare function get_parts_by_herd_id(client: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IPart[]>>; /** * Restores a soft-deleted part by clearing deleted_at timestamp * @param client - Supabase client instance * @param part_id - ID of the part to restore */ export declare function restore_part(client: SupabaseClient<Database>, part_id: number): Promise<IWebResponseCompatible<IPart | null>>; /** * Permanently deletes a soft-deleted part from database * @param client - Supabase client instance * @param part_id - ID of the part to permanently delete */ export declare function hard_delete_part(client: SupabaseClient<Database>, part_id: number): Promise<IWebResponseCompatible<IPart | null>>; /** * Retrieves all soft-deleted parts for a specific device * @param client - Supabase client instance * @param device_id - ID of the device to get deleted parts for */ export declare function get_deleted_parts_by_device_id(client: SupabaseClient<Database>, device_id: number): Promise<IWebResponseCompatible<IPart[]>>; /** * Retrieves a part by its composite unique constraint (product + serial) * @param client - Supabase client instance * @param product_number - Product number to search for * @param serial_number - Serial number to search for */ export declare function get_parts_by_product_and_serial(client: SupabaseClient<Database>, product_number: string, serial_number: string): Promise<IWebResponseCompatible<IPart | null>>;