"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),error_1=require("@b/utils/error");exports.metadata={summary:"Get Verification Results",description:"Retrieves all verification results for a specific KYC application.",operationId:"getVerificationResults",tags:["KYC","Verification Services","Applications"],logModule:"ADMIN_CRM",logTitle:"Get verification results",parameters:[{index:0,name:"id",in:"path",description:"KYC application ID",required:!0,schema:{type:"string"}}],responses:{200:{description:"Verification results retrieved successfully.",content:{"application/json":{schema:{type:"array",items:{type:"object",properties:{id:{type:"string",description:"Verification result ID"},applicationId:{type:"string",description:"KYC application ID"},serviceId:{type:"string",description:"Verification service ID"},status:{type:"string",description:"Verification status (PENDING, APPROVED, REJECTED)"},result:{type:"object",description:"Detailed verification result"},createdAt:{type:"string",format:"date-time",description:"When the verification was initiated"},updatedAt:{type:"string",format:"date-time",description:"When the verification was last updated"}}}}}}},404:{description:"No verification results found for this application."},500:{description:"Internal Server Error."}},permission:"view.kyc.verification",requiresAuth:!0};exports.default=async e=>{const{params:i,ctx:t}=e,{id:r}=i;null==t||t.step(`Fetching verification results for application ${r}`);const s=await db_1.models.kycVerificationResult.findAll({where:{applicationId:r},order:[["createdAt","DESC"]],include:[{model:db_1.models.kycVerificationService,as:"service",attributes:["id","name","type"]}]});if(!s||0===s.length)throw(0,error_1.createError)({statusCode:404,message:"No verification results found for this application"});const o=s.map(e=>{const i=e.toJSON?e.toJSON():e;return{...i,checks:i.checks?JSON.parse(i.checks):i.checks,documentVerifications:i.documentVerifications?JSON.parse(i.documentVerifications):i.documentVerifications}});null==t||t.success("Verification results retrieved successfully");return o};