LoopKitType Reference
Entities
Core entity types — CardBase, NoteBase, NoteType, DeckBase, and more
CardBase
The flashcard with its SRS state.
type CardState = 'new' | 'learning' | 'review' | 'relearning';
interface CardBase {
id: string; // UUID
noteId: string; // Parent note
templateId: string; // Template used to generate this card
deckId: string; // Deck this card belongs to
state: CardState; // Current SRS state
easeFactor: number; // Ease factor (≥ 1.3)
interval: number; // Review interval in days
dueDate: Date; // Next review date
currentStep: number; // Index into learning/relearning steps
lapseCount: number; // Times the card lapsed
reviewCount: number; // Total review count
createdAt: Date;
updatedAt: Date;
}NoteBase
Study material containing field values.
interface NoteBase {
id: string; // UUID
noteTypeId: string; // Reference to NoteType
fields: Field[]; // Field values
tags: string[]; // User-defined tags
createdAt: Date;
updatedAt: Date;
}Field & FieldDef
// Field value (on a note)
interface Field {
name: string; // Must match a FieldDef name
value: string; // The content
ordinal: number; // Display order
}
// Field definition (on a note type)
type FieldType = 'text' | 'richtext' | 'media';
interface FieldDef {
name: string; // Field name
ordinal: number; // Display order
type: FieldType; // Content type
required: boolean; // Whether the field must have a value
}TemplateDef
Card template defining front and back rendering.
interface TemplateDef {
id: string; // Unique template ID
name: string; // Display name (e.g., "Card 1")
front: string; // Front template (e.g., "{{Front}}")
back: string; // Back template (e.g., "{{FrontSide}}<hr>{{Back}}")
css?: string; // Optional per-template CSS
}NoteType
Defines the schema for a category of notes.
interface NoteType {
id: string;
name: string; // e.g., "Basic", "Basic + Reverse"
fields: FieldDef[]; // Field schema
templates: TemplateDef[]; // Card templates
createdAt: Date;
updatedAt: Date;
}A note type with 2 templates generates 2 cards per note.
DeckBase
A collection of cards, optionally nested.
interface DeckBase {
id: string; // UUID
name: string;
description?: string;
parentDeckId?: string | null; // Parent deck (null = root)
presetId?: string | null; // Configuration preset
configOverrides?: Partial<DeckConfig>; // Per-deck overrides
createdAt: Date;
updatedAt: Date;
}DeckTreeNode
Deck with children and aggregated counts (returned by getDeckTree()).
interface DeckTreeNode extends DeckBase {
children: DeckTreeNode[];
counts?: DeckCounts;
}DeckCounts
interface DeckCounts {
new: number;
learning: number;
review: number;
relearning: number;
total: number;
}DeckPreset
Named configuration template for decks.
interface DeckPreset {
id: string;
name: string;
config: DeckConfig;
createdAt: Date;
updatedAt: Date;
}ReviewLog
Immutable record of a single review action.
interface ReviewLog {
id: string;
cardId: string;
deckId: string;
grade: Grade;
prevState: CardStateSnapshot; // Card state before grading
newState: CardStateSnapshot; // Card state after grading
reviewedAt: Date;
timeTakenMs: number; // Time spent reviewing
}CardStateSnapshot
Snapshot of SRS-relevant fields (used in review logs for undo).
interface CardStateSnapshot {
state: CardState;
easeFactor: number;
interval: number;
dueDate: Date;
currentStep: number;
lapseCount: number;
reviewCount: number;
}