mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-16 10:50:38 +09:00
27 lines
710 B
TypeScript
27 lines
710 B
TypeScript
|
|
import type { Db } from "@paperclip/db";
|
||
|
|
import { activityLog } from "@paperclip/db";
|
||
|
|
|
||
|
|
export interface LogActivityInput {
|
||
|
|
companyId: string;
|
||
|
|
actorType: "agent" | "user" | "system";
|
||
|
|
actorId: string;
|
||
|
|
action: string;
|
||
|
|
entityType: string;
|
||
|
|
entityId: string;
|
||
|
|
agentId?: string | null;
|
||
|
|
details?: Record<string, unknown> | null;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function logActivity(db: Db, input: LogActivityInput) {
|
||
|
|
await db.insert(activityLog).values({
|
||
|
|
companyId: input.companyId,
|
||
|
|
actorType: input.actorType,
|
||
|
|
actorId: input.actorId,
|
||
|
|
action: input.action,
|
||
|
|
entityType: input.entityType,
|
||
|
|
entityId: input.entityId,
|
||
|
|
agentId: input.agentId ?? null,
|
||
|
|
details: input.details ?? null,
|
||
|
|
});
|
||
|
|
}
|