import { Types } from "mongoose"; // "signed" - first acceptance of the agreement text for this department // "updated" - vendor checkbox state changed under an already-accepted agreement // "revoked" - data sharing cancelled; the record captures the final (all-off) state export const DataSharingAgreementActions = ["signed", "updated", "revoked"] as const; export type DataSharingAgreementAction = typeof DataSharingAgreementActions[number]; // One vendor / config checkbox as it was shown to the signer. // `checked` is the state AFTER the action this record describes. export interface DataSharingVendorConsentType { key: string, label: string, checked: boolean, } // Append-only legal record: every signature, change and revocation is a new document. // Nothing here is ever updated or deleted through the API - the history is the collection. // Names and agreement text are denormalized on purpose so the record cannot drift from // what the signer actually saw. export interface DataSharingAgreementType { _id: Types.ObjectId, uuid: string, // Who / where. "Account" in the ticket == Department; departmentId is a string // (hex of Department._id) per codebase convention. departmentId: string, departmentName: string, agencyId: Types.ObjectId | null, agencyName: string, userId: string, email: string, signerName: string, // What they signed agreementTitle: string, agreementVersion: string, agreementText: string, action: DataSharingAgreementAction, consents: DataSharingVendorConsentType[], // Evidence captured server-side from the request remoteAddress: string, userAgent: string, appVersion: string, createdAt: Date, modified: Date, }