CourseKitBackend
Storage Interface
Abstract storage classes for implementing custom database adapters
Overview
CourseKit defines abstract storage classes for each entity type. Implement these to use any database — SQL, NoSQL, in-memory, or a remote API. All classes use structural typing and never import ORM-specific packages.
TimetableEventStorage
The core storage interface for events, exceptions, and entity associations.
import { TimetableEventStorage } from '@hfu.digital/coursekit-nestjs';Event CRUD
abstract create(data: Omit<TimetableEvent, 'id' | 'createdAt' | 'updatedAt' | 'version'>): Promise<TimetableEvent>;
abstract findById(id: string): Promise<TimetableEvent | null>;
abstract findByQuery(query: ScheduleQuery): Promise<TimetableEvent[]>;
abstract update(id: string, data: Partial<TimetableEvent>, expectedVersion?: number): Promise<TimetableEvent>;
abstract delete(id: string): Promise<void>;The update method accepts an optional expectedVersion for optimistic concurrency control.
Exception Management
abstract createException(data: Omit<EventException, 'id'>): Promise<EventException>;
abstract findExceptions(eventId: string): Promise<EventException[]>;
abstract deleteException(id: string): Promise<void>;Instructor Associations
abstract addInstructor(data: Omit<EventInstructor, 'id'>): Promise<EventInstructor>;
abstract removeInstructor(eventId: string, instructorId: string): Promise<void>;
abstract findInstructors(eventId: string): Promise<EventInstructor[]>;Group Associations
abstract addGroup(data: Omit<EventGroup, 'id'>): Promise<EventGroup>;
abstract removeGroup(eventId: string, groupId: string): Promise<void>;
abstract findGroups(eventId: string): Promise<EventGroup[]>;RoomStorage
import { RoomStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<Room, 'id'>): Promise<Room>;
abstract findById(id: string): Promise<Room | null>;
abstract findAll(filters?: {
building?: string;
campus?: string;
minCapacity?: number;
tags?: Record<string, unknown>;
}): Promise<Room[]>;
abstract update(id: string, data: Partial<Room>): Promise<Room>;
abstract delete(id: string): Promise<void>;InstructorStorage
import { InstructorStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<Instructor, 'id'>): Promise<Instructor>;
abstract findById(id: string): Promise<Instructor | null>;
abstract findAll(): Promise<Instructor[]>;
abstract update(id: string, data: Partial<Instructor>): Promise<Instructor>;
abstract delete(id: string): Promise<void>;GroupStorage
import { GroupStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<Group, 'id'>): Promise<Group>;
abstract findById(id: string): Promise<Group | null>;
abstract findAll(): Promise<Group[]>;
abstract update(id: string, data: Partial<Group>): Promise<Group>;
abstract delete(id: string): Promise<void>;
abstract addStudent(groupId: string, studentId: string): Promise<StudentGroup>;
abstract removeStudent(groupId: string, studentId: string): Promise<void>;
abstract findStudents(groupId: string): Promise<StudentGroup[]>;AvailabilityStorage
import { AvailabilityStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<Availability, 'id'>): Promise<Availability>;
abstract findById(id: string): Promise<Availability | null>;
abstract findByEntity(entityType: AvailabilityEntityType, entityId: string): Promise<Availability[]>;
abstract findByEntityInRange(
entityType: AvailabilityEntityType,
entityId: string,
dateRange: DateRange,
): Promise<Availability[]>;
abstract update(id: string, data: Partial<Availability>): Promise<Availability>;
abstract delete(id: string): Promise<void>;AcademicPeriodStorage
import { AcademicPeriodStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<AcademicPeriod, 'id'>): Promise<AcademicPeriod>;
abstract findById(id: string): Promise<AcademicPeriod | null>;
abstract findAll(): Promise<AcademicPeriod[]>;
abstract findChildren(parentId: string): Promise<AcademicPeriod[]>;
abstract update(id: string, data: Partial<AcademicPeriod>): Promise<AcademicPeriod>;
abstract delete(id: string): Promise<void>;CourseStorage
import { CourseStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<Course, 'id'>): Promise<Course>;
abstract findById(id: string): Promise<Course | null>;
abstract findAll(): Promise<Course[]>;
abstract findChildren(parentId: string): Promise<Course[]>;
abstract update(id: string, data: Partial<Course>): Promise<Course>;
abstract delete(id: string): Promise<void>;LocationDistanceStorage
Optional. Only needed if you track campus-to-campus travel times.
import { LocationDistanceStorage } from '@hfu.digital/coursekit-nestjs';abstract create(data: Omit<LocationDistance, 'id'>): Promise<LocationDistance>;
abstract findByCampuses(fromCampus: string, toCampus: string): Promise<LocationDistance | null>;
abstract findAll(): Promise<LocationDistance[]>;
abstract delete(id: string): Promise<void>;