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

6 lines
30 KiB
JavaScript
Raw Normal View History

function P(){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 C(r,e){let t=e!=null?e:P(),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 D=p>0&&l[p-1]===13?p-1:p;if(i)return;if(a=r.next(t.toUtf8String(l,c,D))===!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*k(r,e){let t=e!=null?e:P(),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 W=r=>r,S={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},F=class{get(e){var n;let t=e[this.index];return(t===""||t===void 0)&&this.defaultValue&&(t=this.defaultValue),((n=S[this.dataType])!=null?n:W)(t)}},oe=Object.freeze({label:"",dataType:"",group:!1,defaultValue:"",index:Number.MAX_SAFE_INTEGER,get:()=>{}});function L(){return new F}function st(r){var t,n;let e=new F;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 Be=[404,408,425,429,500,502,503,504];function $e(r){return Be.includes(r)}var y=class extends Error{constructor(e){super(e),this.name="IllegalArgumentError",Object.setPrototypeOf(this,y.prototype)}},h=class extends Error{constructor(t,n,i,s,a,o){super();this.statusCode=t;this.statusMessage=n;this.body=i;this.contentType=a;if(Object.setPrototypeOf(this,h.prototype),o)this.message=o;else if(i){if(a!=null&&a.startsWith("application/json"))try{this.json=JSON.parse(i),this.message=this.json.message,this.code=this.json.code}catch(u){}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 $e(this.statusCode)}retryAfter(){return this._retryAfter}},Me=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function at(r){if(r){if(typeof r.canRetry=="function")return!!r.canRetry();if(r.code&&Me.includes(r.code))return!0}else retur
\r `,["\\,","\\ ","\\n","\\r","\\t"]),quoted:Ve('"\\',['\\"',"\\\\"]),tag:j(`, =
\r `,["\\,","\\ ","\\=","\\n","\\r","\\t"])};var _="000000000",Y=!1;function ke(r){return Y=r&&process&&typeof process.hrtime=="function"}ke(!0);var de,U,me=Date.now(),J=0;function X(){if(Y){let r=process.hrtime(),e=Date.now();U?(r[0]=r[0]-U[0],r[1]=r[1]-U[1],r[1]<0&&(r[0]-=1,r[1]+=1e9),e=de+r[0]*1e3+Math.floor(r[1]/1e6)):(U=r,de=e);let t=String(r[1]%1e6);return String(e)+_.substr(0,6-t.length)+t}else{let r=Date.now();r!==me?(me=r,J=0):J++;let e=String(J);return String(r)+_.substr(0,6-e.length)+e}}function he(){if(Y){let r=process.hrtime(),e=String(Math.trunc(r[1]/1e3)%1e3);return String(Date.now())+_.substr(0,3-e.length)+e}else return String(Date.now())+_.substr(0,3)}function ge(){return String(Date.now())}function ye(){return String(Math.floor(Date.now()/1e3))}var be={s:ye,ms:ge,us:he,ns:X,seconds:ye,millis:ge,micros:he,nanos:X},xe={s:r=>`${Math.floor(r.getTime()/1e3)}`,ms:r=>`${r.getTime()}`,us:r=>`${r.getTime()}000`,ns:r=>`${r.getTime()}000000`};function Re(r){return r===void 0?X():typeof r=="string"?r.length>0?r:void 0:r instanceof Date?`${r.getTime()}000000`:String(typeof r=="number"?Math.floor(r):r)}var We={error(r,e){console.error("ERROR: "+r,e||"")},warn(r,e){console.warn("WARN: "+r,e||"")}},B=We,g={error(r,e){B.error(r,e)},warn(r,e){B.warn(r,e)}};function fr(r){let e=B;return B=r,e}var $=Symbol("FLUX_VALUE"),m=class{constructor(e){this.fluxValue=e}toString(){return this.fluxValue}[$](){return this.fluxValue}};function Ne(r){return typeof r=="object"&&typeof r[$]=="function"}function v(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 cr(r){return new m(`"${v(r)}"`)}function Te(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 dr(r){return new m(Te(r))}function Ce(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 mr(r){return new m(Ce(r))}function He(r){return`time(v: "${v(r)}")`}function hr(r){return new m(He(r))}function gr(r){return new m(`duration(v: "${v(r)}")`)}function Se(r){return r instanceof RegExp?r.toString():new RegExp(r).toString()}function yr(r){return new m(Se(r))}function br(r){return r==="true"||r==="false"?new m(r):new m((!!r).toString())}function we(r){return new m(String(r))}function G(r){if(r===void 0)return"";if(r===null)return"null";if(typeof r=="boolean")return r.toString();if(typeof r=="string")return`"${v(r)}"`;if(typeof r=="number")return Number.isSafeInteger(r)?Ce(r):Te(r);if(typeof r=="object"){if(typeof r[$]=="function")return r[$]();if(r instanceof Date)return r.toISOString();if(r instanceof RegExp)return Se(r);if(Array.isArray(r))return`[${r.map(G).join(",")}]`}else if(typeof r=="bigint")return`${r}.0`;return G(r.toString())}function xr(r,...e){if(r.length==1&&e.length===0)return we(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=v(a);else if(o=G(a),o===""&&!Ne(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 we(t.join(""))}var ve=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]=T.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+=`${T.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+=`${T.tag(a)}=${T.tag(o)}`)}});let s=this.time;return e&&e.convertTime?s=e.convertTime(s):s=Re(s),`${T.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&&g.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)}};import{parse as Pe}from"url";import*as Fe from"http";import*as Le from"https";import{Buffer as re}from"buffer";import{Buffer as Ae}from"buffer";var Qe={concat(r,e){return Ae.concat([r,e])},toUtf8String(r,e,t){return r.toString("utf-8",e,t)},copy(r,e,t){let n=Ae.allocUnsafe(t-e);return r.copy(n,0,e,t),n}},Ee=Qe;import M from"zlib";function te(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 De="1.33.1";import{pipeline as je}from"stream";var Je={flush:M.constants.Z_SYNC_FLUSH,finishFlush:M.constants.Z_SYNC_FLUSH},Xe=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=Ee;var u,f,l,p,c,d,D;let{url:t,proxyUrl:n,token:i,transportOptions:s,...a}=e,o=Pe(n||t);if(this.token=i,this.defaultOptions={...fe,...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(se=>this.defaultOptions[se]===void 0&&delete this.defaultOptions[se]),this.contextPath.endsWith("/api/v2")&&(g.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:Fe.request;else if(o.protocol==="https:")this.requestApi=(D=(d=(c=this.defaultOptions["follow-redirects"])==null?void 0:c.https)==null?void 0:d.request)!=null?D:Le.request;else throw new Error(`Unsupported protocol "${o.protocol} in URL: "${e.url}"`);this.headers={"User-Agent":`influxdb-client-js/${De}`,...e.headers},n&&(this.headers.Host=Pe(t).host)}send(e,t,n,i){let s=new ne;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=Xe,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=re.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.startsWith("applicatio
//# sourceMappingURL=index.mjs.map