@influxdata/influxdb-client-browser 1.30.0-nightly.2665 → 1.30.0-nightly.2680
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.
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.gz +0 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +5 -5
- package/dist/index.browser.mjs.gz +0 -0
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -4
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/influxdb.js +4 -4
- package/dist/influxdb.js.gz +0 -0
- package/dist/influxdb.js.map +1 -1
- package/package.json +3 -3
package/dist/index.browser.js
CHANGED
|
@@ -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
|
|
6
|
+
var influxdb=(()=>{var B=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols;var W=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={}))W.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)W.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))!W.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:()=>d,IllegalArgumentError:()=>g,InfluxDB:()=>$,LineSplitter:()=>S,Log:()=>p,Point:()=>le,RequestTimedOutError:()=>O,UNKNOWN_COLUMN:()=>H,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:()=>We,setLogger:()=>Qe,stringToLines:()=>ke,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 m=a>0&&o[a-1]===13?a-1:a;if(i)return;r.next(t.toUtf8String(o,u,m)),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 k=r=>r,w={boolean:r=>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:k,base64Binary:k,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:k)(t)}},H=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)}},d=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,d.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 We(){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 H}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 ke(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 He(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=He(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
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
|
|
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(`"${D(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 Ye(r){return`time(v: "${D(r)}")`}function Ke(r){return new h(Ye(r))}function Ze(r){return new h(`duration(v: "${D(r)}")`)}function Se(r){return r instanceof RegExp?r.toString():new RegExp(r).toString()}function et(r){return new h(Se(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 M(r){if(r===void 0)return"";if(r===null)return"null";if(typeof r=="boolean")return r.toString();if(typeof r=="string")return`"${D(r)}"`;if(typeof r=="number")return Number.isSafeInteger(r)?ae(r):oe(r);if(typeof r=="object"){if(typeof r[v]=="function")return r[v]();if(r instanceof Date)return r.toISOString();if(r instanceof RegExp)return Se(r);if(Array.isArray(r))return`[${r.map(M).join(",")}]`}else if(typeof r=="bigint")return`${r}.0`;return M(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=D(l);else if(o=M(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({},Y),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)}var nt=1,A=class{constructor(e,t){this.maxLines=e;this.retryLines=t;this.size=0;this.nextRetryTime=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&&(n=i-Date.now(),s=i),s>this.nextRetryTime&&(this.nextRetryTime=s),this.first&&this.size+e.length>this.maxLines){let o=this.size,a=o*.7;do{let 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+e.length>a);p.error(`RetryBuffer: ${o-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines`)}let l={lines:e,retryCount:t,expires:i};this.last?(this.last.next=l,this.last=l):(this.first=l,this.last=l,this.scheduleRetry(n)),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,this.first||(this.last=void 0),e}}scheduleRetry(e){this._timeoutHandle=setTimeout(()=>{let t=this.removeLines();t?this.retryLines(t.lines,t.retryCount,t.expires).then(()=>{this.scheduleRetry(nt)}).catch(n=>{this.scheduleRetry(this.nextRetryTime-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}},P=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({},K),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 A(this.writeOptions.maxBufferLines,this.sendBatch)}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 me(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
|
|
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[m,x]=nt(this.first);this.size-=m.lines.length,x?x.next=m.next:(this.first=m.next,this.first&&this.scheduleRetry(this.first.retryTime-Date.now())),m.next=void 0,this.onShrink(m)}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,m){a=m},error(f){let m=i.writeOptions.writeFailed.call(i,f,e,s,n);if(m){m.then(l,o);return}if(f instanceof d&&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 d)||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`,m=new d(a,f,void 0,"0");m.message=f,u.error(m)}}};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 me(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=me(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 d(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 d(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,m;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 de=o.get("x-influxdb-error");de&&(x=de)}throw new d(l,s.statusText,x,s.headers.get("retry-after"),s.headers.get("content-type"))}let u=(m=(f=n.headers)==null?void 0:f.accept)!=null?m: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);})();
|
|
11
11
|
Object.defineProperty(exports, '__esModule', { value: true });Object.assign(exports, influxdb);}));
|
|
12
12
|
//# sourceMappingURL=index.browser.js.map
|
package/dist/index.browser.js.gz
CHANGED
|
Binary file
|