Added case type for all GET APIs

This commit is contained in:
SepehrYahyaee
2026-08-19 12:30:53 +03:30
parent 26c80512ba
commit 3bd6bc6e9d
10 changed files with 95 additions and 14 deletions

View File

@@ -10797,16 +10797,41 @@ export class ClaimRequestManagementService {
} }
claims = [...byId.values()]; claims = [...byId.values()];
} }
const list = (claims as any[]).map((c) => ({ const blameIdsForList = [
claimRequestId: c._id.toString(), ...new Set(
publicId: c.publicId, (claims as any[])
requestNo: c.requestNo, .map((c) => c.blameRequestId?.toString())
status: c.status, .filter((id): id is string => !!id),
claimStatus: c.claimStatus || "PENDING", ),
currentStep: c.workflow?.currentStep || "", ];
createdAt: c.createdAt, const blamesForList =
blameRequestId: c.blameRequestId?.toString(), blameIdsForList.length > 0
})) as ClaimListItemV2Dto[]; ? ((await this.blameRequestDbService.find(
{ _id: { $in: blameIdsForList.map((id) => new Types.ObjectId(id)) } },
{ lean: true, select: "type creationMethod" },
)) as any[])
: [];
const blameByIdForList = new Map<string, any>(
blamesForList.map((b) => [String(b._id), b]),
);
const list = (claims as any[]).map((c) => {
const blameForItem = c.blameRequestId
? blameByIdForList.get(c.blameRequestId.toString())
: undefined;
return {
claimRequestId: c._id.toString(),
publicId: c.publicId,
requestNo: c.requestNo,
status: c.status,
claimStatus: c.claimStatus || "PENDING",
currentStep: c.workflow?.currentStep || "",
createdAt: c.createdAt,
blameRequestId: c.blameRequestId?.toString(),
blameType: blameForItem?.type ?? undefined,
creationMethod: blameForItem?.creationMethod ?? undefined,
};
}) as ClaimListItemV2Dto[];
const paged = applyListQueryV2( const paged = applyListQueryV2(
list, list,
@@ -10856,6 +10881,15 @@ export class ClaimRequestManagementService {
} }
await this.assertActorCanViewClaimV2(claim, currentUserId, actor); await this.assertActorCanViewClaimV2(claim, currentUserId, actor);
const blameForDetail = claim.blameRequestId
? ((
await this.blameRequestDbService.find(
{ _id: new Types.ObjectId(claim.blameRequestId.toString()) },
{ lean: true, select: "type creationMethod" },
)
)[0] ?? null)
: null;
const hasCapture = (data: any, key: string) => const hasCapture = (data: any, key: string) =>
data && (data instanceof Map ? data.get(key) : data[key]); data && (data instanceof Map ? data.get(key) : data[key]);
@@ -11011,6 +11045,8 @@ export class ClaimRequestManagementService {
nextStep: claim.workflow?.nextStep, nextStep: claim.workflow?.nextStep,
blameRequestId: claim.blameRequestId?.toString(), blameRequestId: claim.blameRequestId?.toString(),
blameRequestNo: claim.blameRequestNo, blameRequestNo: claim.blameRequestNo,
blameType: (blameForDetail as any)?.type ?? undefined,
creationMethod: (blameForDetail as any)?.creationMethod ?? undefined,
...(ownerData ? { owner: ownerData } : {}), ...(ownerData ? { owner: ownerData } : {}),
vehicle: claim.vehicle, vehicle: claim.vehicle,
selectedParts: selectedNormDetails, selectedParts: selectedNormDetails,

View File

@@ -122,6 +122,18 @@ export class ClaimDetailsV2ResponseDto {
@ApiPropertyOptional({ description: 'Blame request number' }) @ApiPropertyOptional({ description: 'Blame request number' })
blameRequestNo?: string; blameRequestNo?: string;
@ApiPropertyOptional({
description: 'Blame file type: THIRD_PARTY or CAR_BODY',
example: 'THIRD_PARTY',
})
blameType?: string;
@ApiPropertyOptional({
description: 'How the blame file was initiated: IN_PERSON or LINK',
example: 'IN_PERSON',
})
creationMethod?: string;
@ApiPropertyOptional({ @ApiPropertyOptional({
description: 'Claim owner (damaged party): ids for the user and their insurer client scope', description: 'Claim owner (damaged party): ids for the user and their insurer client scope',
}) })

View File

@@ -28,6 +28,18 @@ export class ClaimListItemV2Dto {
@ApiProperty({ description: 'Blame request ID this claim originated from' }) @ApiProperty({ description: 'Blame request ID this claim originated from' })
blameRequestId?: string; blameRequestId?: string;
@ApiPropertyOptional({
description: 'Blame file type: THIRD_PARTY or CAR_BODY',
example: 'THIRD_PARTY',
})
blameType?: string;
@ApiPropertyOptional({
description: 'How the blame file was initiated: IN_PERSON or LINK',
example: 'IN_PERSON',
})
creationMethod?: string;
} }
export class GetMyClaimsV2ResponseDto { export class GetMyClaimsV2ResponseDto {

View File

@@ -116,6 +116,8 @@ export class AllRequestDtoV2 {
lockFile: boolean; lockFile: boolean;
lockTime: string | null; lockTime: string | null;
type: string; type: string;
/** IN_PERSON or LINK — how the blame file was created */
creationMethod?: string;
blameStatus: string; blameStatus: string;
/** Calculated blame + linked claim lifecycle status */ /** Calculated blame + linked claim lifecycle status */
unifiedFileStatus?: string; unifiedFileStatus?: string;

View File

@@ -762,6 +762,7 @@ export class ExpertBlameService {
? new Date(workflow.lockedAt as string).toISOString() ? new Date(workflow.lockedAt as string).toISOString()
: null, : null,
type: String(doc.type ?? "THIRD_PARTY"), type: String(doc.type ?? "THIRD_PARTY"),
creationMethod: doc.creationMethod ? String(doc.creationMethod) : undefined,
blameStatus: String(doc.blameStatus ?? ""), blameStatus: String(doc.blameStatus ?? ""),
partiesInitialForms: { partiesInitialForms: {
firstParty: statementToFormKey(firstParty?.statement) ?? "", firstParty: statementToFormKey(firstParty?.statement) ?? "",

View File

@@ -52,6 +52,12 @@ export class ClaimDetailV2ResponseDto {
}) })
blameRequestType?: BlameRequestType; blameRequestType?: BlameRequestType;
@ApiPropertyOptional({
description: "How the blame file was initiated: IN_PERSON or LINK",
example: "IN_PERSON",
})
creationMethod?: string;
@ApiPropertyOptional({ @ApiPropertyOptional({
description: description:
"CAR_BODY only: first-step flags — another car (`car`) and/or object (`object`)", "CAR_BODY only: first-step flags — another car (`car`) and/or object (`object`)",

View File

@@ -49,6 +49,12 @@ export class ClaimListItemV2Dto {
}) })
blameRequestType?: BlameRequestType; blameRequestType?: BlameRequestType;
@ApiPropertyOptional({
description: 'How the blame file was initiated: IN_PERSON or LINK',
example: 'IN_PERSON',
})
creationMethod?: string;
@ApiPropertyOptional({ @ApiPropertyOptional({
description: description:
'CAR_BODY only: first-step flags — accident involved another car (`car`) and/or fixed object (`object`)', 'CAR_BODY only: first-step flags — accident involved another car (`car`) and/or fixed object (`object`)',

View File

@@ -629,6 +629,7 @@ export class ExpertClaimService {
*/ */
private blameFileContextForExpert(blame: any): { private blameFileContextForExpert(blame: any): {
blameRequestType?: BlameRequestType; blameRequestType?: BlameRequestType;
creationMethod?: string;
carBodyFirstForm?: { car?: boolean; object?: boolean }; carBodyFirstForm?: { car?: boolean; object?: boolean };
blameStatus?: string; blameStatus?: string;
} { } {
@@ -636,9 +637,11 @@ export class ExpertClaimService {
const blameRequestType = blame.type as BlameRequestType; const blameRequestType = blame.type as BlameRequestType;
const out: { const out: {
blameRequestType?: BlameRequestType; blameRequestType?: BlameRequestType;
creationMethod?: string;
carBodyFirstForm?: { car?: boolean; object?: boolean }; carBodyFirstForm?: { car?: boolean; object?: boolean };
blameStatus?: string; blameStatus?: string;
} = { blameRequestType }; } = { blameRequestType };
if (blame.creationMethod) out.creationMethod = blame.creationMethod;
out.blameStatus = blame.blameStatus; out.blameStatus = blame.blameStatus;
if (blameRequestType !== BlameRequestType.CAR_BODY) return out; if (blameRequestType !== BlameRequestType.CAR_BODY) return out;
@@ -4017,7 +4020,7 @@ export class ExpertClaimService {
blameIds.length > 0 blameIds.length > 0
? ((await this.blameRequestDbService.find( ? ((await this.blameRequestDbService.find(
{ _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } }, { _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } },
{ lean: true, select: "type parties expert.decision blameStatus status isMadeByFileMaker" }, { lean: true, select: "type creationMethod parties expert.decision blameStatus status isMadeByFileMaker" },
)) as any[]) )) as any[])
: []; : [];
const blameById = new Map<string, any>( const blameById = new Map<string, any>(
@@ -4117,7 +4120,7 @@ export class ExpertClaimService {
blameIds.length > 0 blameIds.length > 0
? ((await this.blameRequestDbService.find( ? ((await this.blameRequestDbService.find(
{ _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } }, { _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } },
{ lean: true, select: "type parties expert.decision blameStatus status" }, { lean: true, select: "type creationMethod parties expert.decision blameStatus status" },
)) as any[]) )) as any[])
: []; : [];
const blameById = new Map<string, any>( const blameById = new Map<string, any>(
@@ -4212,7 +4215,7 @@ export class ExpertClaimService {
{ {
lean: true, lean: true,
select: select:
"_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval", "_id type creationMethod parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval",
}, },
)) as any[]; )) as any[];
@@ -4303,7 +4306,7 @@ export class ExpertClaimService {
const makerBlames = (await this.blameRequestDbService.find( const makerBlames = (await this.blameRequestDbService.find(
{ isMadeByFileMaker: true, initiatedByFieldExpertId: makerOid }, { isMadeByFileMaker: true, initiatedByFieldExpertId: makerOid },
{ lean: true, select: "_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval" }, { lean: true, select: "_id type creationMethod parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval" },
)) as any[]; )) as any[];
if (makerBlames.length === 0) { if (makerBlames.length === 0) {

View File

@@ -1498,6 +1498,8 @@ export class ExpertInsurerService {
(blame as any)?.requestNumber || (blame as any)?.requestNumber ||
(claim as any)?.requestNumber, (claim as any)?.requestNumber,
type: (blame as any)?.type ?? (blameFull as any)?.type, type: (blame as any)?.type ?? (blameFull as any)?.type,
creationMethod:
(blame as any)?.creationMethod ?? (blameFull as any)?.creationMethod,
hasClaim: !!claim, hasClaim: !!claim,
blameStatus: (blame as any)?.status ?? (blameFull as any)?.status, blameStatus: (blame as any)?.status ?? (blameFull as any)?.status,
claimStatus: (claim as any)?.status, claimStatus: (claim as any)?.status,

View File

@@ -6116,6 +6116,7 @@ export class RequestManagementService {
requestNo: plain.requestNo, requestNo: plain.requestNo,
publicId: plain.publicId, publicId: plain.publicId,
type: plain.type, type: plain.type,
creationMethod: plain.creationMethod,
status: plain.status, status: plain.status,
blameStatus: plain.blameStatus, blameStatus: plain.blameStatus,
workflow: plain.workflow, workflow: plain.workflow,