"use strict";exports.id=861,exports.ids=[861],exports.modules={42052:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scan=void 0;var s=n(33923);t.scan=async e=>{const{table:t,keys:n}=e;return(0,s.scan)({table:t,options:{...e.options,startKey:n,limit:e.options?.limit||200}})}},20958:(e,t,n)=>{t.ReindexingTaskRunner=void 0;var s=n(42052),i=n(33923);const 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=void 0,t){this.keys=e;const n=e=>{const 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();const e=await(0,s.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.");const r=(0,i.createTableWriteBatch)({table:this.manager.table});for(const t of e.items){if(!t.index)continue;if(!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}const e=t._et||t.entity;if(!e)continue;const s=this.manager.getEntity(e);await this.indexManager.disableIndexing(t.index),r.put(s.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)}}}}};
//# sourceMappingURL=ReindexingTaskRunner.06af1c6f.chunk.js.map