import { ErrorCode } from '../types.js'; import 'mongoose'; /** * ClockIn Errors - Structured Error Hierarchy * * Follows Stripe/Auth0 error handling patterns: * - Machine-readable codes * - HTTP status codes * - Rich context data * - Proper stack traces * * @module @classytic/clockin/errors */ /** * Base error class for all ClockIn errors * * @example * ```typescript * throw new ClockInError( * 'MEMBER_NOT_FOUND', * 404, * 'Member with ID abc123 not found' * ); * ``` */ declare class ClockInError extends Error { readonly code: ErrorCode; readonly status: number; readonly context: Record; readonly timestamp: Date; constructor(code: ErrorCode, status: number, message: string, context?: Record); /** * Convert error to JSON for API responses */ toJSON(): Record; /** * Check if error is operational (expected) vs programmer error */ isOperational(): boolean; } /** * Error thrown when ClockIn is not initialized */ declare class NotInitializedError extends ClockInError { constructor(message?: string); } /** * Error thrown when member is not found */ declare class MemberNotFoundError extends ClockInError { constructor(identifier?: string, context?: Record); } /** * Error thrown when member is invalid for check-in */ declare class InvalidMemberError extends ClockInError { constructor(reason: string, context?: Record); } /** * Error thrown for duplicate check-ins */ declare class DuplicateCheckInError extends ClockInError { readonly lastCheckIn: Date; readonly nextAllowedTime: Date; constructor(lastCheckIn: Date, nextAllowedTime: Date, context?: Record); } /** * Error thrown for validation failures */ declare class ValidationError extends ClockInError { readonly field?: string; readonly validValues?: unknown[]; constructor(message: string, context?: { field?: string; value?: unknown; validValues?: unknown[]; }); } /** * Error thrown when attendance is not enabled for member */ declare class AttendanceNotEnabledError extends ClockInError { constructor(memberId?: string); } /** * Error thrown when no active session exists */ declare class NoActiveSessionError extends ClockInError { constructor(memberId?: string, context?: Record); } /** * Error thrown when member is already checked out */ declare class AlreadyCheckedOutError extends ClockInError { constructor(checkInId?: string, context?: Record); } /** * Error thrown when target model is not in the allowed list */ declare class TargetModelNotAllowedError extends ClockInError { readonly targetModel: string; readonly allowedModels: string[]; constructor(targetModel: string, allowedModels: string[], context?: Record); } /** * Create error from code */ declare function createError(code: ErrorCode, message: string, context?: Record): ClockInError; /** * Check if error is a ClockInError */ declare function isClockInError(error: unknown): error is ClockInError; /** * Extract error info for logging/response */ declare function extractErrorInfo(error: unknown): { code: string; status: number; message: string; context?: Record; }; declare const _default: { ClockInError: typeof ClockInError; NotInitializedError: typeof NotInitializedError; MemberNotFoundError: typeof MemberNotFoundError; InvalidMemberError: typeof InvalidMemberError; DuplicateCheckInError: typeof DuplicateCheckInError; ValidationError: typeof ValidationError; AttendanceNotEnabledError: typeof AttendanceNotEnabledError; NoActiveSessionError: typeof NoActiveSessionError; AlreadyCheckedOutError: typeof AlreadyCheckedOutError; TargetModelNotAllowedError: typeof TargetModelNotAllowedError; createError: typeof createError; isClockInError: typeof isClockInError; extractErrorInfo: typeof extractErrorInfo; }; export { AlreadyCheckedOutError, AttendanceNotEnabledError, ClockInError, DuplicateCheckInError, InvalidMemberError, MemberNotFoundError, NoActiveSessionError, NotInitializedError, TargetModelNotAllowedError, ValidationError, createError, _default as default, extractErrorInfo, isClockInError };