@influxdata/influxdb-client-browser 1.31.0 → 1.32.0-nightly.3012
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.gz +0 -0
- package/dist/index.browser.mjs.gz +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/influxdb.js.gz +0 -0
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2,5 +2,5 @@ var We=Object.defineProperty,He=Object.defineProperties;var qe=Object.getOwnProp
|
|
|
2
2
|
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:Ye('"\\',['\\"',"\\\\"]),tag:Q(`, =
|
|
3
3
|
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var I="000000000",Y=!1;function Ge(t){return Y=t&&process&&typeof process.hrtime=="function"}Ge(!0);var Te,_,Re=Date.now(),J=0;function X(){if(Y){let t=process.hrtime(),e=Date.now();_?(t[0]=t[0]-_[0],t[1]=t[1]-_[1],t[1]<0&&(t[0]-=1,t[1]+=1e9),e=Te+t[0]*1e3+Math.floor(t[1]/1e6)):(_=t,Te=e);let r=String(t[1]%1e6);return String(e)+I.substr(0,6-r.length)+r}else{let t=Date.now();t!==Re?(Re=t,J=0):J++;let e=String(J);return String(t)+I.substr(0,6-e.length)+e}}function Ce(){if(Y){let t=process.hrtime(),e=String(Math.trunc(t[1]/1e3)%1e3);return String(Date.now())+I.substr(0,3-e.length)+e}else return String(Date.now())+I.substr(0,3)}function we(){return String(Date.now())}function Se(){return String(Math.floor(Date.now()/1e3))}var Oe={s:Se,ms:we,us:Ce,ns:X,seconds:Se,millis:we,micros:Ce,nanos:X},ve={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?X():typeof t=="string"?t.length>0?t:void 0:t instanceof Date?`${t.getTime()}000000`:String(typeof t=="number"?Math.floor(t):t)}var Ke={error(t,e){console.error("ERROR: "+t,e||"")},warn(t,e){console.warn("WARN: "+t,e||"")}},$=Ke,g={error(t,e){$.error(t,e)},warn(t,e){$.warn(t,e)}};function ar(t){let e=$;return $=t,e}var B=Symbol("FLUX_VALUE"),d=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[B](){return this.fluxValue}};function Ze(t){return typeof t=="object"&&typeof t[B]=="function"}function O(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`
|
|
4
4
|
`: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 lr(t){return new d(`"${O(t)}"`)}function Pe(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 fr(t){return new d(Pe(t))}function Ee(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 pr(t){return new d(Ee(t))}function et(t){return`time(v: "${O(t)}")`}function cr(t){return new d(et(t))}function mr(t){return new d(`duration(v: "${O(t)}")`)}function Fe(t){return t instanceof RegExp?t.toString():new RegExp(t).toString()}function dr(t){return new d(Fe(t))}function hr(t){return t==="true"||t==="false"?new d(t):new d((!!t).toString())}function De(t){return new d(String(t))}function G(t){if(t===void 0)return"";if(t===null)return"null";if(typeof t=="boolean")return t.toString();if(typeof t=="string")return`"${O(t)}"`;if(typeof t=="number")return Number.isSafeInteger(t)?Ee(t):Pe(t);if(typeof t=="object"){if(typeof t[B]=="function")return t[B]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return Fe(t);if(Array.isArray(t))return`[${t.map(G).join(",")}]`}else if(typeof t=="bigint")return`${t}.0`;return G(t.toString())}function gr(t,...e){if(t.length==1&&e.length===0)return De(t[0]);let r=new Array(t.length+e.length),n=0;for(let i=0;i<t.length;i++){let o=t[i];if(r[n++]=o,i<e.length){let s=e[i],u;if(o.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))u=O(s);else if(u=G(s),u===""&&!Ze(s))throw new Error(`Unsupported parameter literal '${s}' at index: ${i}, type: ${typeof s}`);r[n++]=u}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}return De(r.join(""))}var Le=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 o=n.charCodeAt(i);if(o<48||o>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]=C.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(s=>{if(s){let u=this.fields[s];r.length>0&&(r+=","),r+=`${C.tag(s)}=${u}`}}),r.length===0)return;let n="",i=e&&e.defaultTags?c(c({},e.defaultTags),this.tags):this.tags;Object.keys(i).sort().forEach(s=>{if(s){let u=i[s];u&&(n+=",",n+=`${C.tag(s)}=${C.tag(u)}`)}});let o=this.time;return e&&e.convertTime?o=e.convertTime(o):o=Ae(o),`${C.measurement(this.name)}${n} ${r}${o!==void 0?" "+o:""}`}toString(){let e=this.toLineProtocol(void 0);return e||`invalid point: ${JSON.stringify(this,void 0)}`}};var K=class{constructor(e){this.options=c(c({},be),e),this.success()}nextDelay(e,r){let n=de(e);if(n&&n>0)return n+Math.round(Math.random()*this.options.retryJitter);if(r&&r>0){if(this.options.randomRetry){let o=Math.max(this.options.minRetryDelay,1),s=o*this.options.exponentialBase;for(let u=1;u<r;u++)if(o=s,s=s*this.options.exponentialBase,s>=this.options.maxRetryDelay){s=this.options.maxRetryDelay;break}return o+Math.round(Math.random()*(s-o)+Math.random()*this.options.retryJitter)}let i=Math.max(this.options.minRetryDelay,1);for(let o=1;o<r;o++)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 Ue(t){return new K(t)}function tt(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 v=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 o=Date.now()+n;if(i<o&&(o=i),this.first&&this.size+e.length>this.maxLines){let p=this.size,a=p*.7;do{let[f,m]=tt(this.first);this.size-=f.lines.length,m?m.next=f.next:(this.first=f.next,this.first&&this.scheduleRetry(this.first.retryTime-Date.now())),f.next=void 0,this.onShrink(f)}while(this.first&&this.size+e.length>a);g.error(`RetryBuffer: ${p-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines.`)}let s={lines:e,retryCount:r,retryTime:o,expires:i},u=this.first,l;for(;;){if(!u||u.retryTime>o){s.next=u,l?l.next=s:(this.first=s,this.scheduleRetry(o-Date.now()));break}l=u,u=u.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).catch(()=>{}).finally(()=>{this.first&&this.scheduleRetry(this.first.retryTime-Date.now())}):this._timeoutHandle=void 0},Math.max(e,0))}flush(){return F(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 Z(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 ee=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=Z(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}},A=class{constructor(e,r,n,i,o){this.transport=e;this.closed=!1;this._timeoutHandle=void 0;this.path=`/api/v2/write?org=${encodeURIComponent(r)}&bucket=${encodeURIComponent(n)}&precision=${i}`,o!=null&&o.consistency&&(this.path+=`&consistency=${encodeURIComponent(o.consistency)}`),this.writeOptions=c(c({},xe),o),this.currentTime=Oe[i],this.dateToProtocolTimestamp=ve[i],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:c({"content-type":"text/plain; charset=utf-8"},o==null?void 0:o.headers),gzipThreshold:this.writeOptions.gzipThreshold};let s=()=>{this.writeOptions.flushInterval>0&&(this._clearFlushTimeout(),this.closed||(this._timeoutHandle=setTimeout(()=>this.sendBatch(this.writeBuffer.reset(),this.writeOptions.maxRetries).catch(u=>{}),this.writeOptions.flushInterval)))};this.writeBuffer=new ee(this.writeOptions.batchSize,this.writeOptions.maxBatchBytes,u=>(this._clearFlushTimeout(),this.sendBatch(u,this.writeOptions.maxRetries)),s),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=Ue(this.writeOptions),this.retryBuffer=new v(this.writeOptions.maxBufferLines,this.sendBatch,this.writeOptions.writeRetrySkipped)}sendBatch(e,r,n=Date.now()+this.writeOptions.maxRetryTime){let i=this,o=i.writeOptions.maxRetries+1-r;if(!this.closed&&e.length>0){if(n<=Date.now()){let s=new Error("Max retry time exceeded."),u=i.writeOptions.writeFailed.call(i,s,e,o,n);return u||(g.error(`Write to InfluxDB failed (attempt: ${o}).`,s),Promise.reject(s))}return new Promise((s,u)=>{let l,p={responseStarted(a,f){l=f},error(a){let f=i.writeOptions.writeFailed.call(i,a,e,o,n);if(f){f.then(s,u);return}if(a instanceof h&&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),l=204,p.complete();return}if(!i.closed&&r>0&&(!(a instanceof h)||a.statusCode>=429)){g.warn(`Write to InfluxDB failed (attempt: ${o}).`,a),i.retryBuffer.addLines(e,r-1,i.retryStrategy.nextDelay(a,o),n),u(a);return}g.error("Write to InfluxDB failed.",a),u(a)},complete(){if(l==204||l==null)i.writeOptions.writeSuccess.call(i,e),i.retryStrategy.success(),s();else{let a=`204 HTTP response status code expected, but ${l} returned`,f=new h(l,a,void 0,"0");f.message=a,p.error(f)}}};this.transport.send(this.path,e.join(`
|
|
5
|
-
`),this.sendOptions,p)})}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 F(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)}};import{parse as Be}from"url";import*as ze from"http";import*as Ve from"https";import{Buffer as re}from"buffer";import{Buffer as _e}from"buffer";var rt={concat(t,e){return _e.concat([t,e])},toUtf8String(t,e,r){return t.toString("utf-8",e,r)},copy(t,e,r){let n=_e.allocUnsafe(r-e);return t.copy(n,0,e,r),n}},Ie=rt;import z from"zlib";function te(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}var $e="1.
|
|
5
|
+
`),this.sendOptions,p)})}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 F(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)}};import{parse as Be}from"url";import*as ze from"http";import*as Ve from"https";import{Buffer as re}from"buffer";import{Buffer as _e}from"buffer";var rt={concat(t,e){return _e.concat([t,e])},toUtf8String(t,e,r){return t.toString("utf-8",e,r)},copy(t,e,r){let n=_e.allocUnsafe(r-e);return t.copy(n,0,e,r),n}},Ie=rt;import z from"zlib";function te(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}var $e="1.32.0.nightly";var nt={flush:z.constants.Z_SYNC_FLUSH,finishFlush:z.constants.Z_SYNC_FLUSH},it=re.allocUnsafe(0),ne=class{constructor(){this.cancelled=!1}cancel(){this.cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this.cancelled}},ie=class{constructor(e){this.chunkCombiner=Ie;var p,a,f,m,y,P,se;let l=e,{url:r,proxyUrl:n,token:i,transportOptions:o}=l,s=fe(l,["url","proxyUrl","token","transportOptions"]),u=Be(n||r);if(this.token=i,this.defaultOptions=k(c(c(c({},ye),s),o),{port:u.port,protocol:u.protocol,hostname:u.hostname}),this.contextPath=n?r:(p=u.path)!=null?p:"",this.contextPath.endsWith("/")&&(this.contextPath=this.contextPath.substring(0,this.contextPath.length-1)),Object.keys(this.defaultOptions).forEach(oe=>this.defaultOptions[oe]===void 0&&delete this.defaultOptions[oe]),this.contextPath.endsWith("/api/v2")&&(g.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${u.protocol}//${u.hostname}:${u.port} !`),this.contextPath=""),u.protocol==="http:")this.requestApi=(m=(f=(a=this.defaultOptions["follow-redirects"])==null?void 0:a.http)==null?void 0:f.request)!=null?m:ze.request;else if(u.protocol==="https:")this.requestApi=(se=(P=(y=this.defaultOptions["follow-redirects"])==null?void 0:y.https)==null?void 0:P.request)!=null?se:Ve.request;else throw new Error(`Unsupported protocol "${u.protocol} in URL: "${e.url}"`);this.headers=c({"User-Agent":`influxdb-client-js/${$e}`},e.headers),n&&(this.headers.Host=Be(r).host)}send(e,r,n,i){let o=new ne;i&&i.useCancellable&&i.useCancellable(o),this.createRequestMessage(e,r,n).then(s=>{this._request(s,o,i)},s=>(i==null?void 0:i.error)&&i.error(s))}request(e,r,n,i){r?typeof r!="string"&&(r=JSON.stringify(r)):r="";let o=it,s,u;return new Promise((l,p)=>{this.send(e,r,n,{responseStarted(a,f){i&&i(a,f),s=String(a["content-type"]),u=f},next:a=>{o=re.concat([o,a])},complete:()=>{var f,m;let a=(m=(f=n.headers)==null?void 0:f.accept)!=null?m:s;try{u===204&&l(void 0),a.includes("json")?o.length?l(JSON.parse(o.toString("utf8"))):l(void 0):a.includes("text")||a.startsWith("application/csv")?l(o.toString("utf8")):l(o)}catch(y){p(y)}},error:a=>{p(a)}})})}createRequestMessage(e,r,n){let i=re.from(r,"utf-8"),o=c({"content-type":"application/json; charset=utf-8"},this.headers);this.token&&(o.authorization="Token "+this.token);let s=Promise.resolve(i),u=k(c({},this.defaultOptions),{path:this.contextPath+e,method:n.method,headers:c(c({},o),n.headers)});return n.gzipThreshold!==void 0&&n.gzipThreshold<i.length&&(s=s.then(l=>new Promise((p,a)=>{z.gzip(l,(f,m)=>f?a(f):(u.headers["content-encoding"]="gzip",p(m)))}))),s.then(l=>(u.body=l,u.headers["content-length"]=l.length,u))}_request(e,r,n){let i=te(n);if(r.isCancelled()){i.complete();return}let o=this.requestApi(e,s=>{var a;if(r.isCancelled()){s.resume(),i.complete();return}s.on("aborted",()=>{i.error(new T)}),s.on("error",i.error),i.responseStarted(s.headers,s.statusCode);let u=(a=s.statusCode)!=null?a:600,l=s.headers["content-encoding"],p;if(l==="gzip"?(p=z.createGunzip(nt),p.on("error",i.error),s.pipe(p)):p=s,u>=300){let f="",m=String(s.headers["content-type"]).startsWith("application/json");p.on("data",y=>{f+=y.toString(),!m&&f.length>1e3&&(f=f.slice(0,1e3),s.resume())}),p.on("end",()=>{f===""&&!!s.headers["x-influxdb-error"]&&(f=s.headers["x-influxdb-error"].toString()),i.error(new h(u,s.statusMessage,f,s.headers["retry-after"],s.headers["content-type"]))})}else p.on("data",f=>{if(r.isCancelled())s.resume();else if(i.next(f)===!1){if(!i.useResume){i.error(new Error("Unable to pause, useResume is not configured!")),s.resume();return}s.pause();let m=()=>{s.resume()};r.resume=m,i.useResume(m)}}),p.on("end",i.complete)});typeof o.setTimeout=="function"&&e.timeout&&o.setTimeout(e.timeout),o.on("timeout",()=>{i.error(new x)}),o.on("error",s=>{i.error(s)}),e.body&&o.write(e.body),o.end()}},Me=ie;var ke={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]},D=class{constructor(e,r,n){this.transport=e;this.createCSVResponse=r;this.options=typeof n=="string"?{org:n}:n}with(e){return new D(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,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:o}=this.options;return this.transport.request(`/api/v2/query?org=${encodeURIComponent(r)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:ke,type:n})),{method:"POST",headers:c({accept:"text/csv","accept-encoding":i?"gzip":"identity","content-type":"application/json; encoding=utf-8"},o)})}createExecutor(e){let{org:r,type:n,gzip:i,headers:o}=this.options;return s=>{this.transport.send(`/api/v2/query?org=${encodeURIComponent(r)}`,JSON.stringify(this.decorateRequest({query:e.toString(),dialect:ke,type:n})),{method:"POST",headers:c({"content-type":"application/json; encoding=utf-8","accept-encoding":i?"gzip":"identity"},o)},s)}}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}},Ne=D;function st(t,e){return e.toObject(t)}var V=class{constructor(e,r){this.executor=e;this.chunkCombiner=r}lines(){return new R(this.executor,e=>w(e,this.chunkCombiner))}rows(){return new R(this.executor,e=>w(H({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(H(e),this.chunkCombiner))}collectRows(e=st){let r=[];return new Promise((n,i)=>{this.consumeRows({next(o,s){let u=e.call(this,o,s);u!==void 0&&r.push(u)},error(o){i(o)},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 M=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 Me(this._options),this.processCSVResponse=i=>new V(i,this.transport.chunkCombiner)}getWriteApi(e,r,n="ns",i){return new A(this.transport,e,r,n,i!=null?i:this._options.writeOptions)}getQueryApi(e){return new Ne(this.transport,this.processCSVResponse,e)}};export{T as AbortError,ye as DEFAULT_ConnectionOptions,be as DEFAULT_RetryDelayStrategyOptions,xe as DEFAULT_WriteOptions,B as FLUX_VALUE,h as HttpError,b as IllegalArgumentError,M as InfluxDB,L as LineSplitter,g as Log,Le as Point,x as RequestTimedOutError,ce as UNKNOWN_COLUMN,dt as canRetryHttpCall,w as chunksToLines,Ke as consoleLogger,Ae as convertTimeToNanos,ct as createFluxTableColumn,he as createFluxTableMetaData,pe as createTextDecoderCombiner,Oe as currentTime,ve as dateToProtocolTimestamp,C as escape,gr as flux,hr as fluxBool,cr as fluxDateTime,mr as fluxDuration,De as fluxExpression,fr as fluxFloat,pr as fluxInteger,dr as fluxRegExp,lr as fluxString,de as getRetryDelay,Qe as isStatusCodeRetriable,H as linesToTables,me as newFluxTableColumn,Pe as sanitizeFloat,Ee as sanitizeInteger,xt as serializeDateTimeAsDate,Tt as serializeDateTimeAsNumber,Rt as serializeDateTimeAsString,ar as setLogger,Et as stringToLines,ge as symbolObservable,G as toFluxValue,S as typeSerializers,Ge as useProcessHrtime};
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.gz
CHANGED
|
Binary file
|