forked from Yara724/api
audit fanavaran logs and missing fields null fixed
This commit is contained in:
75
src/fanavaran/schema/fanavaran-audit-log.schema.ts
Normal file
75
src/fanavaran/schema/fanavaran-audit-log.schema.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { HydratedDocument, Types } from "mongoose";
|
||||
import type { FanavaranClientKey } from "src/core/config/fanavaran-client.config";
|
||||
|
||||
export enum FanavaranAuditStep {
|
||||
GET_APP_TOKEN = "GET_APP_TOKEN",
|
||||
LOGIN = "LOGIN",
|
||||
POLICY_INQUIRY = "POLICY_INQUIRY",
|
||||
BUILD_PAYLOAD = "BUILD_PAYLOAD",
|
||||
SUBMIT_CLAIM = "SUBMIT_CLAIM",
|
||||
}
|
||||
|
||||
export enum FanavaranAuditStatus {
|
||||
STARTED = "started",
|
||||
SUCCESS = "success",
|
||||
FAILURE = "failure",
|
||||
}
|
||||
|
||||
export enum FanavaranAuditSource {
|
||||
PREVIEW = "preview",
|
||||
SUBMIT = "submit",
|
||||
AUTO_SUBMIT = "auto_submit",
|
||||
LEGACY_SUBMIT = "legacy_submit",
|
||||
}
|
||||
|
||||
@Schema({ collection: "fanavaranAuditLogs", timestamps: true })
|
||||
export class FanavaranAuditLog {
|
||||
@Prop({ type: String, required: true, index: true })
|
||||
trackingCode: string;
|
||||
|
||||
@Prop({ type: String, required: true, enum: FanavaranAuditStep, index: true })
|
||||
step: FanavaranAuditStep;
|
||||
|
||||
@Prop({ type: String, required: true, enum: FanavaranAuditStatus, index: true })
|
||||
status: FanavaranAuditStatus;
|
||||
|
||||
@Prop({ type: String, required: true, index: true })
|
||||
clientKey: FanavaranClientKey;
|
||||
|
||||
@Prop({ type: String, required: true, enum: FanavaranAuditSource, index: true })
|
||||
source: FanavaranAuditSource;
|
||||
|
||||
@Prop({ type: Types.ObjectId, required: false, index: true })
|
||||
claimCaseId?: Types.ObjectId;
|
||||
|
||||
@Prop({ type: Types.ObjectId, required: false, index: true })
|
||||
claimRequestId?: Types.ObjectId;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
requestUrl?: string;
|
||||
|
||||
@Prop({ type: Number, required: false })
|
||||
httpStatus?: number;
|
||||
|
||||
@Prop({ type: Object, required: false })
|
||||
requestMeta?: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: Object, required: false })
|
||||
responseMeta?: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: String, required: false })
|
||||
errorMessage?: string;
|
||||
|
||||
@Prop({ type: Object, required: false })
|
||||
errorDetails?: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: Number, required: false })
|
||||
durationMs?: number;
|
||||
}
|
||||
|
||||
export type FanavaranAuditLogDocument = HydratedDocument<FanavaranAuditLog>;
|
||||
export const FanavaranAuditLogSchema =
|
||||
SchemaFactory.createForClass(FanavaranAuditLog);
|
||||
|
||||
FanavaranAuditLogSchema.index({ trackingCode: 1, createdAt: 1 });
|
||||
Reference in New Issue
Block a user