"use strict";exports.id=27,exports.ids=[27],exports.modules={64887:(e,n,s)=>{n.createFactories=void 0;var t=s(90719);n.createFactories=()=>({elasticsearchToDynamoDb:e=>new t.ElasticsearchToDynamoDbSynchronization(e)})},90719:(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){const n=e.elasticsearchToDynamoDb?.index;let s=e.elasticsearchToDynamoDb?.cursor;const t=await this.fetchAllIndexes();let i=0;n&&(i=t.findIndex((e=>e===n)));let r=t[i];for(;r;){if(this.manager.isAborted())return this.manager.response.aborted();if(this.manager.isCloseToTimeout(180))return this.manager.response.continue({...e,elasticsearchToDynamoDb:{...e.elasticsearchToDynamoDb,index:r,cursor:s}});const n=await this.fetcher.fetch({index:r,cursor:s,limit:100});if(!(await this.synchronize.execute({done:n.done,index:r,items:n.items})).done&&n.cursor){s=n.cursor;continue}s=void 0;const i=t.findIndex((e=>e===r))+1;r=t[i]}return this.manager.response.continue({...e,elasticsearchToDynamoDb:{finished:!0}})}async fetchAllIndexes(){const e=await this.indexManager.list();if(e.length>0)return e;throw new Error("No Elasticsearch / OpenSearch indexes found.")}}}};
//# sourceMappingURL=createFactories.660b3127.chunk.js.map