"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.create = create; const connection_1 = require("../db/connection"); /** * Repository for persisting audit log entries to the database. * Records user actions and system events for security and compliance tracking. */ /** * Creates a new audit log entry. * @param data - Audit log fields to persist. * @param data.userId - Optional ID of the user who performed the action. * @param data.action - Action identifier (e.g. login, withdrawal). * @param data.resourceType - Optional type of resource affected. * @param data.resourceId - Optional ID of the resource affected. * @param data.ipAddress - Optional client IP address. * @param data.userAgent - Optional client user-agent string. * @param data.metadata - Optional additional context as key-value pairs. * @returns Resolves when the row has been inserted. */ async function create(data) { await (0, connection_1.query)(`INSERT INTO audit_logs (user_id, action, resource_type, resource_id, ip_address, user_agent, metadata) VALUES ($1, $2, $3, $4, $5, $6, $7)`, [ data.userId ?? null, data.action, data.resourceType ?? null, data.resourceId ?? null, data.ipAddress ?? null, data.userAgent ?? null, data.metadata ? JSON.stringify(data.metadata) : null, ]); } //# sourceMappingURL=auditLogRepository.js.map