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