@influxdata/influxdb-client-browser 1.26.0-nightly.2014 → 1.26.0

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.
@@ -1,2 +1,2 @@
1
- export declare const CLIENT_LIB_VERSION = "1.26.0.nightly";
1
+ export declare const CLIENT_LIB_VERSION = "1.26.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/impl/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,mBAAmB,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/impl/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,WAAW,CAAA"}
Binary file
Binary file
package/dist/index.js CHANGED
@@ -13,5 +13,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
- function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]])}return r}(e,["url","proxyUrl","token","transportOptions"]),m=t.parse(f||h);if(this.token=p,this.defaultOptions=Object.assign(Object.assign(Object.assign(Object.assign({},D),g),d),{port:m.port,protocol:m.protocol,hostname:m.hostname}),this.contextPath=f?h:null!==(r=m.path)&&void 0!==r?r:"",this.contextPath.endsWith("/")&&(this.contextPath=this.contextPath.substring(0,this.contextPath.length-1)),Object.keys(this.defaultOptions).forEach((t=>void 0===this.defaultOptions[t]&&delete this.defaultOptions[t])),this.contextPath.endsWith("/api/v2")&&(X.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${m.protocol}//${m.hostname}:${m.port} !`),this.contextPath=""),"http:"===m.protocol)this.requestApi=null!==(i=null===(n=null===(s=this.defaultOptions["follow-redirects"])||void 0===s?void 0:s.http)||void 0===n?void 0:n.request)&&void 0!==i?i:l.request;else{if("https:"!==m.protocol)throw new Error(`Unsupported protocol "${m.protocol} in URL: "${e.url}"`);this.requestApi=null!==(c=null===(u=null===(o=this.defaultOptions["follow-redirects"])||void 0===o?void 0:o.https)||void 0===u?void 0:u.request)&&void 0!==c?c:a.request}this.headers=Object.assign({"User-Agent":"influxdb-client-js/1.26.0.nightly"},e.headers),f&&(this.headers.Host=t.parse(h).host)}send(t,e,r,s){const n=new ft;s&&s.useCancellable&&s.useCancellable(n),this.createRequestMessage(t,e,r).then((t=>{this._request(t,n,s)}),(t=>(null==s?void 0:s.error)&&s.error(t)))}request(t,e,r,n){e?"string"!=typeof e&&(e=JSON.stringify(e)):e="";let i,o,l=ht;return new Promise(((a,u)=>{this.send(t,e,r,{responseStarted(t,e){n&&n(t,e),i=String(t["content-type"]),o=e},next:t=>{l=s.Buffer.concat([l,t])},complete:()=>{var t,e;const s=null!==(e=null===(t=r.headers)||void 0===t?void 0:t.accept)&&void 0!==e?e:i;try{204===o&&a(void 0),s.includes("json")?l.length?a(JSON.parse(l.toString("utf8"))):a(void 0):s.includes("text")||s.startsWith("application/csv")?a(l.toString("utf8")):a(l)}catch(t){u(t)}},error:t=>{u(t)}})}))}createRequestMessage(t,e,r){const n=s.Buffer.from(e,"utf-8"),i=Object.assign({"content-type":"application/json; charset=utf-8"},this.headers);this.token&&(i.authorization="Token "+this.token);let o=Promise.resolve(n);const l=Object.assign(Object.assign({},this.defaultOptions),{path:this.contextPath+t,method:r.method,headers:Object.assign(Object.assign({},i),r.headers)});return void 0!==r.gzipThreshold&&r.gzipThreshold<n.length&&(o=o.then((t=>new Promise(((e,r)=>{u.default.gzip(t,((t,s)=>t?r(t):(l.headers["content-encoding"]="gzip",e(s))))}))))),o.then((t=>(l.body=t,l.headers["content-length"]=t.length,l)))}_request(t,e,r){const s=function(t={}){let e=0;return{next:r=>{0===e&&t.next&&null!=r&&t.next(r)},error:r=>{0===e&&(e=1,t.error&&t.error(r))},complete:()=>{0===e&&(e=2,t.complete&&t.complete())},responseStarted:(e,r)=>{t.responseStarted&&t.responseStarted(e,r)}}}(r);if(e.isCancelled())return void s.complete();const n=this.requestApi(t,(t=>{var r;if(e.isCancelled())return t.resume(),void s.complete();t.on("aborted",(()=>{s.error(new R)})),t.on("error",s.error),s.responseStarted(t.headers,t.statusCode);const n=null!==(r=t.statusCode)&&void 0!==r?r:600;let i;if("gzip"===t.headers["content-encoding"]?(i=u.default.createGunzip(ct),i.on("error",s.error),t.pipe(i)):i=t,n>=300){let e="";const r=String(t.headers["content-type"]).startsWith("application/json");i.on("data",(s=>{e+=s.toString(),!r&&e.length>1e3&&(e=e.slice(0,1e3),t.resume())})),i.on("end",(()=>{""===e&&t.headers["x-influxdb-error"]&&(e=t.headers["x-influxdb-error"].toString()),s.error(new v(n,t.statusMessage,e,t.headers["retry-after"],t.headers["content-type"]))}))}else i.on("data",(r=>{e.isCancelled()?t.resume():s.next(r)})),i.on("end",s.complete)}));"function"==typeof n.setTimeout&&t.timeout&&n.setTimeout(t.timeout),n.on("timeout",(()=>{s.error(new S)})),n.on("error",(t=>{s.error(t)})),t.body&&n.write(t.body),n.end()}}const dt={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class gt{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new gt(this.transport,this.createCSVResponse,Object.assign(Object.assign({},this.options),t))}response(t){return this.createCSVResponse(this.createExecutor(t))}lines(t){return this.response(t).lines()}rows(t){return this.response(t).rows()}queryLines(t,e){return this.response(t).consumeLines(e)}queryRows(t,e){return this.response(t).consumeRows(e)}collectRows(t,e){return this.response(t).collectRows(e)}collectLines(t){return this.response(t).collectLines()}queryRaw(t){const{org:e,type:r,gzip:s,headers:n}=this.options;return this.transport.request(`/api/v2/query?org=${encodeURIComponent(e)}`,JSON.stringify(this.decorateRequest({query:t.toString(),dialect:dt,type:r})),{method:"POST",headers:Object.assign({accept:"text/csv","accept-encoding":s?"gzip":"identity","content-type":"application/json; encoding=utf-8"},n)})}createExecutor(t){const{org:e,type:r,gzip:s,headers:n}=this.options;return i=>{this.transport.send(`/api/v2/query?org=${encodeURIComponent(e)}`,JSON.stringify(this.decorateRequest({query:t.toString(),dialect:dt,type:r})),{method:"POST",headers:Object.assign({"content-type":"application/json; encoding=utf-8","accept-encoding":s?"gzip":"identity"},n)},i)}}decorateRequest(t){var e;return"function"==typeof this.options.now&&(t.now=this.options.now()),t.type=null!==(e=this.options.type)&&void 0!==e?e:"flux",t}}class mt{constructor(t,e){this.isClosed=!1;try{e({next:e=>{t.next(e)},error:e=>{this.isClosed=!0,t.error(e)},complete:()=>{this.isClosed=!0,t.complete()},useCancellable:t=>{this.cancellable=t}})}catch(e){this.isClosed=!0,t.error(e)}}get closed(){return this.isClosed}unsubscribe(){var t;null===(t=this.cancellable)||void 0===t||t.cancel(),this.isClosed=!0}}function yt(){}class xt{constructor(t,e){this.executor=t,this.decorator=e}subscribe(t,e,r){const s=function(t){const{next:e,error:r,complete:s}=t;return{next:e?e.bind(t):yt,error:r?r.bind(t):yt,complete:s?s.bind(t):yt}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new mt(this.decorator(s),this.executor)}[st](){return this}}function wt(t,e){return e.toObject(t)}class bt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new xt(this.executor,(t=>h(t,this.chunkCombiner)))}rows(){return new xt(this.executor,(t=>h($({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner)))}consumeLines(t){this.executor(h(t,this.chunkCombiner))}consumeRows(t){this.executor(h($(t),this.chunkCombiner))}collectRows(t=wt){const e=[];return new Promise(((r,s)=>{this.consumeRows({next(r,s){const n=t.call(this,r,s);void 0!==n&&e.push(n)},error(t){s(t)},complete(){r(e)}})}))}collectLines(){const t=[];return new Promise(((e,r)=>{this.consumeLines({next(e){t.push(e)},error(t){r(t)},complete(){e(t)}})}))}}exports.AbortError=R,exports.DEFAULT_ConnectionOptions=D,exports.DEFAULT_RetryDelayStrategyOptions=j,exports.DEFAULT_WriteOptions=A,exports.FLUX_VALUE=Y,exports.HttpError=v,exports.IllegalArgumentError=b,exports.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new b("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new b("No url specified!");r.endsWith("/")&&(this._options.url=r.substring(0,r.length-1)),this.transport=null!==(e=this._options.transport)&&void 0!==e?e:new pt(this._options),this.processCSVResponse=t=>new bt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new at(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new gt(this.transport,this.processCSVResponse,t)}},exports.LineSplitter=f,exports.Log=X,exports.Point=class{constructor(t){this.tags={},this.fields={},t&&(this.name=t)}measurement(t){return this.name=t,this}tag(t,e){return this.tags[t]=e,this}booleanField(t,e){return this.fields[t]=e?"T":"F",this}intField(t,e){let r;if(r="number"==typeof e?e:parseInt(String(e)),isNaN(r)||r<=-0x8000000000000000||r>=0x8000000000000000)throw new Error(`invalid integer value for field '${t}': '${e}'!`);return this.fields[t]=`${Math.floor(r)}i`,this}uintField(t,e){if("number"==typeof e){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${t}' out of range: ${e}`);this.fields[t]=`${Math.floor(e)}u`}else{const r=String(e);for(let t=0;t<r.length;t++){const s=r.charCodeAt(t);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${t}: ${e}`)}if(r.length>20||20===r.length&&r.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${t}' out of range: ${r}`);this.fields[t]=`${r}u`}return this}floatField(t,e){let r;if(r="number"==typeof e?e:parseFloat(e),!isFinite(r))throw new Error(`invalid float value for field '${t}': ${e}`);return this.fields[t]=String(r),this}stringField(t,e){return null!=e&&("string"!=typeof e&&(e=String(e)),this.fields[t]=_.quoted(e)),this}timestamp(t){return this.time=t,this}toLineProtocol(t){if(!this.name)return;let e="";if(Object.keys(this.fields).sort().forEach((t=>{if(t){const r=this.fields[t];e.length>0&&(e+=","),e+=`${_.tag(t)}=${r}`}})),0===e.length)return;let r="";const s=t&&t.defaultTags?Object.assign(Object.assign({},t.defaultTags),this.tags):this.tags;Object.keys(s).sort().forEach((t=>{if(t){const e=s[t];e&&(r+=",",r+=`${_.tag(t)}=${_.tag(e)}`)}}));let n=this.time;return n=t&&t.convertTime?t.convertTime(n):W(n),`${_.measurement(this.name)}${r} ${e}${void 0!==n?" "+n:""}`}toString(){const t=this.toLineProtocol(void 0);return t||`invalid point: ${JSON.stringify(this,void 0)}`}},exports.RequestTimedOutError=S,exports.UNKNOWN_COLUMN=m,exports.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!O.includes(t.code)))},exports.chunksToLines=h,exports.consoleLogger=J,exports.convertTimeToNanos=W,exports.createFluxTableColumn=function(t){var e,r;const s=new g;return s.label=String(t.label),s.dataType=t.dataType,s.group=Boolean(t.group),s.defaultValue=null!==(e=t.defaultValue)&&void 0!==e?e:"",s.index=null!==(r=t.index)&&void 0!==r?r:0,s},exports.createFluxTableMetaData=E,exports.createTextDecoderCombiner=c,exports.currentTime=V,exports.dateToProtocolTimestamp=H,exports.escape=_,exports.flux=function(t,...e){if(1==t.length&&0===e.length)return et(t[0]);const r=new Array(t.length+e.length);let s=0;for(let i=0;i<t.length;i++){const o=t[i];if(r[s++]=o,i<e.length){const l=e[i];let a;if(o.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))a=Z(l);else if(a=rt(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[Y]))throw new Error(`Unsupported parameter literal '${l}' at index: ${i}, type: ${typeof l}`);r[s++]=a}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}var n;return et(r.join(""))},exports.fluxBool=function(t){return new K("true"===t||"false"===t?t:(!!t).toString())},exports.fluxDateTime=function(t){return new K(function(t){return`time(v: "${Z(t)}")`}(t))},exports.fluxDuration=function(t){return new K(`duration(v: "${Z(t)}")`)},exports.fluxExpression=et,exports.fluxFloat=function(t){return new K(Q(t))},exports.fluxInteger=function(t){const e=Q(t);for(const t of e)if("."===t)throw new Error(`not a flux integer: ${e}`);return new K(e)},exports.fluxRegExp=function(t){return new K(tt(t))},exports.fluxString=function(t){return new K(`"${Z(t)}"`)},exports.getRetryDelay=T,exports.isStatusCodeRetriable=w,exports.linesToTables=$,exports.newFluxTableColumn=y,exports.sanitizeFloat=Q,exports.serializeDateTimeAsDate=function(){d["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},exports.serializeDateTimeAsNumber=function(){d["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},exports.serializeDateTimeAsString=function(){d["dateTime:RFC3339"]=t=>""===t?null:t},exports.setLogger=function(t){const e=G;return G=t,e},exports.stringToLines=function(t,e){let r=!1,s=0,n=0;for(;n<t.length;){const i=t.charCodeAt(n);if(10===i){if(!r){const r=n>0&&13===t.charCodeAt(n-1)?n-1:n;e.next(t.substring(s,r)),s=n+1}}else 34===i&&(r=!r);n++}s<n&&e.next(t.substring(s,n)),e.complete()},exports.symbolObservable=st,exports.toFluxValue=rt,exports.typeSerializers=d,exports.useProcessHrtime=M;
16
+ function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]])}return r}(e,["url","proxyUrl","token","transportOptions"]),m=t.parse(f||h);if(this.token=p,this.defaultOptions=Object.assign(Object.assign(Object.assign(Object.assign({},D),g),d),{port:m.port,protocol:m.protocol,hostname:m.hostname}),this.contextPath=f?h:null!==(r=m.path)&&void 0!==r?r:"",this.contextPath.endsWith("/")&&(this.contextPath=this.contextPath.substring(0,this.contextPath.length-1)),Object.keys(this.defaultOptions).forEach((t=>void 0===this.defaultOptions[t]&&delete this.defaultOptions[t])),this.contextPath.endsWith("/api/v2")&&(X.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${m.protocol}//${m.hostname}:${m.port} !`),this.contextPath=""),"http:"===m.protocol)this.requestApi=null!==(i=null===(n=null===(s=this.defaultOptions["follow-redirects"])||void 0===s?void 0:s.http)||void 0===n?void 0:n.request)&&void 0!==i?i:l.request;else{if("https:"!==m.protocol)throw new Error(`Unsupported protocol "${m.protocol} in URL: "${e.url}"`);this.requestApi=null!==(c=null===(u=null===(o=this.defaultOptions["follow-redirects"])||void 0===o?void 0:o.https)||void 0===u?void 0:u.request)&&void 0!==c?c:a.request}this.headers=Object.assign({"User-Agent":"influxdb-client-js/1.26.0"},e.headers),f&&(this.headers.Host=t.parse(h).host)}send(t,e,r,s){const n=new ft;s&&s.useCancellable&&s.useCancellable(n),this.createRequestMessage(t,e,r).then((t=>{this._request(t,n,s)}),(t=>(null==s?void 0:s.error)&&s.error(t)))}request(t,e,r,n){e?"string"!=typeof e&&(e=JSON.stringify(e)):e="";let i,o,l=ht;return new Promise(((a,u)=>{this.send(t,e,r,{responseStarted(t,e){n&&n(t,e),i=String(t["content-type"]),o=e},next:t=>{l=s.Buffer.concat([l,t])},complete:()=>{var t,e;const s=null!==(e=null===(t=r.headers)||void 0===t?void 0:t.accept)&&void 0!==e?e:i;try{204===o&&a(void 0),s.includes("json")?l.length?a(JSON.parse(l.toString("utf8"))):a(void 0):s.includes("text")||s.startsWith("application/csv")?a(l.toString("utf8")):a(l)}catch(t){u(t)}},error:t=>{u(t)}})}))}createRequestMessage(t,e,r){const n=s.Buffer.from(e,"utf-8"),i=Object.assign({"content-type":"application/json; charset=utf-8"},this.headers);this.token&&(i.authorization="Token "+this.token);let o=Promise.resolve(n);const l=Object.assign(Object.assign({},this.defaultOptions),{path:this.contextPath+t,method:r.method,headers:Object.assign(Object.assign({},i),r.headers)});return void 0!==r.gzipThreshold&&r.gzipThreshold<n.length&&(o=o.then((t=>new Promise(((e,r)=>{u.default.gzip(t,((t,s)=>t?r(t):(l.headers["content-encoding"]="gzip",e(s))))}))))),o.then((t=>(l.body=t,l.headers["content-length"]=t.length,l)))}_request(t,e,r){const s=function(t={}){let e=0;return{next:r=>{0===e&&t.next&&null!=r&&t.next(r)},error:r=>{0===e&&(e=1,t.error&&t.error(r))},complete:()=>{0===e&&(e=2,t.complete&&t.complete())},responseStarted:(e,r)=>{t.responseStarted&&t.responseStarted(e,r)}}}(r);if(e.isCancelled())return void s.complete();const n=this.requestApi(t,(t=>{var r;if(e.isCancelled())return t.resume(),void s.complete();t.on("aborted",(()=>{s.error(new R)})),t.on("error",s.error),s.responseStarted(t.headers,t.statusCode);const n=null!==(r=t.statusCode)&&void 0!==r?r:600;let i;if("gzip"===t.headers["content-encoding"]?(i=u.default.createGunzip(ct),i.on("error",s.error),t.pipe(i)):i=t,n>=300){let e="";const r=String(t.headers["content-type"]).startsWith("application/json");i.on("data",(s=>{e+=s.toString(),!r&&e.length>1e3&&(e=e.slice(0,1e3),t.resume())})),i.on("end",(()=>{""===e&&t.headers["x-influxdb-error"]&&(e=t.headers["x-influxdb-error"].toString()),s.error(new v(n,t.statusMessage,e,t.headers["retry-after"],t.headers["content-type"]))}))}else i.on("data",(r=>{e.isCancelled()?t.resume():s.next(r)})),i.on("end",s.complete)}));"function"==typeof n.setTimeout&&t.timeout&&n.setTimeout(t.timeout),n.on("timeout",(()=>{s.error(new S)})),n.on("error",(t=>{s.error(t)})),t.body&&n.write(t.body),n.end()}}const dt={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class gt{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new gt(this.transport,this.createCSVResponse,Object.assign(Object.assign({},this.options),t))}response(t){return this.createCSVResponse(this.createExecutor(t))}lines(t){return this.response(t).lines()}rows(t){return this.response(t).rows()}queryLines(t,e){return this.response(t).consumeLines(e)}queryRows(t,e){return this.response(t).consumeRows(e)}collectRows(t,e){return this.response(t).collectRows(e)}collectLines(t){return this.response(t).collectLines()}queryRaw(t){const{org:e,type:r,gzip:s,headers:n}=this.options;return this.transport.request(`/api/v2/query?org=${encodeURIComponent(e)}`,JSON.stringify(this.decorateRequest({query:t.toString(),dialect:dt,type:r})),{method:"POST",headers:Object.assign({accept:"text/csv","accept-encoding":s?"gzip":"identity","content-type":"application/json; encoding=utf-8"},n)})}createExecutor(t){const{org:e,type:r,gzip:s,headers:n}=this.options;return i=>{this.transport.send(`/api/v2/query?org=${encodeURIComponent(e)}`,JSON.stringify(this.decorateRequest({query:t.toString(),dialect:dt,type:r})),{method:"POST",headers:Object.assign({"content-type":"application/json; encoding=utf-8","accept-encoding":s?"gzip":"identity"},n)},i)}}decorateRequest(t){var e;return"function"==typeof this.options.now&&(t.now=this.options.now()),t.type=null!==(e=this.options.type)&&void 0!==e?e:"flux",t}}class mt{constructor(t,e){this.isClosed=!1;try{e({next:e=>{t.next(e)},error:e=>{this.isClosed=!0,t.error(e)},complete:()=>{this.isClosed=!0,t.complete()},useCancellable:t=>{this.cancellable=t}})}catch(e){this.isClosed=!0,t.error(e)}}get closed(){return this.isClosed}unsubscribe(){var t;null===(t=this.cancellable)||void 0===t||t.cancel(),this.isClosed=!0}}function yt(){}class xt{constructor(t,e){this.executor=t,this.decorator=e}subscribe(t,e,r){const s=function(t){const{next:e,error:r,complete:s}=t;return{next:e?e.bind(t):yt,error:r?r.bind(t):yt,complete:s?s.bind(t):yt}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new mt(this.decorator(s),this.executor)}[st](){return this}}function wt(t,e){return e.toObject(t)}class bt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new xt(this.executor,(t=>h(t,this.chunkCombiner)))}rows(){return new xt(this.executor,(t=>h($({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner)))}consumeLines(t){this.executor(h(t,this.chunkCombiner))}consumeRows(t){this.executor(h($(t),this.chunkCombiner))}collectRows(t=wt){const e=[];return new Promise(((r,s)=>{this.consumeRows({next(r,s){const n=t.call(this,r,s);void 0!==n&&e.push(n)},error(t){s(t)},complete(){r(e)}})}))}collectLines(){const t=[];return new Promise(((e,r)=>{this.consumeLines({next(e){t.push(e)},error(t){r(t)},complete(){e(t)}})}))}}exports.AbortError=R,exports.DEFAULT_ConnectionOptions=D,exports.DEFAULT_RetryDelayStrategyOptions=j,exports.DEFAULT_WriteOptions=A,exports.FLUX_VALUE=Y,exports.HttpError=v,exports.IllegalArgumentError=b,exports.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new b("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new b("No url specified!");r.endsWith("/")&&(this._options.url=r.substring(0,r.length-1)),this.transport=null!==(e=this._options.transport)&&void 0!==e?e:new pt(this._options),this.processCSVResponse=t=>new bt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new at(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new gt(this.transport,this.processCSVResponse,t)}},exports.LineSplitter=f,exports.Log=X,exports.Point=class{constructor(t){this.tags={},this.fields={},t&&(this.name=t)}measurement(t){return this.name=t,this}tag(t,e){return this.tags[t]=e,this}booleanField(t,e){return this.fields[t]=e?"T":"F",this}intField(t,e){let r;if(r="number"==typeof e?e:parseInt(String(e)),isNaN(r)||r<=-0x8000000000000000||r>=0x8000000000000000)throw new Error(`invalid integer value for field '${t}': '${e}'!`);return this.fields[t]=`${Math.floor(r)}i`,this}uintField(t,e){if("number"==typeof e){if(isNaN(e)||e<0||e>Number.MAX_SAFE_INTEGER)throw new Error(`uint value for field '${t}' out of range: ${e}`);this.fields[t]=`${Math.floor(e)}u`}else{const r=String(e);for(let t=0;t<r.length;t++){const s=r.charCodeAt(t);if(s<48||s>57)throw new Error(`uint value has an unsupported character at pos ${t}: ${e}`)}if(r.length>20||20===r.length&&r.localeCompare("18446744073709551615")>0)throw new Error(`uint value for field '${t}' out of range: ${r}`);this.fields[t]=`${r}u`}return this}floatField(t,e){let r;if(r="number"==typeof e?e:parseFloat(e),!isFinite(r))throw new Error(`invalid float value for field '${t}': ${e}`);return this.fields[t]=String(r),this}stringField(t,e){return null!=e&&("string"!=typeof e&&(e=String(e)),this.fields[t]=_.quoted(e)),this}timestamp(t){return this.time=t,this}toLineProtocol(t){if(!this.name)return;let e="";if(Object.keys(this.fields).sort().forEach((t=>{if(t){const r=this.fields[t];e.length>0&&(e+=","),e+=`${_.tag(t)}=${r}`}})),0===e.length)return;let r="";const s=t&&t.defaultTags?Object.assign(Object.assign({},t.defaultTags),this.tags):this.tags;Object.keys(s).sort().forEach((t=>{if(t){const e=s[t];e&&(r+=",",r+=`${_.tag(t)}=${_.tag(e)}`)}}));let n=this.time;return n=t&&t.convertTime?t.convertTime(n):W(n),`${_.measurement(this.name)}${r} ${e}${void 0!==n?" "+n:""}`}toString(){const t=this.toLineProtocol(void 0);return t||`invalid point: ${JSON.stringify(this,void 0)}`}},exports.RequestTimedOutError=S,exports.UNKNOWN_COLUMN=m,exports.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!O.includes(t.code)))},exports.chunksToLines=h,exports.consoleLogger=J,exports.convertTimeToNanos=W,exports.createFluxTableColumn=function(t){var e,r;const s=new g;return s.label=String(t.label),s.dataType=t.dataType,s.group=Boolean(t.group),s.defaultValue=null!==(e=t.defaultValue)&&void 0!==e?e:"",s.index=null!==(r=t.index)&&void 0!==r?r:0,s},exports.createFluxTableMetaData=E,exports.createTextDecoderCombiner=c,exports.currentTime=V,exports.dateToProtocolTimestamp=H,exports.escape=_,exports.flux=function(t,...e){if(1==t.length&&0===e.length)return et(t[0]);const r=new Array(t.length+e.length);let s=0;for(let i=0;i<t.length;i++){const o=t[i];if(r[s++]=o,i<e.length){const l=e[i];let a;if(o.endsWith('"')&&i+1<t.length&&t[i+1].startsWith('"'))a=Z(l);else if(a=rt(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[Y]))throw new Error(`Unsupported parameter literal '${l}' at index: ${i}, type: ${typeof l}`);r[s++]=a}else if(i<t.length-1)throw new Error("Too few parameters supplied!")}var n;return et(r.join(""))},exports.fluxBool=function(t){return new K("true"===t||"false"===t?t:(!!t).toString())},exports.fluxDateTime=function(t){return new K(function(t){return`time(v: "${Z(t)}")`}(t))},exports.fluxDuration=function(t){return new K(`duration(v: "${Z(t)}")`)},exports.fluxExpression=et,exports.fluxFloat=function(t){return new K(Q(t))},exports.fluxInteger=function(t){const e=Q(t);for(const t of e)if("."===t)throw new Error(`not a flux integer: ${e}`);return new K(e)},exports.fluxRegExp=function(t){return new K(tt(t))},exports.fluxString=function(t){return new K(`"${Z(t)}"`)},exports.getRetryDelay=T,exports.isStatusCodeRetriable=w,exports.linesToTables=$,exports.newFluxTableColumn=y,exports.sanitizeFloat=Q,exports.serializeDateTimeAsDate=function(){d["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},exports.serializeDateTimeAsNumber=function(){d["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},exports.serializeDateTimeAsString=function(){d["dateTime:RFC3339"]=t=>""===t?null:t},exports.setLogger=function(t){const e=G;return G=t,e},exports.stringToLines=function(t,e){let r=!1,s=0,n=0;for(;n<t.length;){const i=t.charCodeAt(n);if(10===i){if(!r){const r=n>0&&13===t.charCodeAt(n-1)?n-1:n;e.next(t.substring(s,r)),s=n+1}}else 34===i&&(r=!r);n++}s<n&&e.next(t.substring(s,n)),e.complete()},exports.symbolObservable=st,exports.toFluxValue=rt,exports.typeSerializers=d,exports.useProcessHrtime=M;
17
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.gz CHANGED
Binary file