LoopKitBackend
Deck Service
Manage flashcard decks with hierarchy and configuration
DeckService
Handles CRUD operations for decks, including hierarchy management and configuration resolution.
Methods
createDeck
async createDeck(input: CreateDeckInput): Promise<DeckBase>interface CreateDeckInput {
name: string;
description?: string;
parentDeckId?: string | null;
presetId?: string | null;
configOverrides?: Partial<DeckConfig>;
}getDeck
async getDeck(id: string): Promise<DeckBase>Throws: EntityNotFoundError if the deck doesn't exist.
updateDeck
async updateDeck(id: string, input: UpdateDeckInput): Promise<DeckBase>deleteDeck
async deleteDeck(deckId: string, deleteCards: boolean): Promise<void>When deleteCards is true, all cards in the deck and its descendants are deleted first, then the deck hierarchy is removed bottom-up.
moveDeck
async moveDeck(deckId: string, newParentId: string | null): Promise<void>Move a deck to a new parent, or make it a root deck by passing null.
getDeckTree
async getDeckTree(): Promise<DeckTreeNode[]>Returns the full deck hierarchy as a tree. Each node includes card counts aggregated from descendants.
interface DeckTreeNode extends DeckBase {
children: DeckTreeNode[];
counts?: DeckCounts;
}getEffectiveConfig
async getEffectiveConfig(deckId: string): Promise<DeckConfig>Resolves the final configuration for a deck by merging:
DEFAULT_DECK_CONFIG(hardcoded defaults)- Deck's preset config (if
presetIdis set) - Deck's
configOverrides
The result is validated and clamped to safe ranges.