import type { Card, CardCreate, CardUpdate } from '@wordeck/domain'; import { api } from './client.ts'; export function listCards(deckId?: string) { const qs = deckId ? `?deck_id=${encodeURIComponent(deckId)}` : ''; return api<{ cards: Card[]; total: number }>(`/api/v1/cards${qs}`); } /** Holt nur die content_hash-Liste — kompakt für Anki-Re-Import-Dedupe. */ export function listCardHashes() { return api<{ hashes: string[]; total: number }>('/api/v1/cards/hashes'); } export function getCard(id: string) { return api(`/api/v1/cards/${id}`); } export function createCard(input: CardCreate) { return api('/api/v1/cards', { method: 'POST', body: input }); } export function updateCard(id: string, patch: CardUpdate) { return api(`/api/v1/cards/${id}`, { method: 'PATCH', body: patch }); } export function deleteCard(id: string) { return api<{ deleted: string }>(`/api/v1/cards/${id}`, { method: 'DELETE' }); }