My App
CourseKitType Reference

Conflict Types

Types for conflict detection, validation, and constraint evaluation

Conflict

A single constraint violation detected by the conflict pipeline.

type ConflictSeverity = 'error' | 'warning';

interface Conflict {
    id: string;
    type: string;                           // e.g. "instructor-double-book", "room-overlap"
    severity: ConflictSeverity;
    message: string;
    involvedEventIds: string[];
    involvedEntityIds: string[];
    metadata: Record<string, unknown>;
}
FieldDescription
idUnique identifier for this specific conflict instance
typeConstraint-defined type string (e.g., 'instructor-double-book', 'room-over-capacity', 'availability-violation')
severity'error' for blocking issues, 'warning' for advisories
messageHuman-readable description
involvedEventIdsIDs of events involved in the conflict
involvedEntityIdsIDs of entities involved (instructors, rooms, groups)
metadataAdditional data from the constraint (times, capacities, etc.)

ConflictCheckResult

Aggregated result from the constraint pipeline.

interface ConflictCheckResult {
    hasErrors: boolean;
    hasWarnings: boolean;
    conflicts: Conflict[];
}

ConstraintContext

Context object passed to ScheduleConstraint.evaluate() with lookup helpers.

interface ConstraintContext {
    dateRange: DateRange;
    allEvents: TimetableEvent[];
    getInstructorsForEvent: (eventId: string) => Promise<string[]>;
    getGroupsForEvent: (eventId: string) => Promise<string[]>;
    getRoomById: (roomId: string) => Promise<Room | null>;
    getGroupStudentCount: (groupId: string) => Promise<number>;
    isEntityAvailable: (
        entityType: AvailabilityEntityType,
        entityId: string,
        start: Date,
        durationMin: number,
    ) => Promise<{ available: boolean; conflicts: Availability[] }>;
}

These helpers are injected by ConflictService to give constraints access to related data without coupling them to storage directly.

ScheduleConstraint

Abstract class that all constraints must extend.

abstract class ScheduleConstraint {
    abstract readonly type: string;
    abstract readonly description: string;

    abstract evaluate(
        occurrences: MaterializedOccurrence[],
        context: ConstraintContext,
    ): Promise<Conflict[]>;
}

ValidationError

Used by DTO static validate() methods.

interface ValidationError {
    field: string;
    message: string;
    value?: unknown;
}

ValidationResult

interface ValidationResult {
    valid: boolean;
    errors: ValidationError[];
}

On this page