@influxdata/influxdb-client-browser 1.23.0 → 1.24.0-nightly.1807

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.23.0";
1
+ export declare const CLIENT_LIB_VERSION = "1.24.0.nightly";
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,WAAW,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/impl/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,mBAAmB,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}(s,["url","proxyUrl","token","transportOptions"]),m=t.parse(f||c);if(this.token=p,this.defaultOptions=Object.assign(Object.assign(Object.assign(Object.assign({},S),g),d),{port:m.port,protocol:m.protocol,hostname:m.hostname}),this.contextPath=f?c:null!==(n=m.path)&&void 0!==n?n:"",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")&&(V.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!==(l=null===(o=null===(i=this.defaultOptions["follow-redirects"])||void 0===i?void 0:i.http)||void 0===o?void 0:o.request)&&void 0!==l?l:e.request;else{if("https:"!==m.protocol)throw new Error(`Unsupported protocol "${m.protocol} in URL: "${s.url}"`);this.requestApi=null!==(h=null===(u=null===(a=this.defaultOptions["follow-redirects"])||void 0===a?void 0:a.https)||void 0===u?void 0:u.request)&&void 0!==h?h:r.request}this.headers=Object.assign({"User-Agent":"influxdb-client-js/1.23.0"},s.headers),f&&(this.headers.Host=t.parse(c).host)}send(t,e,r,s){const n=new lt;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=ot;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"),o=Object.assign({"content-type":"application/json; charset=utf-8"},this.headers);this.token&&(o.authorization="Token "+this.token);let l=Promise.resolve(n);const a=Object.assign(Object.assign({},this.defaultOptions),{path:this.contextPath+t,method:r.method,headers:Object.assign(Object.assign({},o),r.headers)});return void 0!==r.gzipThreshold&&r.gzipThreshold<n.length&&(l=l.then(t=>new Promise((e,r)=>{i.default.gzip(t,(t,s)=>t?r(t):(a.headers["content-encoding"]="gzip",e(s)))}))),l.then(t=>(a.body=t,a.headers["content-length"]=t.length,a))}_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 x)}),t.on("error",s.error),s.responseStarted(t.headers,t.statusCode);const n=null!==(r=t.statusCode)&&void 0!==r?r:600;let o;if("gzip"===t.headers["content-encoding"]?(o=i.default.createGunzip(it),o.on("error",s.error),t.pipe(o)):o=t,n>=300){let e="";const r=String(t.headers["content-type"]).startsWith("application/json");o.on("data",s=>{e+=s.toString(),!r&&e.length>1e3&&(e=e.slice(0,1e3),t.resume())}),o.on("end",()=>{""===e&&t.headers["x-influxdb-error"]&&(e=t.headers["x-influxdb-error"].toString()),s.error(new d(n,t.statusMessage,e,t.headers["retry-after"],t.headers["content-type"]))})}else o.on("data",r=>{e.isCancelled()?t.resume():s.next(r)}),o.on("end",s.complete)});"function"==typeof n.setTimeout&&t.timeout&&n.setTimeout(t.timeout),n.on("timeout",()=>{s.error(new y)}),n.on("error",t=>{s.error(t)}),t.body&&n.write(t.body),n.end()}}const ut={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class ht{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new ht(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:ut,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:ut,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 ct{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 ft(){}class pt{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):ft,error:r?r.bind(t):ft,complete:s?s.bind(t):ft}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new ct(this.decorator(s),this.executor)}[K](){return this}}function dt(t,e){return e.toObject(t)}class gt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new pt(this.executor,t=>l(t,this.chunkCombiner))}rows(){return new pt(this.executor,t=>l(T({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner))}consumeLines(t){this.executor(l(t,this.chunkCombiner))}consumeRows(t){this.executor(l(T(t),this.chunkCombiner))}collectRows(t=dt){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=x,exports.DEFAULT_ConnectionOptions=S,exports.DEFAULT_RetryDelayStrategyOptions=R,exports.DEFAULT_WriteOptions=C,exports.FLUX_VALUE=H,exports.HttpError=d,exports.IllegalArgumentError=p,exports.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new p("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new p("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 at(this._options),this.processCSVResponse=t=>new gt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new st(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new ht(this.transport,this.processCSVResponse,t)}},exports.LineSplitter=a,exports.Log=V,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]=D.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+=`${D.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+=`${D.tag(t)}=${D.tag(e)}`)}});let n=this.time;return n=t&&t.convertTime?t.convertTime(n):z(n),`${D.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=y,exports.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!g.includes(t.code)))},exports.chunksToLines=l,exports.consoleLogger=U,exports.convertTimeToNanos=z,exports.createFluxTableColumn=function(t){var e,r;const s=new u;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=O,exports.createTextDecoderCombiner=o,exports.currentTime=q,exports.dateToProtocolTimestamp=N,exports.escape=D,exports.flux=function(t,...e){if(1==t.length&&0===e.length)return X(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=J(l);else if(a=Z(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[H]))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 X(r.join(""))},exports.fluxBool=function(t){return new W("true"===t||"false"===t?t:(!!t).toString())},exports.fluxDateTime=function(t){return new W(function(t){return`time(v: "${J(t)}")`}(t))},exports.fluxDuration=function(t){return new W(`duration(v: "${J(t)}")`)},exports.fluxExpression=X,exports.fluxFloat=function(t){return new W(Y(t))},exports.fluxInteger=function(t){const e=Y(t);for(const t of e)if("."===t)throw new Error("not a flux integer: "+e);return new W(e)},exports.fluxRegExp=function(t){return new W(G(t))},exports.fluxString=function(t){return new W(`"${J(t)}"`)},exports.getRetryDelay=m,exports.isStatusCodeRetriable=f,exports.linesToTables=T,exports.newFluxTableColumn=h,exports.sanitizeFloat=Y,exports.serializeDateTimeAsDate=function(){b["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},exports.serializeDateTimeAsNumber=function(){b["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},exports.serializeDateTimeAsString=function(){b["dateTime:RFC3339"]=t=>""===t?null:t},exports.setLogger=function(t){const e=k;return k=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=K,exports.toFluxValue=Z,exports.typeSerializers=b,exports.useProcessHrtime=B;
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}(s,["url","proxyUrl","token","transportOptions"]),m=t.parse(f||c);if(this.token=p,this.defaultOptions=Object.assign(Object.assign(Object.assign(Object.assign({},S),g),d),{port:m.port,protocol:m.protocol,hostname:m.hostname}),this.contextPath=f?c:null!==(n=m.path)&&void 0!==n?n:"",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")&&(V.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!==(l=null===(o=null===(i=this.defaultOptions["follow-redirects"])||void 0===i?void 0:i.http)||void 0===o?void 0:o.request)&&void 0!==l?l:e.request;else{if("https:"!==m.protocol)throw new Error(`Unsupported protocol "${m.protocol} in URL: "${s.url}"`);this.requestApi=null!==(h=null===(u=null===(a=this.defaultOptions["follow-redirects"])||void 0===a?void 0:a.https)||void 0===u?void 0:u.request)&&void 0!==h?h:r.request}this.headers=Object.assign({"User-Agent":"influxdb-client-js/1.24.0.nightly"},s.headers),f&&(this.headers.Host=t.parse(c).host)}send(t,e,r,s){const n=new lt;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=ot;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"),o=Object.assign({"content-type":"application/json; charset=utf-8"},this.headers);this.token&&(o.authorization="Token "+this.token);let l=Promise.resolve(n);const a=Object.assign(Object.assign({},this.defaultOptions),{path:this.contextPath+t,method:r.method,headers:Object.assign(Object.assign({},o),r.headers)});return void 0!==r.gzipThreshold&&r.gzipThreshold<n.length&&(l=l.then(t=>new Promise((e,r)=>{i.default.gzip(t,(t,s)=>t?r(t):(a.headers["content-encoding"]="gzip",e(s)))}))),l.then(t=>(a.body=t,a.headers["content-length"]=t.length,a))}_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 x)}),t.on("error",s.error),s.responseStarted(t.headers,t.statusCode);const n=null!==(r=t.statusCode)&&void 0!==r?r:600;let o;if("gzip"===t.headers["content-encoding"]?(o=i.default.createGunzip(it),o.on("error",s.error),t.pipe(o)):o=t,n>=300){let e="";const r=String(t.headers["content-type"]).startsWith("application/json");o.on("data",s=>{e+=s.toString(),!r&&e.length>1e3&&(e=e.slice(0,1e3),t.resume())}),o.on("end",()=>{""===e&&t.headers["x-influxdb-error"]&&(e=t.headers["x-influxdb-error"].toString()),s.error(new d(n,t.statusMessage,e,t.headers["retry-after"],t.headers["content-type"]))})}else o.on("data",r=>{e.isCancelled()?t.resume():s.next(r)}),o.on("end",s.complete)});"function"==typeof n.setTimeout&&t.timeout&&n.setTimeout(t.timeout),n.on("timeout",()=>{s.error(new y)}),n.on("error",t=>{s.error(t)}),t.body&&n.write(t.body),n.end()}}const ut={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class ht{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new ht(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:ut,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:ut,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 ct{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 ft(){}class pt{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):ft,error:r?r.bind(t):ft,complete:s?s.bind(t):ft}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new ct(this.decorator(s),this.executor)}[K](){return this}}function dt(t,e){return e.toObject(t)}class gt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new pt(this.executor,t=>l(t,this.chunkCombiner))}rows(){return new pt(this.executor,t=>l(T({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner))}consumeLines(t){this.executor(l(t,this.chunkCombiner))}consumeRows(t){this.executor(l(T(t),this.chunkCombiner))}collectRows(t=dt){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=x,exports.DEFAULT_ConnectionOptions=S,exports.DEFAULT_RetryDelayStrategyOptions=R,exports.DEFAULT_WriteOptions=C,exports.FLUX_VALUE=H,exports.HttpError=d,exports.IllegalArgumentError=p,exports.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new p("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new p("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 at(this._options),this.processCSVResponse=t=>new gt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new st(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new ht(this.transport,this.processCSVResponse,t)}},exports.LineSplitter=a,exports.Log=V,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]=D.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+=`${D.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+=`${D.tag(t)}=${D.tag(e)}`)}});let n=this.time;return n=t&&t.convertTime?t.convertTime(n):z(n),`${D.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=y,exports.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!g.includes(t.code)))},exports.chunksToLines=l,exports.consoleLogger=U,exports.convertTimeToNanos=z,exports.createFluxTableColumn=function(t){var e,r;const s=new u;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=O,exports.createTextDecoderCombiner=o,exports.currentTime=q,exports.dateToProtocolTimestamp=N,exports.escape=D,exports.flux=function(t,...e){if(1==t.length&&0===e.length)return X(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=J(l);else if(a=Z(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[H]))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 X(r.join(""))},exports.fluxBool=function(t){return new W("true"===t||"false"===t?t:(!!t).toString())},exports.fluxDateTime=function(t){return new W(function(t){return`time(v: "${J(t)}")`}(t))},exports.fluxDuration=function(t){return new W(`duration(v: "${J(t)}")`)},exports.fluxExpression=X,exports.fluxFloat=function(t){return new W(Y(t))},exports.fluxInteger=function(t){const e=Y(t);for(const t of e)if("."===t)throw new Error("not a flux integer: "+e);return new W(e)},exports.fluxRegExp=function(t){return new W(G(t))},exports.fluxString=function(t){return new W(`"${J(t)}"`)},exports.getRetryDelay=m,exports.isStatusCodeRetriable=f,exports.linesToTables=T,exports.newFluxTableColumn=h,exports.sanitizeFloat=Y,exports.serializeDateTimeAsDate=function(){b["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},exports.serializeDateTimeAsNumber=function(){b["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},exports.serializeDateTimeAsString=function(){b["dateTime:RFC3339"]=t=>""===t?null:t},exports.setLogger=function(t){const e=k;return k=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=K,exports.toFluxValue=Z,exports.typeSerializers=b,exports.useProcessHrtime=B;
17
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.gz CHANGED
Binary file