@influxdata/influxdb-client-browser 1.30.0 → 1.31.0-nightly.2887

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.
@@ -3,10 +3,10 @@
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@influxdata/influxdb-client"] = {}));
5
5
  })(this, (function (exports) {
6
- var influxdb=(()=>{var B=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var pe=(r,e,t)=>e in r?B(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c=(r,e)=>{for(var t in e||(e={}))H.call(e,t)&&pe(r,t,e[t]);if(I)for(var t of I(e))he.call(e,t)&&pe(r,t,e[t]);return r};var ge=(r,e)=>{var t={};for(var n in r)H.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&I)for(var n of I(r))e.indexOf(n)<0&&he.call(r,n)&&(t[n]=r[n]);return t};var Le=(r,e)=>{for(var t in e)B(r,t,{get:e[t],enumerable:!0})},$e=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Fe(e))!H.call(r,i)&&i!==t&&B(r,i,{get:()=>e[i],enumerable:!(n=Ee(e,i))||n.enumerable});return r};var Ie=r=>$e(B({},"__esModule",{value:!0}),r);var y=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{o(t.next(a))}catch(u){i(u)}},l=a=>{try{o(t.throw(a))}catch(u){i(u)}},o=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var st={};Le(st,{AbortError:()=>v,DEFAULT_ConnectionOptions:()=>Ne,DEFAULT_RetryDelayStrategyOptions:()=>K,DEFAULT_WriteOptions:()=>Y,FLUX_VALUE:()=>D,HttpError:()=>m,IllegalArgumentError:()=>g,InfluxDB:()=>$,LineSplitter:()=>S,Log:()=>p,Point:()=>le,RequestTimedOutError:()=>O,UNKNOWN_COLUMN:()=>k,canRetryHttpCall:()=>Me,chunksToLines:()=>T,consoleLogger:()=>Se,convertTimeToNanos:()=>ie,createFluxTableColumn:()=>Be,createFluxTableMetaData:()=>q,createTextDecoderCombiner:()=>C,currentTime:()=>re,dateToProtocolTimestamp:()=>ne,escape:()=>b,flux:()=>rt,fluxBool:()=>tt,fluxDateTime:()=>Ye,fluxDuration:()=>Ze,fluxExpression:()=>se,fluxFloat:()=>Xe,fluxInteger:()=>Ge,fluxRegExp:()=>et,fluxString:()=>Je,getRetryDelay:()=>j,isStatusCodeRetriable:()=>ye,linesToTables:()=>U,newFluxTableColumn:()=>N,sanitizeFloat:()=>oe,sanitizeInteger:()=>ae,serializeDateTimeAsDate:()=>Ve,serializeDateTimeAsNumber:()=>ze,serializeDateTimeAsString:()=>He,setLogger:()=>Qe,stringToLines:()=>We,symbolObservable:()=>J,toFluxValue:()=>V,typeSerializers:()=>w,useProcessHrtime:()=>Ce});function C(){let r=new TextDecoder("utf-8");return{concat(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},copy(e,t,n){let i=new Uint8Array(n-t);return i.set(e.subarray(t,n)),i},toUtf8String(e,t,n){return r.decode(e.subarray(t,n))}}}function T(r,e){let t=e!=null?e:C(),n,i=!1,s=!1;function l(o){let a,u=0;for(n?(o=t.concat(n,o),a=n.length):a=0;a<o.length;){let f=o[a];if(f===10){if(!s){let d=a>0&&o[a-1]===13?a-1:a;if(i)return;r.next(t.toUtf8String(o,u,d)),u=a+1}}else f===34&&(s=!s);a++}u<a?n=t.copy(o,u,a):n=void 0}return{next(o){if(!i)try{l(o)}catch(a){this.error(a)}},error(o){i||(i=!0,r.error(o))},complete(){i||(n&&r.next(t.toUtf8String(n,0,n.length)),i=!0,r.complete())},useCancellable(o){if(r.useCancellable){let a=this;r.useCancellable({cancel(){o.cancel(),n=void 0,a.complete()},isCancelled(){return o.isCancelled()}})}}}}var S=class{constructor(){this._reuse=!1}get reuse(){return this._reuse}set reuse(e){e&&!this.reusedValues&&(this.reusedValues=new Array(10)),this._reuse=e}withReuse(){return this.reuse=!0,this}splitLine(e){if(e==null)return this.lastSplitLength=0,[];let t=0,n=0,i=this._reuse?this.reusedValues:[],s=0;for(let o=0;o<e.length;o++){let a=e[o];if(a===","){if(t%2===0){let u=this.getValue(e,n,o,t);this._reuse?i[s++]=u:i.push(u),n=o+1,t=0}}else a==='"'&&t++}let l=this.getValue(e,n,e.length,t);return this._reuse?(i[s]=l,this.lastSplitLength=s+1):(i.push(l),this.lastSplitLength=i.length),i}getValue(e,t,n,i){return t===e.length?"":i===0?e.substring(t,n):i===2?e.substring(t+1,n-1):e.substring(t+1,n-1).replace(/""/gi,'"')}};var W=r=>r,w={boolean:r=>r===""?null:r==="true",unsignedLong:r=>r===""?null:+r,long:r=>r===""?null:+r,double(r){switch(r){case"":return null;case"+Inf":return Number.POSITIVE_INFINITY;case"-Inf":return Number.NEGATIVE_INFINITY;default:return+r}},string:W,base64Binary:W,duration:r=>r===""?null:r,"dateTime:RFC3339":r=>r===""?null:r},_=class{get(e){var n;let t=e[this.index];return(t===""||t===void 0)&&this.defaultValue&&(t=this.defaultValue),((n=w[this.dataType])!=null?n:W)(t)}},k=Object.freeze({label:"",dataType:"",group:!1,defaultValue:"",index:Number.MAX_SAFE_INTEGER,get:()=>{}});function N(){return new _}function Be(r){var t,n;let e=new _;return e.label=String(r.label),e.dataType=r.dataType,e.group=Boolean(r.group),e.defaultValue=(t=r.defaultValue)!=null?t:"",e.index=(n=r.index)!=null?n:0,e}var _e=[404,408,425,429,500,502,503,504];function ye(r){return _e.includes(r)}var g=class extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,g.prototype)}},m=class extends Error{constructor(t,n,i,s,l,o){super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=l;if(Object.setPrototypeOf(this,m.prototype),o)this.message=o;else if(i){if(l!=null&&l.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(a){}this.message||(this.message=`${t} ${n} : ${i}`)}else this.message=`${t} ${n}`;this.name="HttpError",this.setRetryAfter(s)}setRetryAfter(t){typeof t=="string"?/^[0-9]+$/.test(t)?this._retryAfter=parseInt(t):this._retryAfter=0:this._retryAfter=0}canRetry(){return ye(this.statusCode)}retryAfter(){return this._retryAfter}},Ue=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function Me(r){if(r){if(typeof r.canRetry=="function")return!!r.canRetry();if(r.code&&Ue.includes(r.code))return!0}else return!1;return!1}function j(r,e){if(r){let t;return typeof r.retryAfter=="function"?r.retryAfter():(t=0,e&&e>0?t+Math.round(Math.random()*e):t)}else return 0}var O=class extends Error{constructor(){super(),Object.setPrototypeOf(this,O.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}canRetry(){return!0}retryAfter(){return 0}},v=class extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,v.prototype),this.message="Response aborted"}canRetry(){return!0}retryAfter(){return 0}};function Ve(){w["dateTime:RFC3339"]=r=>r===""?null:new Date(Date.parse(r))}function ze(){w["dateTime:RFC3339"]=r=>r===""?null:Date.parse(r)}function He(){w["dateTime:RFC3339"]=r=>r===""?null:r}var Q=class{constructor(e){e.forEach((t,n)=>t.index=n),this.columns=e}column(e,t=!0){for(let n=0;n<this.columns.length;n++){let i=this.columns[n];if(i.label===e)return i}if(t)throw new g(`Column ${e} not found!`);return k}toObject(e){let t={};for(let n=0;n<this.columns.length&&n<e.length;n++){let i=this.columns[n];t[i.label]=i.get(e)}return t}get(e,t){return this.column(t,!1).get(e)}};function q(r){return new Q(r)}function U(r){let e=new S().withReuse(),t,n=!0,i=0,s;return{error(l){r.error(l)},next(l){if(l==="")n=!0,t=void 0;else{let o=e.splitLine(l),a=e.lastSplitLength;if(n){if(!t){t=new Array(a);for(let u=0;u<a;u++)t[u]=N()}if(o[0].startsWith("#")){if(o[0]==="#datatype")for(let u=1;u<a;u++)t[u].dataType=o[u];else if(o[0]==="#default")for(let u=1;u<a;u++)t[u].defaultValue=o[u];else if(o[0]==="#group")for(let u=1;u<a;u++)t[u].group=o[u][0]==="t"}else{o[0]===""?(i=1,t=t.slice(1)):i=0;for(let u=i;u<a;u++)t[u-i].label=o[u];s=q(t),n=!1}}else r.next(o.slice(i,a),s)}},complete(){r.complete()},useCancellable(l){r.useCancellable&&r.useCancellable(l)}}}function We(r,e){let t=!1,n=0,i=0;for(;i<r.length;){let s=r.charCodeAt(i);if(s===10){if(!t){let l=i>0&&r.charCodeAt(i-1)===13?i-1:i;e.next(r.substring(n,l)),n=i+1}}else s===34&&(t=!t);i++}n<i&&e.next(r.substring(n,i)),e.complete()}var J=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();var G=class{constructor(e,t){this.isClosed=!1;try{t({next:n=>{e.next(n)},error:n=>{this.isClosed=!0,e.error(n)},complete:()=>{this.isClosed=!0,e.complete()},useCancellable:n=>{this.cancellable=n}})}catch(n){this.isClosed=!0,e.error(n)}}get closed(){return this.isClosed}unsubscribe(){var e;(e=this.cancellable)==null||e.cancel(),this.isClosed=!0}};function X(){}function ke(r){let{next:e,error:t,complete:n}=r;return{next:e?e.bind(r):X,error:t?t.bind(r):X,complete:n?n.bind(r):X}}var R=class{constructor(e,t){this.executor=e;this.decorator=t}subscribe(e,t,n){let i=ke(typeof e!="object"||e===null?{next:e,error:t,complete:n}:e);return new G(this.decorator(i),this.executor)}[J](){return this}};Symbol.observable;var Ne={timeout:1e4},K={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},Y={batchSize:1e3,maxBatchBytes:5e7,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},writeRetrySkipped:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function Z(r,e){return function(t){let n="",i=0,s=0;for(;s<t.length;){let l=r.indexOf(t[s]);l>=0&&(n+=t.substring(i,s),n+=e[l],i=s+1),s++}return i==0?t:(i<t.length&&(n+=t.substring(i,t.length)),n)}}function je(r,e){let t=Z(r,e);return n=>'"'+t(n)+'"'}var b={measurement:Z(`,
7
- \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:je('"\\',['\\"',"\\\\"]),tag:Z(`, =
8
- \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var Re="000000000";function Ce(r){return!1}Ce(!0);var be=Date.now(),ee=0;function te(){{let r=Date.now();r!==be?(be=r,ee=0):ee++;let e=String(ee);return String(r)+Re.substr(0,6-e.length)+e}}function xe(){return String(Date.now())+Re.substr(0,3)}function Te(){return String(Date.now())}function we(){return String(Math.floor(Date.now()/1e3))}var re={s:we,ms:Te,us:xe,ns:te,seconds:we,millis:Te,micros:xe,nanos:te},ne={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function ie(r){return r===void 0?te():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var Se={error(r,e){console.error("ERROR: "+r,e||"")},warn(r,e){console.warn("WARN: "+r,e||"")}},M=Se,p={error(r,e){M.error(r,e)},warn(r,e){M.warn(r,e)}};function Qe(r){let e=M;return M=r,e}var D=Symbol("FLUX_VALUE"),h=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[D](){return this.fluxValue}};function qe(r){return typeof r=="object"&&typeof r[D]=="function"}function A(r){if(r==null)return"";r=r.toString();let e,t=0;function n(){e===void 0&&(e=r.substring(0,t))}for(;t<r.length;t++){let i=r.charAt(t);switch(i){case"\r":n(),e+="\\r";break;case`
9
- `:n(),e+="\\n";break;case" ":n(),e+="\\t";break;case'"':case"\\":n(),e=e+"\\"+i;break;case"$":if(t+1<r.length&&r.charAt(t+1)==="{"){n(),t++,e+="\\${";break}e!=null&&(e+=i);break;default:e!=null&&(e+=i)}}return e!==void 0?e:r}function Je(r){return new h(`"${A(r)}"`)}function oe(r){let e=Number(r);if(!isFinite(e)){if(typeof r=="number")return`float(v: "${e}")`;throw new Error(`not a flux float: ${r}`)}let t=e.toString(),n=!1;for(let i of t)if(!(i>="0"&&i<="9"||i=="-")){if(i==="."){n=!0;continue}return`float(v: "${t}")`}return n?t:t+".0"}function Xe(r){return new h(oe(r))}function ae(r){let e=String(r),t=e.startsWith("-"),n=t?e.substring(1):e;if(n.length===0||n.length>19)throw new Error(`not a flux integer: ${e}`);for(let i of n)if(i<"0"||i>"9")throw new Error(`not a flux integer: ${e}`);if(n.length===19){if(t&&n>"9223372036854775808")throw new Error(`flux integer out of bounds: ${e}`);if(!t&&n>"9223372036854775807")throw new Error(`flux integer out of bounds: ${e}`)}return e}function Ge(r){return new h(ae(r))}function Ke(r){return`time(v: "${A(r)}")`}function Ye(r){return new h(Ke(r))}function Ze(r){return new h(`duration(v: "${A(r)}")`)}function Oe(r){return r instanceof RegExp?r.toString():new RegExp(r).toString()}function et(r){return new h(Oe(r))}function tt(r){return r==="true"||r==="false"?new h(r):new h((!!r).toString())}function se(r){return new h(String(r))}function V(r){if(r===void 0)return"";if(r===null)return"null";if(typeof r=="boolean")return r.toString();if(typeof r=="string")return`"${A(r)}"`;if(typeof r=="number")return Number.isSafeInteger(r)?ae(r):oe(r);if(typeof r=="object"){if(typeof r[D]=="function")return r[D]();if(r instanceof Date)return r.toISOString();if(r instanceof RegExp)return Oe(r);if(Array.isArray(r))return`[${r.map(V).join(",")}]`}else if(typeof r=="bigint")return`${r}.0`;return V(r.toString())}function rt(r,...e){if(r.length==1&&e.length===0)return se(r[0]);let t=new Array(r.length+e.length),n=0;for(let i=0;i<r.length;i++){let s=r[i];if(t[n++]=s,i<e.length){let l=e[i],o;if(s.endsWith('"')&&i+1<r.length&&r[i+1].startsWith('"'))o=A(l);else if(o=V(l),o===""&&!qe(l))throw new Error(`Unsupported parameter literal '${l}' at index: ${i}, type: ${typeof l}`);t[n++]=o}else if(i<r.length-1)throw new Error("Too few parameters supplied!")}return se(t.join(""))}var le=class{constructor(e){this.tags={};this.fields={};e&&(this.name=e)}measurement(e){return this.name=e,this}tag(e,t){return this.tags[e]=t,this}booleanField(e,t){return this.fields[e]=t?"T":"F",this}intField(e,t){let n;if(typeof t=="number"?n=t:n=parseInt(String(t)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${t}'!`);return this.fields[e]=`${Math.floor(n)}i`,this}uintField(e,t){if(typeof t=="number"){if(isNaN(t)||t<0||t>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${t}`);this.fields[e]=`${Math.floor(t)}u`}else{let n=String(t);for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${t}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this.fields[e]=`${n}u`}return this}floatField(e,t){let n;if(typeof t=="number"?n=t:n=parseFloat(t),!isFinite(n))throw new Error(`invalid float value for field '${e}': ${t}`);return this.fields[e]=String(n),this}stringField(e,t){return t!=null&&(typeof t!="string"&&(t=String(t)),this.fields[e]=b.quoted(t)),this}timestamp(e){return this.time=e,this}toLineProtocol(e){if(!this.name)return;let t="";if(Object.keys(this.fields).sort().forEach(l=>{if(l){let o=this.fields[l];t.length>0&&(t+=","),t+=`${b.tag(l)}=${o}`}}),t.length===0)return;let n="",i=e&&e.defaultTags?c(c({},e.defaultTags),this.tags):this.tags;Object.keys(i).sort().forEach(l=>{if(l){let o=i[l];o&&(n+=",",n+=`${b.tag(l)}=${b.tag(o)}`)}});let s=this.time;return e&&e.convertTime?s=e.convertTime(s):s=ie(s),`${b.measurement(this.name)}${n} ${t}${s!==void 0?" "+s:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var ue=class{constructor(e){this.options=c(c({},K),e),this.success()}nextDelay(e,t){let n=j(e);if(n&&n>0)return n+Math.round(Math.random()*this.options.retryJitter);if(t&&t>0){if(this.options.randomRetry){let s=Math.max(this.options.minRetryDelay,1),l=s*this.options.exponentialBase;for(let o=1;o<t;o++)if(s=l,l=l*this.options.exponentialBase,l>=this.options.maxRetryDelay){l=this.options.maxRetryDelay;break}return s+Math.round(Math.random()*(l-s)+Math.random()*this.options.retryJitter)}let i=Math.max(this.options.minRetryDelay,1);for(let s=1;s<t;s++)if(i=i*this.options.exponentialBase,i>=this.options.maxRetryDelay){i=this.options.maxRetryDelay;break}return i+Math.round(Math.random()*this.options.retryJitter)}else 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);return this.currentDelay}success(){this.currentDelay=void 0}};function ve(r){return new ue(r)}function nt(r){let e,t=r,n=r;for(;n.next;)n.next.expires<t.expires&&(e=n,t=n.next),n=n.next;return[t,e]}var P=class{constructor(e,t,n=()=>{}){this.maxLines=e;this.retryLines=t;this.onShrink=n;this.size=0;this.closed=!1;this._timeoutHandle=void 0}addLines(e,t,n,i){if(this.closed||!e.length)return;let s=Date.now()+n;if(i<s&&(s=i),this.first&&this.size+e.length>this.maxLines){let u=this.size,f=u*.7;do{let[d,x]=nt(this.first);this.size-=d.lines.length,x?x.next=d.next:(this.first=d.next,this.first&&this.scheduleRetry(this.first.retryTime-Date.now())),d.next=void 0,this.onShrink(d)}while(this.first&&this.size+e.length>f);p.error(`RetryBuffer: ${u-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines.`)}let l={lines:e,retryCount:t,retryTime:s,expires:i},o=this.first,a;for(;;){if(!o||o.retryTime>s){l.next=o,a?a.next=l:(this.first=l,this.scheduleRetry(s-Date.now()));break}a=o,o=o.next}this.size+=e.length}removeLines(){if(this.first){let e=this.first;return this.first=this.first.next,e.next=void 0,this.size-=e.lines.length,e}}scheduleRetry(e){this._timeoutHandle&&clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{let t=this.removeLines();t?this.retryLines(t.lines,t.retryCount,t.expires).finally(()=>{this.first&&this.scheduleRetry(this.first.retryTime-Date.now())}):this._timeoutHandle=void 0},Math.max(e,0))}flush(){return y(this,null,function*(){let e;for(;e=this.removeLines();)yield this.retryLines(e.lines,e.retryCount,e.expires)})}close(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size}};function fe(r){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n<128||(n>=128&&n<=2047?e++:n>=2048&&n<=65535?n>=55296&&n<=57343?e++:e+=2:e+=3)}return e}var ce=class{constructor(e,t,n,i){this.maxChunkRecords=e;this.maxBatchBytes=t;this.flushFn=n;this.scheduleSend=i;this.length=0;this.bytes=-1;this.lines=new Array(e)}add(e){let t=fe(e);this.length===0?this.scheduleSend():this.bytes+t+1>=this.maxBatchBytes&&this.flush().catch(n=>{}),this.lines[this.length]=e,this.length++,this.bytes+=t+1,(this.length>=this.maxChunkRecords||this.bytes>=this.maxBatchBytes)&&this.flush().catch(n=>{})}flush(){let e=this.reset();return e.length>0?this.flushFn(e):Promise.resolve()}reset(){let e=this.lines.slice(0,this.length);return this.length=0,this.bytes=-1,e}},E=class{constructor(e,t,n,i,s){this.transport=e;this.closed=!1;this._timeoutHandle=void 0;this.path=`/api/v2/write?org=${encodeURIComponent(t)}&bucket=${encodeURIComponent(n)}&precision=${i}`,s!=null&&s.consistency&&(this.path+=`&consistency=${encodeURIComponent(s.consistency)}`),this.writeOptions=c(c({},Y),s),this.currentTime=re[i],this.dateToProtocolTimestamp=ne[i],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:c({"content-type":"text/plain; charset=utf-8"},s==null?void 0:s.headers),gzipThreshold:this.writeOptions.gzipThreshold};let l=()=>{this.writeOptions.flushInterval>0&&(this._clearFlushTimeout(),this.closed||(this._timeoutHandle=setTimeout(()=>this.sendBatch(this.writeBuffer.reset(),this.writeOptions.maxRetries).catch(o=>{}),this.writeOptions.flushInterval)))};this.writeBuffer=new ce(this.writeOptions.batchSize,this.writeOptions.maxBatchBytes,o=>(this._clearFlushTimeout(),this.sendBatch(o,this.writeOptions.maxRetries)),l),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=ve(this.writeOptions),this.retryBuffer=new P(this.writeOptions.maxBufferLines,this.sendBatch,this.writeOptions.writeRetrySkipped)}sendBatch(e,t,n=Date.now()+this.writeOptions.maxRetryTime){let i=this,s=i.writeOptions.maxRetries+1-t;if(!this.closed&&e.length>0){if(n<=Date.now()){let l=new Error("Max retry time exceeded."),o=i.writeOptions.writeFailed.call(i,l,e,s,n);return o||(p.error(`Write to InfluxDB failed (attempt: ${s}).`,l),Promise.reject(l))}return new Promise((l,o)=>{let a,u={responseStarted(f,d){a=d},error(f){let d=i.writeOptions.writeFailed.call(i,f,e,s,n);if(d){d.then(l,o);return}if(f instanceof m&&f.json&&typeof f.json.error=="string"&&f.json.error.includes("hinted handoff queue not empty")){p.warn("Write to InfluxDB returns: "+f.json.error),a=204,u.complete();return}if(!i.closed&&t>0&&(!(f instanceof m)||f.statusCode>=429)){p.warn(`Write to InfluxDB failed (attempt: ${s}).`,f),i.retryBuffer.addLines(e,t-1,i.retryStrategy.nextDelay(f,s),n),o(f);return}p.error("Write to InfluxDB failed.",f),o(f)},complete(){if(a==204||a==null)i.writeOptions.writeSuccess.call(i,e),i.retryStrategy.success(),l();else{let f=`204 HTTP response status code expected, but ${a} returned`,d=new m(a,f,void 0,"0");d.message=f,u.error(d)}}};this.transport.send(this.path,e.join(`
10
- `),this.sendOptions,u)})}else return Promise.resolve()}_clearFlushTimeout(){this._timeoutHandle!==void 0&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)}writeRecord(e){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(e)}writeRecords(e){if(this.closed)throw new Error("writeApi: already closed!");for(let t=0;t<e.length;t++)this.writeBuffer.add(e[t])}writePoint(e){if(this.closed)throw new Error("writeApi: already closed!");let t=e.toLineProtocol(this);t&&this.writeBuffer.add(t)}writePoints(e){if(this.closed)throw new Error("writeApi: already closed!");for(let t=0;t<e.length;t++){let n=e[t].toLineProtocol(this);n&&this.writeBuffer.add(n)}}flush(e){return y(this,null,function*(){if(yield this.writeBuffer.flush(),e)return yield this.retryBuffer.flush()})}close(){return this.writeBuffer.flush().finally(()=>{let t=this.retryBuffer.close();t&&p.error(`Retry buffer closed with ${t} items that were not written to InfluxDB!`,null),this.closed=!0})}dispose(){return this._clearFlushTimeout(),this.closed=!0,this.retryBuffer.close()+this.writeBuffer.length}useDefaultTags(e){return this.defaultTags=e,this}convertTime(e){return e===void 0?this.currentTime():typeof e=="string"?e.length>0?e:void 0:e instanceof Date?this.dateToProtocolTimestamp(e):String(typeof e=="number"?Math.floor(e):e)}};function de(r={}){let e=0;return{next:n=>{e===0&&r.next&&n!==null&&n!==void 0&&r.next(n)},error:n=>{e===0&&(e=1,r.error&&r.error(n))},complete:()=>{e===0&&(e=2,r.complete&&r.complete())},responseStarted:(n,i)=>{r.responseStarted&&r.responseStarted(n,i)}}}function De(r){let e={};return r.headers.forEach((t,n)=>{let i=e[n];i===void 0?e[n]=t:Array.isArray(i)?i.push(t):e[n]=[i,t]}),e}var F=class{constructor(e){this.connectionOptions=e;this.chunkCombiner=C();this.requestDecorator=function(){};this.defaultHeaders=c({"content-type":"application/json; charset=utf-8"},e.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-7),p.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this.url} !`))}send(e,t,n,i){let s=de(i),l=!1,o=n.signal;if(i&&i.useCancellable){let a=new AbortController;o||(o=a.signal,n=c(c({},n),o)),i.useCancellable({cancel(){l=!0,a.abort()},isCancelled(){return l||o.aborted}})}this.fetch(e,t,n).then(a=>y(this,null,function*(){if(i!=null&&i.responseStarted&&s.responseStarted(De(a),a.status),a.status>=300)return a.text().then(u=>{if(!u){let f=a.headers.get("x-influxdb-error");f&&(u=f)}s.error(new m(a.status,a.statusText,u,a.headers.get("retry-after"),a.headers.get("content-type")))}).catch(u=>{p.warn("Unable to receive error body",u),s.error(new m(a.status,a.statusText,void 0,a.headers.get("retry-after"),a.headers.get("content-type")))});if(a.body){let u=a.body.getReader(),f;do f=yield u.read(),s.next(f.value);while(!f.done)}else if(a.arrayBuffer){let u=yield a.arrayBuffer();s.next(new Uint8Array(u))}else{let u=yield a.text();s.next(new TextEncoder().encode(u))}})).catch(a=>{l||s.error(a)}).finally(()=>s.complete())}request(e,t,n,i){return y(this,null,function*(){var f,d;let s=yield this.fetch(e,t,n),{status:l,headers:o}=s,a=o.get("content-type")||"";if(i&&i(De(s),s.status),l>=300){let x=yield s.text();if(!x){let me=o.get("x-influxdb-error");me&&(x=me)}throw new m(l,s.statusText,x,s.headers.get("retry-after"),s.headers.get("content-type"))}let u=(d=(f=n.headers)==null?void 0:f.accept)!=null?d:a;if(u.includes("json"))return yield s.json();if(u.includes("text")||u.startsWith("application/csv"))return yield s.text()})}fetch(e,t,n){let u=n,{method:i,headers:s}=u,l=ge(u,["method","headers"]),o=`${this.url}${e}`,a=c(c({method:i,body:i==="GET"||i==="HEAD"?void 0:typeof t=="string"?t:JSON.stringify(t),headers:c(c({},this.defaultHeaders),s),credentials:"omit"},this.connectionOptions.transportOptions),l);return this.requestDecorator(a,n,o),fetch(o,a)}};var Ae={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]},L=class{constructor(e,t,n){this.transport=e;this.createCSVResponse=t;this.options=typeof n=="string"?{org:n}:n}with(e){return new L(this.transport,this.createCSVResponse,c(c({},this.options),e))}response(e){return this.createCSVResponse(this.createExecutor(e))}lines(e){return this.response(e).lines()}rows(e){return this.response(e).rows()}queryLines(e,t){return this.response(e).consumeLines(t)}queryRows(e,t){return this.response(e).consumeRows(t)}collectRows(e,t){return this.response(e).collectRows(t)}collectLines(e){return this.response(e).collectLines()}queryRaw(e){let{org:t,type:n,gzip:i,headers:s}=this.options;return this.transport.request(`/api/v2/query?org=${encodeURIComponent(t)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:Ae,type:n})),{method:"POST",headers:c({accept:"text/csv","accept-encoding":i?"gzip":"identity","content-type":"application/json; encoding=utf-8"},s)})}createExecutor(e){let{org:t,type:n,gzip:i,headers:s}=this.options;return l=>{this.transport.send(`/api/v2/query?org=${encodeURIComponent(t)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:Ae,type:n})),{method:"POST",headers:c({"content-type":"application/json; encoding=utf-8","accept-encoding":i?"gzip":"identity"},s)},l)}}decorateRequest(e){var t;return typeof this.options.now=="function"&&(e.now=this.options.now()),e.type=(t=this.options.type)!=null?t:"flux",e}},Pe=L;function it(r,e){return e.toObject(r)}var z=class{constructor(e,t){this.executor=e;this.chunkCombiner=t}lines(){return new R(this.executor,e=>T(e,this.chunkCombiner))}rows(){return new R(this.executor,e=>T(U({next(t,n){e.next({values:t,tableMeta:n})},error(t){e.error(t)},complete(){e.complete()}}),this.chunkCombiner))}consumeLines(e){this.executor(T(e,this.chunkCombiner))}consumeRows(e){this.executor(T(U(e),this.chunkCombiner))}collectRows(e=it){let t=[];return new Promise((n,i)=>{this.consumeRows({next(s,l){let o=e.call(this,s,l);o!==void 0&&t.push(o)},error(s){i(s)},complete(){n(t)}})})}collectLines(){let e=[];return new Promise((t,n)=>{this.consumeLines({next(i){e.push(i)},error(i){n(i)},complete(){t(e)}})})}};var $=class{constructor(e){var n;if(typeof e=="string")this._options={url:e};else if(e!==null&&typeof e=="object")this._options=e;else throw new g("No url or configuration specified!");let t=this._options.url;if(typeof t!="string")throw new g("No url specified!");t.endsWith("/")&&(this._options.url=t.substring(0,t.length-1)),this.transport=(n=this._options.transport)!=null?n:new F(this._options),this.processCSVResponse=i=>new z(i,this.transport.chunkCombiner)}getWriteApi(e,t,n="ns",i){return new E(this.transport,e,t,n,i!=null?i:this._options.writeOptions)}getQueryApi(e){return new Pe(this.transport,this.processCSVResponse,e)}};return Ie(st);})();
6
+ var influxdb=(()=>{var M=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ge=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))k.call(e,r)&&ge(t,r,e[r]);if(_)for(var r of _(e))ye.call(e,r)&&ge(t,r,e[r]);return t};var be=(t,e)=>{var r={};for(var n in t)k.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&_)for(var n of _(t))e.indexOf(n)<0&&ye.call(t,n)&&(r[n]=t[n]);return r};var Ie=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Ue=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $e(e))!k.call(t,i)&&i!==r&&M(t,i,{get:()=>e[i],enumerable:!(n=Le(e,i))||n.enumerable});return t};var Be=t=>Ue(M({},"__esModule",{value:!0}),t);var x=(t,e,r)=>new Promise((n,i)=>{var s=f=>{try{l(r.next(f))}catch(c){i(c)}},o=f=>{try{l(r.throw(f))}catch(c){i(c)}},l=f=>f.done?n(f.value):Promise.resolve(f.value).then(s,o);l((r=r.apply(t,e)).next())});var at={};Ie(at,{AbortError:()=>D,DEFAULT_ConnectionOptions:()=>Qe,DEFAULT_RetryDelayStrategyOptions:()=>ee,DEFAULT_WriteOptions:()=>te,FLUX_VALUE:()=>A,HttpError:()=>p,IllegalArgumentError:()=>b,InfluxDB:()=>I,LineSplitter:()=>S,Log:()=>g,Point:()=>ce,RequestTimedOutError:()=>v,UNKNOWN_COLUMN:()=>Q,canRetryHttpCall:()=>ze,chunksToLines:()=>w,consoleLogger:()=>ve,convertTimeToNanos:()=>ae,createFluxTableColumn:()=>_e,createFluxTableMetaData:()=>G,createTextDecoderCombiner:()=>O,currentTime:()=>se,dateToProtocolTimestamp:()=>oe,escape:()=>T,flux:()=>it,fluxBool:()=>nt,fluxDateTime:()=>et,fluxDuration:()=>tt,fluxExpression:()=>le,fluxFloat:()=>Ke,fluxInteger:()=>Ye,fluxRegExp:()=>rt,fluxString:()=>Ge,getRetryDelay:()=>J,isStatusCodeRetriable:()=>xe,linesToTables:()=>z,newFluxTableColumn:()=>q,sanitizeFloat:()=>ue,sanitizeInteger:()=>fe,serializeDateTimeAsDate:()=>He,serializeDateTimeAsNumber:()=>We,serializeDateTimeAsString:()=>Ne,setLogger:()=>Je,stringToLines:()=>ke,symbolObservable:()=>K,toFluxValue:()=>W,typeSerializers:()=>R,useProcessHrtime:()=>Se});function O(){let t=new TextDecoder("utf-8");return{concat(e,r){let n=new Uint8Array(e.length+r.length);return n.set(e),n.set(r,e.length),n},copy(e,r,n){let i=new Uint8Array(n-r);return i.set(e.subarray(r,n)),i},toUtf8String(e,r,n){return t.decode(e.subarray(r,n))}}}function w(t,e){let r=e!=null?e:O(),n,i=!1,s=!1,o=!1,l;function f(a){let u,m=0;for(n?(u=a.length===0?0:n.length,a=r.concat(n,a)):u=0;u<a.length;){let h=a[u];if(h===10){if(!s){let U=u>0&&a[u-1]===13?u-1:u;if(i)return;if(o=t.next(r.toUtf8String(a,m,U))===!1,m=u+1,o)break}}else h===34&&(s=!s);u++}if(m<a.length?n=r.copy(a,m,a.length):n=void 0,o){if(t.useResume){t.useResume(()=>{o=!1,f(new Uint8Array(0))});return}c.error(new Error("Unable to pause, useResume is not configured!")),o=!1}l&&(l(),l=void 0)}let c={next(a){if(!i)try{return f(a),!o}catch(u){this.error(u)}return!0},error(a){i||(i=!0,t.error(a))},complete(){i||(n&&t.next(r.toUtf8String(n,0,n.length)),i=!0,t.complete())}};return t.useCancellable&&(c.useCancellable=a=>{t.useCancellable&&t.useCancellable({cancel(){a.cancel(),n=void 0,c.complete()},isCancelled(){return a.isCancelled()}})}),t.useResume&&(c.useResume=a=>{l=a}),c}var S=class{constructor(){this._reuse=!1}get reuse(){return this._reuse}set reuse(e){e&&!this.reusedValues&&(this.reusedValues=new Array(10)),this._reuse=e}withReuse(){return this.reuse=!0,this}splitLine(e){if(e==null)return this.lastSplitLength=0,[];let r=0,n=0,i=this._reuse?this.reusedValues:[],s=0;for(let l=0;l<e.length;l++){let f=e[l];if(f===","){if(r%2===0){let c=this.getValue(e,n,l,r);this._reuse?i[s++]=c:i.push(c),n=l+1,r=0}}else f==='"'&&r++}let o=this.getValue(e,n,e.length,r);return this._reuse?(i[s]=o,this.lastSplitLength=s+1):(i.push(o),this.lastSplitLength=i.length),i}getValue(e,r,n,i){return r===e.length?"":i===0?e.substring(r,n):i===2?e.substring(r+1,n-1):e.substring(r+1,n-1).replace(/""/gi,'"')}};var j=t=>t,R={boolean:t=>t===""?null:t==="true",unsignedLong:t=>t===""?null:+t,long:t=>t===""?null:+t,double(t){switch(t){case"":return null;case"+Inf":return Number.POSITIVE_INFINITY;case"-Inf":return Number.NEGATIVE_INFINITY;default:return+t}},string:j,base64Binary:j,duration:t=>t===""?null:t,"dateTime:RFC3339":t=>t===""?null:t},V=class{get(e){var n;let r=e[this.index];return(r===""||r===void 0)&&this.defaultValue&&(r=this.defaultValue),((n=R[this.dataType])!=null?n:j)(r)}},Q=Object.freeze({label:"",dataType:"",group:!1,defaultValue:"",index:Number.MAX_SAFE_INTEGER,get:()=>{}});function q(){return new V}function _e(t){var r,n;let e=new V;return e.label=String(t.label),e.dataType=t.dataType,e.group=Boolean(t.group),e.defaultValue=(r=t.defaultValue)!=null?r:"",e.index=(n=t.index)!=null?n:0,e}var Me=[404,408,425,429,500,502,503,504];function xe(t){return Me.includes(t)}var b=class extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,b.prototype)}},p=class extends Error{constructor(r,n,i,s,o,l){super();this.statusCode=r;this.statusMessage=n;this.body=i;this.contentType=o;if(Object.setPrototypeOf(this,p.prototype),l)this.message=l;else if(i){if(o!=null&&o.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(f){}this.message||(this.message=`${r} ${n} : ${i}`)}else this.message=`${r} ${n}`;this.name="HttpError",this.setRetryAfter(s)}setRetryAfter(r){typeof r=="string"?/^[0-9]+$/.test(r)?this._retryAfter=parseInt(r):this._retryAfter=0:this._retryAfter=0}canRetry(){return xe(this.statusCode)}retryAfter(){return this._retryAfter}},Ve=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function ze(t){if(t){if(typeof t.canRetry=="function")return!!t.canRetry();if(t.code&&Ve.includes(t.code))return!0}else return!1;return!1}function J(t,e){if(t){let r;return typeof t.retryAfter=="function"?t.retryAfter():(r=0,e&&e>0?r+Math.round(Math.random()*e):r)}else return 0}var v=class extends Error{constructor(){super(),Object.setPrototypeOf(this,v.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}canRetry(){return!0}retryAfter(){return 0}},D=class extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,D.prototype),this.message="Response aborted"}canRetry(){return!0}retryAfter(){return 0}};function He(){R["dateTime:RFC3339"]=t=>t===""?null:new Date(Date.parse(t))}function We(){R["dateTime:RFC3339"]=t=>t===""?null:Date.parse(t)}function Ne(){R["dateTime:RFC3339"]=t=>t===""?null:t}var X=class{constructor(e){e.forEach((r,n)=>r.index=n),this.columns=e}column(e,r=!0){for(let n=0;n<this.columns.length;n++){let i=this.columns[n];if(i.label===e)return i}if(r)throw new b(`Column ${e} not found!`);return Q}toObject(e){let r={};for(let n=0;n<this.columns.length&&n<e.length;n++){let i=this.columns[n];r[i.label]=i.get(e)}return r}get(e,r){return this.column(r,!1).get(e)}};function G(t){return new X(t)}function z(t){let e=new S().withReuse(),r,n=!0,i=0,s,o={error(l){t.error(l)},next(l){if(l==="")n=!0,r=void 0;else{let f=e.splitLine(l),c=e.lastSplitLength;if(n){if(!r){r=new Array(c);for(let a=0;a<c;a++)r[a]=q()}if(f[0].startsWith("#")){if(f[0]==="#datatype")for(let a=1;a<c;a++)r[a].dataType=f[a];else if(f[0]==="#default")for(let a=1;a<c;a++)r[a].defaultValue=f[a];else if(f[0]==="#group")for(let a=1;a<c;a++)r[a].group=f[a][0]==="t"}else{f[0]===""?(i=1,r=r.slice(1)):i=0;for(let a=i;a<c;a++)r[a-i].label=f[a];s=G(r),n=!1}}else return t.next(f.slice(i,c),s)}return!0},complete(){t.complete()}};return t.useCancellable&&(o.useCancellable=t.useCancellable.bind(t)),t.useResume&&(o.useResume=t.useResume.bind(t)),o}function ke(t,e){let r=!1,n=0,i=0;for(;i<t.length;){let s=t.charCodeAt(i);if(s===10){if(!r){let o=i>0&&t.charCodeAt(i-1)===13?i-1:i;e.next(t.substring(n,o)),n=i+1}}else s===34&&(r=!r);i++}n<i&&e.next(t.substring(n,i)),e.complete()}var K=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();var Z=class{constructor(e,r){this.isClosed=!1;try{r({next:n=>{e.next(n)},error:n=>{this.isClosed=!0,e.error(n)},complete:()=>{this.isClosed=!0,e.complete()},useCancellable:n=>{this.cancellable=n}})}catch(n){this.isClosed=!0,e.error(n)}}get closed(){return this.isClosed}unsubscribe(){var e;(e=this.cancellable)==null||e.cancel(),this.isClosed=!0}};function Y(){}function je(t){let{next:e,error:r,complete:n}=t;return{next:e?e.bind(t):Y,error:r?r.bind(t):Y,complete:n?n.bind(t):Y}}var C=class{constructor(e,r){this.executor=e;this.decorator=r}subscribe(e,r,n){let i=je(typeof e!="object"||e===null?{next:e,error:r,complete:n}:e);return new Z(this.decorator(i),this.executor)}[K](){return this}};Symbol.observable;var Qe={timeout:1e4},ee={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},te={batchSize:1e3,maxBatchBytes:5e7,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},writeRetrySkipped:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function re(t,e){return function(r){let n="",i=0,s=0;for(;s<r.length;){let o=t.indexOf(r[s]);o>=0&&(n+=r.substring(i,s),n+=e[o],i=s+1),s++}return i==0?r:(i<r.length&&(n+=r.substring(i,r.length)),n)}}function qe(t,e){let r=re(t,e);return n=>'"'+r(n)+'"'}var T={measurement:re(`,
7
+ \r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:qe('"\\',['\\"',"\\\\"]),tag:re(`, =
8
+ \r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var Oe="000000000";function Se(t){return!1}Se(!0);var Te=Date.now(),ne=0;function ie(){{let t=Date.now();t!==Te?(Te=t,ne=0):ne++;let e=String(ne);return String(t)+Oe.substr(0,6-e.length)+e}}function we(){return String(Date.now())+Oe.substr(0,3)}function Re(){return String(Date.now())}function Ce(){return String(Math.floor(Date.now()/1e3))}var se={s:Ce,ms:Re,us:we,ns:ie,seconds:Ce,millis:Re,micros:we,nanos:ie},oe={s:t=>`${Math.floor(t.getTime()/1e3)}`,ms:t=>`${t.getTime()}`,us:t=>`${t.getTime()}000`,ns:t=>`${t.getTime()}000000`};function ae(t){return t===void 0?ie():typeof t=="string"?t.length>0?t:void 0:t instanceof Date?`${t.getTime()}000000`:String(typeof t=="number"?Math.floor(t):t)}var ve={error(t,e){console.error("ERROR: "+t,e||"")},warn(t,e){console.warn("WARN: "+t,e||"")}},H=ve,g={error(t,e){H.error(t,e)},warn(t,e){H.warn(t,e)}};function Je(t){let e=H;return H=t,e}var A=Symbol("FLUX_VALUE"),y=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[A](){return this.fluxValue}};function Xe(t){return typeof t=="object"&&typeof t[A]=="function"}function P(t){if(t==null)return"";t=t.toString();let e,r=0;function n(){e===void 0&&(e=t.substring(0,r))}for(;r<t.length;r++){let i=t.charAt(r);switch(i){case"\r":n(),e+="\\r";break;case`
9
+ `:n(),e+="\\n";break;case" ":n(),e+="\\t";break;case'"':case"\\":n(),e=e+"\\"+i;break;case"$":if(r+1<t.length&&t.charAt(r+1)==="{"){n(),r++,e+="\\${";break}e!=null&&(e+=i);break;default:e!=null&&(e+=i)}}return e!==void 0?e:t}function Ge(t){return new y(`"${P(t)}"`)}function ue(t){let e=Number(t);if(!isFinite(e)){if(typeof t=="number")return`float(v: "${e}")`;throw new Error(`not a flux float: ${t}`)}let r=e.toString(),n=!1;for(let i of r)if(!(i>="0"&&i<="9"||i=="-")){if(i==="."){n=!0;continue}return`float(v: "${r}")`}return n?r:r+".0"}function Ke(t){return new y(ue(t))}function fe(t){let e=String(t),r=e.startsWith("-"),n=r?e.substring(1):e;if(n.length===0||n.length>19)throw new Error(`not a flux integer: ${e}`);for(let i of n)if(i<"0"||i>"9")throw new Error(`not a flux integer: ${e}`);if(n.length===19){if(r&&n>"9223372036854775808")throw new Error(`flux integer out of bounds: ${e}`);if(!r&&n>"9223372036854775807")throw new Error(`flux integer out of bounds: ${e}`)}return e}function Ye(t){return new y(fe(t))}function Ze(t){return`time(v: "${P(t)}")`}function et(t){return new y(Ze(t))}function tt(t){return new y(`duration(v: "${P(t)}")`)}function De(t){return t instanceof RegExp?t.toString():new RegExp(t).toString()}function rt(t){return new y(De(t))}function nt(t){return t==="true"||t==="false"?new y(t):new y((!!t).toString())}function le(t){return new y(String(t))}function W(t){if(t===void 0)return"";if(t===null)return"null";if(typeof t=="boolean")return t.toString();if(typeof t=="string")return`"${P(t)}"`;if(typeof t=="number")return Number.isSafeInteger(t)?fe(t):ue(t);if(typeof t=="object"){if(typeof t[A]=="function")return t[A]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return De(t);if(Array.isArray(t))return`[${t.map(W).join(",")}]`}else if(typeof t=="bigint")return`${t}.0`;return W(t.toString())}function it(t,...e){if(t.length==1&&e.length===0)return le(t[0]);let r=new Array(t.length+e.length),n=0;for(let i=0;i<t.length;i++){let s=t[i];if(r[n++]=s,i<e.length){let o=e[i],l;if(s.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))l=P(o);else if(l=W(o),l===""&&!Xe(o))throw new Error(`Unsupported parameter literal '${o}' at index: ${i}, type: ${typeof o}`);r[n++]=l}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}return le(r.join(""))}var ce=class{constructor(e){this.tags={};this.fields={};e&&(this.name=e)}measurement(e){return this.name=e,this}tag(e,r){return this.tags[e]=r,this}booleanField(e,r){return this.fields[e]=r?"T":"F",this}intField(e,r){let n;if(typeof r=="number"?n=r:n=parseInt(String(r)),isNaN(n)||n<=-9223372036854776e3||n>=9223372036854776e3)throw new Error(`invalid integer value for field '${e}': '${r}'!`);return this.fields[e]=`${Math.floor(n)}i`,this}uintField(e,r){if(typeof r=="number"){if(isNaN(r)||r<0||r>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${e}' out of range: ${r}`);this.fields[e]=`${Math.floor(r)}u`}else{let n=String(r);for(let i=0;i<n.length;i++){let s=n.charCodeAt(i);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${i}: ${r}`)}if(n.length>20||n.length===20&&n.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${e}' out of range: ${n}`);this.fields[e]=`${n}u`}return this}floatField(e,r){let n;if(typeof r=="number"?n=r:n=parseFloat(r),!isFinite(n))throw new Error(`invalid float value for field '${e}': ${r}`);return this.fields[e]=String(n),this}stringField(e,r){return r!=null&&(typeof r!="string"&&(r=String(r)),this.fields[e]=T.quoted(r)),this}timestamp(e){return this.time=e,this}toLineProtocol(e){if(!this.name)return;let r="";if(Object.keys(this.fields).sort().forEach(o=>{if(o){let l=this.fields[o];r.length>0&&(r+=","),r+=`${T.tag(o)}=${l}`}}),r.length===0)return;let n="",i=e&&e.defaultTags?d(d({},e.defaultTags),this.tags):this.tags;Object.keys(i).sort().forEach(o=>{if(o){let l=i[o];l&&(n+=",",n+=`${T.tag(o)}=${T.tag(l)}`)}});let s=this.time;return e&&e.convertTime?s=e.convertTime(s):s=ae(s),`${T.measurement(this.name)}${n} ${r}${s!==void 0?" "+s:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var me=class{constructor(e){this.options=d(d({},ee),e),this.success()}nextDelay(e,r){let n=J(e);if(n&&n>0)return n+Math.round(Math.random()*this.options.retryJitter);if(r&&r>0){if(this.options.randomRetry){let s=Math.max(this.options.minRetryDelay,1),o=s*this.options.exponentialBase;for(let l=1;l<r;l++)if(s=o,o=o*this.options.exponentialBase,o>=this.options.maxRetryDelay){o=this.options.maxRetryDelay;break}return s+Math.round(Math.random()*(o-s)+Math.random()*this.options.retryJitter)}let i=Math.max(this.options.minRetryDelay,1);for(let s=1;s<r;s++)if(i=i*this.options.exponentialBase,i>=this.options.maxRetryDelay){i=this.options.maxRetryDelay;break}return i+Math.round(Math.random()*this.options.retryJitter)}else 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);return this.currentDelay}success(){this.currentDelay=void 0}};function Ae(t){return new me(t)}function st(t){let e,r=t,n=t;for(;n.next;)n.next.expires<r.expires&&(e=n,r=n.next),n=n.next;return[r,e]}var E=class{constructor(e,r,n=()=>{}){this.maxLines=e;this.retryLines=r;this.onShrink=n;this.size=0;this.closed=!1;this._timeoutHandle=void 0}addLines(e,r,n,i){if(this.closed||!e.length)return;let s=Date.now()+n;if(i<s&&(s=i),this.first&&this.size+e.length>this.maxLines){let c=this.size,a=c*.7;do{let[u,m]=st(this.first);this.size-=u.lines.length,m?m.next=u.next:(this.first=u.next,this.first&&this.scheduleRetry(this.first.retryTime-Date.now())),u.next=void 0,this.onShrink(u)}while(this.first&&this.size+e.length>a);g.error(`RetryBuffer: ${c-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines.`)}let o={lines:e,retryCount:r,retryTime:s,expires:i},l=this.first,f;for(;;){if(!l||l.retryTime>s){o.next=l,f?f.next=o:(this.first=o,this.scheduleRetry(s-Date.now()));break}f=l,l=l.next}this.size+=e.length}removeLines(){if(this.first){let e=this.first;return this.first=this.first.next,e.next=void 0,this.size-=e.lines.length,e}}scheduleRetry(e){this._timeoutHandle&&clearTimeout(this._timeoutHandle),this._timeoutHandle=setTimeout(()=>{let r=this.removeLines();r?this.retryLines(r.lines,r.retryCount,r.expires).finally(()=>{this.first&&this.scheduleRetry(this.first.retryTime-Date.now())}):this._timeoutHandle=void 0},Math.max(e,0))}flush(){return x(this,null,function*(){let e;for(;e=this.removeLines();)yield this.retryLines(e.lines,e.retryCount,e.expires)})}close(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size}};function de(t){let e=t.length;for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128||(n>=128&&n<=2047?e++:n>=2048&&n<=65535?n>=55296&&n<=57343?e++:e+=2:e+=3)}return e}var pe=class{constructor(e,r,n,i){this.maxChunkRecords=e;this.maxBatchBytes=r;this.flushFn=n;this.scheduleSend=i;this.length=0;this.bytes=-1;this.lines=new Array(e)}add(e){let r=de(e);this.length===0?this.scheduleSend():this.bytes+r+1>=this.maxBatchBytes&&this.flush().catch(n=>{}),this.lines[this.length]=e,this.length++,this.bytes+=r+1,(this.length>=this.maxChunkRecords||this.bytes>=this.maxBatchBytes)&&this.flush().catch(n=>{})}flush(){let e=this.reset();return e.length>0?this.flushFn(e):Promise.resolve()}reset(){let e=this.lines.slice(0,this.length);return this.length=0,this.bytes=-1,e}},F=class{constructor(e,r,n,i,s){this.transport=e;this.closed=!1;this._timeoutHandle=void 0;this.path=`/api/v2/write?org=${encodeURIComponent(r)}&bucket=${encodeURIComponent(n)}&precision=${i}`,s!=null&&s.consistency&&(this.path+=`&consistency=${encodeURIComponent(s.consistency)}`),this.writeOptions=d(d({},te),s),this.currentTime=se[i],this.dateToProtocolTimestamp=oe[i],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:d({"content-type":"text/plain; charset=utf-8"},s==null?void 0:s.headers),gzipThreshold:this.writeOptions.gzipThreshold};let o=()=>{this.writeOptions.flushInterval>0&&(this._clearFlushTimeout(),this.closed||(this._timeoutHandle=setTimeout(()=>this.sendBatch(this.writeBuffer.reset(),this.writeOptions.maxRetries).catch(l=>{}),this.writeOptions.flushInterval)))};this.writeBuffer=new pe(this.writeOptions.batchSize,this.writeOptions.maxBatchBytes,l=>(this._clearFlushTimeout(),this.sendBatch(l,this.writeOptions.maxRetries)),o),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=Ae(this.writeOptions),this.retryBuffer=new E(this.writeOptions.maxBufferLines,this.sendBatch,this.writeOptions.writeRetrySkipped)}sendBatch(e,r,n=Date.now()+this.writeOptions.maxRetryTime){let i=this,s=i.writeOptions.maxRetries+1-r;if(!this.closed&&e.length>0){if(n<=Date.now()){let o=new Error("Max retry time exceeded."),l=i.writeOptions.writeFailed.call(i,o,e,s,n);return l||(g.error(`Write to InfluxDB failed (attempt: ${s}).`,o),Promise.reject(o))}return new Promise((o,l)=>{let f,c={responseStarted(a,u){f=u},error(a){let u=i.writeOptions.writeFailed.call(i,a,e,s,n);if(u){u.then(o,l);return}if(a instanceof p&&a.json&&typeof a.json.error=="string"&&a.json.error.includes("hinted handoff queue not empty")){g.warn("Write to InfluxDB returns: "+a.json.error),f=204,c.complete();return}if(!i.closed&&r>0&&(!(a instanceof p)||a.statusCode>=429)){g.warn(`Write to InfluxDB failed (attempt: ${s}).`,a),i.retryBuffer.addLines(e,r-1,i.retryStrategy.nextDelay(a,s),n),l(a);return}g.error("Write to InfluxDB failed.",a),l(a)},complete(){if(f==204||f==null)i.writeOptions.writeSuccess.call(i,e),i.retryStrategy.success(),o();else{let a=`204 HTTP response status code expected, but ${f} returned`,u=new p(f,a,void 0,"0");u.message=a,c.error(u)}}};this.transport.send(this.path,e.join(`
10
+ `),this.sendOptions,c)})}else return Promise.resolve()}_clearFlushTimeout(){this._timeoutHandle!==void 0&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)}writeRecord(e){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(e)}writeRecords(e){if(this.closed)throw new Error("writeApi: already closed!");for(let r=0;r<e.length;r++)this.writeBuffer.add(e[r])}writePoint(e){if(this.closed)throw new Error("writeApi: already closed!");let r=e.toLineProtocol(this);r&&this.writeBuffer.add(r)}writePoints(e){if(this.closed)throw new Error("writeApi: already closed!");for(let r=0;r<e.length;r++){let n=e[r].toLineProtocol(this);n&&this.writeBuffer.add(n)}}flush(e){return x(this,null,function*(){if(yield this.writeBuffer.flush(),e)return yield this.retryBuffer.flush()})}close(){return this.writeBuffer.flush().finally(()=>{let r=this.retryBuffer.close();r&&g.error(`Retry buffer closed with ${r} items that were not written to InfluxDB!`,null),this.closed=!0})}dispose(){return this._clearFlushTimeout(),this.closed=!0,this.retryBuffer.close()+this.writeBuffer.length}useDefaultTags(e){return this.defaultTags=e,this}convertTime(e){return e===void 0?this.currentTime():typeof e=="string"?e.length>0?e:void 0:e instanceof Date?this.dateToProtocolTimestamp(e):String(typeof e=="number"?Math.floor(e):e)}};function he(t={}){let e=0,r={next:n=>{if(e===0&&t.next&&n!==null&&n!==void 0)return t.next(n)},error:n=>{e===0&&(e=1,t.error&&t.error(n))},complete:()=>{e===0&&(e=2,t.complete&&t.complete())},responseStarted:(n,i)=>{t.responseStarted&&t.responseStarted(n,i)}};return t.useCancellable&&(r.useCancellable=t.useCancellable.bind(t)),t.useResume&&(r.useResume=t.useResume.bind(t)),r}function Pe(t){let e={};return t.headers.forEach((r,n)=>{let i=e[n];i===void 0?e[n]=r:Array.isArray(i)?i.push(r):e[n]=[i,r]}),e}var L=class{constructor(e){this.connectionOptions=e;this.chunkCombiner=O();this.requestDecorator=function(){};this.defaultHeaders=d({"content-type":"application/json; charset=utf-8"},e.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-7),g.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this.url} !`))}send(e,r,n,i){let s=he(i),o=!1,l=n.signal,f,c=()=>{},a=c;if(i&&i.useCancellable){let u=new AbortController;l||(l=u.signal,n=d(d({},n),l)),l.addEventListener("abort",()=>{a()}),i.useCancellable({cancel(){o=!0,u.abort()},isCancelled(){return o||l.aborted}})}this.fetch(e,r,n).then(u=>x(this,null,function*(){if(i!=null&&i.responseStarted&&s.responseStarted(Pe(u),u.status),u.status>=300)return u.text().then(m=>{if(!m){let h=u.headers.get("x-influxdb-error");h&&(m=h)}s.error(new p(u.status,u.statusText,m,u.headers.get("retry-after"),u.headers.get("content-type")))}).catch(m=>{g.warn("Unable to receive error body",m),s.error(new p(u.status,u.statusText,void 0,u.headers.get("retry-after"),u.headers.get("content-type")))});if(u.body){let m=u.body.getReader(),h;do{if(f&&(yield f),o)break;if(h=yield m.read(),s.next(h.value)===!1){let U=s.useResume;if(!U){let B="Unable to pause, useResume is not configured!";return yield m.cancel(B),Promise.reject(new Error(B))}f=new Promise(B=>{a=()=>{B(),f=void 0,a=c},U(a)})}}while(!h.done)}else if(u.arrayBuffer){let m=yield u.arrayBuffer();s.next(new Uint8Array(m))}else{let m=yield u.text();s.next(new TextEncoder().encode(m))}})).catch(u=>{o||s.error(u)}).finally(()=>s.complete())}request(e,r,n,i){return x(this,null,function*(){var a,u;let s=yield this.fetch(e,r,n),{status:o,headers:l}=s,f=l.get("content-type")||"";if(i&&i(Pe(s),s.status),o>=300){let m=yield s.text();if(!m){let h=l.get("x-influxdb-error");h&&(m=h)}throw new p(o,s.statusText,m,s.headers.get("retry-after"),s.headers.get("content-type"))}let c=(u=(a=n.headers)==null?void 0:a.accept)!=null?u:f;if(c.includes("json"))return yield s.json();if(c.includes("text")||c.startsWith("application/csv"))return yield s.text()})}fetch(e,r,n){let c=n,{method:i,headers:s}=c,o=be(c,["method","headers"]),l=`${this.url}${e}`,f=d(d({method:i,body:i==="GET"||i==="HEAD"?void 0:typeof r=="string"?r:JSON.stringify(r),headers:d(d({},this.defaultHeaders),s),credentials:"omit"},this.connectionOptions.transportOptions),o);return this.requestDecorator(f,n,l),fetch(l,f)}};var Ee={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]},$=class{constructor(e,r,n){this.transport=e;this.createCSVResponse=r;this.options=typeof n=="string"?{org:n}:n}with(e){return new $(this.transport,this.createCSVResponse,d(d({},this.options),e))}response(e){return this.createCSVResponse(this.createExecutor(e))}lines(e){return this.response(e).lines()}rows(e){return this.response(e).rows()}queryLines(e,r){return this.response(e).consumeLines(r)}queryRows(e,r){return this.response(e).consumeRows(r)}collectRows(e,r){return this.response(e).collectRows(r)}collectLines(e){return this.response(e).collectLines()}queryRaw(e){let{org:r,type:n,gzip:i,headers:s}=this.options;return this.transport.request(`/api/v2/query?org=${encodeURIComponent(r)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:Ee,type:n})),{method:"POST",headers:d({accept:"text/csv","accept-encoding":i?"gzip":"identity","content-type":"application/json; encoding=utf-8"},s)})}createExecutor(e){let{org:r,type:n,gzip:i,headers:s}=this.options;return o=>{this.transport.send(`/api/v2/query?org=${encodeURIComponent(r)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:Ee,type:n})),{method:"POST",headers:d({"content-type":"application/json; encoding=utf-8","accept-encoding":i?"gzip":"identity"},s)},o)}}decorateRequest(e){var r;return typeof this.options.now=="function"&&(e.now=this.options.now()),e.type=(r=this.options.type)!=null?r:"flux",e}},Fe=$;function ot(t,e){return e.toObject(t)}var N=class{constructor(e,r){this.executor=e;this.chunkCombiner=r}lines(){return new C(this.executor,e=>w(e,this.chunkCombiner))}rows(){return new C(this.executor,e=>w(z({next(r,n){e.next({values:r,tableMeta:n})},error(r){e.error(r)},complete(){e.complete()}}),this.chunkCombiner))}consumeLines(e){this.executor(w(e,this.chunkCombiner))}consumeRows(e){this.executor(w(z(e),this.chunkCombiner))}collectRows(e=ot){let r=[];return new Promise((n,i)=>{this.consumeRows({next(s,o){let l=e.call(this,s,o);l!==void 0&&r.push(l)},error(s){i(s)},complete(){n(r)}})})}collectLines(){let e=[];return new Promise((r,n)=>{this.consumeLines({next(i){e.push(i)},error(i){n(i)},complete(){r(e)}})})}};var I=class{constructor(e){var n;if(typeof e=="string")this._options={url:e};else if(e!==null&&typeof e=="object")this._options=e;else throw new b("No url or configuration specified!");let r=this._options.url;if(typeof r!="string")throw new b("No url specified!");r.endsWith("/")&&(this._options.url=r.substring(0,r.length-1)),this.transport=(n=this._options.transport)!=null?n:new L(this._options),this.processCSVResponse=i=>new N(i,this.transport.chunkCombiner)}getWriteApi(e,r,n="ns",i){return new F(this.transport,e,r,n,i!=null?i:this._options.writeOptions)}getQueryApi(e){return new Fe(this.transport,this.processCSVResponse,e)}};return Be(at);})();
11
11
  Object.defineProperty(exports, '__esModule', { value: true });Object.assign(exports, influxdb);}));
12
12
  //# sourceMappingURL=index.browser.js.map
Binary file