(
kv: StateKV,
operation: AuditEntry["operation"],
functionId: string,
targetIds: string[],
details: Record<string, unknown> = {},
qualityScore?: number,
userId?: string,
)
| 32 | // BEFORE kv.delete(...) and match one of the two shapes above. |
| 33 | |
| 34 | export async function recordAudit( |
| 35 | kv: StateKV, |
| 36 | operation: AuditEntry["operation"], |
| 37 | functionId: string, |
| 38 | targetIds: string[], |
| 39 | details: Record<string, unknown> = {}, |
| 40 | qualityScore?: number, |
| 41 | userId?: string, |
| 42 | ): Promise<AuditEntry> { |
| 43 | const entry: AuditEntry = { |
| 44 | id: generateId("aud"), |
| 45 | timestamp: new Date().toISOString(), |
| 46 | operation, |
| 47 | userId, |
| 48 | functionId, |
| 49 | targetIds, |
| 50 | details, |
| 51 | qualityScore, |
| 52 | }; |
| 53 | await kv.set(KV.audit, entry.id, entry); |
| 54 | return entry; |
| 55 | } |
| 56 | |
| 57 | export async function safeAudit( |
| 58 | kv: StateKV, |
no test coverage detected