"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),query_1=require("@b/utils/query"),cache_1=require("@b/utils/cache"),console_1=require("@b/utils/console");exports.metadata={summary:"Update Status for an Extension",operationId:"updateExtensionStatus",tags:["Admin","Extensions"],parameters:[{index:0,name:"id",in:"path",required:!0,description:"ID of the Extension to update",schema:{type:"string"}}],requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{status:{type:"boolean",description:"New status to apply to the Extension (true for active, false for inactive)"}},required:["status"]}}}},responses:(0,query_1.updateRecordResponses)("Extension"),requiresAuth:!0,permission:"edit.extension",logModule:"ADMIN_SYS",logTitle:"Update extension status"};exports.default=async e=>{const{body:t,params:s,ctx:a}=e,{id:n}=s,{status:o}=t;try{null==a||a.step(`Updating extension ${n} status to ${o?"active":"inactive"}`);await db_1.models.extension.update({status:o},{where:{productId:n}});null==a||a.step("Clearing cache");const e=cache_1.CacheManager.getInstance();await e.clearCache();null==a||a.success("Extension status updated successfully");return{message:"Extension status updated successfully"}}catch(e){console_1.logger.error("EXTENSION","Error updating extension status",e);null==a||a.fail(`Failed to update extension status: ${e.message}`);return{message:"Failed to update extension status",error:e}}};