@influxdata/influxdb-client-browser 1.26.0-nightly.2004 → 1.26.0

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.
@@ -13,5 +13,5 @@ var influxdb=function(t){"use strict";function e(){var t=new TextDecoder("utf-8"
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- var c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function l(t,e){function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var f=function(){return f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},f.apply(this,arguments)};function h(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function p(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var d=[404,408,425,429,500,502,503,504];function y(t){return d.includes(t)}var v=function(t){function e(n){var r=t.call(this,n)||this;return r.name="IllegalArgumentError",Object.setPrototypeOf(r,e.prototype),r}return l(e,t),e}(Error),m=function(t){function e(n,r,o,i,s,u){var a=t.call(this)||this;if(a.statusCode=n,a.statusMessage=r,a.body=o,a.contentType=s,Object.setPrototypeOf(a,e.prototype),u)a.message=u;else if(o){if(null==s?void 0:s.startsWith("application/json"))try{a.json=JSON.parse(o),a.message=a.json.message,a.code=a.json.code}catch(t){}a.message||(a.message="".concat(n," ").concat(r," : ").concat(o))}else a.message="".concat(n," ").concat(r);return a.name="HttpError",a.setRetryAfter(i),a}return l(e,t),e.prototype.setRetryAfter=function(t){"string"==typeof t&&/^[0-9]+$/.test(t)?this._retryAfter=parseInt(t):this._retryAfter=0},e.prototype.canRetry=function(){return y(this.statusCode)},e.prototype.retryAfter=function(){return this._retryAfter},e}(Error),g=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function w(t,e){if(t){var n=void 0;return"function"==typeof t.retryAfter?t.retryAfter():(n=0,e&&e>0?n+Math.round(Math.random()*e):n)}return 0}var b=function(t){function e(){var n=t.call(this)||this;return Object.setPrototypeOf(n,e.prototype),n.name="RequestTimedOutError",n.message="Request timed out",n}return l(e,t),e.prototype.canRetry=function(){return!0},e.prototype.retryAfter=function(){return 0},e}(Error),x=function(t){function e(){var n=t.call(this)||this;return n.name="AbortError",Object.setPrototypeOf(n,e.prototype),n.message="Response aborted",n}return l(e,t),e.prototype.canRetry=function(){return!0},e.prototype.retryAfter=function(){return 0},e}(Error);var T=function(){function t(t){t.forEach((function(t,e){return t.index=e})),this.columns=t}return t.prototype.column=function(t,e){void 0===e&&(e=!0);for(var n=0;n<this.columns.length;n++){var r=this.columns[n];if(r.label===t)return r}if(e)throw new v("Column ".concat(t," not found!"));return u},t.prototype.toObject=function(t){for(var e={},n=0;n<this.columns.length&&n<t.length;n++){var r=this.columns[n];e[r.label]=r.get(t)}return e},t.prototype.get=function(t,e){return this.column(e,!1).get(t)},t}();function R(t){return new T(t)}function O(t){var e,n,o=(new r).withReuse(),i=!0,s=0;return{error:function(e){t.error(e)},next:function(r){if(""===r)i=!0,e=void 0;else{var u=o.splitLine(r),c=o.lastSplitLength;if(i){if(!e){e=new Array(c);for(var l=0;l<c;l++)e[l]=a()}if(u[0].startsWith("#")){if("#datatype"===u[0])for(l=1;l<c;l++)e[l].dataType=u[l];else if("#default"===u[0])for(l=1;l<c;l++)e[l].defaultValue=u[l];else if("#group"===u[0])for(l=1;l<c;l++)e[l].group="t"===u[l][0]}else{""===u[0]?(s=1,e=e.slice(1)):s=0;for(var l=s;l<c;l++)e[l-s].label=u[l];n=R(e),i=!1}}else t.next(u.slice(s,c),n)}},complete:function(){t.complete()},useCancellable:function(e){t.useCancellable&&t.useCancellable(e)}}}var S={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},E={batchSize:1e3,maxBatchBytes:5e7,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function C(t,e){return function(n){for(var r="",o=0,i=0;i<n.length;){var s=t.indexOf(n[i]);s>=0&&(r+=n.substring(o,i),r+=e[s],o=i+1),i++}return 0==o?n:(o<n.length&&(r+=n.substring(o,n.length)),r)}}var D,A,_,B={measurement:C(", \n\r\t",["\\,","\\ ","\\n","\\r","\\t"]),quoted:(D='"\\',A=['\\"',"\\\\"],_=C(D,A),function(t){return'"'+_(t)+'"'}),tag:C(", =\n\r\t",["\\,","\\ ","\\=","\\n","\\r","\\t"])},L="000000000";var P=Date.now(),F=0;function j(){var t=Date.now();t!==P?(P=t,F=0):F++;var e=String(F);return String(t)+L.substr(0,6-e.length)+e}function I(){return String(Date.now())+L.substr(0,3)}function N(){return String(Date.now())}function M(){return String(Math.floor(Date.now()/1e3))}var k={s:M,ms:N,us:I,ns:j,seconds:M,millis:N,micros:I,nanos:j},U={s:function(t){return"".concat(Math.floor(t.getTime()/1e3))},ms:function(t){return"".concat(t.getTime())},us:function(t){return"".concat(t.getTime(),"000")},ns:function(t){return"".concat(t.getTime(),"000000")}};function z(t){return void 0===t?j():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?"".concat(t.getTime(),"000000"):String("number"==typeof t?Math.floor(t):t)}var V={error:function(t,e){console.error("ERROR: "+t,e||"")},warn:function(t,e){console.warn("WARN: "+t,e||"")}},H=V,q={error:function(t,e){H.error(t,e)},warn:function(t,e){H.warn(t,e)}};var W=Symbol("FLUX_VALUE"),J=function(){function t(t){this.fluxValue=t}return t.prototype.toString=function(){return this.fluxValue},t.prototype[W]=function(){return this.fluxValue},t}();function G(t){return"object"==typeof t&&"function"==typeof t[W]}function X(t){if(null==t)return"";t=t.toString();var e=void 0,n=0;function r(){void 0===e&&(e=t.substring(0,n))}for(;n<t.length;n++){var o=t.charAt(n);switch(o){case"\r":r(),e+="\\r";break;case"\n":r(),e+="\\n";break;case"\t":r(),e+="\\t";break;case'"':case"\\":r(),e=e+"\\"+o;break;case"$":if(n+1<t.length&&"{"===t.charAt(n+1)){r(),n++,e+="\\${";break}null!=e&&(e+=o);break;default:null!=e&&(e+=o)}}return void 0!==e?e:t}function $(t){if("number"==typeof t){if(!isFinite(t))throw new Error("not a flux float: ".concat(t));return t.toString()}for(var e=String(t),n=!1,r=0,o=e;r<o.length;r++){var i=o[r];if("."!==i){if("."!==i&&"-"!==i&&(i<"0"||i>"9"))throw new Error("not a flux float: ".concat(e))}else{if(n)throw new Error("not a flux float: ".concat(e));n=!n}}return e}function K(t){return'regexp.compile(v: "'.concat(X(t),'")')}function Y(t){return new J(String(t))}function Q(t){if(void 0===t)return"";if(null===t)return"null";if("boolean"==typeof t)return t.toString();if("string"==typeof t)return'"'.concat(X(t),'"');if("number"==typeof t)return $(t);if("object"==typeof t){if("function"==typeof t[W])return t[W]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return K(t);if(Array.isArray(t))return"[".concat(t.map(Q).join(","),"]")}return Q(t.toString())}var Z="function"==typeof Symbol&&Symbol.observable||"@@observable",tt=function(){function t(t){this.tags={},this.fields={},t&&(this.name=t)}return t.prototype.measurement=function(t){return this.name=t,this},t.prototype.tag=function(t,e){return this.tags[t]=e,this},t.prototype.booleanField=function(t,e){return this.fields[t]=e?"T":"F",this},t.prototype.intField=function(t,e){var n;if(n="number"==typeof e?e:parseInt(String(e)),isNaN(n)||n<=-0x8000000000000000||n>=0x8000000000000000)throw new Error("invalid integer value for field '".concat(t,"': '").concat(e,"'!"));return this.fields[t]="".concat(Math.floor(n),"i"),this},t.prototype.uintField=function(t,e){if("number"==typeof e){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error("uint value for field '".concat(t,"' out of range: ").concat(e));this.fields[t]="".concat(Math.floor(e),"u")}else{for(var n=String(e),r=0;r<n.length;r++){var o=n.charCodeAt(r);if(o<48||o>57)throw new Error("uint value has an unsupported character at pos ".concat(r,": ").concat(e))}if(n.length>20||20===n.length&&n.localeCompare("18446744073709551615")>0)throw new Error("uint value for field '".concat(t,"' out of range: ").concat(n));this.fields[t]="".concat(n,"u")}return this},t.prototype.floatField=function(t,e){var n;if(n="number"==typeof e?e:parseFloat(e),!isFinite(n))throw new Error("invalid float value for field '".concat(t,"': ").concat(e));return this.fields[t]=String(n),this},t.prototype.stringField=function(t,e){return null!=e&&("string"!=typeof e&&(e=String(e)),this.fields[t]=B.quoted(e)),this},t.prototype.timestamp=function(t){return this.time=t,this},t.prototype.toLineProtocol=function(t){var e=this;if(this.name){var n="";if(Object.keys(this.fields).sort().forEach((function(t){if(t){var r=e.fields[t];n.length>0&&(n+=","),n+="".concat(B.tag(t),"=").concat(r)}})),0!==n.length){var r="",o=t&&t.defaultTags?f(f({},t.defaultTags),this.tags):this.tags;Object.keys(o).sort().forEach((function(t){if(t){var e=o[t];e&&(r+=",",r+="".concat(B.tag(t),"=").concat(B.tag(e)))}}));var i=this.time;return i=t&&t.convertTime?t.convertTime(i):z(i),"".concat(B.measurement(this.name)).concat(r," ").concat(n).concat(void 0!==i?" "+i:"")}}},t.prototype.toString=function(){var t=this.toLineProtocol(void 0);return t||"invalid point: ".concat(JSON.stringify(this,void 0))},t}(),et=function(){function t(t){this.options=f(f({},S),t),this.success()}return t.prototype.nextDelay=function(t,e){var n=w(t);if(n&&n>0)return n+Math.round(Math.random()*this.options.retryJitter);if(e&&e>0){if(this.options.randomRetry){for(var r=Math.max(this.options.minRetryDelay,1),o=r*this.options.exponentialBase,i=1;i<e;i++)if(r=o,(o*=this.options.exponentialBase)>=this.options.maxRetryDelay){o=this.options.maxRetryDelay;break}return r+Math.round(Math.random()*(o-r)+Math.random()*this.options.retryJitter)}var s=Math.max(this.options.minRetryDelay,1);for(i=1;i<e;i++)if((s*=this.options.exponentialBase)>=this.options.maxRetryDelay){s=this.options.maxRetryDelay;break}return s+Math.round(Math.random()*this.options.retryJitter)}return this.currentDelay?this.currentDelay=Math.min(Math.max(this.currentDelay*this.options.exponentialBase,1)+Math.round(Math.random()*this.options.retryJitter),this.options.maxRetryDelay):this.currentDelay=this.options.minRetryDelay+Math.round(Math.random()*this.options.retryJitter),this.currentDelay},t.prototype.success=function(){this.currentDelay=void 0},t}();var nt=function(){function t(t,e){this.maxLines=t,this.retryLines=e,this.size=0,this.nextRetryTime=0,this.closed=!1,this._timeoutHandle=void 0}return t.prototype.addLines=function(t,e,n,r){if(!this.closed&&t.length){var o=Date.now()+n;if(r<o&&(n=r-Date.now(),o=r),o>this.nextRetryTime&&(this.nextRetryTime=o),this.first&&this.size+t.length>this.maxLines){var i=this.size,s=.7*i;do{var u=this.first.next;this.size-=this.first.lines.length,this.first.next=void 0,this.first=u,this.first||(this.last=void 0)}while(this.first&&this.size+t.length>s);q.error("RetryBuffer: ".concat(i-this.size," oldest lines removed to keep buffer size under the limit of ").concat(this.maxLines," lines"))}var a={lines:t,retryCount:e,expires:r};this.last?(this.last.next=a,this.last=a):(this.first=a,this.last=a,this.scheduleRetry(n)),this.size+=t.length}},t.prototype.removeLines=function(){if(this.first){var t=this.first;return this.first=this.first.next,t.next=void 0,this.size-=t.lines.length,this.first||(this.last=void 0),t}},t.prototype.scheduleRetry=function(t){var e=this;this._timeoutHandle=setTimeout((function(){var t=e.removeLines();t?e.retryLines(t.lines,t.retryCount,t.expires).then((function(){e.scheduleRetry(1)})).catch((function(t){e.scheduleRetry(e.nextRetryTime-Date.now())})):e._timeoutHandle=void 0}),Math.max(t,0))},t.prototype.flush=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return(t=this.removeLines())?[4,this.retryLines(t.lines,t.retryCount,t.expires)]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}))},t.prototype.close=function(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size},t}();var rt=function(){function t(t,e,n,r){this.maxChunkRecords=t,this.maxBatchBytes=e,this.flushFn=n,this.scheduleSend=r,this.length=0,this.bytes=-1,this.lines=new Array(t)}return t.prototype.add=function(t){var e=function(t){for(var e=t.length,n=0;n<t.length;n++){var r=t.charCodeAt(n);r<128||(r>=128&&r<=2047?e++:r>=2048&&r<=65535?r>=55296&&r<=57343?e++:e+=2:e+=3)}return e}(t);0===this.length?this.scheduleSend():this.bytes+e+1>=this.maxBatchBytes&&this.flush().catch((function(t){})),this.lines[this.length]=t,this.length++,this.bytes+=e+1,(this.length>=this.maxChunkRecords||this.bytes>=this.maxBatchBytes)&&this.flush().catch((function(t){}))},t.prototype.flush=function(){var t=this.reset();return t.length>0?this.flushFn(t):Promise.resolve()},t.prototype.reset=function(){var t=this.lines.slice(0,this.length);return this.length=0,this.bytes=-1,t},t}(),ot=function(){function t(t,e,n,r,o){var i=this;this.transport=t,this.closed=!1,this._timeoutHandle=void 0,this.httpPath="/api/v2/write?org=".concat(encodeURIComponent(e),"&bucket=").concat(encodeURIComponent(n),"&precision=").concat(r),(null==o?void 0:o.consistency)&&(this.httpPath+="&consistency=".concat(encodeURIComponent(o.consistency))),this.writeOptions=f(f({},E),o),this.currentTime=k[r],this.dateToProtocolTimestamp=U[r],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:f({"content-type":"text/plain; charset=utf-8"},null==o?void 0:o.headers),gzipThreshold:this.writeOptions.gzipThreshold};var s;this.writeBuffer=new rt(this.writeOptions.batchSize,this.writeOptions.maxBatchBytes,(function(t){return i._clearFlushTimeout(),i.sendBatch(t,i.writeOptions.maxRetries)}),(function(){i.writeOptions.flushInterval>0&&(i._clearFlushTimeout(),i.closed||(i._timeoutHandle=setTimeout((function(){return i.sendBatch(i.writeBuffer.reset(),i.writeOptions.maxRetries).catch((function(t){}))}),i.writeOptions.flushInterval)))})),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=(s=this.writeOptions,new et(s)),this.retryBuffer=new nt(this.writeOptions.maxBufferLines,this.sendBatch)}return t.prototype.sendBatch=function(t,e,n){var r=this;void 0===n&&(n=Date.now()+this.writeOptions.maxRetryTime);var o=this,i=o.writeOptions.maxRetries+1-e;if(!this.closed&&t.length>0){if(n<=Date.now()){var s=new Error("Max retry time exceeded."),u=o.writeOptions.writeFailed.call(o,s,t,i,n);return u||(q.error("Write to InfluxDB failed (attempt: ".concat(i,")."),s),Promise.reject(s))}return new Promise((function(s,u){var a,c={responseStarted:function(t,e){a=e},error:function(r){var a=o.writeOptions.writeFailed.call(o,r,t,i,n);if(a)a.then(s,u);else{if(!o.closed&&e>0&&(!(r instanceof m)||r.statusCode>=429))return q.warn("Write to InfluxDB failed (attempt: ".concat(i,")."),r),o.retryBuffer.addLines(t,e-1,o.retryStrategy.nextDelay(r,i),n),void u(r);q.error("Write to InfluxDB failed.",r),u(r)}},complete:function(){if(204==a||null==a)o.writeOptions.writeSuccess.call(o,t),o.retryStrategy.success(),s();else{var e="204 HTTP response status code expected, but ".concat(a," returned"),n=new m(a,e,void 0,"0");n.message=e,c.error(n)}}};r.transport.send(r.httpPath,t.join("\n"),r.sendOptions,c)}))}return Promise.resolve()},t.prototype._clearFlushTimeout=function(){void 0!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)},t.prototype.writeRecord=function(t){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(t)},t.prototype.writeRecords=function(t){if(this.closed)throw new Error("writeApi: already closed!");for(var e=0;e<t.length;e++)this.writeBuffer.add(t[e])},t.prototype.writePoint=function(t){if(this.closed)throw new Error("writeApi: already closed!");var e=t.toLineProtocol(this);e&&this.writeBuffer.add(e)},t.prototype.writePoints=function(t){if(this.closed)throw new Error("writeApi: already closed!");for(var e=0;e<t.length;e++){var n=t[e].toLineProtocol(this);n&&this.writeBuffer.add(n)}},t.prototype.flush=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this.writeBuffer.flush()];case 1:return e.sent(),t?[4,this.retryBuffer.flush()]:[3,3];case 2:return[2,e.sent()];case 3:return[2]}}))}))},t.prototype.close=function(){var t=this;return this.writeBuffer.flush().finally((function(){var e=t.retryBuffer.close();e&&q.error("Retry buffer closed with ".concat(e," items that were not written to InfluxDB!"),null),t.closed=!0}))},t.prototype.dispose=function(){return this._clearFlushTimeout(),this.closed=!0,this.retryBuffer.close()+this.writeBuffer.length},t.prototype.useDefaultTags=function(t){return this.defaultTags=t,this},t.prototype.convertTime=function(t){return void 0===t?this.currentTime():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?this.dateToProtocolTimestamp(t):String("number"==typeof t?Math.floor(t):t)},t}();function it(t){var e={};return t.headers.forEach((function(t,n){var r=e[n];void 0===r?e[n]=t:Array.isArray(r)?r.push(t):e[n]=[r,t]})),e}var st=function(){function t(t){this.connectionOptions=t,this.chunkCombiner=e(),this.requestDecorator=function(){},this.defaultHeaders=f({"content-type":"application/json; charset=utf-8"},t.headers),this.connectionOptions.token&&(this.defaultHeaders.Authorization="Token "+this.connectionOptions.token),this.url=String(this.connectionOptions.url),this.url.endsWith("/")&&(this.url=this.url.substring(0,this.url.length-1)),this.url.endsWith("/api/v2")&&(this.url=this.url.substring(0,this.url.length-"/api/v2".length),q.warn("Please remove '/api/v2' context path from InfluxDB base url, using ".concat(this.url," !")))}return t.prototype.send=function(t,e,n,r){var o=this,i=function(t){void 0===t&&(t={});var e=0;return{next:function(n){0===e&&t.next&&null!=n&&t.next(n)},error:function(n){0===e&&(e=1,t.error&&t.error(n))},complete:function(){0===e&&(e=2,t.complete&&t.complete())},responseStarted:function(e,n){t.responseStarted&&t.responseStarted(e,n)}}}(r),s=!1,u=n.signal;if(r&&r.useCancellable){var a=new AbortController;u||(u=a.signal,n=f(f({},n),u)),r.useCancellable({cancel:function(){s=!0,a.abort()},isCancelled:function(){return s||u.aborted}})}this.fetch(t,e,n).then((function(t){return h(o,void 0,void 0,(function(){var e,n,o,s;return p(this,(function(u){switch(u.label){case 0:return(null==r?void 0:r.responseStarted)&&i.responseStarted(it(t),t.status),t.status>=300?[2,t.text().then((function(e){if(!e){var n=t.headers.get("x-influxdb-error");n&&(e=n)}i.error(new m(t.status,t.statusText,e,t.headers.get("retry-after"),t.headers.get("content-type")))})).catch((function(e){q.warn("Unable to receive error body",e),i.error(new m(t.status,t.statusText,void 0,t.headers.get("retry-after"),t.headers.get("content-type")))}))]:[3,1];case 1:if(!t.body)return[3,6];e=t.body.getReader(),n=void 0,u.label=2;case 2:return[4,e.read()];case 3:n=u.sent(),i.next(n.value),u.label=4;case 4:if(!n.done)return[3,2];u.label=5;case 5:return[3,10];case 6:return t.arrayBuffer?[4,t.arrayBuffer()]:[3,8];case 7:return o=u.sent(),i.next(new Uint8Array(o)),[3,10];case 8:return[4,t.text()];case 9:s=u.sent(),i.next((new TextEncoder).encode(s)),u.label=10;case 10:return[2]}}))}))})).catch((function(t){s||i.error(t)})).finally((function(){return i.complete()}))},t.prototype.request=function(t,e,n,r){var o,i;return h(this,void 0,void 0,(function(){var s,u,a,c,l,f,h;return p(this,(function(p){switch(p.label){case 0:return[4,this.fetch(t,e,n)];case 1:return s=p.sent(),u=s.status,a=s.headers,c=a.get("content-type")||"",r&&r(it(s),s.status),u>=300?[4,s.text()]:[3,3];case 2:throw(l=p.sent())||(f=a.get("x-influxdb-error"))&&(l=f),new m(u,s.statusText,l,s.headers.get("retry-after"),s.headers.get("content-type"));case 3:return(h=null!==(i=null===(o=n.headers)||void 0===o?void 0:o.accept)&&void 0!==i?i:c).includes("json")?[4,s.json()]:[3,5];case 4:case 6:return[2,p.sent()];case 5:return h.includes("text")||h.startsWith("application/csv")?[4,s.text()]:[3,7];case 7:return[2]}}))}))},t.prototype.fetch=function(t,e,n){var r=n.method,o=n.headers,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(n,["method","headers"]),s="".concat(this.url).concat(t),u=f({method:r,body:"GET"===r||"HEAD"===r?void 0:"string"==typeof e?e:JSON.stringify(e),headers:f(f({},this.defaultHeaders),o),credentials:"omit"},i);return this.requestDecorator(u,n,s),fetch(s,u)},t}(),ut={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]},at=function(){function t(t,e,n){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof n?{org:n}:n}return t.prototype.with=function(e){return new t(this.transport,this.createCSVResponse,f(f({},this.options),e))},t.prototype.response=function(t){return this.createCSVResponse(this.createExecutor(t))},t.prototype.lines=function(t){return this.response(t).lines()},t.prototype.rows=function(t){return this.response(t).rows()},t.prototype.queryLines=function(t,e){return this.response(t).consumeLines(e)},t.prototype.queryRows=function(t,e){return this.response(t).consumeRows(e)},t.prototype.collectRows=function(t,e){return this.response(t).collectRows(e)},t.prototype.collectLines=function(t){return this.response(t).collectLines()},t.prototype.queryRaw=function(t){var e=this.options,n=e.org,r=e.type,o=e.gzip,i=e.headers;return this.transport.request("/api/v2/query?org=".concat(encodeURIComponent(n)),JSON.stringify(this.decorateRequest({query:t.toString(),dialect:ut,type:r})),{method:"POST",headers:f({accept:"text/csv","accept-encoding":o?"gzip":"identity","content-type":"application/json; encoding=utf-8"},i)})},t.prototype.createExecutor=function(t){var e=this,n=this.options,r=n.org,o=n.type,i=n.gzip,s=n.headers;return function(n){e.transport.send("/api/v2/query?org=".concat(encodeURIComponent(r)),JSON.stringify(e.decorateRequest({query:t.toString(),dialect:ut,type:o})),{method:"POST",headers:f({"content-type":"application/json; encoding=utf-8","accept-encoding":i?"gzip":"identity"},s)},n)}},t.prototype.decorateRequest=function(t){var e;return"function"==typeof this.options.now&&(t.now=this.options.now()),t.type=null!==(e=this.options.type)&&void 0!==e?e:"flux",t},t}(),ct=function(){function t(t,e){var n=this;this.isClosed=!1;try{e({next:function(e){t.next(e)},error:function(e){n.isClosed=!0,t.error(e)},complete:function(){n.isClosed=!0,t.complete()},useCancellable:function(t){n.cancellable=t}})}catch(e){this.isClosed=!0,t.error(e)}}return Object.defineProperty(t.prototype,"closed",{get:function(){return this.isClosed},enumerable:!1,configurable:!0}),t.prototype.unsubscribe=function(){var t;null===(t=this.cancellable)||void 0===t||t.cancel(),this.isClosed=!0},t}();function lt(){}var ft=function(){function t(t,e){this.executor=t,this.decorator=e}return t.prototype.subscribe=function(t,e,n){var r=function(t){var e=t.next,n=t.error,r=t.complete;return{next:e?e.bind(t):lt,error:n?n.bind(t):lt,complete:r?r.bind(t):lt}}("object"!=typeof t||null===t?{next:t,error:e,complete:n}:t);return new ct(this.decorator(r),this.executor)},t.prototype[Z]=function(){return this},t}();function ht(t,e){return e.toObject(t)}var pt=function(){function t(t,e){this.executor=t,this.chunkCombiner=e}return t.prototype.lines=function(){var t=this;return new ft(this.executor,(function(e){return n(e,t.chunkCombiner)}))},t.prototype.rows=function(){var t=this;return new ft(this.executor,(function(e){return n(O({next:function(t,n){e.next({values:t,tableMeta:n})},error:function(t){e.error(t)},complete:function(){e.complete()}}),t.chunkCombiner)}))},t.prototype.consumeLines=function(t){this.executor(n(t,this.chunkCombiner))},t.prototype.consumeRows=function(t){this.executor(n(O(t),this.chunkCombiner))},t.prototype.collectRows=function(t){var e=this;void 0===t&&(t=ht);var n=[];return new Promise((function(r,o){e.consumeRows({next:function(e,r){var o=t.call(this,e,r);void 0!==o&&n.push(o)},error:function(t){o(t)},complete:function(){r(n)}})}))},t.prototype.collectLines=function(){var t=this,e=[];return new Promise((function(n,r){t.consumeLines({next:function(t){e.push(t)},error:function(t){r(t)},complete:function(){n(e)}})}))},t}(),dt=function(){function t(t){var e,n=this;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new v("No url or configuration specified!");this._options=t}var r=this._options.url;if("string"!=typeof r)throw new v("No url specified!");r.endsWith("/")&&(this._options.url=r.substring(0,r.length-1)),this.transport=null!==(e=this._options.transport)&&void 0!==e?e:new st(this._options),this.processCSVResponse=function(t){return new pt(t,n.transport.chunkCombiner)}}return t.prototype.getWriteApi=function(t,e,n,r){return void 0===n&&(n="ns"),new ot(this.transport,t,e,n,null!=r?r:this._options.writeOptions)},t.prototype.getQueryApi=function(t){return new at(this.transport,this.processCSVResponse,t)},t}();return t.AbortError=x,t.DEFAULT_ConnectionOptions={timeout:1e4},t.DEFAULT_RetryDelayStrategyOptions=S,t.DEFAULT_WriteOptions=E,t.FLUX_VALUE=W,t.HttpError=m,t.IllegalArgumentError=v,t.InfluxDB=dt,t.LineSplitter=r,t.Log=q,t.Point=tt,t.RequestTimedOutError=b,t.UNKNOWN_COLUMN=u,t.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!g.includes(t.code)))},t.chunksToLines=n,t.consoleLogger=V,t.convertTimeToNanos=z,t.createFluxTableColumn=function(t){var e,n,r=new s;return r.label=String(t.label),r.dataType=t.dataType,r.group=Boolean(t.group),r.defaultValue=null!==(e=t.defaultValue)&&void 0!==e?e:"",r.index=null!==(n=t.index)&&void 0!==n?n:0,r},t.createFluxTableMetaData=R,t.createTextDecoderCombiner=e,t.currentTime=k,t.dateToProtocolTimestamp=U,t.escape=B,t.flux=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(1==t.length&&0===e.length)return Y(t[0]);for(var r=new Array(t.length+e.length),o=0,i=0;i<t.length;i++){var s=t[i];if(r[o++]=s,i<e.length){var u=e[i],a=void 0;if(s.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))a=X(u);else if(""===(a=Q(u))&&!G(u))throw new Error("Unsupported parameter literal '".concat(u,"' at index: ").concat(i,", type: ").concat(typeof u));r[o++]=a}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}return Y(r.join(""))},t.fluxBool=function(t){return new J("true"===t||"false"===t?t:(!!t).toString())},t.fluxDateTime=function(t){return new J(function(t){return'time(v: "'.concat(X(t),'")')}(t))},t.fluxDuration=function(t){return new J('duration(v: "'.concat(X(t),'")'))},t.fluxExpression=Y,t.fluxFloat=function(t){return new J($(t))},t.fluxInteger=function(t){for(var e=$(t),n=0,r=e;n<r.length;n++){if("."===r[n])throw new Error("not a flux integer: ".concat(e))}return new J(e)},t.fluxRegExp=function(t){return new J(K(t))},t.fluxString=function(t){return new J('"'.concat(X(t),'"'))},t.getRetryDelay=w,t.isStatusCodeRetriable=y,t.linesToTables=O,t.newFluxTableColumn=a,t.sanitizeFloat=$,t.serializeDateTimeAsDate=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:new Date(Date.parse(t))}},t.serializeDateTimeAsNumber=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:Date.parse(t)}},t.serializeDateTimeAsString=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:t}},t.setLogger=function(t){var e=H;return H=t,e},t.stringToLines=function(t,e){for(var n=!1,r=0,o=0;o<t.length;){var i=t.charCodeAt(o);if(10===i){if(!n){var s=o>0&&13===t.charCodeAt(o-1)?o-1:o;e.next(t.substring(r,s)),r=o+1}}else 34===i&&(n=!n);o++}r<o&&e.next(t.substring(r,o)),e.complete()},t.symbolObservable=Z,t.toFluxValue=Q,t.typeSerializers=i,t.useProcessHrtime=function(t){return!1},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
16
+ var c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},c(t,e)};function l(t,e){function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var f=function(){return f=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},f.apply(this,arguments)};function h(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function u(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function p(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var d=[404,408,425,429,500,502,503,504];function y(t){return d.includes(t)}var v=function(t){function e(n){var r=t.call(this,n)||this;return r.name="IllegalArgumentError",Object.setPrototypeOf(r,e.prototype),r}return l(e,t),e}(Error),m=function(t){function e(n,r,o,i,s,u){var a=t.call(this)||this;if(a.statusCode=n,a.statusMessage=r,a.body=o,a.contentType=s,Object.setPrototypeOf(a,e.prototype),u)a.message=u;else if(o){if(null==s?void 0:s.startsWith("application/json"))try{a.json=JSON.parse(o),a.message=a.json.message,a.code=a.json.code}catch(t){}a.message||(a.message="".concat(n," ").concat(r," : ").concat(o))}else a.message="".concat(n," ").concat(r);return a.name="HttpError",a.setRetryAfter(i),a}return l(e,t),e.prototype.setRetryAfter=function(t){"string"==typeof t&&/^[0-9]+$/.test(t)?this._retryAfter=parseInt(t):this._retryAfter=0},e.prototype.canRetry=function(){return y(this.statusCode)},e.prototype.retryAfter=function(){return this._retryAfter},e}(Error),g=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function w(t,e){if(t){var n=void 0;return"function"==typeof t.retryAfter?t.retryAfter():(n=0,e&&e>0?n+Math.round(Math.random()*e):n)}return 0}var b=function(t){function e(){var n=t.call(this)||this;return Object.setPrototypeOf(n,e.prototype),n.name="RequestTimedOutError",n.message="Request timed out",n}return l(e,t),e.prototype.canRetry=function(){return!0},e.prototype.retryAfter=function(){return 0},e}(Error),x=function(t){function e(){var n=t.call(this)||this;return n.name="AbortError",Object.setPrototypeOf(n,e.prototype),n.message="Response aborted",n}return l(e,t),e.prototype.canRetry=function(){return!0},e.prototype.retryAfter=function(){return 0},e}(Error);var T=function(){function t(t){t.forEach((function(t,e){return t.index=e})),this.columns=t}return t.prototype.column=function(t,e){void 0===e&&(e=!0);for(var n=0;n<this.columns.length;n++){var r=this.columns[n];if(r.label===t)return r}if(e)throw new v("Column ".concat(t," not found!"));return u},t.prototype.toObject=function(t){for(var e={},n=0;n<this.columns.length&&n<t.length;n++){var r=this.columns[n];e[r.label]=r.get(t)}return e},t.prototype.get=function(t,e){return this.column(e,!1).get(t)},t}();function R(t){return new T(t)}function O(t){var e,n,o=(new r).withReuse(),i=!0,s=0;return{error:function(e){t.error(e)},next:function(r){if(""===r)i=!0,e=void 0;else{var u=o.splitLine(r),c=o.lastSplitLength;if(i){if(!e){e=new Array(c);for(var l=0;l<c;l++)e[l]=a()}if(u[0].startsWith("#")){if("#datatype"===u[0])for(l=1;l<c;l++)e[l].dataType=u[l];else if("#default"===u[0])for(l=1;l<c;l++)e[l].defaultValue=u[l];else if("#group"===u[0])for(l=1;l<c;l++)e[l].group="t"===u[l][0]}else{""===u[0]?(s=1,e=e.slice(1)):s=0;for(var l=s;l<c;l++)e[l-s].label=u[l];n=R(e),i=!1}}else t.next(u.slice(s,c),n)}},complete:function(){t.complete()},useCancellable:function(e){t.useCancellable&&t.useCancellable(e)}}}var S={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},E={batchSize:1e3,maxBatchBytes:5e7,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function C(t,e){return function(n){for(var r="",o=0,i=0;i<n.length;){var s=t.indexOf(n[i]);s>=0&&(r+=n.substring(o,i),r+=e[s],o=i+1),i++}return 0==o?n:(o<n.length&&(r+=n.substring(o,n.length)),r)}}var D,A,_,B={measurement:C(", \n\r\t",["\\,","\\ ","\\n","\\r","\\t"]),quoted:(D='"\\',A=['\\"',"\\\\"],_=C(D,A),function(t){return'"'+_(t)+'"'}),tag:C(", =\n\r\t",["\\,","\\ ","\\=","\\n","\\r","\\t"])},L="000000000";var P=Date.now(),F=0;function j(){var t=Date.now();t!==P?(P=t,F=0):F++;var e=String(F);return String(t)+L.substr(0,6-e.length)+e}function I(){return String(Date.now())+L.substr(0,3)}function N(){return String(Date.now())}function M(){return String(Math.floor(Date.now()/1e3))}var k={s:M,ms:N,us:I,ns:j,seconds:M,millis:N,micros:I,nanos:j},U={s:function(t){return"".concat(Math.floor(t.getTime()/1e3))},ms:function(t){return"".concat(t.getTime())},us:function(t){return"".concat(t.getTime(),"000")},ns:function(t){return"".concat(t.getTime(),"000000")}};function z(t){return void 0===t?j():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?"".concat(t.getTime(),"000000"):String("number"==typeof t?Math.floor(t):t)}var V={error:function(t,e){console.error("ERROR: "+t,e||"")},warn:function(t,e){console.warn("WARN: "+t,e||"")}},H=V,q={error:function(t,e){H.error(t,e)},warn:function(t,e){H.warn(t,e)}};var W=Symbol("FLUX_VALUE"),J=function(){function t(t){this.fluxValue=t}return t.prototype.toString=function(){return this.fluxValue},t.prototype[W]=function(){return this.fluxValue},t}();function G(t){return"object"==typeof t&&"function"==typeof t[W]}function X(t){if(null==t)return"";t=t.toString();var e=void 0,n=0;function r(){void 0===e&&(e=t.substring(0,n))}for(;n<t.length;n++){var o=t.charAt(n);switch(o){case"\r":r(),e+="\\r";break;case"\n":r(),e+="\\n";break;case"\t":r(),e+="\\t";break;case'"':case"\\":r(),e=e+"\\"+o;break;case"$":if(n+1<t.length&&"{"===t.charAt(n+1)){r(),n++,e+="\\${";break}null!=e&&(e+=o);break;default:null!=e&&(e+=o)}}return void 0!==e?e:t}function $(t){if("number"==typeof t){if(!isFinite(t))throw new Error("not a flux float: ".concat(t));return t.toString()}for(var e=String(t),n=!1,r=0,o=e;r<o.length;r++){var i=o[r];if("."!==i){if("."!==i&&"-"!==i&&(i<"0"||i>"9"))throw new Error("not a flux float: ".concat(e))}else{if(n)throw new Error("not a flux float: ".concat(e));n=!n}}return e}function K(t){return'regexp.compile(v: "'.concat(X(t),'")')}function Y(t){return new J(String(t))}function Q(t){if(void 0===t)return"";if(null===t)return"null";if("boolean"==typeof t)return t.toString();if("string"==typeof t)return'"'.concat(X(t),'"');if("number"==typeof t)return $(t);if("object"==typeof t){if("function"==typeof t[W])return t[W]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return K(t);if(Array.isArray(t))return"[".concat(t.map(Q).join(","),"]")}return Q(t.toString())}var Z="function"==typeof Symbol&&Symbol.observable||"@@observable",tt=function(){function t(t){this.tags={},this.fields={},t&&(this.name=t)}return t.prototype.measurement=function(t){return this.name=t,this},t.prototype.tag=function(t,e){return this.tags[t]=e,this},t.prototype.booleanField=function(t,e){return this.fields[t]=e?"T":"F",this},t.prototype.intField=function(t,e){var n;if(n="number"==typeof e?e:parseInt(String(e)),isNaN(n)||n<=-0x8000000000000000||n>=0x8000000000000000)throw new Error("invalid integer value for field '".concat(t,"': '").concat(e,"'!"));return this.fields[t]="".concat(Math.floor(n),"i"),this},t.prototype.uintField=function(t,e){if("number"==typeof e){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error("uint value for field '".concat(t,"' out of range: ").concat(e));this.fields[t]="".concat(Math.floor(e),"u")}else{for(var n=String(e),r=0;r<n.length;r++){var o=n.charCodeAt(r);if(o<48||o>57)throw new Error("uint value has an unsupported character at pos ".concat(r,": ").concat(e))}if(n.length>20||20===n.length&&n.localeCompare("18446744073709551615")>0)throw new Error("uint value for field '".concat(t,"' out of range: ").concat(n));this.fields[t]="".concat(n,"u")}return this},t.prototype.floatField=function(t,e){var n;if(n="number"==typeof e?e:parseFloat(e),!isFinite(n))throw new Error("invalid float value for field '".concat(t,"': ").concat(e));return this.fields[t]=String(n),this},t.prototype.stringField=function(t,e){return null!=e&&("string"!=typeof e&&(e=String(e)),this.fields[t]=B.quoted(e)),this},t.prototype.timestamp=function(t){return this.time=t,this},t.prototype.toLineProtocol=function(t){var e=this;if(this.name){var n="";if(Object.keys(this.fields).sort().forEach((function(t){if(t){var r=e.fields[t];n.length>0&&(n+=","),n+="".concat(B.tag(t),"=").concat(r)}})),0!==n.length){var r="",o=t&&t.defaultTags?f(f({},t.defaultTags),this.tags):this.tags;Object.keys(o).sort().forEach((function(t){if(t){var e=o[t];e&&(r+=",",r+="".concat(B.tag(t),"=").concat(B.tag(e)))}}));var i=this.time;return i=t&&t.convertTime?t.convertTime(i):z(i),"".concat(B.measurement(this.name)).concat(r," ").concat(n).concat(void 0!==i?" "+i:"")}}},t.prototype.toString=function(){var t=this.toLineProtocol(void 0);return t||"invalid point: ".concat(JSON.stringify(this,void 0))},t}(),et=function(){function t(t){this.options=f(f({},S),t),this.success()}return t.prototype.nextDelay=function(t,e){var n=w(t);if(n&&n>0)return n+Math.round(Math.random()*this.options.retryJitter);if(e&&e>0){if(this.options.randomRetry){for(var r=Math.max(this.options.minRetryDelay,1),o=r*this.options.exponentialBase,i=1;i<e;i++)if(r=o,(o*=this.options.exponentialBase)>=this.options.maxRetryDelay){o=this.options.maxRetryDelay;break}return r+Math.round(Math.random()*(o-r)+Math.random()*this.options.retryJitter)}var s=Math.max(this.options.minRetryDelay,1);for(i=1;i<e;i++)if((s*=this.options.exponentialBase)>=this.options.maxRetryDelay){s=this.options.maxRetryDelay;break}return s+Math.round(Math.random()*this.options.retryJitter)}return this.currentDelay?this.currentDelay=Math.min(Math.max(this.currentDelay*this.options.exponentialBase,1)+Math.round(Math.random()*this.options.retryJitter),this.options.maxRetryDelay):this.currentDelay=this.options.minRetryDelay+Math.round(Math.random()*this.options.retryJitter),this.currentDelay},t.prototype.success=function(){this.currentDelay=void 0},t}();var nt=function(){function t(t,e){this.maxLines=t,this.retryLines=e,this.size=0,this.nextRetryTime=0,this.closed=!1,this._timeoutHandle=void 0}return t.prototype.addLines=function(t,e,n,r){if(!this.closed&&t.length){var o=Date.now()+n;if(r<o&&(n=r-Date.now(),o=r),o>this.nextRetryTime&&(this.nextRetryTime=o),this.first&&this.size+t.length>this.maxLines){var i=this.size,s=.7*i;do{var u=this.first.next;this.size-=this.first.lines.length,this.first.next=void 0,this.first=u,this.first||(this.last=void 0)}while(this.first&&this.size+t.length>s);q.error("RetryBuffer: ".concat(i-this.size," oldest lines removed to keep buffer size under the limit of ").concat(this.maxLines," lines"))}var a={lines:t,retryCount:e,expires:r};this.last?(this.last.next=a,this.last=a):(this.first=a,this.last=a,this.scheduleRetry(n)),this.size+=t.length}},t.prototype.removeLines=function(){if(this.first){var t=this.first;return this.first=this.first.next,t.next=void 0,this.size-=t.lines.length,this.first||(this.last=void 0),t}},t.prototype.scheduleRetry=function(t){var e=this;this._timeoutHandle=setTimeout((function(){var t=e.removeLines();t?e.retryLines(t.lines,t.retryCount,t.expires).then((function(){e.scheduleRetry(1)})).catch((function(t){e.scheduleRetry(e.nextRetryTime-Date.now())})):e._timeoutHandle=void 0}),Math.max(t,0))},t.prototype.flush=function(){return h(this,void 0,void 0,(function(){var t;return p(this,(function(e){switch(e.label){case 0:return(t=this.removeLines())?[4,this.retryLines(t.lines,t.retryCount,t.expires)]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}))},t.prototype.close=function(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size},t}();var rt=function(){function t(t,e,n,r){this.maxChunkRecords=t,this.maxBatchBytes=e,this.flushFn=n,this.scheduleSend=r,this.length=0,this.bytes=-1,this.lines=new Array(t)}return t.prototype.add=function(t){var e=function(t){for(var e=t.length,n=0;n<t.length;n++){var r=t.charCodeAt(n);r<128||(r>=128&&r<=2047?e++:r>=2048&&r<=65535?r>=55296&&r<=57343?e++:e+=2:e+=3)}return e}(t);0===this.length?this.scheduleSend():this.bytes+e+1>=this.maxBatchBytes&&this.flush().catch((function(t){})),this.lines[this.length]=t,this.length++,this.bytes+=e+1,(this.length>=this.maxChunkRecords||this.bytes>=this.maxBatchBytes)&&this.flush().catch((function(t){}))},t.prototype.flush=function(){var t=this.reset();return t.length>0?this.flushFn(t):Promise.resolve()},t.prototype.reset=function(){var t=this.lines.slice(0,this.length);return this.length=0,this.bytes=-1,t},t}(),ot=function(){function t(t,e,n,r,o){var i=this;this.transport=t,this.closed=!1,this._timeoutHandle=void 0,this.httpPath="/api/v2/write?org=".concat(encodeURIComponent(e),"&bucket=").concat(encodeURIComponent(n),"&precision=").concat(r),(null==o?void 0:o.consistency)&&(this.httpPath+="&consistency=".concat(encodeURIComponent(o.consistency))),this.writeOptions=f(f({},E),o),this.currentTime=k[r],this.dateToProtocolTimestamp=U[r],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:f({"content-type":"text/plain; charset=utf-8"},null==o?void 0:o.headers),gzipThreshold:this.writeOptions.gzipThreshold};var s;this.writeBuffer=new rt(this.writeOptions.batchSize,this.writeOptions.maxBatchBytes,(function(t){return i._clearFlushTimeout(),i.sendBatch(t,i.writeOptions.maxRetries)}),(function(){i.writeOptions.flushInterval>0&&(i._clearFlushTimeout(),i.closed||(i._timeoutHandle=setTimeout((function(){return i.sendBatch(i.writeBuffer.reset(),i.writeOptions.maxRetries).catch((function(t){}))}),i.writeOptions.flushInterval)))})),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=(s=this.writeOptions,new et(s)),this.retryBuffer=new nt(this.writeOptions.maxBufferLines,this.sendBatch)}return t.prototype.sendBatch=function(t,e,n){var r=this;void 0===n&&(n=Date.now()+this.writeOptions.maxRetryTime);var o=this,i=o.writeOptions.maxRetries+1-e;if(!this.closed&&t.length>0){if(n<=Date.now()){var s=new Error("Max retry time exceeded."),u=o.writeOptions.writeFailed.call(o,s,t,i,n);return u||(q.error("Write to InfluxDB failed (attempt: ".concat(i,")."),s),Promise.reject(s))}return new Promise((function(s,u){var a,c={responseStarted:function(t,e){a=e},error:function(r){var a=o.writeOptions.writeFailed.call(o,r,t,i,n);if(a)a.then(s,u);else{if(!o.closed&&e>0&&(!(r instanceof m)||r.statusCode>=429))return q.warn("Write to InfluxDB failed (attempt: ".concat(i,")."),r),o.retryBuffer.addLines(t,e-1,o.retryStrategy.nextDelay(r,i),n),void u(r);q.error("Write to InfluxDB failed.",r),u(r)}},complete:function(){if(204==a||null==a)o.writeOptions.writeSuccess.call(o,t),o.retryStrategy.success(),s();else{var e="204 HTTP response status code expected, but ".concat(a," returned"),n=new m(a,e,void 0,"0");n.message=e,c.error(n)}}};r.transport.send(r.httpPath,t.join("\n"),r.sendOptions,c)}))}return Promise.resolve()},t.prototype._clearFlushTimeout=function(){void 0!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)},t.prototype.writeRecord=function(t){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(t)},t.prototype.writeRecords=function(t){if(this.closed)throw new Error("writeApi: already closed!");for(var e=0;e<t.length;e++)this.writeBuffer.add(t[e])},t.prototype.writePoint=function(t){if(this.closed)throw new Error("writeApi: already closed!");var e=t.toLineProtocol(this);e&&this.writeBuffer.add(e)},t.prototype.writePoints=function(t){if(this.closed)throw new Error("writeApi: already closed!");for(var e=0;e<t.length;e++){var n=t[e].toLineProtocol(this);n&&this.writeBuffer.add(n)}},t.prototype.flush=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){switch(e.label){case 0:return[4,this.writeBuffer.flush()];case 1:return e.sent(),t?[4,this.retryBuffer.flush()]:[3,3];case 2:return[2,e.sent()];case 3:return[2]}}))}))},t.prototype.close=function(){var t=this;return this.writeBuffer.flush().finally((function(){var e=t.retryBuffer.close();e&&q.error("Retry buffer closed with ".concat(e," items that were not written to InfluxDB!"),null),t.closed=!0}))},t.prototype.dispose=function(){return this._clearFlushTimeout(),this.closed=!0,this.retryBuffer.close()+this.writeBuffer.length},t.prototype.useDefaultTags=function(t){return this.defaultTags=t,this},t.prototype.convertTime=function(t){return void 0===t?this.currentTime():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?this.dateToProtocolTimestamp(t):String("number"==typeof t?Math.floor(t):t)},t}();function it(t){var e={};return t.headers.forEach((function(t,n){var r=e[n];void 0===r?e[n]=t:Array.isArray(r)?r.push(t):e[n]=[r,t]})),e}var st=function(){function t(t){this.connectionOptions=t,this.chunkCombiner=e(),this.requestDecorator=function(){},this.defaultHeaders=f({"content-type":"application/json; charset=utf-8"},t.headers),this.connectionOptions.token&&(this.defaultHeaders.Authorization="Token "+this.connectionOptions.token),this.url=String(this.connectionOptions.url),this.url.endsWith("/")&&(this.url=this.url.substring(0,this.url.length-1)),this.url.endsWith("/api/v2")&&(this.url=this.url.substring(0,this.url.length-"/api/v2".length),q.warn("Please remove '/api/v2' context path from InfluxDB base url, using ".concat(this.url," !")))}return t.prototype.send=function(t,e,n,r){var o=this,i=function(t){void 0===t&&(t={});var e=0;return{next:function(n){0===e&&t.next&&null!=n&&t.next(n)},error:function(n){0===e&&(e=1,t.error&&t.error(n))},complete:function(){0===e&&(e=2,t.complete&&t.complete())},responseStarted:function(e,n){t.responseStarted&&t.responseStarted(e,n)}}}(r),s=!1,u=n.signal;if(r&&r.useCancellable){var a=new AbortController;u||(u=a.signal,n=f(f({},n),u)),r.useCancellable({cancel:function(){s=!0,a.abort()},isCancelled:function(){return s||u.aborted}})}this.fetch(t,e,n).then((function(t){return h(o,void 0,void 0,(function(){var e,n,o,s;return p(this,(function(u){switch(u.label){case 0:return(null==r?void 0:r.responseStarted)&&i.responseStarted(it(t),t.status),t.status>=300?[2,t.text().then((function(e){if(!e){var n=t.headers.get("x-influxdb-error");n&&(e=n)}i.error(new m(t.status,t.statusText,e,t.headers.get("retry-after"),t.headers.get("content-type")))})).catch((function(e){q.warn("Unable to receive error body",e),i.error(new m(t.status,t.statusText,void 0,t.headers.get("retry-after"),t.headers.get("content-type")))}))]:[3,1];case 1:if(!t.body)return[3,6];e=t.body.getReader(),n=void 0,u.label=2;case 2:return[4,e.read()];case 3:n=u.sent(),i.next(n.value),u.label=4;case 4:if(!n.done)return[3,2];u.label=5;case 5:return[3,10];case 6:return t.arrayBuffer?[4,t.arrayBuffer()]:[3,8];case 7:return o=u.sent(),i.next(new Uint8Array(o)),[3,10];case 8:return[4,t.text()];case 9:s=u.sent(),i.next((new TextEncoder).encode(s)),u.label=10;case 10:return[2]}}))}))})).catch((function(t){s||i.error(t)})).finally((function(){return i.complete()}))},t.prototype.request=function(t,e,n,r){var o,i;return h(this,void 0,void 0,(function(){var s,u,a,c,l,f,h;return p(this,(function(p){switch(p.label){case 0:return[4,this.fetch(t,e,n)];case 1:return s=p.sent(),u=s.status,a=s.headers,c=a.get("content-type")||"",r&&r(it(s),s.status),u>=300?[4,s.text()]:[3,3];case 2:throw(l=p.sent())||(f=a.get("x-influxdb-error"))&&(l=f),new m(u,s.statusText,l,s.headers.get("retry-after"),s.headers.get("content-type"));case 3:return(h=null!==(i=null===(o=n.headers)||void 0===o?void 0:o.accept)&&void 0!==i?i:c).includes("json")?[4,s.json()]:[3,5];case 4:case 6:return[2,p.sent()];case 5:return h.includes("text")||h.startsWith("application/csv")?[4,s.text()]:[3,7];case 7:return[2]}}))}))},t.prototype.fetch=function(t,e,n){var r=n.method,o=n.headers,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(n,["method","headers"]),s="".concat(this.url).concat(t),u=f(f({method:r,body:"GET"===r||"HEAD"===r?void 0:"string"==typeof e?e:JSON.stringify(e),headers:f(f({},this.defaultHeaders),o),credentials:"omit"},this.connectionOptions.transportOptions),i);return this.requestDecorator(u,n,s),fetch(s,u)},t}(),ut={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]},at=function(){function t(t,e,n){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof n?{org:n}:n}return t.prototype.with=function(e){return new t(this.transport,this.createCSVResponse,f(f({},this.options),e))},t.prototype.response=function(t){return this.createCSVResponse(this.createExecutor(t))},t.prototype.lines=function(t){return this.response(t).lines()},t.prototype.rows=function(t){return this.response(t).rows()},t.prototype.queryLines=function(t,e){return this.response(t).consumeLines(e)},t.prototype.queryRows=function(t,e){return this.response(t).consumeRows(e)},t.prototype.collectRows=function(t,e){return this.response(t).collectRows(e)},t.prototype.collectLines=function(t){return this.response(t).collectLines()},t.prototype.queryRaw=function(t){var e=this.options,n=e.org,r=e.type,o=e.gzip,i=e.headers;return this.transport.request("/api/v2/query?org=".concat(encodeURIComponent(n)),JSON.stringify(this.decorateRequest({query:t.toString(),dialect:ut,type:r})),{method:"POST",headers:f({accept:"text/csv","accept-encoding":o?"gzip":"identity","content-type":"application/json; encoding=utf-8"},i)})},t.prototype.createExecutor=function(t){var e=this,n=this.options,r=n.org,o=n.type,i=n.gzip,s=n.headers;return function(n){e.transport.send("/api/v2/query?org=".concat(encodeURIComponent(r)),JSON.stringify(e.decorateRequest({query:t.toString(),dialect:ut,type:o})),{method:"POST",headers:f({"content-type":"application/json; encoding=utf-8","accept-encoding":i?"gzip":"identity"},s)},n)}},t.prototype.decorateRequest=function(t){var e;return"function"==typeof this.options.now&&(t.now=this.options.now()),t.type=null!==(e=this.options.type)&&void 0!==e?e:"flux",t},t}(),ct=function(){function t(t,e){var n=this;this.isClosed=!1;try{e({next:function(e){t.next(e)},error:function(e){n.isClosed=!0,t.error(e)},complete:function(){n.isClosed=!0,t.complete()},useCancellable:function(t){n.cancellable=t}})}catch(e){this.isClosed=!0,t.error(e)}}return Object.defineProperty(t.prototype,"closed",{get:function(){return this.isClosed},enumerable:!1,configurable:!0}),t.prototype.unsubscribe=function(){var t;null===(t=this.cancellable)||void 0===t||t.cancel(),this.isClosed=!0},t}();function lt(){}var ft=function(){function t(t,e){this.executor=t,this.decorator=e}return t.prototype.subscribe=function(t,e,n){var r=function(t){var e=t.next,n=t.error,r=t.complete;return{next:e?e.bind(t):lt,error:n?n.bind(t):lt,complete:r?r.bind(t):lt}}("object"!=typeof t||null===t?{next:t,error:e,complete:n}:t);return new ct(this.decorator(r),this.executor)},t.prototype[Z]=function(){return this},t}();function ht(t,e){return e.toObject(t)}var pt=function(){function t(t,e){this.executor=t,this.chunkCombiner=e}return t.prototype.lines=function(){var t=this;return new ft(this.executor,(function(e){return n(e,t.chunkCombiner)}))},t.prototype.rows=function(){var t=this;return new ft(this.executor,(function(e){return n(O({next:function(t,n){e.next({values:t,tableMeta:n})},error:function(t){e.error(t)},complete:function(){e.complete()}}),t.chunkCombiner)}))},t.prototype.consumeLines=function(t){this.executor(n(t,this.chunkCombiner))},t.prototype.consumeRows=function(t){this.executor(n(O(t),this.chunkCombiner))},t.prototype.collectRows=function(t){var e=this;void 0===t&&(t=ht);var n=[];return new Promise((function(r,o){e.consumeRows({next:function(e,r){var o=t.call(this,e,r);void 0!==o&&n.push(o)},error:function(t){o(t)},complete:function(){r(n)}})}))},t.prototype.collectLines=function(){var t=this,e=[];return new Promise((function(n,r){t.consumeLines({next:function(t){e.push(t)},error:function(t){r(t)},complete:function(){n(e)}})}))},t}(),dt=function(){function t(t){var e,n=this;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new v("No url or configuration specified!");this._options=t}var r=this._options.url;if("string"!=typeof r)throw new v("No url specified!");r.endsWith("/")&&(this._options.url=r.substring(0,r.length-1)),this.transport=null!==(e=this._options.transport)&&void 0!==e?e:new st(this._options),this.processCSVResponse=function(t){return new pt(t,n.transport.chunkCombiner)}}return t.prototype.getWriteApi=function(t,e,n,r){return void 0===n&&(n="ns"),new ot(this.transport,t,e,n,null!=r?r:this._options.writeOptions)},t.prototype.getQueryApi=function(t){return new at(this.transport,this.processCSVResponse,t)},t}();return t.AbortError=x,t.DEFAULT_ConnectionOptions={timeout:1e4},t.DEFAULT_RetryDelayStrategyOptions=S,t.DEFAULT_WriteOptions=E,t.FLUX_VALUE=W,t.HttpError=m,t.IllegalArgumentError=v,t.InfluxDB=dt,t.LineSplitter=r,t.Log=q,t.Point=tt,t.RequestTimedOutError=b,t.UNKNOWN_COLUMN=u,t.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!g.includes(t.code)))},t.chunksToLines=n,t.consoleLogger=V,t.convertTimeToNanos=z,t.createFluxTableColumn=function(t){var e,n,r=new s;return r.label=String(t.label),r.dataType=t.dataType,r.group=Boolean(t.group),r.defaultValue=null!==(e=t.defaultValue)&&void 0!==e?e:"",r.index=null!==(n=t.index)&&void 0!==n?n:0,r},t.createFluxTableMetaData=R,t.createTextDecoderCombiner=e,t.currentTime=k,t.dateToProtocolTimestamp=U,t.escape=B,t.flux=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(1==t.length&&0===e.length)return Y(t[0]);for(var r=new Array(t.length+e.length),o=0,i=0;i<t.length;i++){var s=t[i];if(r[o++]=s,i<e.length){var u=e[i],a=void 0;if(s.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))a=X(u);else if(""===(a=Q(u))&&!G(u))throw new Error("Unsupported parameter literal '".concat(u,"' at index: ").concat(i,", type: ").concat(typeof u));r[o++]=a}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}return Y(r.join(""))},t.fluxBool=function(t){return new J("true"===t||"false"===t?t:(!!t).toString())},t.fluxDateTime=function(t){return new J(function(t){return'time(v: "'.concat(X(t),'")')}(t))},t.fluxDuration=function(t){return new J('duration(v: "'.concat(X(t),'")'))},t.fluxExpression=Y,t.fluxFloat=function(t){return new J($(t))},t.fluxInteger=function(t){for(var e=$(t),n=0,r=e;n<r.length;n++){if("."===r[n])throw new Error("not a flux integer: ".concat(e))}return new J(e)},t.fluxRegExp=function(t){return new J(K(t))},t.fluxString=function(t){return new J('"'.concat(X(t),'"'))},t.getRetryDelay=w,t.isStatusCodeRetriable=y,t.linesToTables=O,t.newFluxTableColumn=a,t.sanitizeFloat=$,t.serializeDateTimeAsDate=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:new Date(Date.parse(t))}},t.serializeDateTimeAsNumber=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:Date.parse(t)}},t.serializeDateTimeAsString=function(){i["dateTime:RFC3339"]=function(t){return""===t?null:t}},t.setLogger=function(t){var e=H;return H=t,e},t.stringToLines=function(t,e){for(var n=!1,r=0,o=0;o<t.length;){var i=t.charCodeAt(o);if(10===i){if(!n){var s=o>0&&13===t.charCodeAt(o-1)?o-1:o;e.next(t.substring(r,s)),r=o+1}}else 34===i&&(n=!n);o++}r<o&&e.next(t.substring(r,o)),e.complete()},t.symbolObservable=Z,t.toFluxValue=Q,t.typeSerializers=i,t.useProcessHrtime=function(t){return!1},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
17
17
  //# sourceMappingURL=influxdb.min.js.map
Binary file