Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+65
@@ -0,0 +1,65 @@
|
||||
import type { JsonValue } from "@hivegrid/foundation";
|
||||
import { createAuditEvent } from "@hivegrid/db/audit-events.server";
|
||||
import { logActivity } from "@hivegrid/activity";
|
||||
import type { LeadRouteContext } from "./leadAccess.server";
|
||||
import type { LeadRow } from "./leadService.server";
|
||||
|
||||
export type LeadAuditAction =
|
||||
| "lead.created"
|
||||
| "lead.updated"
|
||||
| "lead.status_changed"
|
||||
| "lead.assigned"
|
||||
| "lead.bulk_updated"
|
||||
| "lead.qualified"
|
||||
| "lead.convert_requested"
|
||||
| "lead.source_created"
|
||||
| "lead.source_updated"
|
||||
| "lead.anti_spam_updated";
|
||||
|
||||
export async function auditLeadEvent(input: {
|
||||
ctx: Pick<LeadRouteContext, "tenantId" | "userId">;
|
||||
action: LeadAuditAction;
|
||||
targetType: "lead" | "lead_source" | "lead_anti_spam";
|
||||
targetId: string;
|
||||
metadata?: Record<string, JsonValue>;
|
||||
}): Promise<void> {
|
||||
try {
|
||||
await createAuditEvent({
|
||||
tenantId: input.ctx.tenantId,
|
||||
actorId: input.ctx.userId,
|
||||
actorType: "user",
|
||||
action: input.action,
|
||||
targetType: input.targetType,
|
||||
targetId: input.targetId,
|
||||
metadata: input.metadata ?? null,
|
||||
});
|
||||
} catch {
|
||||
// Best-effort: audit failures are reported upstream, not to the user action.
|
||||
}
|
||||
}
|
||||
|
||||
export async function logLeadActivity(input: {
|
||||
ctx: Pick<LeadRouteContext, "tenantId" | "userId">;
|
||||
leadId: string;
|
||||
activityType: "lead_created" | "lead_updated" | "lead_qualified" | "assignee_changed" | "status_changed";
|
||||
summaryText: string;
|
||||
}): Promise<void> {
|
||||
try {
|
||||
await logActivity({
|
||||
tenantId: input.ctx.tenantId,
|
||||
actorUserId: input.ctx.userId,
|
||||
actorKind: "user",
|
||||
activityType: input.activityType,
|
||||
subjectType: "lead",
|
||||
subjectId: input.leadId,
|
||||
summaryText: input.summaryText,
|
||||
});
|
||||
} catch {
|
||||
// Activity is best-effort; never break the mutation.
|
||||
}
|
||||
}
|
||||
|
||||
export function leadDisplayName(row: Pick<LeadRow, "vorname" | "nachname" | "email" | "telefon" | "quelle">): string {
|
||||
const name = `${row.vorname ?? ""} ${row.nachname ?? ""}`.trim();
|
||||
return name || row.email || row.telefon || row.quelle;
|
||||
}
|
||||
Reference in new issue
Block a user