import type { SupabaseClient } from '@supabase/supabase-js'; import type { ModuleAdapter } from './types'; export type AdapterConfig = { /** The module type identifier (e.g., 'note', 'category', 'lesson') */ moduleType: string; /** API functions for CRUD operations */ api: { list: () => Promise; listByContext: (contextType: string, contextId: string) => Promise; create: (input: CreateInput) => Promise; update: (id: string, patch: UpdateInput) => Promise; remove: (id: string) => Promise; }; /** Extract the title/name from an item for display */ getTitle: (item: T) => string; /** Optional Supabase client for realtime subscriptions */ supabaseClient?: SupabaseClient; /** Optional disassociate function for context-aware removal */ disassociate?: (body: { parentType: string; parentId: string; childType: string; childId: string; }) => Promise; }; /** * Factory function to create a standardized ModuleAdapter * * This centralizes the common logic across all module adapters: * - Context-aware listing * - Context-aware removal (disassociate vs delete) * - Optional realtime subscriptions via Supabase * - Standard getKey implementation * * @example * ```ts * import { createClient } from '@supabase/supabase-js'; * import { createModuleAdapter } from '@micahgoodman/notes'; * * const supabase = createClient(url, key); * * const NoteAdapter = createModuleAdapter({ * moduleType: 'note', * api: { * list: fetchNotes, * listByContext: fetchNotesByContext, * create: createNote, * update: updateNote, * remove: deleteNote, * }, * getTitle: (note) => note.text.substring(0, 50), * supabaseClient: supabase, * disassociate: disassociateNote * }); * ``` */ export declare function createModuleAdapter(config: AdapterConfig): ModuleAdapter; //# sourceMappingURL=createAdapter.d.ts.map