UNPKG

typesense-instantsearch-adapter

Version:
2 lines 166 kB
/*! For license information please see typesense-instantsearch-adapter.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.TypesenseInstantSearchAdapter=t():e.TypesenseInstantSearchAdapter=t()}(self,(()=>(()=>{var e={3065:function(e,t,n){var r,i;!function(o,a){"use strict";r=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],i={},o=null;function a(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function u(){for(var n=this.getLevel(),i=0;i<r.length;i++){var o=r[i];this[o]=i<n?e:this.methodFactory(o,n,this.name)}if(this.log=this.debug,typeof console===t&&n<this.levels.SILENT)return"No console available for logging"}function c(e){return function(){typeof console!==t&&(u.call(this),this[e].apply(this,arguments))}}function l(r,i,o){return function(r){return"debug"===r&&(r="log"),typeof console!==t&&("trace"===r&&n?s:void 0!==console[r]?a(console,r):void 0!==console.log?a(console,"log"):e)}(r)||c.apply(this,arguments)}function d(e,n){var a,s,c,d=this,p="loglevel";function h(){var e;if(typeof window!==t&&p){try{e=window.localStorage[p]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,r=encodeURIComponent(p),i=n.indexOf(r+"=");-1!==i&&(e=/^([^;]+)/.exec(n.slice(i+r.length+1))[1])}catch(e){}return void 0===d.levels[e]&&(e=void 0),e}}function f(e){var t=e;if("string"==typeof t&&void 0!==d.levels[t.toUpperCase()]&&(t=d.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=d.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?p+=":"+e:"symbol"==typeof e&&(p=void 0),d.name=e,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=n||l,d.getLevel=function(){return null!=c?c:null!=s?s:a},d.setLevel=function(e,n){return c=f(e),!1!==n&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t&&p){try{return void(window.localStorage[p]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(p)+"="+n+";"}catch(e){}}}(c),u.call(d)},d.setDefaultLevel=function(e){s=f(e),h()||d.setLevel(e,!1)},d.resetLevel=function(){c=null,function(){if(typeof window!==t&&p){try{window.localStorage.removeItem(p)}catch(e){}try{window.document.cookie=encodeURIComponent(p)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),u.call(d)},d.enableAll=function(e){d.setLevel(d.levels.TRACE,e)},d.disableAll=function(e){d.setLevel(d.levels.SILENT,e)},d.rebuild=function(){if(o!==d&&(a=f(o.getLevel())),u.call(d),o===d)for(var e in i)i[e].rebuild()},a=f(o?o.getLevel():"WARN");var y=h();null!=y&&(c=f(y)),u.call(d)}(o=new d).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=i[e];return t||(t=i[e]=new d(e,o.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return o.noConflict=function(){return typeof window!==t&&window.log===o&&(window.log=p),o},o.getLoggers=function(){return i},o.default=o,o},void 0===(i=r.call(t,n,t,e))||(e.exports=i)}()},8567:(e,t,n)=>{"use strict";t._t=void 0;var r=n(3301),i=r.__importDefault(n(5641));i.default;var o=r.__importDefault(n(8557));t._t=o.default;r.__importStar(n(4410));i.default,o.default},5300:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(612)),o=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=o},612:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i="/aliases",o=function(){function e(e){this.apiCall=e}return e.prototype.upsert=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.put(this.endpointPath(e),t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(i)]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH,"/").concat(encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return i},enumerable:!1,configurable:!0}),e}();t.default=o},800:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(9813)),o=r.__importDefault(n(3614)),a=r.__importDefault(n(4145)),s=function(){function e(e){this.apiCall=e,this.individualAnalyticsRules={},this.apiCall=e,this._analyticsRules=new i.default(this.apiCall),this._analyticsEvents=new a.default(this.apiCall)}return e.prototype.rules=function(e){return void 0===e?this._analyticsRules:(void 0===this.individualAnalyticsRules[e]&&(this.individualAnalyticsRules[e]=new o.default(e,this.apiCall)),this.individualAnalyticsRules[e])},e.prototype.events=function(){return this._analyticsEvents},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics"},enumerable:!1,configurable:!0}),e}();t.default=s},4145:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.post(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.get(this.endpointPath(),e)]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics/events"},enumerable:!1,configurable:!0}),e}();t.default=i},3614:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(9813)),o=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=o},4695:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(5276)),o=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=o},9813:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.post(this.endpointPath(),e,{},{})]}))}))},e.prototype.upsert=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.put(this.endpointPath(e),t)]}))}))},e.prototype.retrieve=function(e){return r.__awaiter(this,void 0,void 0,(function(){var t;return r.__generator(this,(function(n){return t={},e&&(t.rule_tag=e),[2,this.apiCall.get(this.endpointPath(),t)]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics/rules"},enumerable:!1,configurable:!0}),e}();t.default=i},5276:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.upsert=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.put(this.endpointPath(e),t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics/rules"},enumerable:!1,configurable:!0}),e}();t.default=i},3421:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(5276)),o=r.__importDefault(n(4695)),a=r.__importDefault(n(4145)),s=function(){function e(e){this.apiCall=e,this.individualAnalyticsRules={},this.apiCall=e,this._analyticsRules=new i.default(this.apiCall),this._analyticsEvents=new a.default(this.apiCall)}return e.prototype.rules=function(t){return e.hasWarnedDeprecation||(console.warn("[typesense] 'analyticsV1' is deprecated starting with Typesense Server v30 and will be removed in a future release. Please use 'analytics' instead."),e.hasWarnedDeprecation=!0),void 0===t?this._analyticsRules:(void 0===this.individualAnalyticsRules[t]&&(this.individualAnalyticsRules[t]=new o.default(t,this.apiCall)),this.individualAnalyticsRules[t])},e.prototype.events=function(){return this._analyticsEvents},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/analytics"},enumerable:!1,configurable:!0}),e.hasWarnedDeprecation=!1,e}();t.default=s},5996:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(6425)),o=n(5978),a=n(7205),s=n(4410),u=r.__importDefault(n(7796)),c=n(7353),l=!0,d="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node&&"undefined"==typeof window,p=function(){function e(e){this.configuration=e,this.apiKey=this.configuration.apiKey,this.nodes=null==this.configuration.nodes?this.configuration.nodes:JSON.parse(JSON.stringify(this.configuration.nodes)),this.nearestNode=null==this.configuration.nearestNode?this.configuration.nearestNode:JSON.parse(JSON.stringify(this.configuration.nearestNode)),this.connectionTimeoutSeconds=this.configuration.connectionTimeoutSeconds,this.healthcheckIntervalSeconds=this.configuration.healthcheckIntervalSeconds,this.numRetriesPerRequest=this.configuration.numRetries,this.retryIntervalSeconds=this.configuration.retryIntervalSeconds,this.sendApiKeyAsQueryParam=this.configuration.sendApiKeyAsQueryParam,this.additionalUserHeaders=this.configuration.additionalHeaders,this.logger=this.configuration.logger,this.initializeMetadataForNodes(),this.currentNodeIndex=-1}return e.prototype.get=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t,n){void 0===t&&(t={});var i=void 0===n?{}:n,o=i.abortSignal,a=void 0===o?null:o,s=i.responseType,u=void 0===s?void 0:s,c=i.streamConfig,l=void 0===c?void 0:c,d=i.isStreamingRequest;return r.__generator(this,(function(n){return[2,this.performRequest("get",e,{queryParameters:t,abortSignal:a,responseType:u,streamConfig:l,isStreamingRequest:d})]}))}))},e.prototype.delete=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){return[2,this.performRequest("delete",e,{queryParameters:t,isStreamingRequest:!1})]}))}))},e.prototype.post=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t,n,i,o){void 0===t&&(t={}),void 0===n&&(n={}),void 0===i&&(i={});var a=void 0===o?{}:o,s=a.abortSignal,u=void 0===s?null:s,c=a.responseType,l=void 0===c?void 0:c,d=a.streamConfig,p=void 0===d?void 0:d,h=a.isStreamingRequest;return r.__generator(this,(function(r){return[2,this.performRequest("post",e,{queryParameters:n,bodyParameters:t,additionalHeaders:i,abortSignal:u,responseType:l,streamConfig:p,isStreamingRequest:h})]}))}))},e.prototype.put=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),r.__generator(this,(function(r){return[2,this.performRequest("put",e,{queryParameters:n,bodyParameters:t,isStreamingRequest:!1})]}))}))},e.prototype.patch=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),r.__generator(this,(function(r){return[2,this.performRequest("patch",e,{queryParameters:n,bodyParameters:t,isStreamingRequest:!1})]}))}))},e.prototype.getAdapter=function(){if(this.configuration.axiosAdapter)return"function"==typeof this.configuration.axiosAdapter?this.configuration.axiosAdapter:"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent?i.default.getAdapter(this.configuration.axiosAdapter).bind(globalThis):i.default.getAdapter(this.configuration.axiosAdapter)},e.prototype.performRequest=function(e,t,n){return r.__awaiter(this,arguments,void 0,(function(e,t,n){var s,u,c,p,h,f,y,v,m,_,g,b=n.queryParameters,w=void 0===b?null:b,C=n.bodyParameters,S=void 0===C?null:C,R=n.additionalHeaders,O=void 0===R?{}:R,P=n.abortSignal,E=void 0===P?null:P,A=n.responseType,T=void 0===A?void 0:A,j=n.skipConnectionTimeout,N=void 0!==j&&j,x=n.enableKeepAlive,k=void 0===x?void 0:x,D=n.streamConfig,U=void 0===D?void 0:D,I=n.isStreamingRequest;return r.__generator(this,(function(n){switch(n.label){case 0:this.configuration.validate(),I&&(this.logger.debug("Request: Performing streaming request to ".concat(t)),d||"undefined"==typeof fetch||(this.logger.debug("Using fetch adapter for browser streaming"),T="stream")),s=Date.now(),c=!1,this.logger.debug("Request #".concat(s,": Performing ").concat(e.toUpperCase()," request: ").concat(t)),p=function(n){var p,f,y,b,C,R,P;return r.__generator(this,(function(A){switch(A.label){case 0:if(p=h.getNextNode(s),h.logger.debug("Request #".concat(s,": Attempting ").concat(e.toUpperCase()," request Try #").concat(n," to Node ").concat(p.index)),E&&E.aborted)return[2,{value:Promise.reject(new Error("Request aborted by caller."))}];f=void 0,A.label=1;case 1:return A.trys.push([1,3,5,6]),(y={method:e,url:h.uriFor(t,p),headers:Object.assign({},h.defaultHeaders(),O,h.additionalUserHeaders),maxContentLength:1/0,maxBodyLength:1/0,validateStatus:function(e){return e>0},transformResponse:[function(e,t){var n=e;return void 0!==t&&"string"==typeof e&&t["content-type"]&&t["content-type"].startsWith("application/json")&&(n=JSON.parse(e)),n}]}).adapter=I&&!d?"fetch":h.getAdapter(),!0!==N&&(y.timeout=1e3*h.connectionTimeoutSeconds),w&&0!==Object.keys(w).length&&(y.params=w),h.sendApiKeyAsQueryParam&&(y.params=y.params||{},y.params["x-typesense-api-key"]=h.apiKey),h.configuration.httpAgent?(h.logger.debug("Request #".concat(s,": Using custom httpAgent")),y.httpAgent=h.configuration.httpAgent):!0===k&&(d?(h.logger.debug("Request #".concat(s,": Enabling KeepAlive")),y.httpAgent=new o.Agent({keepAlive:!0})):h.logger.warn("Request #".concat(s,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),h.configuration.httpsAgent?(h.logger.debug("Request #".concat(s,": Using custom httpsAgent")),y.httpsAgent=h.configuration.httpsAgent):!0===k&&(d?(h.logger.debug("Request #".concat(s,": Enabling keepAlive")),y.httpsAgent=new a.Agent({keepAlive:!0})):h.logger.warn("Request #".concat(s,": Cannot use custom httpAgent in a browser environment to enable keepAlive"))),h.configuration.paramsSerializer&&(h.logger.debug("Request #".concat(s,": Using custom paramsSerializer")),y.paramsSerializer=h.configuration.paramsSerializer),S&&("string"==typeof S&&0!==S.length||"object"==typeof S&&0!==Object.keys(S).length)&&(y.data=S),E&&(b=i.default.CancelToken,C=b.source(),f=function(){c=!0,C.cancel()},E.addEventListener("abort",f),y.cancelToken=C.token),I?(y.responseType="stream",d||(y.headers=r.__assign(r.__assign({},y.headers),{Accept:"text/event-stream"}))):T&&(y.responseType=T),[4,(0,i.default)(y)];case 2:if((R=A.sent()).status>=1&&R.status<=499&&h.setNodeHealthcheck(p,l),h.logger.debug("Request #".concat(s,": Request to Node ").concat(p.index," was made. Response Code was ").concat(R.status,".")),R.status>=200&&R.status<300)return I?[2,{value:h.handleStreamingResponse(R,U)}]:[2,{value:Promise.resolve(R.data)}];if(R.status<500)return[2,{value:Promise.reject(h.customErrorForResponse(R,null===(v=R.data)||void 0===v?void 0:v.message,y.data))}];throw h.customErrorForResponse(R,null===(m=R.data)||void 0===m?void 0:m.message,y.data);case 3:return P=A.sent(),c||h.setNodeHealthcheck(p,!1),u=P,h.logger.warn("Request #".concat(s,": Request to Node ").concat(p.index,' failed due to "').concat(null!==(_=null==P?void 0:P.code)&&void 0!==_?_:""," ").concat(P.message).concat(null==P.response?"":" - "+JSON.stringify(null===(g=P.response)||void 0===g?void 0:g.data),'"')),c?[2,{value:Promise.reject(new Error("Request aborted by caller."))}]:(I&&h.invokeOnErrorCallback(P,U),n<h.numRetriesPerRequest+1?(h.logger.warn("Request #".concat(s,": Sleeping for ").concat(h.retryIntervalSeconds,"s and then retrying request...")),[4,h.timer(h.retryIntervalSeconds)]):(h.logger.debug("Request #".concat(s,": No retries left. Raising last error")),[2,{value:Promise.reject(u)}]));case 4:return A.sent(),[3,6];case 5:return E&&f&&E.removeEventListener("abort",f),[7];case 6:return[2]}}))},h=this,f=1,n.label=1;case 1:return f<=this.numRetriesPerRequest+1?[5,p(f)]:[3,4];case 2:if("object"==typeof(y=n.sent()))return[2,y.value];n.label=3;case 3:return f++,[3,1];case 4:return this.logger.debug("Request #".concat(s,": No retries left. Raising last error")),[2,Promise.reject(u)]}}))}))},e.prototype.processStreamingLine=function(e){if(!e.trim()||"data: [DONE]"===e)return null;if(e.startsWith("data: "))return this.processDataLine(e.slice(6).trim());if(e.trim().startsWith("{"))try{var t=JSON.parse(e.trim());return t&&"object"==typeof t?(t.conversation_id||(t.conversation_id="unknown"),t.message||""===t.message||(t.message=""),t):{conversation_id:"unknown",message:JSON.stringify(t)}}catch(t){return{conversation_id:"unknown",message:e.trim()}}return{conversation_id:"unknown",message:e.trim()}},e.prototype.processDataLine=function(e){if(!e)return null;if(e.startsWith("{"))try{var t=JSON.parse(e);return t&&"object"==typeof t?(t.conversation_id||(t.conversation_id="unknown"),t.message||""===t.message||(t.message=""),t):{conversation_id:"unknown",message:JSON.stringify(t)}}catch(t){return{conversation_id:"unknown",message:e}}return{conversation_id:"unknown",message:e}},e.prototype.handleStreamingResponse=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return this.logger.debug("Handling streaming response. Environment: ".concat(d?"Node.js":"Browser")),d&&e.data?[2,this.handleNodeStreaming(e,t)]:d?(this.logger.debug("Processing non-streaming response"),this.invokeOnCompleteCallback(e.data,t),[2,Promise.resolve(e.data)]):[2,this.handleBrowserStreaming(e,t)]}))}))},e.prototype.handleNodeStreaming=function(e,t){var n=this;return this.logger.debug("Processing Node.js stream"),new Promise((function(r,i){var o=e.data,a=[],s="";o.on("data",(function(e){var r;try{var o=e.toString(),u=(s+=o).split("\n");s=null!==(r=u.pop())&&void 0!==r?r:"",n.processStreamLines(u,a,t)}catch(e){i(e)}})),o.on("end",(function(){if(s.trim().length>0){var i=s.split("\n");n.processStreamLines(i,a,t)}n.finalizeStreamResult(a,r,e,t)})),o.on("error",(function(e){n.logger.error("Stream error: ".concat(e)),n.invokeOnErrorCallback(e,t),i(e)}))}))},e.prototype.handleBrowserStreaming=function(e,t){var n=this;return this.logger.debug("Processing browser stream"),new Promise((function(i,o){return r.__awaiter(n,void 0,void 0,(function(){return r.__generator(this,(function(n){try{return e.data&&"function"==typeof e.data.getReader?[2,this.handleBrowserReadableStream(e.data,i,o,e,t)]:"string"==typeof e.data?[2,this.handleBrowserStringResponse(e.data,i,e,t)]:"object"==typeof e.data&&null!==e.data?(this.logger.debug("No stream found, but data object is available"),this.invokeOnCompleteCallback(e.data,t),[2,i(e.data)]):(this.logger.error("No usable data found in response"),[2,o(new Error("No usable data found in response"))])}catch(e){this.logger.error("Error processing streaming response: ".concat(e)),this.invokeOnErrorCallback(e,t),o(e)}return[2]}))}))}))},e.prototype.handleBrowserReadableStream=function(e,t,n,i,o){return r.__awaiter(this,void 0,void 0,(function(){var a,s,u,c,l,d,p,h,f,y;return r.__generator(this,(function(r){switch(r.label){case 0:this.logger.debug("Found ReadableStream in response.data"),a=e.getReader(),s=[],u="",r.label=1;case 1:r.trys.push([1,5,,6]),r.label=2;case 2:return[4,a.read()];case 3:return c=r.sent(),l=c.done,d=c.value,l?(this.logger.debug("Stream reading complete"),u.trim()&&(p=u.split("\n"),this.processStreamLines(p,s,o)),[3,4]):(h=(new TextDecoder).decode(d),this.logger.debug("Received chunk: ".concat(h.length," bytes")),f=(u+=h).split("\n"),u=f.pop()||"",this.processStreamLines(f,s,o),[3,2]);case 4:return this.finalizeStreamResult(s,t,i,o),[3,6];case 5:return y=r.sent(),this.logger.error("Stream error: ".concat(y)),this.invokeOnErrorCallback(y,o),n(y),[3,6];case 6:return[2]}}))}))},e.prototype.handleBrowserStringResponse=function(e,t,n,r){this.logger.debug("Processing text response as stream data");var i=[],o=e.split("\n");if(this.processStreamLines(o,i,r),i.length>0){var a=this.combineStreamingChunks(i);this.invokeOnCompleteCallback(a,r),t(a)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(n.data,r),t(n.data)},e.prototype.processStreamLines=function(e,t,n){for(var r=0,i=e;r<i.length;r++){var o=i[r];if(o.trim()&&"data: [DONE]"!==o){var a=this.processStreamingLine(o);null!==a&&(this.invokeOnChunkCallback(a,n),t.push(a))}}},e.prototype.finalizeStreamResult=function(e,t,n,r){if(e.length>0){var i=this.combineStreamingChunks(e);this.logger.debug("Stream processing complete"),this.invokeOnCompleteCallback(i,r),t(i)}else this.logger.debug("No chunks processed, returning original API response"),this.invokeOnCompleteCallback(n.data,r),t(n.data)},e.prototype.combineStreamingChunks=function(e){if(0===e.length)return{};if(1===e.length)return e[0];var t=this.getMessageChunks(e);if(t.length>0)return this.combineMessageChunks(e,t);var n=e[e.length-1];if(!this.isCompleteSearchResponse(n))throw new Error("Last chunk is not a complete search response");return n},e.prototype.getMessageChunks=function(e){return e.filter(this.isChunkMessage)},e.prototype.isChunkMessage=function(e){return"object"==typeof e&&null!==e&&"message"in e&&"conversation_id"in e},e.prototype.combineMessageChunks=function(e,t){this.logger.debug("Found ".concat(t.length," message chunks to combine"));var n=e[e.length-1];if(this.isCompleteSearchResponse(n))return n;var r=e.find(this.isCompleteSearchResponse);if(!r)throw new Error("No metadata chunk found");return r},e.prototype.isCompleteSearchResponse=function(e){return"object"==typeof e&&null!==e&&Object.keys(e).length>0&&("results"in e||"found"in e||"hits"in e||"page"in e||"search_time_ms"in e)},e.prototype.getNextNode=function(e){if(void 0===e&&(e=0),null!=this.nearestNode){if(this.logger.debug("Request #".concat(e,": Nodes Health: Node ").concat(this.nearestNode.index," is ").concat(!0===this.nearestNode.isHealthy?"Healthy":"Unhealthy")),!0===this.nearestNode.isHealthy||this.nodeDueForHealthcheck(this.nearestNode,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(this.nearestNode.index)),this.nearestNode;this.logger.debug("Request #".concat(e,": Falling back to individual nodes"))}this.logger.debug("Request #".concat(e,": Nodes Health: ").concat(this.nodes.map((function(e){return"Node ".concat(e.index," is ").concat(!0===e.isHealthy?"Healthy":"Unhealthy")})).join(" || ")));for(var t=this.nodes[0],n=0;n<=this.nodes.length;n++)if(this.currentNodeIndex=(this.currentNodeIndex+1)%this.nodes.length,!0===(t=this.nodes[this.currentNodeIndex]).isHealthy||this.nodeDueForHealthcheck(t,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(t.index)),t;return this.logger.debug("Request #".concat(e,": No healthy nodes were found. Returning the next node, Node ").concat(t.index)),t},e.prototype.nodeDueForHealthcheck=function(e,t){void 0===t&&(t=0);var n=Date.now()-e.lastAccessTimestamp>1e3*this.healthcheckIntervalSeconds;return n&&this.logger.debug("Request #".concat(t,": Node ").concat(e.index," has exceeded healtcheckIntervalSeconds of ").concat(this.healthcheckIntervalSeconds,". Adding it back into rotation.")),n},e.prototype.initializeMetadataForNodes=function(){var e=this;null!=this.nearestNode&&(this.nearestNode.index="nearestNode",this.setNodeHealthcheck(this.nearestNode,l)),this.nodes.forEach((function(t,n){t.index=n,e.setNodeHealthcheck(t,l)}))},e.prototype.setNodeHealthcheck=function(e,t){e.isHealthy=t,e.lastAccessTimestamp=Date.now()},e.prototype.uriFor=function(e,t){return null!=t.url?"".concat(t.url).concat(e):"".concat(t.protocol,"://").concat(t.host,":").concat(t.port).concat(t.path).concat(e)},e.prototype.defaultHeaders=function(){var e={};return this.sendApiKeyAsQueryParam||(e["X-TYPESENSE-API-KEY"]=this.apiKey),e["Content-Type"]="application/json",e},e.prototype.timer=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,1e3*e)}))]}))}))},e.prototype.customErrorForResponse=function(e,t,n){var r="Request failed with HTTP code ".concat(e.status);return"string"==typeof t&&""!==t.trim()&&(r+=" | Server said: ".concat(t)),new u.default(r,n,e.status),400===e.status?new s.RequestMalformed(r,n,e.status):401===e.status?new s.RequestUnauthorized(r,n,e.status):404===e.status?new s.ObjectNotFound(r,n,e.status):409===e.status?new s.ObjectAlreadyExists(r,n,e.status):422===e.status?new s.ObjectUnprocessable(r,n,e.status):e.status>=500&&e.status<=599?new s.ServerError(r,n,e.status):new s.HTTPError(r,n,e.status)},e.prototype.invokeOnChunkCallback=function(e,t){if(null==t?void 0:t.onChunk)try{t.onChunk(e)}catch(e){this.logger.warn("Error in onChunk callback: ".concat(e))}},e.prototype.invokeOnCompleteCallback=function(e,t){if(null==t?void 0:t.onComplete)try{t.onComplete(e)}catch(e){this.logger.warn("Error in onComplete callback: ".concat(e))}},e.prototype.invokeOnErrorCallback=function(e,t){if(null==t?void 0:t.onError){var n=(0,c.toErrorWithMessage)(e);try{t.onError(n)}catch(e){this.logger.warn("Error in onError callback: ".concat(e))}}},e}();t.default=p},5641:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(5706)),o=r.__importDefault(n(5996)),a=r.__importDefault(n(7361)),s=r.__importDefault(n(2626)),u=r.__importDefault(n(612)),c=r.__importDefault(n(5300)),l=r.__importDefault(n(326)),d=r.__importDefault(n(2275)),p=r.__importDefault(n(3343)),h=r.__importDefault(n(657)),f=r.__importDefault(n(4955)),y=r.__importDefault(n(8231)),v=r.__importDefault(n(3684)),m=r.__importDefault(n(8621)),_=r.__importDefault(n(5156)),g=r.__importDefault(n(3777)),b=r.__importDefault(n(3421)),w=r.__importDefault(n(800)),C=r.__importDefault(n(3533)),S=r.__importDefault(n(4646)),R=r.__importDefault(n(8700)),O=r.__importDefault(n(8313)),P=r.__importDefault(n(2786)),E=r.__importDefault(n(5350)),A=r.__importDefault(n(7187)),T=r.__importDefault(n(4200)),j=r.__importDefault(n(2077)),N=r.__importDefault(n(476)),x=r.__importDefault(n(1049)),k=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null!==(t=e.sendApiKeyAsQueryParam)&&void 0!==t&&t,this.configuration=new i.default(e),this.apiCall=new o.default(this.configuration),this.debug=new p.default(this.apiCall),this.metrics=new h.default(this.apiCall),this.stats=new f.default(this.apiCall),this.health=new y.default(this.apiCall),this.operations=new v.default(this.apiCall),this.multiSearch=new m.default(this.apiCall,this.configuration),this._collections=new a.default(this.apiCall),this.individualCollections={},this._aliases=new u.default(this.apiCall),this.individualAliases={},this._keys=new l.default(this.apiCall),this.individualKeys={},this._presets=new _.default(this.apiCall),this.individualPresets={},this._stopwords=new C.default(this.apiCall),this.individualStopwords={},this.analytics=new w.default(this.apiCall),this.analyticsV1=new b.default(this.apiCall),this.stemming=new P.default(this.apiCall),this._conversations=new R.default(this.apiCall),this.individualConversations={},this._nlSearchModels=new E.default(this.apiCall),this.individualNLSearchModels={},this._synonymSets=new T.default(this.apiCall),this.individualSynonymSets={},this._curationSets=new N.default(this.apiCall),this.individualCurationSets={}}return e.prototype.collections=function(e){return void 0===e?this._collections:(void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.default(e,this.apiCall,this.configuration)),this.individualCollections[e])},e.prototype.aliases=function(e){return void 0===e?this._aliases:(void 0===this.individualAliases[e]&&(this.individualAliases[e]=new c.default(e,this.apiCall)),this.individualAliases[e])},e.prototype.keys=function(e){return void 0===e?this._keys:(void 0===this.individualKeys[e]&&(this.individualKeys[e]=new d.default(e,this.apiCall)),this.individualKeys[e])},e.prototype.presets=function(e){return void 0===e?this._presets:(void 0===this.individualPresets[e]&&(this.individualPresets[e]=new g.default(e,this.apiCall)),this.individualPresets[e])},e.prototype.stopwords=function(e){return void 0===e?this._stopwords:(void 0===this.individualStopwords[e]&&(this.individualStopwords[e]=new S.default(e,this.apiCall)),this.individualStopwords[e])},e.prototype.conversations=function(e){return void 0===e?this._conversations:(void 0===this.individualConversations[e]&&(this.individualConversations[e]=new O.default(e,this.apiCall)),this.individualConversations[e])},e.prototype.nlSearchModels=function(e){return void 0===e?this._nlSearchModels:(void 0===this.individualNLSearchModels[e]&&(this.individualNLSearchModels[e]=new A.default(e,this.apiCall)),this.individualNLSearchModels[e])},e.prototype.synonymSets=function(e){return void 0===e?this._synonymSets:(void 0===this.individualSynonymSets[e]&&(this.individualSynonymSets[e]=new j.default(e,this.apiCall)),this.individualSynonymSets[e])},e.prototype.curationSets=function(e){return void 0===e?this._curationSets:(void 0===this.individualCurationSets[e]&&(this.individualCurationSets[e]=new x.default(e,this.apiCall)),this.individualCurationSets[e])},e}();t.default=k},2626:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(7361)),o=r.__importDefault(n(9078)),a=n(4410),s=r.__importDefault(n(3629)),u=r.__importDefault(n(6582)),c=r.__importDefault(n(1104)),l=r.__importDefault(n(6821)),d=n(9459),p=function(){function e(e,t,n){this.name=e,this.apiCall=t,this.configuration=n,this.individualDocuments={},this.individualOverrides={},this.individualSynonyms={},this.name=e,this.apiCall=t,this.configuration=n,this._documents=new o.default(this.name,this.apiCall,this.configuration),this._overrides=new s.default(this.name,this.apiCall),this._synonyms=new c.default(this.name,this.apiCall)}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.patch(this.endpointPath(),e)]}))}))},e.prototype.delete=function(){return r.__awaiter(this,arguments,void 0,(function(e){return void 0===e&&(e={}),r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},e.prototype.exists=function(){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.retrieve()];case 1:return t.sent(),[2,!0];case 2:if((e=t.sent())instanceof a.ObjectNotFound)return[2,!1];throw e;case 3:return[2]}}))}))},e.prototype.documents=function(e){return e?(void 0===this.individualDocuments[e]&&(this.individualDocuments[e]=new d.Document(this.name,e,this.apiCall)),this.individualDocuments[e]):this._documents},e.prototype.overrides=function(e){return void 0===e?this._overrides:(void 0===this.individualOverrides[e]&&(this.individualOverrides[e]=new u.default(this.name,e,this.apiCall)),this.individualOverrides[e])},e.prototype.synonyms=function(e){return void 0===e?this._synonyms:(void 0===this.individualSynonyms[e]&&(this.individualSynonyms[e]=new l.default(this.name,e,this.apiCall)),this.individualSynonyms[e])},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=p},7361:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i="/collections",o=function(){function e(e){this.apiCall=e}return e.prototype.create=function(e,t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return[2,this.apiCall.post(i,e,t)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,arguments,void 0,(function(e){return void 0===e&&(e={}),r.__generator(this,(function(t){return[2,this.apiCall.get(i,e)]}))}))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return i},enumerable:!1,configurable:!0}),e}();t.default=o},5706:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importStar(n(3065)),o=n(4410),a=function(){function e(e){var t=this;this.nodes=e.nodes||[],this.nodes=this.nodes.map((function(e){return t.setDefaultPathInNode(e)})).map((function(e){return t.setDefaultPortInNode(e)})).map((function(e){return r.__assign({},e)})),null==e.randomizeNodes&&(e.randomizeNodes=!0),!0===e.randomizeNodes&&this.shuffleArray(this.nodes),this.nearestNode=e.nearestNode,this.nearestNode=this.setDefaultPathInNode(this.nearestNode),this.nearestNode=this.setDefaultPortInNode(this.nearestNode),this.connectionTimeoutSeconds=e.connectionTimeoutSeconds||e.timeoutSeconds||5,this.healthcheckIntervalSeconds=e.healthcheckIntervalSeconds||60,this.numRetries=(void 0!==e.numRetries&&e.numRetries>=0?e.numRetries:this.nodes.length+(null==this.nearestNode?0:1))||3,this.retryIntervalSeconds=e.retryIntervalSeconds||.1,this.apiKey=e.apiKey,this.sendApiKeyAsQueryParam=e.sendApiKeyAsQueryParam,this.cacheSearchResultsForSeconds=e.cacheSearchResultsForSeconds||0,this.useServerSideSearchCache=e.useServerSideSearchCache||!1,this.axiosAdapter=e.axiosAdapter,this.logger=e.logger||i,this.logLevel=e.logLevel||"warn",this.logger.setLevel(this.logLevel),this.additionalHeaders=e.additionalHeaders,this.httpAgent=e.httpAgent,this.httpsAgent=e.httpsAgent,this.paramsSerializer=e.paramsSerializer,this.showDeprecationWarnings(e),this.validate()}return e.prototype.validate=function(){if(null==this.nodes||0===this.nodes.length||this.validateNodes())throw new o.MissingConfigurationError("Ensure that nodes[].protocol, nodes[].host and nodes[].port are set");if(null!=this.nearestNode&&this.isNodeMissingAnyParameters(this.nearestNode))throw new o.MissingConfigurationError("Ensure that nearestNodes.protocol, nearestNodes.host and nearestNodes.port are set");if(null==this.apiKey)throw new o.MissingConfigurationError("Ensure that apiKey is set");return!0},e.prototype.validateNodes=function(){var e=this;return this.nodes.some((function(t){return e.isNodeMissingAnyParameters(t)}))},e.prototype.isNodeMissingAnyParameters=function(e){return!["protocol","host","port","path"].every((function(t){return e.hasOwnProperty(t)}))&&null==e.url},e.prototype.setDefaultPathInNode=function(e){return null==e||e.hasOwnProperty("path")||(e.path=""),e},e.prototype.setDefaultPortInNode=function(e){if(null!=e&&!e.hasOwnProperty("port")&&e.hasOwnProperty("protocol"))switch(e.protocol){case"https":e.port=443;break;case"http":e.port=80}return e},e.prototype.showDeprecationWarnings=function(e){e.timeoutSeconds&&this.logger.warn("Deprecation warning: timeoutSeconds is now renamed to connectionTimeoutSeconds"),e.masterNode&&this.logger.warn("Deprecation warning: masterNode is now consolidated to nodes, starting with Typesense Server v0.12"),e.readReplicaNodes&&this.logger.warn("Deprecation warning: readReplicaNodes is now consolidated to nodes, starting with Typesense Server v0.12")},e.prototype.shuffleArray=function(e){for(var t,n=e.length-1;n>0;n--){var r=Math.floor(Math.random()*(n+1));t=[e[r],e[n]],e[n]=t[0],e[r]=t[1]}},e}();t.default=a},8313:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(8700)),o=function(){function e(e,t){this.id=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();t.default=o},5168:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(2783)),o=function(){function e(e,t){this.id=e,this.apiCall=t}return e.prototype.update=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.id))},e}();t.default=o},2783:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e,this.apiCall=e}return e.prototype.create=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.post(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.endpointPath=function(t){return"".concat(e.RESOURCEPATH).concat(void 0===t?"":"/"+encodeURIComponent(t))},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return"/conversations/models"},enumerable:!1,configurable:!0}),e}();t.default=i},8700:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(2783)),o=r.__importDefault(n(5168)),a="/conversations",s=function(){function e(e){this.apiCall=e,this.individualConversationModels={},this.apiCall=e,this._conversationsModels=new i.default(this.apiCall)}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(a)]}))}))},e.prototype.models=function(e){return void 0===e?this._conversationsModels:(void 0===this.individualConversationModels[e]&&(this.individualConversationModels[e]=new o.default(e,this.apiCall)),this.individualConversationModels[e])},Object.defineProperty(e,"RESOURCEPATH",{get:function(){return a},enumerable:!1,configurable:!0}),e}();t.default=s},1049:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(476)),o=r.__importDefault(n(285)),a=r.__importDefault(n(4326)),s=function(){function e(e,t){this.name=e,this.apiCall=t,this.individualItems={},this._items=new o.default(this.name,t)}return e.prototype.upsert=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.items=function(e){return void 0===e?this._items:(void 0===this.individualItems[e]&&(this.individualItems[e]=new a.default(this.name,e,this.apiCall)),this.individualItems[e])},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name))},e}();t.default=s},4326:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(476)),o=function(){function e(e,t,n){this.name=e,this.itemId=t,this.apiCall=n}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.upsert=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.put(this.endpointPath(),e)]}))}))},e.prototype.delete=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.delete(this.endpointPath())]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name),"/items/").concat(encodeURIComponent(this.itemId))},e}();t.default=o},285:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=r.__importDefault(n(476)),o=function(){function e(e,t){this.name=e,this.apiCall=t}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.endpointPath=function(e){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.name),"/items").concat(void 0===e?"":"/"+encodeURIComponent(e))},e}();t.default=o},476:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.get(e.RESOURCEPATH)]}))}))},e.RESOURCEPATH="/curation_sets",e}();t.default=i},3343:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=function(){function e(e){this.apiCall=e}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get("/debug")]}))}))},e}();t.default=i},9459:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Document=void 0;var r=n(3301),i=r.__importDefault(n(7361)),o=r.__importDefault(n(9078)),a=function(){function e(e,t,n){this.collectionName=e,this.documentId=t,this.apiCall=n}return e.prototype.retrieve=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return[2,this.apiCall.get(this.endpointPath())]}))}))},e.prototype.delete=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},e.prototype.update=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){return[2,this.apiCall.patch(this.endpointPath(),e,t)]}))}))},e.prototype.endpointPath=function(){return"".concat(i.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.collectionName)).concat(o.default.RESOURCEPATH,"/").concat(encodeURIComponent(this.documentId))},e}();t.Document=a},9078:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3301),i=n(4410),o=n(6124),a="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,s=function(e){function t(t,n,r){return e.call(this,t,n,r)||this}return r.__extends(t,e),t.prototype.create=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),e,t)]}))}))},t.prototype.upsert=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return[2,this.apiCall.post(this.endpointPath(),e,Object.assign({},t,{action:"upsert"}))]}))}))},t.prototype.update=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){if(!e)throw new Error("No document provided");return null!=t.filter_by?[2,this.apiCall.patch(this.endpointPath(),e,Object.assign({},t))]:[2,this.apiCall.post(this.endpointPath(),e,Object.assign({},t,{action:"update"}))]}))}))},t.prototype.delete=function(){return r.__awaiter(this,arguments,void 0,(function(e){return void 0===e&&(e={}),r.__generator(this,(function(t){return[2,this.apiCall.delete(this.endpointPath(),e)]}))}))},t.prototype.createMany=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){return void 0===t&&(t={}),r.__generator(this,(function(n){return this.configuration.logger.warn("createMany is deprecated and will be removed in a future version. Use import instead, which now takes both an array of documents or a JSONL string of documents"),[2,this.import(e,t)]}))}))},t.prototype.import=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){var n,o,s,u,c;return void 0===t&&(t={}),r.__generator(this,(function(l){switch(l.label){case 0:if(n=r.__assign({throwOnFail:!0},t),Array.isArray(e)){if(0===e.length)throw new i.RequestMalformed("No documents provided");try{o=e.map((function(e){return JSON.stringify(e)})).join("\n")}catch(e){if(e instanceof RangeError&&e.message.includes("Too many properties to enumerate"))throw new Error("".concat(e,"\n It looks like you have reached a Node.js limit that restricts the number of keys in an Object: https://stackoverflow.com/questions/9282869/are-there-limits-to-the-number-of-properties-in-a-javascript-object\n\n Please try reducing the number of keys in your document, or using CURL to import your data.\n "));throw new Error(e)}}else if(null==(d=o=e)||""===d||0===d.length)throw new i.RequestMalformed("No documents provided");return[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:n,bodyParameters:o,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!a})];case 1:if(s=l.sent(),Array.isArray(e)){if(u=s.split("\n").map((function(e){return JSON.parse(e)})),(c=u.filter((function(e){return!1===e.success}))).length>0&&n.throwOnFail)throw new i.ImportError("".concat(u.length-c.length," documents imported successfully, ").concat(c.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),u,{documentsInJSONLFormat:o,options:n,failedItems:c,successCount:u.length-c.length});return[2,u]}return[2,s]}var d}))}))},t.prototype.importStream=function(e){return r.__awaiter(this,arguments,void 0,(function(e,t){var n,o,s,u;return void 0===t&&(t={}),r.__generator(this,(function(c){switch(c.label){case 0:return n=r.__assign({throwOnFail:!0},t),[4,this.apiCall.performRequest("post",this.endpointPath("import"),{queryParameters:n,bodyParameters:e,additionalHeaders:{"Content-Type":"text/plain"},skipConnectionTimeout:!0,enableKeepAlive:!!a})];case 1:if(o=c.sent(),s=o.split("\n").map((function(e){return JSON.parse(e)})),(u=s.filter((function(e){return!1===e.success}))).length>0&&n.throwOnFail)throw new i.ImportError("".concat(s.length-u.length," documents imported successfully, ").concat(u.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),s,{documentsInJSONLFormat:e,options:n,failedItems:u,successCount:s.length-u.length});return[2,s]}}))}))},t.prototype.export=function(){return r.__awaiter(this,arguments,void 0,(function(e){return void 0===e&&(e={}),r.__generator(