@algolia/ingestion 1.55.1 → 1.55.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,11 +4,11 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@algolia/ingestion"] = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- function Y(s){let a,c=`algolia-client-js-${s.key}`;function i(){return a===void 0&&(a=s.localStorage||window.localStorage),a}function P(){return JSON.parse(i().getItem(c)||"{}")}function R(e){i().setItem(c,JSON.stringify(e));}function k(){return new Promise(e=>setTimeout(e,0))}function d(){let e=s.timeToLive?s.timeToLive*1e3:null,t=P(),o=new Date().getTime(),n=false;return {namespace:Object.fromEntries(Object.entries(t).filter(([,r])=>!r||r.timestamp===void 0||e&&r.timestamp+e<o?(n=true,false):true)),changed:n}}return {get(e,t,o={miss:()=>Promise.resolve()}){return k().then(()=>{let{namespace:n,changed:m}=d(),r=n[JSON.stringify(e)];return m&&R(n),r?r.value:t().then(p=>o.miss(p).then(()=>p))})},set(e,t){return k().then(()=>{let o=P();return o[JSON.stringify(e)]={timestamp:new Date().getTime(),value:t},i().setItem(c,JSON.stringify(o)),t})},delete(e){return k().then(()=>{let t=P();delete t[JSON.stringify(e)],i().setItem(c,JSON.stringify(t));})},clear(){return Promise.resolve().then(()=>{i().removeItem(c);})}}}function ce(){return {get(s,a,c={miss:()=>Promise.resolve()}){return a().then(P=>Promise.all([P,c.miss(P)])).then(([P])=>P)},set(s,a){return Promise.resolve(a)},delete(s){return Promise.resolve()},clear(){return Promise.resolve()}}}function A(s){let a=[...s.caches],c=a.shift();return c===void 0?ce():{get(i,P,R={miss:()=>Promise.resolve()}){return c.get(i,P,R).catch(()=>A({caches:a}).get(i,P,R))},set(i,P){return c.set(i,P).catch(()=>A({caches:a}).set(i,P))},delete(i){return c.delete(i).catch(()=>A({caches:a}).delete(i))},clear(){return c.clear().catch(()=>A({caches:a}).clear())}}}function H(s={serializable:true}){let a={};return {get(c,i,P={miss:()=>Promise.resolve()}){let R=JSON.stringify(c);if(R in a)return Promise.resolve(s.serializable?JSON.parse(a[R]):a[R]);let k=i();return k.then(d=>P.miss(d)).then(()=>k)},set(c,i){return a[JSON.stringify(c)]=s.serializable?JSON.stringify(i):i,Promise.resolve(i)},delete(c){return delete a[JSON.stringify(c)],Promise.resolve()},clear(){return a={},Promise.resolve()}}}function me(s){let a={value:`Algolia for JavaScript (${s})`,add(c){let i=`; ${c.segment}${c.version!==void 0?` (${c.version})`:""}`;return a.value.indexOf(i)===-1&&(a.value=`${a.value}${i}`),a}};return a}function Z(s,a,c="WithinHeaders"){let i={"x-algolia-api-key":a,"x-algolia-application-id":s};return {headers(){return c==="WithinHeaders"?i:{}},queryParameters(){return c==="WithinQueryParameters"?i:{}}}}function ee({func:s,validate:a,aggregator:c,error:i,timeout:P=()=>0}){let R=k=>new Promise((d,e)=>{s(k).then(async t=>(c&&await c(t),await a(t)?d(t):i&&await i.validate(t)?e(new Error(await i.message(t))):setTimeout(()=>{R(t).then(d).catch(e);},await P()))).catch(t=>{e(t);});});return R()}function te({algoliaAgents:s,client:a,version:c}){let i=me(c).add({segment:a,version:c});return s.forEach(P=>i.add(P)),i}function re(){return {debug(s,a){return Promise.resolve()},info(s,a){return Promise.resolve()},error(s,a){return Promise.resolve()}}}var de=10*1024*1024;async function*pe(s){let a=s.getReader();try{for(;;){let{done:c,value:i}=await a.read();if(c)return;yield i;}}finally{a.releaseLock();}}function he(s){return Symbol.asyncIterator in s?s:pe(s)}async function*fe(s){let a=new TextDecoder("utf-8"),c=[],i=0,P=false,R=true;for await(let d of he(s)){let e=a.decode(d,{stream:true}),t=0;for(P&&(P=false,e.length>0&&e[0]===`
7
+ function Y(s){let a,m=`algolia-client-js-${s.key}`;function i(){return a===void 0&&(a=s.localStorage||window.localStorage),a}function P(){return JSON.parse(i().getItem(m)||"{}")}function R(e){i().setItem(m,JSON.stringify(e));}function S(){return new Promise(e=>setTimeout(e,0))}function d(){let e=s.timeToLive?s.timeToLive*1e3:null,t=P(),o=new Date().getTime(),n=false;return {namespace:Object.fromEntries(Object.entries(t).filter(([,r])=>!r||r.timestamp===void 0||e&&r.timestamp+e<o?(n=true,false):true)),changed:n}}return {get(e,t,o={miss:()=>Promise.resolve()}){return S().then(()=>{let{namespace:n,changed:c}=d(),r=n[JSON.stringify(e)];return c&&R(n),r?r.value:t().then(p=>o.miss(p).then(()=>p))})},set(e,t){return S().then(()=>{let o=P();return o[JSON.stringify(e)]={timestamp:new Date().getTime(),value:t},i().setItem(m,JSON.stringify(o)),t})},delete(e){return S().then(()=>{let t=P();delete t[JSON.stringify(e)],i().setItem(m,JSON.stringify(t));})},clear(){return Promise.resolve().then(()=>{i().removeItem(m);})}}}function ce(){return {get(s,a,m={miss:()=>Promise.resolve()}){return a().then(P=>Promise.all([P,m.miss(P)])).then(([P])=>P)},set(s,a){return Promise.resolve(a)},delete(s){return Promise.resolve()},clear(){return Promise.resolve()}}}function A(s){let a=[...s.caches],m=a.shift();return m===void 0?ce():{get(i,P,R={miss:()=>Promise.resolve()}){return m.get(i,P,R).catch(()=>A({caches:a}).get(i,P,R))},set(i,P){return m.set(i,P).catch(()=>A({caches:a}).set(i,P))},delete(i){return m.delete(i).catch(()=>A({caches:a}).delete(i))},clear(){return m.clear().catch(()=>A({caches:a}).clear())}}}function H(s={serializable:true}){let a={};return {get(m,i,P={miss:()=>Promise.resolve()}){let R=JSON.stringify(m);if(R in a)return Promise.resolve(s.serializable?JSON.parse(a[R]):a[R]);let S=i();return S.then(d=>P.miss(d)).then(()=>S)},set(m,i){return a[JSON.stringify(m)]=s.serializable?JSON.stringify(i):i,Promise.resolve(i)},delete(m){return delete a[JSON.stringify(m)],Promise.resolve()},clear(){return a={},Promise.resolve()}}}function me(s){let a={value:`Algolia for JavaScript (${s})`,add(m){let i=`; ${m.segment}${m.version!==void 0?` (${m.version})`:""}`;return a.value.indexOf(i)===-1&&(a.value=`${a.value}${i}`),a}};return a}function Z(s,a,m="WithinHeaders"){let i={"x-algolia-api-key":a,"x-algolia-application-id":s};return {headers(){return m==="WithinHeaders"?i:{}},queryParameters(){return m==="WithinQueryParameters"?i:{}}}}function ee({func:s,validate:a,aggregator:m,error:i,timeout:P=()=>0}){let R=S=>new Promise((d,e)=>{s(S).then(async t=>(m&&await m(t),await a(t)?d(t):i&&await i.validate(t)?e(new Error(await i.message(t))):setTimeout(()=>{R(t).then(d).catch(e);},await P()))).catch(t=>{e(t);});});return R()}function te({algoliaAgents:s,client:a,version:m}){let i=me(m).add({segment:a,version:m});return s.forEach(P=>i.add(P)),i}function re(){return {debug(s,a){return Promise.resolve()},info(s,a){return Promise.resolve()},error(s,a){return Promise.resolve()}}}var de=10*1024*1024;async function*pe(s){let a=s.getReader();try{for(;;){let{done:m,value:i}=await a.read();if(m)return;yield i;}}finally{a.releaseLock();}}function he(s){return Symbol.asyncIterator in s?s:pe(s)}async function*fe(s){let a=new TextDecoder("utf-8"),m=[],i=0,P=false,R=true;for await(let d of he(s)){let e=a.decode(d,{stream:true}),t=0;for(P&&(P=false,e.length>0&&e[0]===`
8
8
  `&&(t=1));t<e.length;){let o=e.indexOf("\r",t),n=e.indexOf(`
9
- `,t);if(o===-1&&n===-1){let h=e.slice(t);if(c.push(h),i+=h.length,i>de)throw new Error("SSE line buffer exceeded 10MB");break}let m,r;o!==-1&&(n===-1||o<n)?(m=o,o+1<e.length?r=e[o+1]===`
10
- `?2:1:(P=true,r=1)):(m=n,r=1);let p=e.slice(t,m);c.push(p);let q=c.length===1?c[0]:c.join("");c.length=0,i=0,R&&(q.startsWith("\uFEFF")&&(q=q.slice(1)),R=false),yield q,t=m+r;}}let k=a.decode();if(k&&c.push(k),c.length>0){let d=c.join("");R&&d.startsWith("\uFEFF")&&(d=d.slice(1)),yield d;}}var le=class{data=[];eventType="";lastEventId=null;retry=null;decode(s){if(s==="")return this.dispatch();if(s[0]===":")return null;let a=s.indexOf(":"),c,i;switch(a===-1?(c=s,i=""):(c=s.slice(0,a),i=s.slice(a+1),i[0]===" "&&(i=i.slice(1))),c){case "data":this.data.push(i);break;case "event":this.eventType=i;break;case "id":i.includes("\0")||(this.lastEventId=i);break;case "retry":/^[0-9]+$/.test(i)&&(this.retry=parseInt(i,10));break}return null}dispatch(){let s=this.eventType;if(this.eventType="",this.data.length===0)return null;let a={data:this.data.join(`
11
- `),event:s,id:this.lastEventId,retry:this.retry};return this.data=[],a}};async function*Pe(s){let a=new le;for await(let c of fe(s)){let i=a.decode(c);i!==null&&(yield i);}}var qe=750,F=120*1e3;function M(s,a="up"){let c=Date.now();function i(){return a==="up"||Date.now()-c>F}function P(){return a==="timed out"&&Date.now()-c<=F}return {...s,status:a,lastUpdate:c,isUp:i,isTimedOut:P}}var se=class extends Error{name="AlgoliaError";constructor(s,a){super(s),a&&(this.name=a);}};var oe=class extends se{stackTrace;constructor(s,a,c){super(s,c),this.stackTrace=a;}},J=class extends oe{constructor(s){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",s,"RetryError");}},N=class extends oe{status;constructor(s,a,c,i="ApiError"){super(s,c,i),this.status=a;}},ye=class extends se{response;constructor(s,a){super(s,"DeserializationError"),this.response=a;}},Te=class extends N{error;constructor(s,a,c,i){super(s,a,i,"DetailedApiError"),this.error=c;}};function z(s,a,c){let i=Re(c),P=`${s.protocol}://${s.url}${s.port?`:${s.port}`:""}/${a.charAt(0)==="/"?a.substring(1):a}`;return i.length&&(P+=`?${i}`),P}function Re(s){return Object.keys(s).filter(a=>s[a]!==void 0).sort().map(a=>`${a}=${encodeURIComponent(Object.prototype.toString.call(s[a])==="[object Array]"?s[a].join(","):s[a]).replace(/\+/g,"%20")}`).join("&")}function X(s,a){if(s.method==="GET"||s.data===void 0&&a.data===void 0)return;let c=Array.isArray(s.data)?s.data:{...s.data,...a.data};return JSON.stringify(c)}function K(s,a,c){let i={Accept:"application/json",...s,...a,...c},P={};return Object.keys(i).forEach(R=>{let k=i[R];P[R.toLowerCase()]=k;}),P}function ge(s){if(!(s.status===204||s.content.length===0))try{return JSON.parse(s.content)}catch(a){throw new ye(a.message,s)}}function Se({content:s,status:a},c){try{let i=JSON.parse(s);return "error"in i?new Te(i.message,a,i.error,c):new N(i.message,a,c)}catch{}return new N(s,a,c)}function ke({isTimedOut:s,status:a}){return !s&&~~a===0}function xe({isTimedOut:s,status:a}){return s||ke({isTimedOut:s,status:a})||~~(a/100)!==2&&~~(a/100)!==4}function De({status:s}){return ~~(s/100)===2}function Ie(s){return s.map(a=>ae(a))}function ae(s){let a=s.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...s,request:{...s.request,headers:{...s.request.headers,...a}}}}function ne({hosts:s,hostsCache:a,baseHeaders:c,logger:i,baseQueryParameters:P,algoliaAgent:R,timeouts:k,requester:d,requestsCache:e,responsesCache:t,compress:o,compression:n}){async function m(h){let f=await Promise.all(h.map(T=>a.get(T,()=>Promise.resolve(M(T))))),y=f.filter(T=>T.isUp()),g=f.filter(T=>T.isTimedOut()),l=[...y,...g];return {hosts:l.length>0?l:h,getTimeout(T,x){return (g.length===0&&T===0?1:g.length+3+T)*x}}}async function r(h,f,y){let g=[],l=X(h,f),S=K(c,h.headers,f.headers),T=n==="gzip"&&l!==void 0&&l.length>qe&&(h.method==="POST"||h.method==="PUT");T&&o===void 0&&i.info("Compression is disabled because no compress method is available.");let x=T&&o!==void 0,O=x?await o(l):l;x&&(S["content-encoding"]="gzip");let E=h.method==="GET"?{...h.data,...f.data}:{},v={...P,...h.queryParameters,...E};if(R.value&&(v["x-algolia-agent"]=R.value),f&&f.queryParameters)for(let D of Object.keys(f.queryParameters))!f.queryParameters[D]||Object.prototype.toString.call(f.queryParameters[D])==="[object Object]"?v[D]=f.queryParameters[D]:v[D]=f.queryParameters[D].toString();let U=0,b=async(D,Q)=>{let w=D.pop();if(w===void 0)throw new J(Ie(g));let V={...k,...f.timeouts},$={data:O,headers:S,method:h.method,url:z(w,h.path,v),connectTimeout:Q(U,V.connect),responseTimeout:Q(U,y?V.read:V.write)},j=G=>{let B={request:$,response:G,host:w,triesLeft:D.length};return g.push(B),B},C=await d.send($);if(xe(C)){let G=j(C);return C.isTimedOut&&U++,i.info("Retryable failure",ae(G)),await a.set(w,M(w,C.isTimedOut?"timed out":"down")),b(D,Q)}if(De(C))return ge(C);throw j(C),Se(C,g)},I=s.filter(D=>D.accept==="readWrite"||(y?D.accept==="read":D.accept==="write")),W=await m(I);return b([...W.hosts].reverse(),W.getTimeout)}function p(h,f={}){let y=()=>r(h,f,g),g=h.useReadTransporter||h.method==="GET";if((f.cacheable||h.cacheable)!==true)return y();let S={request:h,requestOptions:f,transporter:{queryParameters:P,headers:c}};return t.get(S,()=>e.get(S,()=>e.set(S,y()).then(T=>Promise.all([e.delete(S),T]),T=>Promise.all([e.delete(S),Promise.reject(T)])).then(([T,x])=>x)),{miss:T=>t.set(S,T)})}async function*q(h,f={}){if(!d.sendStream)throw new Error("This requester does not support streaming");let y=X(h,f),g=K(c,h.headers,f.headers);g.accept="text/event-stream";let l=h.method==="GET"?{...h.data,...f.data}:{},S={...P,...h.queryParameters,...l};if(R.value&&(S["x-algolia-agent"]=R.value),f&&f.queryParameters)for(let I of Object.keys(f.queryParameters))!f.queryParameters[I]||Object.prototype.toString.call(f.queryParameters[I])==="[object Object]"?S[I]=f.queryParameters[I]:S[I]=f.queryParameters[I].toString();let T=h.useReadTransporter||h.method==="GET",x=s.filter(I=>I.accept==="readWrite"||(T?I.accept==="read":I.accept==="write")),E=(await m(x)).hosts[0];if(!E)throw new J([]);let v={...k,...f.timeouts},U={data:y,headers:g,method:h.method,url:z(E,h.path,S),connectTimeout:v.connect,responseTimeout:T?v.read:v.write},b=await d.sendStream(U);yield*Pe(b);}return {hostsCache:a,requester:d,timeouts:k,logger:i,algoliaAgent:R,baseHeaders:c,baseQueryParameters:P,hosts:s,request:p,requestStream:q,requestsCache:e,responsesCache:t}}function u(s,a,c){if(c==null||typeof c=="string"&&c.length===0)throw new Error(`Parameter \`${s}\` is required when calling \`${a}\`.`)}function ie(){function s(a){return new Promise(c=>{let i=new XMLHttpRequest;i.open(a.method,a.url,true),Object.keys(a.headers).forEach(d=>i.setRequestHeader(d,a.headers[d]));let P=(d,e)=>setTimeout(()=>{i.abort(),c({status:0,content:e,isTimedOut:true});},d),R=P(a.connectTimeout,"Connection timeout"),k;i.onreadystatechange=()=>{i.readyState>i.OPENED&&k===void 0&&(clearTimeout(R),k=P(a.responseTimeout,"Socket timeout"));},i.onerror=()=>{i.status===0&&(clearTimeout(R),clearTimeout(k),c({content:i.responseText||"Network request failed",status:i.status,isTimedOut:false}));},i.onload=()=>{clearTimeout(R),clearTimeout(k),c({content:i.responseText,status:i.status,isTimedOut:false});},i.send(a.data);})}return {send:s}}var L="1.55.1",_=["eu","us"];function Ee(s){return [{url:"data.{region}.algolia.com".replace("{region}",s),accept:"readWrite",protocol:"https"}]}function ve(s){return s.type==="onDemand"}function Ce(s){return s.type==="schedule"}function Oe(s){return s.type==="subscription"}function ue({appId:s,apiKey:a,authMode:c,algoliaAgents:i,region:P,...R}){let k=Z(s,a,c),d=ne({hosts:Ee(P),...R,algoliaAgent:te({algoliaAgents:i,client:"Ingestion",version:L}),baseHeaders:{"content-type":"text/plain",...k.headers(),...R.baseHeaders},baseQueryParameters:{...k.queryParameters(),...R.baseQueryParameters}});return {transporter:d,appId:s,apiKey:a,clearCache(){return Promise.all([d.requestsCache.clear(),d.responsesCache.clear()]).then(()=>{})},get _ua(){return d.algoliaAgent.value},addAlgoliaAgent(e,t){d.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!c||c==="WithinHeaders"?d.baseHeaders["x-algolia-api-key"]=e:d.baseQueryParameters["x-algolia-api-key"]=e;},async chunkedPush({indexName:e,objects:t,action:o="addObject",waitForTasks:n,batchSize:m=1e3,referenceIndexName:r,maxRetries:p=100},q){let h=[],f=0,y=[],g=Math.floor(m/10)||m,l=t.entries();for(let[S,T]of l)if(h.push(T),(h.length===m||S===t.length-1)&&(y.push(await this.push({indexName:e,pushTaskPayload:{action:o,records:h},referenceIndexName:r},q)),h=[]),n&&y.length>0&&(y.length%g===0||S===t.length-1)){for(let x of y.slice(f,f+g)){if(!x.eventID)throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");let O=0;await ee({func:async()=>{if(x.eventID===void 0||!x.eventID)throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");return this.getEvent({runID:x.runID,eventID:x.eventID}).catch(E=>{if(E.status!==404)throw E})},validate:E=>E!==void 0,aggregator:()=>O+=1,error:{validate:()=>O>=p,message:()=>`Stopped waiting for the task after ${p} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>Math.min(O*1500,5e3)});}f+=g;}return y},createAuthentication(e,t){u("authenticationCreate","createAuthentication",e),u("authenticationCreate.type","createAuthentication",e.type),u("authenticationCreate.name","createAuthentication",e.name),u("authenticationCreate.input","createAuthentication",e.input);let r={method:"POST",path:"/1/authentications",queryParameters:{},headers:{},data:e};return d.request(r,t)},createDestination(e,t){u("destinationCreate","createDestination",e),u("destinationCreate.type","createDestination",e.type),u("destinationCreate.name","createDestination",e.name),u("destinationCreate.input","createDestination",e.input);let r={method:"POST",path:"/1/destinations",queryParameters:{},headers:{},data:e};return d.request(r,t)},createSource(e,t){u("sourceCreate","createSource",e),u("sourceCreate.type","createSource",e.type),u("sourceCreate.name","createSource",e.name);let r={method:"POST",path:"/1/sources",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTask(e,t){u("taskCreate","createTask",e),u("taskCreate.sourceID","createTask",e.sourceID),u("taskCreate.destinationID","createTask",e.destinationID),u("taskCreate.action","createTask",e.action);let r={method:"POST",path:"/2/tasks",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTaskV1(e,t){u("taskCreate","createTaskV1",e),u("taskCreate.sourceID","createTaskV1",e.sourceID),u("taskCreate.destinationID","createTaskV1",e.destinationID),u("taskCreate.trigger","createTaskV1",e.trigger),u("taskCreate.action","createTaskV1",e.action);let r={method:"POST",path:"/1/tasks",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTransformation(e,t){u("transformationCreate","createTransformation",e),u("transformationCreate.name","createTransformation",e.name);let r={method:"POST",path:"/1/transformations",queryParameters:{},headers:{},data:e};return d.request(r,t)},customDelete({path:e,parameters:t},o){u("path","customDelete",e);let p={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return d.request(p,o)},customGet({path:e,parameters:t},o){u("path","customGet",e);let p={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return d.request(p,o)},customPost({path:e,parameters:t,body:o},n){u("path","customPost",e);let q={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:o||{}};return d.request(q,n)},customPut({path:e,parameters:t,body:o},n){u("path","customPut",e);let q={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:o||{}};return d.request(q,n)},deleteAuthentication({authenticationID:e},t){u("authenticationID","deleteAuthentication",e);let r={method:"DELETE",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteDestination({destinationID:e},t){u("destinationID","deleteDestination",e);let r={method:"DELETE",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteSource({sourceID:e},t){u("sourceID","deleteSource",e);let r={method:"DELETE",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTask({taskID:e},t){u("taskID","deleteTask",e);let r={method:"DELETE",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTaskV1({taskID:e},t){u("taskID","deleteTaskV1",e);let r={method:"DELETE",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTransformation({transformationID:e},t){u("transformationID","deleteTransformation",e);let r={method:"DELETE",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},disableTask({taskID:e},t){u("taskID","disableTask",e);let r={method:"PUT",path:"/2/tasks/{taskID}/disable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},disableTaskV1({taskID:e},t){u("taskID","disableTaskV1",e);let r={method:"PUT",path:"/1/tasks/{taskID}/disable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},enableTask({taskID:e},t){u("taskID","enableTask",e);let r={method:"PUT",path:"/2/tasks/{taskID}/enable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},enableTaskV1({taskID:e},t){u("taskID","enableTaskV1",e);let r={method:"PUT",path:"/1/tasks/{taskID}/enable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getAuthentication({authenticationID:e},t){u("authenticationID","getAuthentication",e);let r={method:"GET",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getDestination({destinationID:e},t){u("destinationID","getDestination",e);let r={method:"GET",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getEvent({runID:e,eventID:t},o){u("runID","getEvent",e),u("eventID","getEvent",t);let p={method:"GET",path:"/1/runs/{runID}/events/{eventID}".replace("{runID}",encodeURIComponent(e)).replace("{eventID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return d.request(p,o)},getRun({runID:e},t){u("runID","getRun",e);let r={method:"GET",path:"/1/runs/{runID}".replace("{runID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getSource({sourceID:e},t){u("sourceID","getSource",e);let r={method:"GET",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTask({taskID:e},t){u("taskID","getTask",e);let r={method:"GET",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTaskV1({taskID:e},t){u("taskID","getTaskV1",e);let r={method:"GET",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTransformation({transformationID:e},t){u("transformationID","getTransformation",e);let r={method:"GET",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},listAuthentications({itemsPerPage:e,page:t,type:o,platform:n,sort:m,order:r}={},p=void 0){let q="/1/authentications",h={},f={};e!==void 0&&(f.itemsPerPage=e.toString()),t!==void 0&&(f.page=t.toString()),o!==void 0&&(f.type=o.toString()),n!==void 0&&(f.platform=n.toString()),m!==void 0&&(f.sort=m.toString()),r!==void 0&&(f.order=r.toString());let y={method:"GET",path:q,queryParameters:f,headers:h};return d.request(y,p)},listDestinations({itemsPerPage:e,page:t,type:o,authenticationID:n,transformationID:m,sort:r,order:p}={},q=void 0){let h="/1/destinations",f={},y={};e!==void 0&&(y.itemsPerPage=e.toString()),t!==void 0&&(y.page=t.toString()),o!==void 0&&(y.type=o.toString()),n!==void 0&&(y.authenticationID=n.toString()),m!==void 0&&(y.transformationID=m.toString()),r!==void 0&&(y.sort=r.toString()),p!==void 0&&(y.order=p.toString());let g={method:"GET",path:h,queryParameters:y,headers:f};return d.request(g,q)},listEvents({runID:e,itemsPerPage:t,page:o,status:n,type:m,sort:r,order:p,startDate:q,endDate:h},f){u("runID","listEvents",e);let y="/1/runs/{runID}/events".replace("{runID}",encodeURIComponent(e)),g={},l={};t!==void 0&&(l.itemsPerPage=t.toString()),o!==void 0&&(l.page=o.toString()),n!==void 0&&(l.status=n.toString()),m!==void 0&&(l.type=m.toString()),r!==void 0&&(l.sort=r.toString()),p!==void 0&&(l.order=p.toString()),q!==void 0&&(l.startDate=q.toString()),h!==void 0&&(l.endDate=h.toString());let S={method:"GET",path:y,queryParameters:l,headers:g};return d.request(S,f)},listRuns({itemsPerPage:e,page:t,status:o,type:n,taskID:m,sort:r,order:p,startDate:q,endDate:h}={},f=void 0){let y="/1/runs",g={},l={};e!==void 0&&(l.itemsPerPage=e.toString()),t!==void 0&&(l.page=t.toString()),o!==void 0&&(l.status=o.toString()),n!==void 0&&(l.type=n.toString()),m!==void 0&&(l.taskID=m.toString()),r!==void 0&&(l.sort=r.toString()),p!==void 0&&(l.order=p.toString()),q!==void 0&&(l.startDate=q.toString()),h!==void 0&&(l.endDate=h.toString());let S={method:"GET",path:y,queryParameters:l,headers:g};return d.request(S,f)},listSources({itemsPerPage:e,page:t,type:o,authenticationID:n,sort:m,order:r}={},p=void 0){let q="/1/sources",h={},f={};e!==void 0&&(f.itemsPerPage=e.toString()),t!==void 0&&(f.page=t.toString()),o!==void 0&&(f.type=o.toString()),n!==void 0&&(f.authenticationID=n.toString()),m!==void 0&&(f.sort=m.toString()),r!==void 0&&(f.order=r.toString());let y={method:"GET",path:q,queryParameters:f,headers:h};return d.request(y,p)},listTasks({itemsPerPage:e,page:t,action:o,enabled:n,sourceID:m,sourceType:r,destinationID:p,triggerType:q,withEmailNotifications:h,sort:f,order:y}={},g=void 0){let l="/2/tasks",S={},T={};e!==void 0&&(T.itemsPerPage=e.toString()),t!==void 0&&(T.page=t.toString()),o!==void 0&&(T.action=o.toString()),n!==void 0&&(T.enabled=n.toString()),m!==void 0&&(T.sourceID=m.toString()),r!==void 0&&(T.sourceType=r.toString()),p!==void 0&&(T.destinationID=p.toString()),q!==void 0&&(T.triggerType=q.toString()),h!==void 0&&(T.withEmailNotifications=h.toString()),f!==void 0&&(T.sort=f.toString()),y!==void 0&&(T.order=y.toString());let x={method:"GET",path:l,queryParameters:T,headers:S};return d.request(x,g)},listTasksV1({itemsPerPage:e,page:t,action:o,enabled:n,sourceID:m,destinationID:r,triggerType:p,sort:q,order:h}={},f=void 0){let y="/1/tasks",g={},l={};e!==void 0&&(l.itemsPerPage=e.toString()),t!==void 0&&(l.page=t.toString()),o!==void 0&&(l.action=o.toString()),n!==void 0&&(l.enabled=n.toString()),m!==void 0&&(l.sourceID=m.toString()),r!==void 0&&(l.destinationID=r.toString()),p!==void 0&&(l.triggerType=p.toString()),q!==void 0&&(l.sort=q.toString()),h!==void 0&&(l.order=h.toString());let S={method:"GET",path:y,queryParameters:l,headers:g};return d.request(S,f)},listTransformations({itemsPerPage:e,page:t,sort:o,order:n,type:m}={},r=void 0){let p="/1/transformations",q={},h={};e!==void 0&&(h.itemsPerPage=e.toString()),t!==void 0&&(h.page=t.toString()),o!==void 0&&(h.sort=o.toString()),n!==void 0&&(h.order=n.toString()),m!==void 0&&(h.type=m.toString());let f={method:"GET",path:p,queryParameters:h,headers:q};return d.request(f,r)},push({indexName:e,pushTaskPayload:t,watch:o,referenceIndexName:n},m){u("indexName","push",e),u("pushTaskPayload","push",t),u("pushTaskPayload.action","push",t.action),u("pushTaskPayload.records","push",t.records);let r="/1/push/{indexName}".replace("{indexName}",encodeURIComponent(e)),p={},q={};o!==void 0&&(q.watch=o.toString()),n!==void 0&&(q.referenceIndexName=n.toString());let h={method:"POST",path:r,queryParameters:q,headers:p,data:t};return m={timeouts:{connect:18e4,read:18e4,write:18e4,...m?.timeouts}},d.request(h,m)},pushTask({taskID:e,pushTaskPayload:t,watch:o},n){u("taskID","pushTask",e),u("pushTaskPayload","pushTask",t),u("pushTaskPayload.action","pushTask",t.action),u("pushTaskPayload.records","pushTask",t.records);let m="/2/tasks/{taskID}/push".replace("{taskID}",encodeURIComponent(e)),r={},p={};o!==void 0&&(p.watch=o.toString());let q={method:"POST",path:m,queryParameters:p,headers:r,data:t};return n={timeouts:{connect:18e4,read:18e4,write:18e4,...n?.timeouts}},d.request(q,n)},replaceTask({taskID:e,taskReplace:t},o){u("taskID","replaceTask",e),u("taskReplace","replaceTask",t),u("taskReplace.destinationID","replaceTask",t.destinationID),u("taskReplace.action","replaceTask",t.action);let p={method:"PUT",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},runSource({sourceID:e,runSourcePayload:t},o){u("sourceID","runSource",e);let p={method:"POST",path:"/1/sources/{sourceID}/run".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},runTask({taskID:e,runTaskPayload:t},o){u("taskID","runTask",e);let p={method:"POST",path:"/2/tasks/{taskID}/run".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},runTaskV1({taskID:e,runTaskPayload:t},o){u("taskID","runTaskV1",e);let p={method:"POST",path:"/1/tasks/{taskID}/run".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},searchAuthentications(e,t){u("authenticationSearch","searchAuthentications",e),u("authenticationSearch.authenticationIDs","searchAuthentications",e.authenticationIDs);let r={method:"POST",path:"/1/authentications/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchDestinations(e,t){u("destinationSearch","searchDestinations",e),u("destinationSearch.destinationIDs","searchDestinations",e.destinationIDs);let r={method:"POST",path:"/1/destinations/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchSources(e,t){u("sourceSearch","searchSources",e),u("sourceSearch.sourceIDs","searchSources",e.sourceIDs);let r={method:"POST",path:"/1/sources/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTasks(e,t){u("taskSearch","searchTasks",e),u("taskSearch.taskIDs","searchTasks",e.taskIDs);let r={method:"POST",path:"/2/tasks/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTasksV1(e,t){u("taskSearch","searchTasksV1",e),u("taskSearch.taskIDs","searchTasksV1",e.taskIDs);let r={method:"POST",path:"/1/tasks/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTransformations(e,t){u("transformationSearch","searchTransformations",e),u("transformationSearch.transformationIDs","searchTransformations",e.transformationIDs);let r={method:"POST",path:"/1/transformations/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},triggerDockerSourceDiscover({sourceID:e},t){u("sourceID","triggerDockerSourceDiscover",e);let r={method:"POST",path:"/1/sources/{sourceID}/discover".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return t={timeouts:{connect:18e4,read:18e4,write:18e4,...t?.timeouts}},d.request(r,t)},tryTransformation(e,t){u("transformationTry","tryTransformation",e),u("transformationTry.sampleRecord","tryTransformation",e.sampleRecord);let r={method:"POST",path:"/1/transformations/try",queryParameters:{},headers:{},data:e};return d.request(r,t)},tryTransformationBeforeUpdate({transformationID:e,transformationTry:t},o){u("transformationID","tryTransformationBeforeUpdate",e),u("transformationTry","tryTransformationBeforeUpdate",t),u("transformationTry.sampleRecord","tryTransformationBeforeUpdate",t.sampleRecord);let p={method:"POST",path:"/1/transformations/{transformationID}/try".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateAuthentication({authenticationID:e,authenticationUpdate:t},o){u("authenticationID","updateAuthentication",e),u("authenticationUpdate","updateAuthentication",t);let p={method:"PATCH",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateDestination({destinationID:e,destinationUpdate:t},o){u("destinationID","updateDestination",e),u("destinationUpdate","updateDestination",t);let p={method:"PATCH",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateSource({sourceID:e,sourceUpdate:t},o){u("sourceID","updateSource",e),u("sourceUpdate","updateSource",t);let p={method:"PATCH",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTask({taskID:e,taskUpdate:t},o){u("taskID","updateTask",e),u("taskUpdate","updateTask",t);let p={method:"PATCH",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTaskV1({taskID:e,taskUpdate:t},o){u("taskID","updateTaskV1",e),u("taskUpdate","updateTaskV1",t);let p={method:"PATCH",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTransformation({transformationID:e,transformationCreate:t},o){u("transformationID","updateTransformation",e),u("transformationCreate","updateTransformation",t),u("transformationCreate.name","updateTransformation",t.name);let p={method:"PUT",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},validateSource(e,t=void 0){let r={method:"POST",path:"/1/sources/validate",queryParameters:{},headers:{},data:e||{}};return t={timeouts:{connect:18e4,read:18e4,write:18e4,...t?.timeouts}},d.request(r,t)},validateSourceBeforeUpdate({sourceID:e,sourceUpdate:t},o){u("sourceID","validateSourceBeforeUpdate",e),u("sourceUpdate","validateSourceBeforeUpdate",t);let p={method:"POST",path:"/1/sources/{sourceID}/validate".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return o={timeouts:{connect:18e4,read:18e4,write:18e4,...o?.timeouts}},d.request(p,o)}}}function Vs(s,a,c,i){if(!s||typeof s!="string")throw new Error("`appId` is missing.");if(!a||typeof a!="string")throw new Error("`apiKey` is missing.");if(!c||c&&(typeof c!="string"||!_.includes(c)))throw new Error(`\`region\` is required and must be one of the following: ${_.join(", ")}`);let{compression:P,...R}=i||{};return ue({appId:s,apiKey:a,region:c,timeouts:{connect:25e3,read:25e3,write:25e3},logger:re(),requester:ie(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:H(),requestsCache:H({serializable:false}),hostsCache:A({caches:[Y({key:`${L}-${s}`}),H()]}),...R})}
9
+ `,t);if(o===-1&&n===-1){let f=e.slice(t);if(m.push(f),i+=f.length,i>de)throw new Error("SSE line buffer exceeded 10MB");break}let c,r;o!==-1&&(n===-1||o<n)?(c=o,o+1<e.length?r=e[o+1]===`
10
+ `?2:1:(P=true,r=1)):(c=n,r=1);let p=e.slice(t,c);m.push(p);let y=m.length===1?m[0]:m.join("");m.length=0,i=0,R&&(y.startsWith("\uFEFF")&&(y=y.slice(1)),R=false),yield y,t=c+r;}}let S=a.decode();if(S&&m.push(S),m.length>0){let d=m.join("");R&&d.startsWith("\uFEFF")&&(d=d.slice(1)),yield d;}}var le=class{data=[];eventType="";lastEventId=null;retry=null;decode(s){if(s==="")return this.dispatch();if(s[0]===":")return null;let a=s.indexOf(":"),m,i;switch(a===-1?(m=s,i=""):(m=s.slice(0,a),i=s.slice(a+1),i[0]===" "&&(i=i.slice(1))),m){case "data":this.data.push(i);break;case "event":this.eventType=i;break;case "id":i.includes("\0")||(this.lastEventId=i);break;case "retry":/^[0-9]+$/.test(i)&&(this.retry=parseInt(i,10));break}return null}dispatch(){let s=this.eventType;if(this.eventType="",this.data.length===0)return null;let a={data:this.data.join(`
11
+ `),event:s,id:this.lastEventId,retry:this.retry};return this.data=[],a}};async function*Pe(s){let a=new le;for await(let m of fe(s)){let i=a.decode(m);i!==null&&(yield i);}}var qe=750,F=120*1e3;function M(s,a="up"){let m=Date.now();function i(){return a==="up"||Date.now()-m>F}function P(){return a==="timed out"&&Date.now()-m<=F}return {...s,status:a,lastUpdate:m,isUp:i,isTimedOut:P}}var se=class extends Error{name="AlgoliaError";constructor(s,a){super(s),a&&(this.name=a);}};var oe=class extends se{stackTrace;constructor(s,a,m){super(s,m),this.stackTrace=a;}},J=class extends oe{constructor(s){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",s,"RetryError");}},N=class extends oe{status;constructor(s,a,m,i="ApiError"){super(s,m,i),this.status=a;}},ye=class extends se{response;constructor(s,a){super(s,"DeserializationError"),this.response=a;}},Te=class extends N{error;constructor(s,a,m,i){super(s,a,i,"DetailedApiError"),this.error=m;}};function z(s,a,m){let i=Re(m),P=`${s.protocol}://${s.url}${s.port?`:${s.port}`:""}/${a.charAt(0)==="/"?a.substring(1):a}`;return i.length&&(P+=`?${i}`),P}function Re(s){return Object.keys(s).filter(a=>s[a]!==void 0).sort().map(a=>`${a}=${encodeURIComponent(Object.prototype.toString.call(s[a])==="[object Array]"?s[a].join(","):s[a]).replace(/\+/g,"%20")}`).join("&")}function X(s,a){if(s.method==="GET"||s.data===void 0&&a.data===void 0)return;let m=Array.isArray(s.data)?s.data:{...s.data,...a.data};return JSON.stringify(m)}function K(s,a,m){let i={Accept:"application/json",...s,...a,...m},P={};return Object.keys(i).forEach(R=>{let S=i[R];P[R.toLowerCase()]=S;}),P}function ge(s){if(!(s.status===204||s.content.length===0))try{return JSON.parse(s.content)}catch(a){throw new ye(a.message,s)}}function Se({content:s,status:a},m){try{let i=JSON.parse(s);return "error"in i?new Te(i.message,a,i.error,m):new N(i.message,a,m)}catch{}return new N(s,a,m)}function ke({isTimedOut:s,status:a}){return !s&&~~a===0}function xe({isTimedOut:s,status:a}){return s||ke({isTimedOut:s,status:a})||~~(a/100)!==2&&~~(a/100)!==4}function De({status:s}){return ~~(s/100)===2}function Ie(s){return s.map(a=>ae(a))}function ae(s){let a=s.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...s,request:{...s.request,headers:{...s.request.headers,...a}}}}function ne({hosts:s,hostsCache:a,baseHeaders:m,logger:i,baseQueryParameters:P,algoliaAgent:R,timeouts:S,requester:d,requestsCache:e,responsesCache:t,compress:o,compression:n}){async function c(f){let h=await Promise.all(f.map(q=>a.get(q,()=>Promise.resolve(M(q))))),T=h.filter(q=>q.isUp()),g=h.filter(q=>q.isTimedOut()),l=[...T,...g];return {hosts:l.length>0?l:f,getTimeout(q,x){return (g.length===0&&q===0?1:g.length+3+q)*x}}}async function r(f,h,T){let g=[],l=X(f,h),k=K(m,f.headers,h.headers),q=n==="gzip"&&l!==void 0&&l.length>qe&&(f.method==="POST"||f.method==="PUT");q&&o===void 0&&i.info("Compression is disabled because no compress method is available.");let x=q&&o!==void 0,v=x?await o(l):l;x&&(k["content-encoding"]="gzip");let C=f.method==="GET"?{...f.data,...h.data}:{},I={...P,...f.queryParameters,...C};if(R.value&&(I["x-algolia-agent"]=R.value),h&&h.queryParameters)for(let D of Object.keys(h.queryParameters))!h.queryParameters[D]||Object.prototype.toString.call(h.queryParameters[D])==="[object Object]"?I[D]=h.queryParameters[D]:I[D]=h.queryParameters[D].toString();let U=0,b=async(D,Q)=>{let w=D.pop();if(w===void 0)throw new J(Ie(g));let V={...S,...h.timeouts},j={data:v,headers:k,method:f.method,url:z(w,f.path,I),connectTimeout:Q(U,V.connect),responseTimeout:Q(U,T?V.read:V.write)},$=G=>{let B={request:j,response:G,host:w,triesLeft:D.length};return g.push(B),B},O=await d.send(j);if(xe(O)){let G=$(O);return O.isTimedOut&&U++,i.info("Retryable failure",ae(G)),await a.set(w,M(w,O.isTimedOut?"timed out":"down")),b(D,Q)}if(De(O))return ge(O);throw $(O),Se(O,g)},E=s.filter(D=>D.accept==="readWrite"||(T?D.accept==="read":D.accept==="write")),W=await c(E);return b([...W.hosts].reverse(),W.getTimeout)}function p(f,h={}){let T=()=>r(f,h,g),g=f.useReadTransporter||f.method==="GET";if((h.cacheable||f.cacheable)!==true)return T();let k={request:f,requestOptions:h,transporter:{queryParameters:P,headers:m}};return t.get(k,()=>e.get(k,()=>e.set(k,T()).then(q=>Promise.all([e.delete(k),q]),q=>Promise.all([e.delete(k),Promise.reject(q)])).then(([q,x])=>x)),{miss:q=>t.set(k,q)})}async function*y(f,h={}){if(!d.sendStream)throw new Error("This requester does not support streaming");let T=X(f,h),g=K(m,f.headers,h.headers);g.accept="text/event-stream";let l=f.method==="GET"?{...f.data,...h.data}:{},k={...P,...f.queryParameters,...l};if(R.value&&(k["x-algolia-agent"]=R.value),h&&h.queryParameters)for(let E of Object.keys(h.queryParameters))!h.queryParameters[E]||Object.prototype.toString.call(h.queryParameters[E])==="[object Object]"?k[E]=h.queryParameters[E]:k[E]=h.queryParameters[E].toString();let q=f.useReadTransporter||f.method==="GET",x=s.filter(E=>E.accept==="readWrite"||(q?E.accept==="read":E.accept==="write")),C=(await c(x)).hosts[0];if(!C)throw new J([]);let I={...S,...h.timeouts},U={data:T,headers:g,method:f.method,url:z(C,f.path,k),connectTimeout:I.connect,responseTimeout:q?I.read:I.write},b=await d.sendStream(U);yield*Pe(b);}return {hostsCache:a,requester:d,timeouts:S,logger:i,algoliaAgent:R,baseHeaders:m,baseQueryParameters:P,hosts:s,request:p,requestStream:y,requestsCache:e,responsesCache:t}}function u(s,a,m){if(m==null||typeof m=="string"&&m.length===0)throw new Error(`Parameter \`${s}\` is required when calling \`${a}\`.`)}function ie(){function s(a){return new Promise(m=>{let i=new XMLHttpRequest;i.open(a.method,a.url,true),Object.keys(a.headers).forEach(d=>i.setRequestHeader(d,a.headers[d]));let P=(d,e)=>setTimeout(()=>{i.abort(),m({status:0,content:e,isTimedOut:true});},d),R=P(a.connectTimeout,"Connection timeout"),S;i.onreadystatechange=()=>{i.readyState>i.OPENED&&S===void 0&&(clearTimeout(R),S=P(a.responseTimeout,"Socket timeout"));},i.onerror=()=>{i.status===0&&(clearTimeout(R),clearTimeout(S),m({content:i.responseText||"Network request failed",status:i.status,isTimedOut:false}));},i.onload=()=>{clearTimeout(R),clearTimeout(S),m({content:i.responseText,status:i.status,isTimedOut:false});},i.send(a.data);})}return {send:s}}var L="1.55.2",_=["eu","us"];function Ee(s){return [{url:"data.{region}.algolia.com".replace("{region}",s),accept:"readWrite",protocol:"https"}]}function ve(s){return s.type==="onDemand"}function Ce(s){return s.type==="schedule"}function Oe(s){return s.type==="subscription"}function ue({appId:s,apiKey:a,authMode:m,algoliaAgents:i,region:P,...R}){let S=Z(s,a,m),d=ne({hosts:Ee(P),...R,algoliaAgent:te({algoliaAgents:i,client:"Ingestion",version:L}),baseHeaders:{"content-type":"text/plain",...S.headers(),...R.baseHeaders},baseQueryParameters:{...S.queryParameters(),...R.baseQueryParameters}});return {transporter:d,appId:s,apiKey:a,clearCache(){return Promise.all([d.requestsCache.clear(),d.responsesCache.clear()]).then(()=>{})},get _ua(){return d.algoliaAgent.value},addAlgoliaAgent(e,t){d.algoliaAgent.add({segment:e,version:t});},setClientApiKey({apiKey:e}){!m||m==="WithinHeaders"?d.baseHeaders["x-algolia-api-key"]=e:d.baseQueryParameters["x-algolia-api-key"]=e;},async chunkedPush({indexName:e,objects:t,action:o="addObject",waitForTasks:n,batchSize:c=1e3,referenceIndexName:r,maxRetries:p=100},y){if(c<1)throw new Error("`batchSize` must be at least 1.");let f=[],h=0,T=[],g=Math.floor(c/10)||c,l=async(q,x)=>{for(let v of T.slice(q,x)){if(!v.eventID)throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");let C=0;await ee({func:async()=>{if(v.eventID===void 0||!v.eventID)throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");return this.getEvent({runID:v.runID,eventID:v.eventID}).catch(I=>{if(I.status!==404)throw I})},validate:I=>I!==void 0,aggregator:()=>C+=1,error:{validate:()=>C>=p,message:()=>`Stopped waiting for the task after ${p} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>Math.min(C*1500,5e3)});}},k=t.entries();for(let[q,x]of k)f.push(x),(f.length===c||q===t.length-1)&&(T.push(await this.push({indexName:e,pushTaskPayload:{action:o,records:f},referenceIndexName:r},y)),f=[]),n&&T.length-h>=g&&(await l(h,h+g),h+=g);return n&&await l(h,T.length),T},createAuthentication(e,t){u("authenticationCreate","createAuthentication",e),u("authenticationCreate.type","createAuthentication",e.type),u("authenticationCreate.name","createAuthentication",e.name),u("authenticationCreate.input","createAuthentication",e.input);let r={method:"POST",path:"/1/authentications",queryParameters:{},headers:{},data:e};return d.request(r,t)},createDestination(e,t){u("destinationCreate","createDestination",e),u("destinationCreate.type","createDestination",e.type),u("destinationCreate.name","createDestination",e.name),u("destinationCreate.input","createDestination",e.input);let r={method:"POST",path:"/1/destinations",queryParameters:{},headers:{},data:e};return d.request(r,t)},createSource(e,t){u("sourceCreate","createSource",e),u("sourceCreate.type","createSource",e.type),u("sourceCreate.name","createSource",e.name);let r={method:"POST",path:"/1/sources",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTask(e,t){u("taskCreate","createTask",e),u("taskCreate.sourceID","createTask",e.sourceID),u("taskCreate.destinationID","createTask",e.destinationID),u("taskCreate.action","createTask",e.action);let r={method:"POST",path:"/2/tasks",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTaskV1(e,t){u("taskCreate","createTaskV1",e),u("taskCreate.sourceID","createTaskV1",e.sourceID),u("taskCreate.destinationID","createTaskV1",e.destinationID),u("taskCreate.trigger","createTaskV1",e.trigger),u("taskCreate.action","createTaskV1",e.action);let r={method:"POST",path:"/1/tasks",queryParameters:{},headers:{},data:e};return d.request(r,t)},createTransformation(e,t){u("transformationCreate","createTransformation",e),u("transformationCreate.name","createTransformation",e.name);let r={method:"POST",path:"/1/transformations",queryParameters:{},headers:{},data:e};return d.request(r,t)},customDelete({path:e,parameters:t},o){u("path","customDelete",e);let p={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return d.request(p,o)},customGet({path:e,parameters:t},o){u("path","customGet",e);let p={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return d.request(p,o)},customPost({path:e,parameters:t,body:o},n){u("path","customPost",e);let y={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:o||{}};return d.request(y,n)},customPut({path:e,parameters:t,body:o},n){u("path","customPut",e);let y={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:o||{}};return d.request(y,n)},deleteAuthentication({authenticationID:e},t){u("authenticationID","deleteAuthentication",e);let r={method:"DELETE",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteDestination({destinationID:e},t){u("destinationID","deleteDestination",e);let r={method:"DELETE",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteSource({sourceID:e},t){u("sourceID","deleteSource",e);let r={method:"DELETE",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTask({taskID:e},t){u("taskID","deleteTask",e);let r={method:"DELETE",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTaskV1({taskID:e},t){u("taskID","deleteTaskV1",e);let r={method:"DELETE",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},deleteTransformation({transformationID:e},t){u("transformationID","deleteTransformation",e);let r={method:"DELETE",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},disableTask({taskID:e},t){u("taskID","disableTask",e);let r={method:"PUT",path:"/2/tasks/{taskID}/disable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},disableTaskV1({taskID:e},t){u("taskID","disableTaskV1",e);let r={method:"PUT",path:"/1/tasks/{taskID}/disable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},enableTask({taskID:e},t){u("taskID","enableTask",e);let r={method:"PUT",path:"/2/tasks/{taskID}/enable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},enableTaskV1({taskID:e},t){u("taskID","enableTaskV1",e);let r={method:"PUT",path:"/1/tasks/{taskID}/enable".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getAuthentication({authenticationID:e},t){u("authenticationID","getAuthentication",e);let r={method:"GET",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getDestination({destinationID:e},t){u("destinationID","getDestination",e);let r={method:"GET",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getEvent({runID:e,eventID:t},o){u("runID","getEvent",e),u("eventID","getEvent",t);let p={method:"GET",path:"/1/runs/{runID}/events/{eventID}".replace("{runID}",encodeURIComponent(e)).replace("{eventID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return d.request(p,o)},getRun({runID:e},t){u("runID","getRun",e);let r={method:"GET",path:"/1/runs/{runID}".replace("{runID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getSource({sourceID:e},t){u("sourceID","getSource",e);let r={method:"GET",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTask({taskID:e},t){u("taskID","getTask",e);let r={method:"GET",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTaskV1({taskID:e},t){u("taskID","getTaskV1",e);let r={method:"GET",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},getTransformation({transformationID:e},t){u("transformationID","getTransformation",e);let r={method:"GET",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return d.request(r,t)},listAuthentications({itemsPerPage:e,page:t,type:o,platform:n,sort:c,order:r}={},p=void 0){let y="/1/authentications",f={},h={};e!==void 0&&(h.itemsPerPage=e.toString()),t!==void 0&&(h.page=t.toString()),o!==void 0&&(h.type=o.toString()),n!==void 0&&(h.platform=n.toString()),c!==void 0&&(h.sort=c.toString()),r!==void 0&&(h.order=r.toString());let T={method:"GET",path:y,queryParameters:h,headers:f};return d.request(T,p)},listDestinations({itemsPerPage:e,page:t,type:o,authenticationID:n,transformationID:c,sort:r,order:p}={},y=void 0){let f="/1/destinations",h={},T={};e!==void 0&&(T.itemsPerPage=e.toString()),t!==void 0&&(T.page=t.toString()),o!==void 0&&(T.type=o.toString()),n!==void 0&&(T.authenticationID=n.toString()),c!==void 0&&(T.transformationID=c.toString()),r!==void 0&&(T.sort=r.toString()),p!==void 0&&(T.order=p.toString());let g={method:"GET",path:f,queryParameters:T,headers:h};return d.request(g,y)},listEvents({runID:e,itemsPerPage:t,page:o,status:n,type:c,sort:r,order:p,startDate:y,endDate:f},h){u("runID","listEvents",e);let T="/1/runs/{runID}/events".replace("{runID}",encodeURIComponent(e)),g={},l={};t!==void 0&&(l.itemsPerPage=t.toString()),o!==void 0&&(l.page=o.toString()),n!==void 0&&(l.status=n.toString()),c!==void 0&&(l.type=c.toString()),r!==void 0&&(l.sort=r.toString()),p!==void 0&&(l.order=p.toString()),y!==void 0&&(l.startDate=y.toString()),f!==void 0&&(l.endDate=f.toString());let k={method:"GET",path:T,queryParameters:l,headers:g};return d.request(k,h)},listRuns({itemsPerPage:e,page:t,status:o,type:n,taskID:c,sort:r,order:p,startDate:y,endDate:f}={},h=void 0){let T="/1/runs",g={},l={};e!==void 0&&(l.itemsPerPage=e.toString()),t!==void 0&&(l.page=t.toString()),o!==void 0&&(l.status=o.toString()),n!==void 0&&(l.type=n.toString()),c!==void 0&&(l.taskID=c.toString()),r!==void 0&&(l.sort=r.toString()),p!==void 0&&(l.order=p.toString()),y!==void 0&&(l.startDate=y.toString()),f!==void 0&&(l.endDate=f.toString());let k={method:"GET",path:T,queryParameters:l,headers:g};return d.request(k,h)},listSources({itemsPerPage:e,page:t,type:o,authenticationID:n,sort:c,order:r}={},p=void 0){let y="/1/sources",f={},h={};e!==void 0&&(h.itemsPerPage=e.toString()),t!==void 0&&(h.page=t.toString()),o!==void 0&&(h.type=o.toString()),n!==void 0&&(h.authenticationID=n.toString()),c!==void 0&&(h.sort=c.toString()),r!==void 0&&(h.order=r.toString());let T={method:"GET",path:y,queryParameters:h,headers:f};return d.request(T,p)},listTasks({itemsPerPage:e,page:t,action:o,enabled:n,sourceID:c,sourceType:r,destinationID:p,triggerType:y,withEmailNotifications:f,sort:h,order:T}={},g=void 0){let l="/2/tasks",k={},q={};e!==void 0&&(q.itemsPerPage=e.toString()),t!==void 0&&(q.page=t.toString()),o!==void 0&&(q.action=o.toString()),n!==void 0&&(q.enabled=n.toString()),c!==void 0&&(q.sourceID=c.toString()),r!==void 0&&(q.sourceType=r.toString()),p!==void 0&&(q.destinationID=p.toString()),y!==void 0&&(q.triggerType=y.toString()),f!==void 0&&(q.withEmailNotifications=f.toString()),h!==void 0&&(q.sort=h.toString()),T!==void 0&&(q.order=T.toString());let x={method:"GET",path:l,queryParameters:q,headers:k};return d.request(x,g)},listTasksV1({itemsPerPage:e,page:t,action:o,enabled:n,sourceID:c,destinationID:r,triggerType:p,sort:y,order:f}={},h=void 0){let T="/1/tasks",g={},l={};e!==void 0&&(l.itemsPerPage=e.toString()),t!==void 0&&(l.page=t.toString()),o!==void 0&&(l.action=o.toString()),n!==void 0&&(l.enabled=n.toString()),c!==void 0&&(l.sourceID=c.toString()),r!==void 0&&(l.destinationID=r.toString()),p!==void 0&&(l.triggerType=p.toString()),y!==void 0&&(l.sort=y.toString()),f!==void 0&&(l.order=f.toString());let k={method:"GET",path:T,queryParameters:l,headers:g};return d.request(k,h)},listTransformations({itemsPerPage:e,page:t,sort:o,order:n,type:c}={},r=void 0){let p="/1/transformations",y={},f={};e!==void 0&&(f.itemsPerPage=e.toString()),t!==void 0&&(f.page=t.toString()),o!==void 0&&(f.sort=o.toString()),n!==void 0&&(f.order=n.toString()),c!==void 0&&(f.type=c.toString());let h={method:"GET",path:p,queryParameters:f,headers:y};return d.request(h,r)},push({indexName:e,pushTaskPayload:t,watch:o,referenceIndexName:n},c){u("indexName","push",e),u("pushTaskPayload","push",t),u("pushTaskPayload.action","push",t.action),u("pushTaskPayload.records","push",t.records);let r="/1/push/{indexName}".replace("{indexName}",encodeURIComponent(e)),p={},y={};o!==void 0&&(y.watch=o.toString()),n!==void 0&&(y.referenceIndexName=n.toString());let f={method:"POST",path:r,queryParameters:y,headers:p,data:t};return c={timeouts:{connect:18e4,read:18e4,write:18e4,...c?.timeouts}},d.request(f,c)},pushTask({taskID:e,pushTaskPayload:t,watch:o},n){u("taskID","pushTask",e),u("pushTaskPayload","pushTask",t),u("pushTaskPayload.action","pushTask",t.action),u("pushTaskPayload.records","pushTask",t.records);let c="/2/tasks/{taskID}/push".replace("{taskID}",encodeURIComponent(e)),r={},p={};o!==void 0&&(p.watch=o.toString());let y={method:"POST",path:c,queryParameters:p,headers:r,data:t};return n={timeouts:{connect:18e4,read:18e4,write:18e4,...n?.timeouts}},d.request(y,n)},replaceTask({taskID:e,taskReplace:t},o){u("taskID","replaceTask",e),u("taskReplace","replaceTask",t),u("taskReplace.destinationID","replaceTask",t.destinationID),u("taskReplace.action","replaceTask",t.action);let p={method:"PUT",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},runSource({sourceID:e,runSourcePayload:t},o){u("sourceID","runSource",e);let p={method:"POST",path:"/1/sources/{sourceID}/run".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},runTask({taskID:e,runTaskPayload:t},o){u("taskID","runTask",e);let p={method:"POST",path:"/2/tasks/{taskID}/run".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},runTaskV1({taskID:e,runTaskPayload:t},o){u("taskID","runTaskV1",e);let p={method:"POST",path:"/1/tasks/{taskID}/run".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{}};return d.request(p,o)},searchAuthentications(e,t){u("authenticationSearch","searchAuthentications",e),u("authenticationSearch.authenticationIDs","searchAuthentications",e.authenticationIDs);let r={method:"POST",path:"/1/authentications/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchDestinations(e,t){u("destinationSearch","searchDestinations",e),u("destinationSearch.destinationIDs","searchDestinations",e.destinationIDs);let r={method:"POST",path:"/1/destinations/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchSources(e,t){u("sourceSearch","searchSources",e),u("sourceSearch.sourceIDs","searchSources",e.sourceIDs);let r={method:"POST",path:"/1/sources/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTasks(e,t){u("taskSearch","searchTasks",e),u("taskSearch.taskIDs","searchTasks",e.taskIDs);let r={method:"POST",path:"/2/tasks/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTasksV1(e,t){u("taskSearch","searchTasksV1",e),u("taskSearch.taskIDs","searchTasksV1",e.taskIDs);let r={method:"POST",path:"/1/tasks/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},searchTransformations(e,t){u("transformationSearch","searchTransformations",e),u("transformationSearch.transformationIDs","searchTransformations",e.transformationIDs);let r={method:"POST",path:"/1/transformations/search",queryParameters:{},headers:{},data:e};return d.request(r,t)},triggerDockerSourceDiscover({sourceID:e},t){u("sourceID","triggerDockerSourceDiscover",e);let r={method:"POST",path:"/1/sources/{sourceID}/discover".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return t={timeouts:{connect:18e4,read:18e4,write:18e4,...t?.timeouts}},d.request(r,t)},tryTransformation(e,t){u("transformationTry","tryTransformation",e),u("transformationTry.sampleRecord","tryTransformation",e.sampleRecord);let r={method:"POST",path:"/1/transformations/try",queryParameters:{},headers:{},data:e};return d.request(r,t)},tryTransformationBeforeUpdate({transformationID:e,transformationTry:t},o){u("transformationID","tryTransformationBeforeUpdate",e),u("transformationTry","tryTransformationBeforeUpdate",t),u("transformationTry.sampleRecord","tryTransformationBeforeUpdate",t.sampleRecord);let p={method:"POST",path:"/1/transformations/{transformationID}/try".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateAuthentication({authenticationID:e,authenticationUpdate:t},o){u("authenticationID","updateAuthentication",e),u("authenticationUpdate","updateAuthentication",t);let p={method:"PATCH",path:"/1/authentications/{authenticationID}".replace("{authenticationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateDestination({destinationID:e,destinationUpdate:t},o){u("destinationID","updateDestination",e),u("destinationUpdate","updateDestination",t);let p={method:"PATCH",path:"/1/destinations/{destinationID}".replace("{destinationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateSource({sourceID:e,sourceUpdate:t},o){u("sourceID","updateSource",e),u("sourceUpdate","updateSource",t);let p={method:"PATCH",path:"/1/sources/{sourceID}".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTask({taskID:e,taskUpdate:t},o){u("taskID","updateTask",e),u("taskUpdate","updateTask",t);let p={method:"PATCH",path:"/2/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTaskV1({taskID:e,taskUpdate:t},o){u("taskID","updateTaskV1",e),u("taskUpdate","updateTaskV1",t);let p={method:"PATCH",path:"/1/tasks/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},updateTransformation({transformationID:e,transformationCreate:t},o){u("transformationID","updateTransformation",e),u("transformationCreate","updateTransformation",t),u("transformationCreate.name","updateTransformation",t.name);let p={method:"PUT",path:"/1/transformations/{transformationID}".replace("{transformationID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return d.request(p,o)},validateSource(e,t=void 0){let r={method:"POST",path:"/1/sources/validate",queryParameters:{},headers:{},data:e||{}};return t={timeouts:{connect:18e4,read:18e4,write:18e4,...t?.timeouts}},d.request(r,t)},validateSourceBeforeUpdate({sourceID:e,sourceUpdate:t},o){u("sourceID","validateSourceBeforeUpdate",e),u("sourceUpdate","validateSourceBeforeUpdate",t);let p={method:"POST",path:"/1/sources/{sourceID}/validate".replace("{sourceID}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return o={timeouts:{connect:18e4,read:18e4,write:18e4,...o?.timeouts}},d.request(p,o)}}}function Vs(s,a,m,i){if(!s||typeof s!="string")throw new Error("`appId` is missing.");if(!a||typeof a!="string")throw new Error("`apiKey` is missing.");if(!m||m&&(typeof m!="string"||!_.includes(m)))throw new Error(`\`region\` is required and must be one of the following: ${_.join(", ")}`);let{compression:P,...R}=i||{};return ue({appId:s,apiKey:a,region:m,timeouts:{connect:25e3,read:25e3,write:25e3},logger:re(),requester:ie(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:H(),requestsCache:H({serializable:false}),hostsCache:A({caches:[Y({key:`${L}-${s}`}),H()]}),...R})}
12
12
 
13
13
  exports.apiClientVersion = L;
14
14
  exports.ingestionClient = Vs;
@@ -11,7 +11,7 @@ import {
11
11
  getAlgoliaAgent,
12
12
  validateRequired
13
13
  } from "@algolia/client-common";
14
- var apiClientVersion = "1.55.1";
14
+ var apiClientVersion = "1.55.2";
15
15
  var REGIONS = ["eu", "us"];
16
16
  function getDefaultHosts(region) {
17
17
  const url = "data.{region}.algolia.com".replace("{region}", region);
@@ -120,10 +120,41 @@ function createIngestionClient({
120
120
  referenceIndexName,
121
121
  maxRetries = 100
122
122
  }, requestOptions) {
123
+ if (batchSize < 1) {
124
+ throw new Error("`batchSize` must be at least 1.");
125
+ }
123
126
  let records = [];
124
127
  let offset = 0;
125
128
  const responses = [];
126
129
  const waitBatchSize = Math.floor(batchSize / 10) || batchSize;
130
+ const waitForBatch = async (start, end) => {
131
+ for (const resp of responses.slice(start, end)) {
132
+ if (!resp.eventID) {
133
+ throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
134
+ }
135
+ let retryCount = 0;
136
+ await createIterablePromise({
137
+ func: async () => {
138
+ if (resp.eventID === void 0 || !resp.eventID) {
139
+ throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
140
+ }
141
+ return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
142
+ if (error.status === 404) {
143
+ return void 0;
144
+ }
145
+ throw error;
146
+ });
147
+ },
148
+ validate: (response) => response !== void 0,
149
+ aggregator: () => retryCount += 1,
150
+ error: {
151
+ validate: () => retryCount >= maxRetries,
152
+ message: () => `Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
153
+ },
154
+ timeout: () => Math.min(retryCount * 1500, 5e3)
155
+ });
156
+ }
157
+ };
127
158
  const objectEntries = objects.entries();
128
159
  for (const [i, obj] of objectEntries) {
129
160
  records.push(obj);
@@ -133,36 +164,14 @@ function createIngestionClient({
133
164
  );
134
165
  records = [];
135
166
  }
136
- if (waitForTasks && responses.length > 0 && (responses.length % waitBatchSize === 0 || i === objects.length - 1)) {
137
- for (const resp of responses.slice(offset, offset + waitBatchSize)) {
138
- if (!resp.eventID) {
139
- throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
140
- }
141
- let retryCount = 0;
142
- await createIterablePromise({
143
- func: async () => {
144
- if (resp.eventID === void 0 || !resp.eventID) {
145
- throw new Error("received unexpected response from the push endpoint, eventID must not be undefined");
146
- }
147
- return this.getEvent({ runID: resp.runID, eventID: resp.eventID }).catch((error) => {
148
- if (error.status === 404) {
149
- return void 0;
150
- }
151
- throw error;
152
- });
153
- },
154
- validate: (response) => response !== void 0,
155
- aggregator: () => retryCount += 1,
156
- error: {
157
- validate: () => retryCount >= maxRetries,
158
- message: () => `Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
159
- },
160
- timeout: () => Math.min(retryCount * 1500, 5e3)
161
- });
162
- }
167
+ if (waitForTasks && responses.length - offset >= waitBatchSize) {
168
+ await waitForBatch(offset, offset + waitBatchSize);
163
169
  offset += waitBatchSize;
164
170
  }
165
171
  }
172
+ if (waitForTasks) {
173
+ await waitForBatch(offset, responses.length);
174
+ }
166
175
  return responses;
167
176
  },
168
177
  /**