"use strict";exports.ids=["758"],exports.modules={39582:function(e,t,n){t.ReindexingTaskRunner=void 0;var i=n(40853),s=n(92431);let a=e=>{if(e.lastEvaluatedKey?.PK&&e.lastEvaluatedKey?.SK)return{PK:e.lastEvaluatedKey.PK,SK:e.lastEvaluatedKey.SK}};t.ReindexingTaskRunner=class{constructor(e,t){this.manager=e,this.response=e.response,this.indexManager=t}async exec(e,t){this.keys=e;let n=e=>{let t=this.manager.store.getInput();return"string"!=typeof t.matching||!t.matching||e.includes(t.matching)};try{for(;!1===this.manager.isCloseToTimeout();){if(this.manager.isAborted())return this.response.aborted();let e=await (0,i.scan)({table:this.manager.table,keys:this.keys,options:{limit:t}});if(0===e.items.length)return await this.indexManager.enableIndexing(),this.response.done("No more items to process.");let r=(0,s.createTableWriteBatch)({table:this.manager.table});for(let t of e.items){if(!t.index||!1===n(t.index))continue;if(!await this.indexManager.indexExists(t.index)){await this.manager.store.addInfoLog({message:`Index "${t.index}" does not exist. Skipping the item.`});continue}let e=t._et||t.entity;if(!e)continue;let i=this.manager.getEntity(e);await this.indexManager.disableIndexing(t.index),r.put(i.entity,{...t,TYPE:t.TYPE||"unknown",modified:new Date().toISOString()})}if(await r.execute(),this.keys=a(e),await this.manager.store.updateInput({settings:this.indexManager.settings,keys:this.keys}),!this.keys)return await this.indexManager.enableIndexing(),this.response.done("No more items to process - no last evaluated keys.")}return this.response.continue({keys:this.keys})}catch(e){try{await this.indexManager.enableIndexing()}catch(t){return t.data=e,this.response.error(t)}return this.response.error(e)}}}},40853:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.scan=void 0;var i=n(92431);t.scan=async e=>{let{table:t,keys:n}=e;return(0,i.scan)({table:t,options:{...e.options,startKey:n,limit:e.options?.limit||200}})}}};
//# sourceMappingURL=ReindexingTaskRunner.37975491.chunk.js.map