1
0
forked from Yara724/api
Files
yara724-api/src/claim-request-management/entites/schema/claim-case.media.schema.ts

89 lines
2.2 KiB
TypeScript

import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Schema as MongooseSchema, Types } from "mongoose";
import { AiImagesModel } from "./ai-image.schema";
import { CarGreenCardModel } from "./car-green-card.schema";
import { ImageRequiredModel } from "./image-required.schema";
@Schema({ _id: false })
export class CapturedImage {
@Prop({ type: String })
path?: string;
@Prop({ type: String })
fileName?: string;
@Prop({ type: String })
url?: string;
@Prop({ type: Date })
capturedAt?: Date;
}
export const CapturedImageSchema = SchemaFactory.createForClass(CapturedImage);
/** One row per selected damaged part (index-aligned with `damage.selectedParts`). */
@Schema({ _id: false })
export class DamagedPartMediaV2Row {
@Prop({ type: Number })
id?: number;
@Prop({ type: String })
name?: string;
@Prop({ type: String })
side?: string;
@Prop({ type: String })
label_fa?: string;
@Prop({ type: String })
catalogKey?: string;
@Prop({ type: String })
path?: string;
@Prop({ type: String })
fileName?: string;
@Prop({ type: String })
url?: string;
@Prop({ type: Date })
capturedAt?: Date;
}
export const DamagedPartMediaV2RowSchema =
SchemaFactory.createForClass(DamagedPartMediaV2Row);
@Schema({ _id: false })
export class ClaimMedia {
@Prop({ type: CarGreenCardModel })
carGreenCard?: CarGreenCardModel;
@Prop({ type: ImageRequiredModel })
imageRequired?: ImageRequiredModel;
@Prop({ type: AiImagesModel })
aiImages?: AiImagesModel;
@Prop({ type: Types.ObjectId })
videoCaptureId?: Types.ObjectId;
/**
* V2: Car angles captures (front, back, left, right)
* Map of angle key to captured image
*/
@Prop({
type: Map,
of: CapturedImageSchema,
default: () => ({}),
})
carAngles?: Map<string, CapturedImage>;
/**
* V2: Damaged parts captures — prefer an array (index matches `damage.selectedParts`).
* Legacy documents may store a plain object map keyed by part slug until migrated on write.
*/
@Prop({ type: MongooseSchema.Types.Mixed })
damagedParts?: DamagedPartMediaV2Row[] | Record<string, unknown>;
}
export const ClaimMediaSchema = SchemaFactory.createForClass(ClaimMedia);