"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const utils_1=require("@b/api/admin/system/utils");exports.metadata={summary:"Downloads an update for a product",operationId:"downloadProductUpdate",tags:["Admin","System"],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{productId:{type:"string",description:"Product ID to download update for"},updateId:{type:"string",description:"Update ID to download"},version:{type:"string",description:"Version of the update"},product:{type:"string",description:"Name of the product"},type:{type:"string",description:"Type of the update"}},required:["productId","updateId","version","product"]}}}},permission:"create.license",responses:{200:{description:"Update downloaded successfully",content:{"application/json":{schema:{type:"object",properties:{message:{type:"string",description:"Confirmation message indicating successful download"}}}}}},401:{description:"Unauthorized, admin permission required"},500:{description:"Internal server error or update download failed"}},requiresAuth:!0,logModule:"ADMIN_SYS",logTitle:"Download product update"};exports.default=async e=>{const{body:t,ctx:o}=e,{productId:d,updateId:s,version:r,product:i,type:n}=t;null==o||o.step(`Downloading update ${r} for ${i}`);const p=await(0,utils_1.downloadUpdate)(d,s,r,i,n);null==o||o.success(`Update ${r} downloaded successfully`);return p};