import { CheckInMethodValue } from "../domain/enums/check-in-method.enum.mjs"; import { GeoPoint } from "../domain/value-objects/geo-point.vo.mjs"; import { DeviceInfo } from "../domain/value-objects/device-info.vo.mjs"; import { RecordTypeValue } from "../domain/enums/record-type.enum.mjs"; import { Document, Schema, Types } from "mongoose"; //#region src/models/attendance-record.model.d.ts /** * AttendanceRecord is the APPEND-ONLY event log for a session. Every * check-in, check-out, break boundary, and approved correction materialises * as a new record. Records are NEVER updated or soft-deleted — superseded * entries are only "superseded" logically via `correction_applied` records * pointing at them via `correctionOf`. */ interface AttendanceRecordDocument extends Document { _id: Types.ObjectId; organizationId: Types.ObjectId | string; sessionId: Types.ObjectId; subjectRef: string; subjectModel: string; recordType: RecordTypeValue; /** When the event is claimed to have occurred (wall-clock time). */ occurredAt: Date; /** When muster wrote the record (server-clock time). */ recordedAt: Date; /** Not applicable to `correction_applied` records. */ method?: CheckInMethodValue; geo?: GeoPoint; device?: DeviceInfo; /** Populated on `correction_applied` records — points at the record being * superseded (or null when a new value is being written rather than * correcting an existing one). */ correctionOf?: Types.ObjectId | null; /** Populated on `correction_applied` records — points at the * AttendanceCorrection document that authorised this write. */ correctionId?: Types.ObjectId; /** Who recorded this entry (actor from MusterContext). */ recordedBy: string; /** Free-form note (optional, max 500 chars enforced at schema level). */ note?: string; /** * Device-replay dedupe key. Biometric fleets (ZKTeco ADMS/iClock and kin) * RE-UPLOAD unacknowledged punch batches on every reconnect — the natural * key is `SN:PIN:timestamp`. A partial unique index makes the replay a * duplicate-key no-op instead of a second record; `punch()` / `checkIn` / * `checkOut` return the ORIGINAL result on a key hit. */ idempotencyKey?: string; metadata?: Record; createdAt: Date; } //#endregion export { AttendanceRecordDocument };