1
0
forked from Yara724/api

Added expert field mirror flow

This commit is contained in:
SepehrYahyaee
2026-06-15 11:24:41 +03:30
committed by Sepehr Yahyaee
parent 79905345e5
commit 19dc2a76f2
39 changed files with 2310 additions and 182 deletions

View File

@@ -87,6 +87,32 @@ export function assertClaimCaseForTenant(
}
}
/**
* Returns true when a field expert (no clientKey) initiated this claim via an
* expert-initiated IN_PERSON blame file.
*/
export function claimCaseInitiatedByFieldExpert(
doc: any,
actor: { sub: string },
): boolean {
return (
!!doc.initiatedByFieldExpertId &&
String(doc.initiatedByFieldExpertId) === String(actor.sub)
);
}
/**
* Authorization check that works for both damage experts (clientKey tenant
* scope) and field experts (initiatedByFieldExpertId ownership).
*/
export function assertClaimCaseForExpertActor(
doc: any,
actor: { sub: string; clientKey?: string },
): void {
if (claimCaseInitiatedByFieldExpert(doc, actor)) return;
assertClaimCaseForTenant(doc, actor);
}
export function resolveGuiltyPartyClientId(doc: any): string | null {
const parties: any[] = doc?.parties ?? [];