import { createClient } from "@supabase/supabase-js" ; import { IData , IProject } from "./types" ; const supabase = createClient ( process . env . NEXT_PUBLIC_SUPABASE_URL , process . env . NEXT_PUBLIC_SUPABASE_KEY ) ; function getDocumentFromData ( data ) { const { id , name , nodes , globs , groups , pages , code , version } = data ; return { id , name , nodes , globs , groups , pages , version , code , } ; } param name param document returns export async function createSharedProject ( data ) { const document = getDocumentFromData ( data ) ; return supabase . from ( "projects" ) . insert ( [ { name : data . name , document } ] ) ; } param url returns export async function fetchSharedProject ( data ) { return supabase . from ( "projects" ) . select ( "*" ) . eq ( "document->>id" , data . id ) ; } param id param name param json returns export async function updateSharedProject ( data , uuid ) { const { name } = data ; const document = getDocumentFromData ( data ) ; return supabase . from ( "projects" ) . update ( { name , document } ) . eq ( "uuid" , uuid ) ; } param url returns export async function deleteSharedProject ( data , uuid ) { return supabase . from ( "projects" ) . delete ( ) . eq ( "uuid" , uuid ) ; } param url returns export async function fetchSharedProjectByUuid ( uuid ) { return supabase . from ( "projects" ) . select ( "*" ) . eq ( "uuid" , uuid ) ; }