"use strict";async function getKyc(e,t){const r=await db_1.models.kycApplication.findOne({where:{userId:e,id:t},include:[{model:db_1.models.kycLevel,as:"level",paranoid:!1},{model:db_1.models.kycVerificationResult,as:"verificationResult"}]});if(!r)throw(0,error_1.createError)({statusCode:404,message:"KYC record not found"});return r.get({plain:!0})}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getKyc=getKyc;const db_1=require("@b/db"),error_1=require("@b/utils/error"),query_1=require("@b/utils/query");exports.metadata={summary:"Retrieves a KYC application for the logged-in user",description:"Fetches a specific Know Your Customer (KYC) application, identified by ID, for the currently authenticated user. This endpoint requires user authentication and returns the KYC application details, including the verification status and other information.",operationId:"getUserKycApplication",tags:["KYC"],logModule:"USER",logTitle:"Get KYC application",parameters:[{index:0,name:"id",in:"path",description:"The ID of the KYC record to retrieve",required:!0,schema:{type:"string"}}],responses:{200:{description:"KYC application retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{id:{type:"number",description:"KYC ID"},userId:{type:"number",description:"User ID associated with the KYC record"},templateId:{type:"number",description:"ID of the KYC template used"},data:{type:"object",description:"KYC data as a JSON object",nullable:!0},status:{type:"string",description:"Current status of the KYC verification",enum:["PENDING","APPROVED","REJECTED"]},level:{type:"number",description:"Verification level"},notes:{type:"string",description:"Administrative notes, if any",nullable:!0},createdAt:{type:"string",format:"date-time",description:"Timestamp when the KYC record was created"},updatedAt:{type:"string",format:"date-time",description:"Timestamp when the KYC record was last updated"}}}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Kyc"),500:query_1.serverErrorResponse},requiresAuth:!0};exports.default=async e=>{const{user:t,params:r,body:i,ctx:s}=e;if(!(null==t?void 0:t.id)){null==s||s.fail("User not authenticated");throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"})}const{id:a}=r;null==s||s.step("Retrieving KYC application");const o=await getKyc(t.id,a);null==s||s.success("KYC application retrieved successfully");return o};