"use strict";exports.ids=["72"],exports.modules={32029:function(e,n,i){n.createFactories=void 0;var t=i(72684);n.createFactories=()=>({elasticsearchToDynamoDb:e=>new t.ElasticsearchToDynamoDbSynchronization(e)})},72684:function(e,n){Object.defineProperty(n,"__esModule",{value:!0}),n.ElasticsearchToDynamoDbSynchronization=void 0,n.ElasticsearchToDynamoDbSynchronization=class{constructor(e){this.manager=e.manager,this.indexManager=e.indexManager,this.synchronize=e.synchronize,this.fetcher=e.fetcher}async run(e){let n=e.elasticsearchToDynamoDb?.index,i=e.elasticsearchToDynamoDb?.cursor,t=await this.fetchAllIndexes(),a=0;n&&(a=t.findIndex(e=>e===n));let s=t[a];for(;s;){if(this.manager.isAborted())return this.manager.response.aborted();if(this.manager.isCloseToTimeout(180))return this.manager.response.continue({...e,elasticsearchToDynamoDb:{...e.elasticsearchToDynamoDb,index:s,cursor:i}});let n=await this.fetcher.fetch({index:s,cursor:i,limit:100});if(!(await this.synchronize.execute({done:n.done,index:s,items:n.items})).done&&n.cursor){i=n.cursor;continue}i=void 0;let a=t.findIndex(e=>e===s)+1;s=t[a]}return this.manager.response.continue({...e,elasticsearchToDynamoDb:{finished:!0}})}async fetchAllIndexes(){let e=await this.indexManager.list();if(e.length>0)return e;throw Error("No Elasticsearch / OpenSearch indexes found.")}}}};
//# sourceMappingURL=createFactories.90a085ea.chunk.js.map