"use strict";exports.ids=["409"],exports.modules={14914:function(e,t,r){t.PruneLogs=void 0;var s=r(31065),a=r(92431),i=r(61681);let o=(e,t=60)=>e?new Date(e):new Date(new Date().getTime()-1e3*t);t.PruneLogs=class{constructor(e){this.documentClient=e.documentClient,this.keys=e.keys}async execute(e){let t;let{list:r,response:n,input:c,isAborted:u,isCloseToTimeout:l,store:m}=e,{entity:d,table:y}=(0,s.create)({documentClient:this.documentClient}),h=c.keys||void 0,p=o(c.createdAfter),g=c.items||0,w=e=>{let t=new Date(e.createdOn).getTime()<=p.getTime();return t&&(c.source||c.type)?c.source&&c.type?c.source===e.source&&c.type===e.type||t:c.source?c.source===e.source||t:c.type===e.type||t:t};do{if(u())return n.aborted();if(l()){let e={...c,createdAfter:p.toISOString(),items:g,keys:h};return n.continue(e)}let e=(t=await r({where:{tenant:c.tenant,source:c.source,type:c.type},limit:100})).items.filter(w);e.length>0&&(await (0,a.batchWriteAll)({items:t.items.map(e=>d.deleteBatch({PK:this.keys.createPartitionKey(),SK:this.keys.createSortKey(e)})),table:y}),g+=e.length),t?.meta?.hasMoreItems&&(h=t.meta.cursor||void 0)}while(h);let v={items:g},f=(0,i.createStoreKey)(),k=await m.getValue(f);if(!k.data?.taskId)return n.done(v);try{await m.removeValue(f)}catch{return n.done({...v,message:"Failed to remove the stored value. Please remove it manually.",key:f})}return n.done(v)}}}};
//# sourceMappingURL=PruneLogs.a323f8c1.chunk.js.map