@mantis-core/supabase-core
v0.1.1
Published
Reusable Supabase infrastructure for Mantis Core apps.
Maintainers
Readme
@mantis-core/supabase-core
Reusable Supabase infrastructure for Mantis Core applications.
Scope
- Env resolution/validation for Supabase.
- Browser and server Supabase client factories.
- Standard action execution contract (
runAction). - Storage helper utilities.
- Generic search/pagination helpers.
Out Of Scope
- Domain repositories and domain actions.
- Client-specific migrations/RLS policies.
- Domain schema ownership.
Public API Modules
@mantis-core/supabase-core/action-utils@mantis-core/supabase-core/env@mantis-core/supabase-core/client@mantis-core/supabase-core/server@mantis-core/supabase-core/storage@mantis-core/supabase-core/utils/search@mantis-core/supabase-core/utils/pagination
Key Functions
runAction<T>(fn, options?) -> Promise<{ data: T | null; error: string | null }>
resolveSupabaseEnv(options?) -> ResolvedSupabaseEnv
createMantisCoreBrowserClient<Database>(url, key)
createMantisCoreServerClient<Database>(options)
createMantisCoreRouteHandlerClient<Database>(options)
sanitizeStorageFileName(name)
createTimestampedStorageFileName(name)
createStorageObjectPath(fileName, parentPath?)
getPublicStorageUrl(supabaseUrl, bucket, filePath)Recommended App Flow
- UI/feature layer
- Domain hook (client reads)
- Server action (
runActioncontract) - Domain repository
- Supabase
This package provides layer 4.5 infrastructure, not domain logic.
Usage Example
import { runAction } from "@mantis-core/supabase-core/action-utils";
import { createMantisCoreServerClient } from "@mantis-core/supabase-core/server";
export async function safeMutation() {
return runAction(async () => {
const supabase = createMantisCoreServerClient({
supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL!,
supabaseAnonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
cookieStore: {
getAll: () => [],
set: () => undefined,
},
});
const { data, error } = await supabase.from("table").select("*");
if (error) throw error;
return data;
});
}Build
pnpm --filter @mantis-core/supabase-core build
pnpm --filter @mantis-core/supabase-core typecheckPeer Dependencies
next(cookie/runtime integration)- Supabase packages are standard dependencies in this package.
