iot-backend/software/flow/node_modules/@influxdata/influxdb-client/dist/index.js

6 lines
32 KiB
JavaScript
Raw Normal View History

"use strict";var Ne=Object.create;var B=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Je=(r,e)=>{for(var t in e)B(r,t,{get:e[t],enumerable:!0})},Se=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qe(e))!je.call(r,i)&&i!==t&&B(r,i,{get:()=>e[i],enumerable:!(n=He(e,i))||n.enumerable});return r};var Q=(r,e,t)=>(t=r!=null?Ne(Qe(r)):{},Se(e||!r||!r.__esModule?B(t,"default",{value:r,enumerable:!0}):t,r)),Xe=r=>Se(B({},"__esModule",{value:!0}),r);var Tt={};Je(Tt,{AbortError:()=>b,DEFAULT_ConnectionOptions:()=>te,DEFAULT_RetryDelayStrategyOptions:()=>re,DEFAULT_WriteOptions:()=>ne,FLUX_VALUE:()=>E,HttpError:()=>m,IllegalArgumentError:()=>y,InfluxDB:()=>U,LineSplitter:()=>R,Log:()=>h,Point:()=>me,RequestTimedOutError:()=>x,UNKNOWN_COLUMN:()=>J,canRetryHttpCall:()=>Ze,chunksToLines:()=>T,chunksToLinesIterable:()=>$,consoleLogger:()=>Le,convertTimeToNanos:()=>fe,createFluxTableColumn:()=>Ye,createFluxTableMetaData:()=>A,createTextDecoderCombiner:()=>v,currentTime:()=>le,dateToProtocolTimestamp:()=>ue,escape:()=>w,flux:()=>gt,fluxBool:()=>ht,fluxDateTime:()=>ct,fluxDuration:()=>dt,fluxExpression:()=>pe,fluxFloat:()=>ut,fluxInteger:()=>ft,fluxRegExp:()=>mt,fluxString:()=>lt,getRetryDelay:()=>X,isStatusCodeRetriable:()=>ve,linesToRowsIterable:()=>G,linesToTables:()=>z,newFluxTableColumn:()=>O,sanitizeFloat:()=>ce,sanitizeInteger:()=>de,serializeDateTimeAsDate:()=>et,serializeDateTimeAsNumber:()=>tt,serializeDateTimeAsString:()=>rt,setLogger:()=>ot,stringToLines:()=>nt,symbolObservable:()=>K,toFluxValue:()=>N,typeSerializers:()=>C,useProcessHrtime:()=>Fe});module.exports=Xe(Tt);function v(){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:v(),n,i=!1,s=!1,a=!1,o;function u(l){let p,c=0;for(n?(p=l.length===0?0:n.length,l=t.concat(n,l)):p=0;p<l.length;){let d=l[p];if(d===10){if(!s){let _=p>0&&l[p-1]===13?p-1:p;if(i)return;if(a=r.next(t.toUtf8String(l,c,_))===!1,c=p+1,a)break}}else d===34&&(s=!s);p++}if(c<l.length?n=t.copy(l,c,l.length):n=void 0,a){if(r.useResume){r.useResume(()=>{a=!1,u(new Uint8Array(0))});return}f.error(new Error("Unable to pause, useResume is not configured!")),a=!1}o&&(o(),o=void 0)}let f={next(l){if(!i)try{return u(l),!a}catch(p){this.error(p)}return!0},error(l){i||(i=!0,r.error(l))},complete(){i||(n&&r.next(t.toUtf8String(n,0,n.length)),i=!0,r.complete())}};return r.useCancellable&&(f.useCancellable=l=>{r.useCancellable&&r.useCancellable({cancel(){l.cancel(),n=void 0,f.complete()},isCancelled(){return l.isCancelled()}})}),r.useResume&&(f.useResume=l=>{o=l}),f}async function*$(r,e){let t=e!=null?e:v(),n,i=!1;for await(let s of r){let a,o=0;for(n?(a=n.length,s=t.concat(n,s)):a=0;a<s.length;){let u=s[a];if(u===10){if(!i){let f=a>0&&s[a-1]===13?a-1:a;yield t.toUtf8String(s,o,f),o=a+1}}else u===34&&(i=!i);a++}o<s.length?n=t.copy(s,o,s.length):n=void 0}n&&(yield t.toUtf8String(n,0,n.length))}var R=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 u=e[o];if(u===","){if(t%2===0){let f=this.getValue(e,n,o,t);this._reuse?i[s++]=f:i.push(f),n=o+1,t=0}}else u==='"'&&t++}let a=this.getValue(e,n,e.length,t);return this._reuse?(i[s]=a,this.lastSplitLength=s+1):(i.push(a),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 j=r=>r,C={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":ret
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:st('"\\',['\\"',"\\\\"]),tag:ie(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var k="000000000",ae=!1;function Fe(r){return ae=r&&process&&typeof process.hrtime=="function"}Fe(!0);var Oe,V,Ae=Date.now(),se=0;function oe(){if(ae){let r=process.hrtime(),e=Date.now();V?(r[0]=r[0]-V[0],r[1]=r[1]-V[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=Oe+r[0]*1e3+Math.floor(r[1]/1e6)):(V=r,Oe=e);let t=String(r[1]%1e6);return String(e)+k.substr(0,6-t.length)+t}else{let r=Date.now();r!==Ae?(Ae=r,se=0):se++;let e=String(se);return String(r)+k.substr(0,6-e.length)+e}}function Ee(){if(ae){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+k.substr(0,3-e.length)+e}else return String(Date.now())+k.substr(0,3)}function De(){return String(Date.now())}function Pe(){return String(Math.floor(Date.now()/1e3))}var le={s:Pe,ms:De,us:Ee,ns:oe,seconds:Pe,millis:De,micros:Ee,nanos:oe},ue={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function fe(r){return r===void 0?oe():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var Le={error(r,e){console.error("ERROR: "+r,e||"")},warn(r,e){console.warn("WARN: "+r,e||"")}},W=Le,h={error(r,e){W.error(r,e)},warn(r,e){W.warn(r,e)}};function ot(r){let e=W;return W=r,e}var E=Symbol("FLUX_VALUE"),g=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[E](){return this.fluxValue}};function at(r){return typeof r=="object"&&typeof r[E]=="function"}function D(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`
`: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 lt(r){return new g(`"${D(r)}"`)}function ce(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 ut(r){return new g(ce(r))}function de(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 ft(r){return new g(de(r))}function pt(r){return`time(v: "${D(r)}")`}function ct(r){return new g(pt(r))}function dt(r){return new g(`duration(v: "${D(r)}")`)}function Ie(r){return r instanceof RegExp?r.toString():new RegExp(r).toString()}function mt(r){return new g(Ie(r))}function ht(r){return r==="true"||r==="false"?new g(r):new g((!!r).toString())}function pe(r){return new g(String(r))}function N(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)?de(r):ce(r);if(typeof r=="object"){if(typeof r[E]=="function")return r[E]();if(r instanceof Date)return r.toISOString();if(r instanceof RegExp)return Ie(r);if(Array.isArray(r))return`[${r.map(N).join(",")}]`}else if(typeof r=="bigint")return`${r}.0`;return N(r.toString())}function gt(r,...e){if(r.length==1&&e.length===0)return pe(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 a=e[i],o;if(s.endsWith('"')&&i+1<r.length&&r[i+1].startsWith('"'))o=D(a);else if(o=N(a),o===""&&!at(a))throw new Error(`Unsupported parameter literal '${a}' at index: ${i}, type: ${typeof a}`);t[n++]=o}else if(i<r.length-1)throw new Error("Too few parameters supplied!")}return pe(t.join(""))}var me=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]=w.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(a=>{if(a){let o=this.fields[a];t.length>0&&(t+=","),t+=`${w.tag(a)}=${o}`}}),t.length===0)return;let n="",i=e&&e.defaultTags?{...e.defaultTags,...this.tags}:this.tags;Object.keys(i).sort().forEach(a=>{if(a){let o=i[a];o&&(n+=",",n+=`${w.tag(a)}=${w.tag(o)}`)}});let s=this.time;return e&&e.convertTime?s=e.convertTime(s):s=fe(s),`${w.measurement(this.name)}${n} ${t}${s!==void 0?" "+s:""}`}toString(){let e=t
`),this.sendOptions,f)})}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)}}async flush(e){if(await this.writeBuffer.flush(),e)return await this.retryBuffer.flush()}close(){return this.writeBuffer.flush().finally(()=>{let t=this.retryBuffer.close();t&&h.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)}};var Re=require("url"),$e=Q(require("http")),Me=Q(require("https")),H=require("buffer");var be=require("buffer"),bt={concat(r,e){return be.Buffer.concat([r,e])},toUtf8String(r,e,t){return r.toString("utf-8",e,t)},copy(r,e,t){let n=be.Buffer.allocUnsafe(t-e);return r.copy(n,0,e,t),n}},_e=bt;var L=Q(require("zlib"));function xe(r={}){let e=0,t={next:n=>{if(e===0&&r.next&&n!==null&&n!==void 0)return 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)}};return r.useCancellable&&(t.useCancellable=r.useCancellable.bind(r)),r.useResume&&(t.useResume=r.useResume.bind(r)),t}var Be="1.33.1";var ze=require("stream"),xt={flush:L.default.constants.Z_SYNC_FLUSH,finishFlush:L.default.constants.Z_SYNC_FLUSH},Rt=H.Buffer.allocUnsafe(0),we=class{constructor(){this.cancelled=!1}cancel(){this.cancelled=!0,this.resume&&(this.resume(),this.resume=void 0)}isCancelled(){return this.cancelled}},Te=class{constructor(e){this.chunkCombiner=_e;var u,f,l,p,c,d,_;let{url:t,proxyUrl:n,token:i,transportOptions:s,...a}=e,o=(0,Re.parse)(n||t);if(this.token=i,this.defaultOptions={...te,...a,...s,port:o.port,protocol:o.protocol,hostname:o.hostname},this.contextPath=n?t:(u=o.path)!=null?u:"",this.contextPath.endsWith("/")&&(this.contextPath=this.contextPath.substring(0,this.contextPath.length-1)),Object.keys(this.defaultOptions).forEach(Ce=>this.defaultOptions[Ce]===void 0&&delete this.defaultOptions[Ce]),this.contextPath.endsWith("/api/v2")&&(h.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${o.protocol}//${o.hostname}:${o.port} !`),this.contextPath=""),o.protocol==="http:")this.requestApi=(p=(l=(f=this.defaultOptions["follow-redirects"])==null?void 0:f.http)==null?void 0:l.request)!=null?p:$e.request;else if(o.protocol==="https:")this.requestApi=(_=(d=(c=this.defaultOptions["follow-redirects"])==null?void 0:c.https)==null?void 0:d.request)!=null?_:Me.request;else throw new Error(`Unsupported protocol "${o.protocol} in URL: "${e.url}"`);this.headers={"User-Agent":`influxdb-client-js/${Be}`,...e.headers},n&&(this.headers.Host=(0,Re.parse)(t).host)}send(e,t,n,i){let s=new we;i&&i.useCancellable&&i.useCancellable(s),this.createRequestMessage(e,t,n,a=>{this._request(a,s,i)},a=>(i==null?void 0:i.error)&&i.error(a))}request(e,t,n,i){t?typeof t!="string"&&(t=JSON.stringify(t)):t="";let s=Rt,a,o;return new Promise((u,f)=>{this.send(e,t,n,{responseStarted(l,p){i&&i(l,p),a=String(l["content-type"]),o=p},next:l=>{s=H.Buffer.concat([s,l])},complete:()=>{var p,c;let l=(c=(p=n.headers)==null?void 0:p.accept)!=null?c:a;try{o===204&&u(void 0),l.includes("json")?s.length?u(JSON.parse(s.toString("utf8"))):u(void 0):l.includes("text")||l.start
//# sourceMappingURL=index.js.map