forked from Yara724/api
Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
|
import { Schema as MongooseSchema } from "mongoose";
|
|
import { CarDamagePartModel, CarDamagePartOtherModel } from "./car-parts.schema";
|
|
|
|
@Schema({ _id: false })
|
|
export class ClaimDamageSelection {
|
|
/**
|
|
* V2: Selected outer damaged parts (ordered). Prefer objects
|
|
* `{ id, name, side, label_fa, catalogKey? }`; legacy string keys are still accepted until migrated.
|
|
*/
|
|
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
|
|
selectedParts?: unknown[];
|
|
|
|
/**
|
|
* V2: Array of selected other (non-body) damaged parts
|
|
* Examples: ['engine', 'suspension', 'headlight']
|
|
*/
|
|
@Prop({ type: [String], default: [] })
|
|
otherParts?: string[];
|
|
|
|
/**
|
|
* Append-only expert edit revisions. Each revision preserves the prior
|
|
* selection and capture metadata for removed parts before the live arrays
|
|
* are replaced. Mixed keeps legacy/free-text part shapes readable.
|
|
*/
|
|
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
|
|
partSelectionHistory?: unknown[];
|
|
|
|
/** Parts introduced by an expert across revisions (used for origin labels). */
|
|
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
|
|
expertAddedParts?: unknown[];
|
|
|
|
/**
|
|
* Legacy fields - kept for backward compatibility
|
|
*/
|
|
@Prop({ type: [CarDamagePartModel] })
|
|
legacyParts?: CarDamagePartModel[];
|
|
|
|
@Prop({ type: CarDamagePartOtherModel })
|
|
legacyOtherParts?: CarDamagePartOtherModel;
|
|
}
|
|
export const ClaimDamageSelectionSchema =
|
|
SchemaFactory.createForClass(ClaimDamageSelection);
|