@influxdata/influxdb-client 1.21.0-nightly.1636 → 1.21.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @influxdata/influxdb-client
2
2
 
3
- The reference javascript client for InfluxDB 2.0. Both node and browser environments are supported. The package.json
3
+ The reference javascript client for InfluxDB 2.x. Both node and browser environments are supported. The package.json
4
4
 
5
5
  - **main** points to node.js CJS distribution
6
6
  - **module** points to node.js ESM distribution
@@ -4,7 +4,7 @@ import { Transport } from './transport';
4
4
  import QueryApi, { QueryOptions } from './QueryApi';
5
5
  import { AnnotatedCSVResponse, APIExecutor } from './results';
6
6
  /**
7
- * InfluxDB 2.0 entry point that configures communication with InfluxDB server
7
+ * InfluxDB entry point that configures communication with InfluxDB server
8
8
  * and provide APIs to write and query data.
9
9
  */
10
10
  export default class InfluxDB {
@@ -28,8 +28,8 @@ export interface QueryOptions {
28
28
  };
29
29
  }
30
30
  /**
31
- * Query InfluxDB 2.0. Provides methods that notify abouts result lines of the executed query.
32
- * See {@link https://v2.docs.influxdata.com/v2.0/api/#operation/PostQuery }
31
+ * Query InfluxDB. Provides methods that notify about result lines of the executed query.
32
+ * See {@link https://docs.influxdata.com/influxdb/v2.1/api/#operation/PostQuery }
33
33
  */
34
34
  export default interface QueryApi {
35
35
  /**
@@ -63,7 +63,7 @@ export default interface QueryApi {
63
63
  rows(query: string | ParameterizedQuery): Observable<Row>;
64
64
  /**
65
65
  * Executes the query and receives result lines (including empty and annotation lines)
66
- * through the supplied consumer. See [annotated-csv](https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/).
66
+ * through the supplied consumer. See [annotated-csv](https://docs.influxdata.com/influxdb/v2.1/reference/syntax/annotated-csv/).
67
67
  *
68
68
  * @param query - query
69
69
  * @param consumer - csv result lines and error consumer
@@ -1,6 +1,6 @@
1
1
  import { Point, PointSettings } from './Point';
2
2
  /**
3
- * The asynchronous buffering API to Write time-series data into InfluxDB 2.0.
3
+ * The asynchronous buffering API to Write time-series data into InfluxDB.
4
4
  * This API always buffers points/lines to create batches under the hood
5
5
  * to optimize data transfer to InfluxDB server, use `flush` to send
6
6
  * the buffered data to InfluxDB immediately.
package/dist/all.d.ts CHANGED
@@ -94,7 +94,7 @@ interface CommunicationObserver<T> {
94
94
  declare function chunksToLines(target: CommunicationObserver<string>, chunkCombiner?: ChunkCombiner): CommunicationObserver<Uint8Array>;
95
95
 
96
96
  /**
97
- * Type of query result column, see {@link https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/#valid-data-types }
97
+ * Type of query result column, see {@link https://docs.influxdata.com/influxdb/v2.1/reference/syntax/annotated-csv/#data-types }
98
98
  */
99
99
  declare type ColumnType = 'boolean' | 'unsignedLong' | 'long' | 'double' | 'string' | 'base64Binary' | 'dateTime:RFC3339' | 'duration' | string;
100
100
  /**
@@ -136,7 +136,7 @@ declare function createFluxTableColumn(object: Partial<FluxTableColumn>): FluxTa
136
136
 
137
137
  /**
138
138
  * A dictionary of serializers of particular types returned by a flux query.
139
- * See {@link https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/#valid-data-types }
139
+ * See {@link https://docs.influxdata.com/influxdb/v2.1/reference/syntax/annotated-csv/#data-types }
140
140
  */
141
141
  declare const typeSerializers: Record<ColumnType, (val: string) => any>;
142
142
  /**
@@ -320,7 +320,7 @@ interface AnnotatedCSVResponse {
320
320
  rows(): Observable<Row>;
321
321
  /**
322
322
  * ConsumesLines consumes result lines (including empty and annotation lines)
323
- * through the supplied consumer. See [annotated-csv](https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/).
323
+ * through the supplied consumer. See [annotated-csv](https://docs.influxdata.com/influxdb/v2.1/reference/syntax/annotated-csv/).
324
324
  * @param consumer - csv result lines and error consumer
325
325
  */
326
326
  consumeLines(consumer: CommunicationObserver<string>): void;
@@ -513,7 +513,7 @@ declare class Point {
513
513
  }
514
514
 
515
515
  /**
516
- * The asynchronous buffering API to Write time-series data into InfluxDB 2.0.
516
+ * The asynchronous buffering API to Write time-series data into InfluxDB.
517
517
  * This API always buffers points/lines to create batches under the hood
518
518
  * to optimize data transfer to InfluxDB server, use `flush` to send
519
519
  * the buffered data to InfluxDB immediately.
@@ -691,7 +691,7 @@ interface ClientOptions extends ConnectionOptions {
691
691
  }
692
692
  /**
693
693
  * Timestamp precision used in write operations.
694
- * See {@link https://v2.docs.influxdata.com/v2.0/api/#operation/PostWrite }
694
+ * See {@link https://docs.influxdata.com/influxdb/v2.1/api/#operation/PostWrite }
695
695
  */
696
696
  declare type WritePrecisionType = 'ns' | 'us' | 'ms' | 's';
697
697
 
@@ -937,8 +937,8 @@ interface QueryOptions {
937
937
  };
938
938
  }
939
939
  /**
940
- * Query InfluxDB 2.0. Provides methods that notify abouts result lines of the executed query.
941
- * See {@link https://v2.docs.influxdata.com/v2.0/api/#operation/PostQuery }
940
+ * Query InfluxDB. Provides methods that notify about result lines of the executed query.
941
+ * See {@link https://docs.influxdata.com/influxdb/v2.1/api/#operation/PostQuery }
942
942
  */
943
943
  interface QueryApi {
944
944
  /**
@@ -972,7 +972,7 @@ interface QueryApi {
972
972
  rows(query: string | ParameterizedQuery): Observable<Row>;
973
973
  /**
974
974
  * Executes the query and receives result lines (including empty and annotation lines)
975
- * through the supplied consumer. See [annotated-csv](https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/).
975
+ * through the supplied consumer. See [annotated-csv](https://docs.influxdata.com/influxdb/v2.1/reference/syntax/annotated-csv/).
976
976
  *
977
977
  * @param query - query
978
978
  * @param consumer - csv result lines and error consumer
@@ -1017,7 +1017,7 @@ interface QueryApi {
1017
1017
  }
1018
1018
 
1019
1019
  /**
1020
- * InfluxDB 2.0 entry point that configures communication with InfluxDB server
1020
+ * InfluxDB entry point that configures communication with InfluxDB server
1021
1021
  * and provide APIs to write and query data.
1022
1022
  */
1023
1023
  declare class InfluxDB {
@@ -1 +1 @@
1
- {"version":3,"file":"WriteApiImpl.d.ts","sourceRoot":"","sources":["../src/impl/WriteApiImpl.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAEL,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,SAAS,EAAc,MAAM,cAAc,CAAA;AAGnD,OAAO,EAAY,kBAAkB,EAAC,MAAM,WAAW,CAAA;AACvD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAA;AAI9B,OAAO,WAAW,MAAM,eAAe,CAAA;AAyCvC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IAcjD,OAAO,CAAC,SAAS;IAbnB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,uBAAuB,CAAqB;IAEpD,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,kBAAkB,CAAA;gBAGvB,SAAS,EAAE,SAAS,EAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,kBAAkB,EAC7B,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IA2DtC,SAAS,CACP,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAoD,GAC5D,OAAO,CAAC,IAAI,CAAC;IAoFhB,OAAO,CAAC,kBAAkB;IAO1B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMjC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI;IAQ9C,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAO9B,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI;IASrC,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAatB,OAAO,IAAI,MAAM;IAOjB,WAAW,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,SAAS,CAAA;IAChD,cAAc,CAAC,IAAI,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,QAAQ;IASvD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;CAa3E"}
1
+ {"version":3,"file":"WriteApiImpl.d.ts","sourceRoot":"","sources":["../src/impl/WriteApiImpl.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAEL,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,SAAS,EAAc,MAAM,cAAc,CAAA;AAGnD,OAAO,EAAY,kBAAkB,EAAC,MAAM,WAAW,CAAA;AACvD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAA;AAG9B,OAAO,WAAW,MAAM,eAAe,CAAA;AAyCvC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IAcjD,OAAO,CAAC,SAAS;IAbnB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,uBAAuB,CAAqB;IAEpD,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,kBAAkB,CAAA;gBAGvB,SAAS,EAAE,SAAS,EAC5B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,kBAAkB,EAC7B,YAAY,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IA2DtC,SAAS,CACP,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAoD,GAC5D,OAAO,CAAC,IAAI,CAAC;IAoFhB,OAAO,CAAC,kBAAkB;IAO1B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMjC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI;IAQ9C,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAO9B,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI;IASrC,KAAK,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAatB,OAAO,IAAI,MAAM;IAOjB,WAAW,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,SAAS,CAAA;IAChD,cAAc,CAAC,IAAI,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,QAAQ;IAIvD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS;CAa3E"}
@@ -1,2 +1,2 @@
1
- export declare const CLIENT_LIB_VERSION = "1.21.0.nightly";
1
+ export declare const CLIENT_LIB_VERSION = "1.21.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"}
@@ -1,4 +1,4 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@influxdata/influxdb-client"]={})}(this,(function(t){"use strict";function e(){const t=new TextDecoder("utf-8");return{concat(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r},copy(t,e,r){const s=new Uint8Array(r-e);return s.set(t.subarray(e,r)),s},toUtf8String:(e,r,s)=>t.decode(e.subarray(r,s))}}function r(t,r){const s=null!=r?r:e();let n,i=!1,o=!1;return{next(e){if(!i)try{!function(e){let r,l=0;for(n?(e=s.concat(n,e),r=n.length):r=0;r<e.length;){const n=e[r];if(10===n){if(!o){const n=r>0&&13===e[r-1]?r-1:r;if(i)return;t.next(s.toUtf8String(e,l,n)),l=r+1}}else 34===n&&(o=!o);r++}n=l<r?s.copy(e,l,r):void 0}(e)}catch(t){this.error(t)}},error(e){i||(i=!0,t.error(e))},complete(){i||(n&&t.next(s.toUtf8String(n,0,n.length)),i=!0,t.complete())},useCancellable(e){if(t.useCancellable){const r=this;t.useCancellable({cancel(){e.cancel(),n=void 0,r.complete()},isCancelled:()=>e.isCancelled()})}}}}class s{constructor(){this._reuse=!1}get reuse(){return this._reuse}set reuse(t){t&&!this.reusedValues&&(this.reusedValues=new Array(10)),this._reuse=t}withReuse(){return this.reuse=!0,this}splitLine(t){if(null==t)return this.lastSplitLength=0,[];let e=0,r=0;const s=this._reuse?this.reusedValues:[];let n=0;for(let i=0;i<t.length;i++){const o=t[i];if(","===o){if(e%2==0){const o=this.getValue(t,r,i,e);this._reuse?s[n++]=o:s.push(o),r=i+1,e=0}}else'"'===o&&e++}const i=this.getValue(t,r,t.length,e);return this._reuse?(s[n]=i,this.lastSplitLength=n+1):(s.push(i),this.lastSplitLength=s.length),s}getValue(t,e,r,s){return e===t.length?"":0===s?t.substring(e,r):2===s?t.substring(e+1,r-1):t.substring(e+1,r-1).replace(/""/gi,'"')}}class n{}function i(){return new n}const o=[404,408,425,429,500,502,503,504];function l(t){return o.includes(t)}class a extends Error{constructor(t){super(t),this.name="IllegalArgumentError",Object.setPrototypeOf(this,a.prototype)}}class u extends Error{constructor(t,e,r,s,n,i){if(super(),this.statusCode=t,this.statusMessage=e,this.body=r,this.contentType=n,Object.setPrototypeOf(this,u.prototype),i)this.message=i;else if(r){if(null==n?void 0:n.startsWith("application/json"))try{this.json=JSON.parse(r),this.message=this.json.message,this.code=this.json.code}catch(t){}this.message||(this.message=`${t} ${e} : ${r}`)}else this.message=`${t} ${e}`;this.name="HttpError",this.setRetryAfter(s)}setRetryAfter(t){"string"==typeof t&&/^[0-9]+$/.test(t)?this._retryAfter=parseInt(t):this._retryAfter=0}canRetry(){return l(this.statusCode)}retryAfter(){return this._retryAfter}}const c=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function h(t,e){if(t){let r;return"function"==typeof t.retryAfter?t.retryAfter():(r=0,e&&e>0?r+Math.round(Math.random()*e):r)}return 0}class f extends Error{constructor(){super(),Object.setPrototypeOf(this,f.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}canRetry(){return!0}retryAfter(){return 0}}class d extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,d.prototype),this.message="Response aborted"}canRetry(){return!0}retryAfter(){return 0}}const p=t=>t,g={boolean:t=>"true"===t,unsignedLong:t=>""===t?null:+t,long:t=>""===t?null:+t,double(t){switch(t){case"":return null;case"+Inf":return Number.POSITIVE_INFINITY;case"-Inf":return Number.NEGATIVE_INFINITY;default:return+t}},string:p,base64Binary:p,duration:t=>""===t?null:t,"dateTime:RFC3339":t=>""===t?null:t};class y{constructor(t){t.forEach((t,e)=>t.index=e),this.columns=t}column(t){for(let e=0;e<this.columns.length;e++){const r=this.columns[e];if(r.label===t)return r}throw new a(`Column ${t} not found!`)}toObject(t){var e;const r={};for(let s=0;s<this.columns.length&&s<t.length;s++){let n=t[s];const i=this.columns[s];""===n&&i.defaultValue&&(n=i.defaultValue),r[i.label]=(null!==(e=g[i.dataType])&&void 0!==e?e:p)(n)}return r}}function m(t){return new y(t)}function w(t){const e=(new s).withReuse();let r,n,o=!0,l=0;return{error(e){t.error(e)},next(s){if(""===s)o=!0,r=void 0;else{const a=e.splitLine(s),u=e.lastSplitLength;if(o){if(!r){r=new Array(u);for(let t=0;t<u;t++)r[t]=i()}if(a[0].startsWith("#")){if("#datatype"===a[0])for(let t=1;t<u;t++)r[t].dataType=a[t];else if("#default"===a[0])for(let t=1;t<u;t++)r[t].defaultValue=a[t];else if("#group"===a[0])for(let t=1;t<u;t++)r[t].group="t"===a[t][0]}else{""===a[0]?(l=1,r=r.slice(1)):l=0;for(let t=l;t<u;t++)r[t-l].label=a[t];n=m(r),o=!1}}else t.next(a.slice(l,u),n)}},complete(){t.complete()},useCancellable(e){t.useCancellable&&t.useCancellable(e)}}}const b={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},x={batchSize:1e3,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function v(t,e){return function(r){let s="",n=0,i=0;for(;i<r.length;){const o=t.indexOf(r[i]);o>=0&&(s+=r.substring(n,i),s+=e[o],n=i+1),i++}return 0==n?r:(n<r.length&&(s+=r.substring(n,r.length)),s)}}const T={measurement:v(", \n\r\t",["\\,","\\ ","\\n","\\r","\\t"]),quoted:function(t,e){const r=v(t,e);return t=>'"'+r(t)+'"'}('"\\',['\\"',"\\\\"]),tag:v(", =\n\r\t",["\\,","\\ ","\\=","\\n","\\r","\\t"])};let O=Date.now(),R=0;function S(){{const t=Date.now();t!==O?(O=t,R=0):R++;const e=String(R);return String(t)+"000000000".substr(0,6-e.length)+e}}function E(){return String(Date.now())+"000000000".substr(0,3)}function D(){return String(Date.now())}function C(){return String(Math.floor(Date.now()/1e3))}const A={s:C,ms:D,us:E,ns:S,seconds:C,millis:D,micros:E,nanos:S},j={s:t=>""+Math.floor(t.getTime()/1e3),ms:t=>""+t.getTime(),us:t=>t.getTime()+"000",ns:t=>t.getTime()+"000000"};function $(t){return void 0===t?S():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?t.getTime()+"000000":String("number"==typeof t?Math.floor(t):t)}const L={error(t,e){console.error("ERROR: "+t,e||"")},warn(t,e){console.warn("WARN: "+t,e||"")}};let _=L;const B={error(t,e){_.error(t,e)},warn(t,e){_.warn(t,e)}};const F=Symbol("FLUX_VALUE");class P{constructor(t){this.fluxValue=t}toString(){return this.fluxValue}[F](){return this.fluxValue}}function I(t){if(null==t)return"";t=t.toString();let e=void 0,r=0;function s(){void 0===e&&(e=t.substring(0,r))}for(;r<t.length;r++){const n=t.charAt(r);switch(n){case"\r":s(),e+="\\r";break;case"\n":s(),e+="\\n";break;case"\t":s(),e+="\\t";break;case'"':case"\\":s(),e=e+"\\"+n;break;case"$":if(r+1<t.length&&"{"===t.charAt(r+1)){s(),r++,e+="\\${";break}null!=e&&(e+=n);break;default:null!=e&&(e+=n)}}return void 0!==e?e:t}function M(t){if("number"==typeof t){if(!isFinite(t))throw new Error("not a flux float: "+t);return t.toString()}const e=String(t);let r=!1;for(const t of e)if("."!==t){if("."!==t&&"-"!==t&&(t<"0"||t>"9"))throw new Error("not a flux float: "+e)}else{if(r)throw new Error("not a flux float: "+e);r=!r}return e}function N(t){return`regexp.compile(v: "${I(t)}")`}function k(t){return new P(String(t))}function z(t){if(void 0===t)return"";if(null===t)return"null";if("boolean"==typeof t)return t.toString();if("string"==typeof t)return`"${I(t)}"`;if("number"==typeof t)return M(t);if("object"==typeof t){if("function"==typeof t[F])return t[F]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return N(t);if(Array.isArray(t))return`[${t.map(z).join(",")}]`}return z(t.toString())}const U="function"==typeof Symbol&&Symbol.observable||"@@observable";function V(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{a(s.next(t))}catch(t){i(t)}}function l(t){try{a(s.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}a((s=s.apply(t,e||[])).next())}))}class H{constructor(t){this.options=Object.assign(Object.assign({},b),t),this.success()}nextDelay(t,e){const r=h(t);if(r&&r>0)return r+Math.round(Math.random()*this.options.retryJitter);if(e&&e>0){if(this.options.randomRetry){let t=Math.max(this.options.minRetryDelay,1),r=t*this.options.exponentialBase;for(let s=1;s<e;s++)if(t=r,r*=this.options.exponentialBase,r>=this.options.maxRetryDelay){r=this.options.maxRetryDelay;break}return t+Math.round(Math.random()*(r-t)+Math.random()*this.options.retryJitter)}let t=Math.max(this.options.minRetryDelay,1);for(let r=1;r<e;r++)if(t*=this.options.exponentialBase,t>=this.options.maxRetryDelay){t=this.options.maxRetryDelay;break}return t+Math.round(Math.random()*this.options.retryJitter)}return 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),this.currentDelay}success(){this.currentDelay=void 0}}class q{constructor(t,e){this.maxLines=t,this.retryLines=e,this.size=0,this.nextRetryTime=0,this.closed=!1,this._timeoutHandle=void 0}addLines(t,e,r,s){if(this.closed)return;if(!t.length)return;let n=Date.now()+r;if(s<n&&(r=s-Date.now(),n=s),n>this.nextRetryTime&&(this.nextRetryTime=n),this.first&&this.size+t.length>this.maxLines){const e=this.size,r=.7*e;do{const t=this.first.next;this.size-=this.first.lines.length,this.first.next=void 0,this.first=t,this.first||(this.last=void 0)}while(this.first&&this.size+t.length>r);B.error(`RetryBuffer: ${e-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines`)}const i={lines:t,retryCount:e,expires:s};this.last?(this.last.next=i,this.last=i):(this.first=i,this.last=i,this.scheduleRetry(r)),this.size+=t.length}removeLines(){if(this.first){const t=this.first;return this.first=this.first.next,t.next=void 0,this.size-=t.lines.length,this.first||(this.last=void 0),t}}scheduleRetry(t){this._timeoutHandle=setTimeout(()=>{const t=this.removeLines();t?this.retryLines(t.lines,t.retryCount,t.expires).then(()=>{this.scheduleRetry(1)}).catch(t=>{this.scheduleRetry(this.nextRetryTime-Date.now())}):this._timeoutHandle=void 0},Math.max(t,0))}flush(){return V(this,void 0,void 0,(function*(){let t;for(;t=this.removeLines();)yield this.retryLines(t.lines,t.retryCount,t.expires)}))}close(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size}}class W{constructor(t,e,r){this.maxChunkRecords=t,this.flushFn=e,this.scheduleSend=r,this.length=0,this.lines=new Array(t)}add(t){0===this.length&&this.scheduleSend(),this.lines[this.length]=t,this.length++,this.length>=this.maxChunkRecords&&this.flush().catch(t=>{})}flush(){const t=this.reset();return t.length>0?this.flushFn(t):Promise.resolve()}reset(){const t=this.lines.slice(0,this.length);return this.length=0,t}}class J{constructor(t,e,r,s,n){this.transport=t,this.closed=!1,this._timeoutHandle=void 0,this.httpPath=`/api/v2/write?org=${encodeURIComponent(e)}&bucket=${encodeURIComponent(r)}&precision=${s}`,this.writeOptions=Object.assign(Object.assign({},x),n),this.currentTime=A[s],this.dateToProtocolTimestamp=j[s],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:Object.assign({"content-type":"text/plain; charset=utf-8"},null==n?void 0:n.headers),gzipThreshold:this.writeOptions.gzipThreshold};var i;this.writeBuffer=new W(this.writeOptions.batchSize,t=>(this._clearFlushTimeout(),this.sendBatch(t,this.writeOptions.maxRetries+1)),()=>{this.writeOptions.flushInterval>0&&(this._clearFlushTimeout(),this.closed||(this._timeoutHandle=setTimeout(()=>this.sendBatch(this.writeBuffer.reset(),this.writeOptions.maxRetries+1).catch(t=>{}),this.writeOptions.flushInterval)))}),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=(i=this.writeOptions,new H(i)),this.retryBuffer=new q(this.writeOptions.maxBufferLines,this.sendBatch)}sendBatch(t,e,r=Date.now()+this.writeOptions.maxRetryTime){const s=this,n=s.writeOptions.maxRetries+2-e;if(!this.closed&&t.length>0){if(r<=Date.now()){const t=new Error("Max retry time exceeded.");return B.error(`Write to InfluxDB failed (attempt: ${n}).`,t),Promise.reject(t)}return new Promise((i,o)=>{let l;const a={responseStarted(t,e){l=e},error(l){const a=s.writeOptions.writeFailed.call(s,l,t,n);if(a)a.then(i,o);else{if(!s.closed&&e>1&&(!(l instanceof u)||l.statusCode>=429))return B.warn(`Write to InfluxDB failed (attempt: ${n}).`,l),s.retryBuffer.addLines(t,e-1,s.retryStrategy.nextDelay(l,n),r),void o(l);B.error("Write to InfluxDB failed.",l),o(l)}},complete(){if(204==l||null==l)s.writeOptions.writeSuccess.call(s,t),s.retryStrategy.success(),i();else{const t=`204 HTTP response status code expected, but ${l} returned`,e=new u(l,t,void 0,"0");e.message=t,a.error(e)}}};this.transport.send(this.httpPath,t.join("\n"),this.sendOptions,a)})}return Promise.resolve()}_clearFlushTimeout(){void 0!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)}writeRecord(t){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(t)}writeRecords(t){if(this.closed)throw new Error("writeApi: already closed!");for(let e=0;e<t.length;e++)this.writeBuffer.add(t[e])}writePoint(t){if(this.closed)throw new Error("writeApi: already closed!");const e=t.toLineProtocol(this);e&&this.writeBuffer.add(e)}writePoints(t){if(this.closed)throw new Error("writeApi: already closed!");for(let e=0;e<t.length;e++){const r=t[e].toLineProtocol(this);r&&this.writeBuffer.add(r)}}flush(t){return V(this,void 0,void 0,(function*(){if(yield this.writeBuffer.flush(),t)return yield this.retryBuffer.flush()}))}close(){return this.writeBuffer.flush().finally(()=>{const t=this.retryBuffer.close();t&&B.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(t){return this.defaultTags=void 0,Object.keys(t).forEach(e=>{(this.defaultTags||(this.defaultTags={}))[e]=T.tag(t[e])}),this}convertTime(t){return void 0===t?this.currentTime():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?this.dateToProtocolTimestamp(t):String("number"==typeof t?Math.floor(t):t)}}function G(t){const e={};return t.headers.forEach((t,r)=>{const s=e[r];void 0===s?e[r]=t:Array.isArray(s)?s.push(t):e[r]=[s,t]}),e}class X{constructor(t){this.connectionOptions=t,this.chunkCombiner=e(),this.requestDecorator=function(){},this.defaultHeaders={"content-type":"application/json; charset=utf-8"},this.connectionOptions.token&&(this.defaultHeaders.Authorization="Token "+this.connectionOptions.token),this.url=String(this.connectionOptions.url),this.url.endsWith("/")&&(this.url=this.url.substring(0,this.url.length-1)),this.url.endsWith("/api/v2")&&(this.url=this.url.substring(0,this.url.length-"/api/v2".length),B.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this.url} !`))}send(t,e,r,s){const n=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)}}}(s);let i=!1,o=r.signal;if(s&&s.useCancellable){const t=new AbortController;o||(o=t.signal,r=Object.assign(Object.assign({},r),o)),s.useCancellable({cancel(){i=!0,t.abort()},isCancelled:()=>i||o.aborted})}this.fetch(t,e,r).then(t=>V(this,void 0,void 0,(function*(){if((null==s?void 0:s.responseStarted)&&n.responseStarted(G(t),t.status),t.status>=300)return t.text().then(e=>{if(!e){const r=t.headers.get("x-influxdb-error");r&&(e=r)}n.error(new u(t.status,t.statusText,e,t.headers.get("retry-after"),t.headers.get("content-type")))}).catch(e=>{B.warn("Unable to receive error body",e),n.error(new u(t.status,t.statusText,void 0,t.headers.get("retry-after"),t.headers.get("content-type")))});if(t.body){const e=t.body.getReader();let r;do{r=yield e.read(),n.next(r.value)}while(!r.done)}else if(t.arrayBuffer){const e=yield t.arrayBuffer();n.next(new Uint8Array(e))}else{const e=yield t.text();n.next((new TextEncoder).encode(e))}}))).catch(t=>{i||n.error(t)}).finally(()=>n.complete())}request(t,e,r,s){var n,i;return V(this,void 0,void 0,(function*(){const o=yield this.fetch(t,e,r),{status:l,headers:a}=o,c=a.get("content-type")||"";if(s&&s(G(o),o.status),l>=300){let t=yield o.text();if(!t){const e=a.get("x-influxdb-error");e&&(t=e)}throw new u(l,o.statusText,t,o.headers.get("retry-after"),o.headers.get("content-type"))}const h=null!==(i=null===(n=r.headers)||void 0===n?void 0:n.accept)&&void 0!==i?i:c;return h.includes("json")?yield o.json():h.includes("text")||h.startsWith("application/csv")?yield o.text():void 0}))}fetch(t,e,r){const{method:s,headers:n}=r,i=
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@influxdata/influxdb-client"]={})}(this,(function(t){"use strict";function e(){const t=new TextDecoder("utf-8");return{concat(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r},copy(t,e,r){const s=new Uint8Array(r-e);return s.set(t.subarray(e,r)),s},toUtf8String:(e,r,s)=>t.decode(e.subarray(r,s))}}function r(t,r){const s=null!=r?r:e();let n,i=!1,o=!1;return{next(e){if(!i)try{!function(e){let r,l=0;for(n?(e=s.concat(n,e),r=n.length):r=0;r<e.length;){const n=e[r];if(10===n){if(!o){const n=r>0&&13===e[r-1]?r-1:r;if(i)return;t.next(s.toUtf8String(e,l,n)),l=r+1}}else 34===n&&(o=!o);r++}n=l<r?s.copy(e,l,r):void 0}(e)}catch(t){this.error(t)}},error(e){i||(i=!0,t.error(e))},complete(){i||(n&&t.next(s.toUtf8String(n,0,n.length)),i=!0,t.complete())},useCancellable(e){if(t.useCancellable){const r=this;t.useCancellable({cancel(){e.cancel(),n=void 0,r.complete()},isCancelled:()=>e.isCancelled()})}}}}class s{constructor(){this._reuse=!1}get reuse(){return this._reuse}set reuse(t){t&&!this.reusedValues&&(this.reusedValues=new Array(10)),this._reuse=t}withReuse(){return this.reuse=!0,this}splitLine(t){if(null==t)return this.lastSplitLength=0,[];let e=0,r=0;const s=this._reuse?this.reusedValues:[];let n=0;for(let i=0;i<t.length;i++){const o=t[i];if(","===o){if(e%2==0){const o=this.getValue(t,r,i,e);this._reuse?s[n++]=o:s.push(o),r=i+1,e=0}}else'"'===o&&e++}const i=this.getValue(t,r,t.length,e);return this._reuse?(s[n]=i,this.lastSplitLength=n+1):(s.push(i),this.lastSplitLength=s.length),s}getValue(t,e,r,s){return e===t.length?"":0===s?t.substring(e,r):2===s?t.substring(e+1,r-1):t.substring(e+1,r-1).replace(/""/gi,'"')}}class n{}function i(){return new n}const o=[404,408,425,429,500,502,503,504];function l(t){return o.includes(t)}class a extends Error{constructor(t){super(t),this.name="IllegalArgumentError",Object.setPrototypeOf(this,a.prototype)}}class u extends Error{constructor(t,e,r,s,n,i){if(super(),this.statusCode=t,this.statusMessage=e,this.body=r,this.contentType=n,Object.setPrototypeOf(this,u.prototype),i)this.message=i;else if(r){if(null==n?void 0:n.startsWith("application/json"))try{this.json=JSON.parse(r),this.message=this.json.message,this.code=this.json.code}catch(t){}this.message||(this.message=`${t} ${e} : ${r}`)}else this.message=`${t} ${e}`;this.name="HttpError",this.setRetryAfter(s)}setRetryAfter(t){"string"==typeof t&&/^[0-9]+$/.test(t)?this._retryAfter=parseInt(t):this._retryAfter=0}canRetry(){return l(this.statusCode)}retryAfter(){return this._retryAfter}}const c=["ECONNRESET","ENOTFOUND","ESOCKETTIMEDOUT","ETIMEDOUT","ECONNREFUSED","EHOSTUNREACH","EPIPE"];function h(t,e){if(t){let r;return"function"==typeof t.retryAfter?t.retryAfter():(r=0,e&&e>0?r+Math.round(Math.random()*e):r)}return 0}class f extends Error{constructor(){super(),Object.setPrototypeOf(this,f.prototype),this.name="RequestTimedOutError",this.message="Request timed out"}canRetry(){return!0}retryAfter(){return 0}}class d extends Error{constructor(){super(),this.name="AbortError",Object.setPrototypeOf(this,d.prototype),this.message="Response aborted"}canRetry(){return!0}retryAfter(){return 0}}const p=t=>t,g={boolean:t=>"true"===t,unsignedLong:t=>""===t?null:+t,long:t=>""===t?null:+t,double(t){switch(t){case"":return null;case"+Inf":return Number.POSITIVE_INFINITY;case"-Inf":return Number.NEGATIVE_INFINITY;default:return+t}},string:p,base64Binary:p,duration:t=>""===t?null:t,"dateTime:RFC3339":t=>""===t?null:t};class y{constructor(t){t.forEach((t,e)=>t.index=e),this.columns=t}column(t){for(let e=0;e<this.columns.length;e++){const r=this.columns[e];if(r.label===t)return r}throw new a(`Column ${t} not found!`)}toObject(t){var e;const r={};for(let s=0;s<this.columns.length&&s<t.length;s++){let n=t[s];const i=this.columns[s];""===n&&i.defaultValue&&(n=i.defaultValue),r[i.label]=(null!==(e=g[i.dataType])&&void 0!==e?e:p)(n)}return r}}function m(t){return new y(t)}function w(t){const e=(new s).withReuse();let r,n,o=!0,l=0;return{error(e){t.error(e)},next(s){if(""===s)o=!0,r=void 0;else{const a=e.splitLine(s),u=e.lastSplitLength;if(o){if(!r){r=new Array(u);for(let t=0;t<u;t++)r[t]=i()}if(a[0].startsWith("#")){if("#datatype"===a[0])for(let t=1;t<u;t++)r[t].dataType=a[t];else if("#default"===a[0])for(let t=1;t<u;t++)r[t].defaultValue=a[t];else if("#group"===a[0])for(let t=1;t<u;t++)r[t].group="t"===a[t][0]}else{""===a[0]?(l=1,r=r.slice(1)):l=0;for(let t=l;t<u;t++)r[t-l].label=a[t];n=m(r),o=!1}}else t.next(a.slice(l,u),n)}},complete(){t.complete()},useCancellable(e){t.useCancellable&&t.useCancellable(e)}}}const b={retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:5,randomRetry:!0},x={batchSize:1e3,flushInterval:6e4,writeFailed:function(){},writeSuccess:function(){},maxRetries:5,maxRetryTime:18e4,maxBufferLines:32e3,retryJitter:200,minRetryDelay:5e3,maxRetryDelay:125e3,exponentialBase:2,gzipThreshold:1e3,randomRetry:!0};function v(t,e){return function(r){let s="",n=0,i=0;for(;i<r.length;){const o=t.indexOf(r[i]);o>=0&&(s+=r.substring(n,i),s+=e[o],n=i+1),i++}return 0==n?r:(n<r.length&&(s+=r.substring(n,r.length)),s)}}const T={measurement:v(", \n\r\t",["\\,","\\ ","\\n","\\r","\\t"]),quoted:function(t,e){const r=v(t,e);return t=>'"'+r(t)+'"'}('"\\',['\\"',"\\\\"]),tag:v(", =\n\r\t",["\\,","\\ ","\\=","\\n","\\r","\\t"])};let R=Date.now(),O=0;function S(){{const t=Date.now();t!==R?(R=t,O=0):O++;const e=String(O);return String(t)+"000000000".substr(0,6-e.length)+e}}function E(){return String(Date.now())+"000000000".substr(0,3)}function D(){return String(Date.now())}function C(){return String(Math.floor(Date.now()/1e3))}const A={s:C,ms:D,us:E,ns:S,seconds:C,millis:D,micros:E,nanos:S},$={s:t=>""+Math.floor(t.getTime()/1e3),ms:t=>""+t.getTime(),us:t=>t.getTime()+"000",ns:t=>t.getTime()+"000000"};function j(t){return void 0===t?S():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?t.getTime()+"000000":String("number"==typeof t?Math.floor(t):t)}const L={error(t,e){console.error("ERROR: "+t,e||"")},warn(t,e){console.warn("WARN: "+t,e||"")}};let _=L;const B={error(t,e){_.error(t,e)},warn(t,e){_.warn(t,e)}};const F=Symbol("FLUX_VALUE");class P{constructor(t){this.fluxValue=t}toString(){return this.fluxValue}[F](){return this.fluxValue}}function I(t){if(null==t)return"";t=t.toString();let e=void 0,r=0;function s(){void 0===e&&(e=t.substring(0,r))}for(;r<t.length;r++){const n=t.charAt(r);switch(n){case"\r":s(),e+="\\r";break;case"\n":s(),e+="\\n";break;case"\t":s(),e+="\\t";break;case'"':case"\\":s(),e=e+"\\"+n;break;case"$":if(r+1<t.length&&"{"===t.charAt(r+1)){s(),r++,e+="\\${";break}null!=e&&(e+=n);break;default:null!=e&&(e+=n)}}return void 0!==e?e:t}function M(t){if("number"==typeof t){if(!isFinite(t))throw new Error("not a flux float: "+t);return t.toString()}const e=String(t);let r=!1;for(const t of e)if("."!==t){if("."!==t&&"-"!==t&&(t<"0"||t>"9"))throw new Error("not a flux float: "+e)}else{if(r)throw new Error("not a flux float: "+e);r=!r}return e}function N(t){return`regexp.compile(v: "${I(t)}")`}function k(t){return new P(String(t))}function z(t){if(void 0===t)return"";if(null===t)return"null";if("boolean"==typeof t)return t.toString();if("string"==typeof t)return`"${I(t)}"`;if("number"==typeof t)return M(t);if("object"==typeof t){if("function"==typeof t[F])return t[F]();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return N(t);if(Array.isArray(t))return`[${t.map(z).join(",")}]`}return z(t.toString())}const U="function"==typeof Symbol&&Symbol.observable||"@@observable";function V(t,e,r,s){return new(r||(r=Promise))((function(n,i){function o(t){try{a(s.next(t))}catch(t){i(t)}}function l(t){try{a(s.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}a((s=s.apply(t,e||[])).next())}))}class H{constructor(t){this.options=Object.assign(Object.assign({},b),t),this.success()}nextDelay(t,e){const r=h(t);if(r&&r>0)return r+Math.round(Math.random()*this.options.retryJitter);if(e&&e>0){if(this.options.randomRetry){let t=Math.max(this.options.minRetryDelay,1),r=t*this.options.exponentialBase;for(let s=1;s<e;s++)if(t=r,r*=this.options.exponentialBase,r>=this.options.maxRetryDelay){r=this.options.maxRetryDelay;break}return t+Math.round(Math.random()*(r-t)+Math.random()*this.options.retryJitter)}let t=Math.max(this.options.minRetryDelay,1);for(let r=1;r<e;r++)if(t*=this.options.exponentialBase,t>=this.options.maxRetryDelay){t=this.options.maxRetryDelay;break}return t+Math.round(Math.random()*this.options.retryJitter)}return 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),this.currentDelay}success(){this.currentDelay=void 0}}class q{constructor(t,e){this.maxLines=t,this.retryLines=e,this.size=0,this.nextRetryTime=0,this.closed=!1,this._timeoutHandle=void 0}addLines(t,e,r,s){if(this.closed)return;if(!t.length)return;let n=Date.now()+r;if(s<n&&(r=s-Date.now(),n=s),n>this.nextRetryTime&&(this.nextRetryTime=n),this.first&&this.size+t.length>this.maxLines){const e=this.size,r=.7*e;do{const t=this.first.next;this.size-=this.first.lines.length,this.first.next=void 0,this.first=t,this.first||(this.last=void 0)}while(this.first&&this.size+t.length>r);B.error(`RetryBuffer: ${e-this.size} oldest lines removed to keep buffer size under the limit of ${this.maxLines} lines`)}const i={lines:t,retryCount:e,expires:s};this.last?(this.last.next=i,this.last=i):(this.first=i,this.last=i,this.scheduleRetry(r)),this.size+=t.length}removeLines(){if(this.first){const t=this.first;return this.first=this.first.next,t.next=void 0,this.size-=t.lines.length,this.first||(this.last=void 0),t}}scheduleRetry(t){this._timeoutHandle=setTimeout(()=>{const t=this.removeLines();t?this.retryLines(t.lines,t.retryCount,t.expires).then(()=>{this.scheduleRetry(1)}).catch(t=>{this.scheduleRetry(this.nextRetryTime-Date.now())}):this._timeoutHandle=void 0},Math.max(t,0))}flush(){return V(this,void 0,void 0,(function*(){let t;for(;t=this.removeLines();)yield this.retryLines(t.lines,t.retryCount,t.expires)}))}close(){return this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0),this.closed=!0,this.size}}class W{constructor(t,e,r){this.maxChunkRecords=t,this.flushFn=e,this.scheduleSend=r,this.length=0,this.lines=new Array(t)}add(t){0===this.length&&this.scheduleSend(),this.lines[this.length]=t,this.length++,this.length>=this.maxChunkRecords&&this.flush().catch(t=>{})}flush(){const t=this.reset();return t.length>0?this.flushFn(t):Promise.resolve()}reset(){const t=this.lines.slice(0,this.length);return this.length=0,t}}class J{constructor(t,e,r,s,n){this.transport=t,this.closed=!1,this._timeoutHandle=void 0,this.httpPath=`/api/v2/write?org=${encodeURIComponent(e)}&bucket=${encodeURIComponent(r)}&precision=${s}`,this.writeOptions=Object.assign(Object.assign({},x),n),this.currentTime=A[s],this.dateToProtocolTimestamp=$[s],this.writeOptions.defaultTags&&this.useDefaultTags(this.writeOptions.defaultTags),this.sendOptions={method:"POST",headers:Object.assign({"content-type":"text/plain; charset=utf-8"},null==n?void 0:n.headers),gzipThreshold:this.writeOptions.gzipThreshold};var i;this.writeBuffer=new W(this.writeOptions.batchSize,t=>(this._clearFlushTimeout(),this.sendBatch(t,this.writeOptions.maxRetries+1)),()=>{this.writeOptions.flushInterval>0&&(this._clearFlushTimeout(),this.closed||(this._timeoutHandle=setTimeout(()=>this.sendBatch(this.writeBuffer.reset(),this.writeOptions.maxRetries+1).catch(t=>{}),this.writeOptions.flushInterval)))}),this.sendBatch=this.sendBatch.bind(this),this.retryStrategy=(i=this.writeOptions,new H(i)),this.retryBuffer=new q(this.writeOptions.maxBufferLines,this.sendBatch)}sendBatch(t,e,r=Date.now()+this.writeOptions.maxRetryTime){const s=this,n=s.writeOptions.maxRetries+2-e;if(!this.closed&&t.length>0){if(r<=Date.now()){const t=new Error("Max retry time exceeded.");return B.error(`Write to InfluxDB failed (attempt: ${n}).`,t),Promise.reject(t)}return new Promise((i,o)=>{let l;const a={responseStarted(t,e){l=e},error(l){const a=s.writeOptions.writeFailed.call(s,l,t,n);if(a)a.then(i,o);else{if(!s.closed&&e>1&&(!(l instanceof u)||l.statusCode>=429))return B.warn(`Write to InfluxDB failed (attempt: ${n}).`,l),s.retryBuffer.addLines(t,e-1,s.retryStrategy.nextDelay(l,n),r),void o(l);B.error("Write to InfluxDB failed.",l),o(l)}},complete(){if(204==l||null==l)s.writeOptions.writeSuccess.call(s,t),s.retryStrategy.success(),i();else{const t=`204 HTTP response status code expected, but ${l} returned`,e=new u(l,t,void 0,"0");e.message=t,a.error(e)}}};this.transport.send(this.httpPath,t.join("\n"),this.sendOptions,a)})}return Promise.resolve()}_clearFlushTimeout(){void 0!==this._timeoutHandle&&(clearTimeout(this._timeoutHandle),this._timeoutHandle=void 0)}writeRecord(t){if(this.closed)throw new Error("writeApi: already closed!");this.writeBuffer.add(t)}writeRecords(t){if(this.closed)throw new Error("writeApi: already closed!");for(let e=0;e<t.length;e++)this.writeBuffer.add(t[e])}writePoint(t){if(this.closed)throw new Error("writeApi: already closed!");const e=t.toLineProtocol(this);e&&this.writeBuffer.add(e)}writePoints(t){if(this.closed)throw new Error("writeApi: already closed!");for(let e=0;e<t.length;e++){const r=t[e].toLineProtocol(this);r&&this.writeBuffer.add(r)}}flush(t){return V(this,void 0,void 0,(function*(){if(yield this.writeBuffer.flush(),t)return yield this.retryBuffer.flush()}))}close(){return this.writeBuffer.flush().finally(()=>{const t=this.retryBuffer.close();t&&B.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(t){return this.defaultTags=t,this}convertTime(t){return void 0===t?this.currentTime():"string"==typeof t?t.length>0?t:void 0:t instanceof Date?this.dateToProtocolTimestamp(t):String("number"==typeof t?Math.floor(t):t)}}function G(t){const e={};return t.headers.forEach((t,r)=>{const s=e[r];void 0===s?e[r]=t:Array.isArray(s)?s.push(t):e[r]=[s,t]}),e}class X{constructor(t){this.connectionOptions=t,this.chunkCombiner=e(),this.requestDecorator=function(){},this.defaultHeaders={"content-type":"application/json; charset=utf-8"},this.connectionOptions.token&&(this.defaultHeaders.Authorization="Token "+this.connectionOptions.token),this.url=String(this.connectionOptions.url),this.url.endsWith("/")&&(this.url=this.url.substring(0,this.url.length-1)),this.url.endsWith("/api/v2")&&(this.url=this.url.substring(0,this.url.length-"/api/v2".length),B.warn(`Please remove '/api/v2' context path from InfluxDB base url, using ${this.url} !`))}send(t,e,r,s){const n=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)}}}(s);let i=!1,o=r.signal;if(s&&s.useCancellable){const t=new AbortController;o||(o=t.signal,r=Object.assign(Object.assign({},r),o)),s.useCancellable({cancel(){i=!0,t.abort()},isCancelled:()=>i||o.aborted})}this.fetch(t,e,r).then(t=>V(this,void 0,void 0,(function*(){if((null==s?void 0:s.responseStarted)&&n.responseStarted(G(t),t.status),t.status>=300)return t.text().then(e=>{if(!e){const r=t.headers.get("x-influxdb-error");r&&(e=r)}n.error(new u(t.status,t.statusText,e,t.headers.get("retry-after"),t.headers.get("content-type")))}).catch(e=>{B.warn("Unable to receive error body",e),n.error(new u(t.status,t.statusText,void 0,t.headers.get("retry-after"),t.headers.get("content-type")))});if(t.body){const e=t.body.getReader();let r;do{r=yield e.read(),n.next(r.value)}while(!r.done)}else if(t.arrayBuffer){const e=yield t.arrayBuffer();n.next(new Uint8Array(e))}else{const e=yield t.text();n.next((new TextEncoder).encode(e))}}))).catch(t=>{i||n.error(t)}).finally(()=>n.complete())}request(t,e,r,s){var n,i;return V(this,void 0,void 0,(function*(){const o=yield this.fetch(t,e,r),{status:l,headers:a}=o,c=a.get("content-type")||"";if(s&&s(G(o),o.status),l>=300){let t=yield o.text();if(!t){const e=a.get("x-influxdb-error");e&&(t=e)}throw new u(l,o.statusText,t,o.headers.get("retry-after"),o.headers.get("content-type"))}const h=null!==(i=null===(n=r.headers)||void 0===n?void 0:n.accept)&&void 0!==i?i:c;return h.includes("json")?yield o.json():h.includes("text")||h.startsWith("application/csv")?yield o.text():void 0}))}fetch(t,e,r){const{method:s,headers:n}=r,i=
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -13,5 +13,5 @@
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}(r,["method","headers"]),o=`${this.url}${t}`,l=Object.assign({method:s,body:"GET"===s||"HEAD"===s?void 0:"string"==typeof e?e:JSON.stringify(e),headers:Object.assign(Object.assign({},this.defaultHeaders),n),credentials:"omit"},i);return this.requestDecorator(l,r,o),fetch(o,l)}}const Y={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class K{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new K(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:Y,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:Y,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 Q{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 Z(){}class tt{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):Z,error:r?r.bind(t):Z,complete:s?s.bind(t):Z}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new Q(this.decorator(s),this.executor)}[U](){return this}}function et(t,e){return e.toObject(t)}class rt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new tt(this.executor,t=>r(t,this.chunkCombiner))}rows(){return new tt(this.executor,t=>r(w({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner))}consumeLines(t){this.executor(r(t,this.chunkCombiner))}consumeRows(t){this.executor(r(w(t),this.chunkCombiner))}collectRows(t=et){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)}})})}}t.AbortError=d,t.DEFAULT_ConnectionOptions={timeout:1e4},t.DEFAULT_RetryDelayStrategyOptions=b,t.DEFAULT_WriteOptions=x,t.FLUX_VALUE=F,t.HttpError=u,t.IllegalArgumentError=a,t.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new a("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new a("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 X(this._options),this.processCSVResponse=t=>new rt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new J(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new K(this.transport,this.processCSVResponse,t)}},t.LineSplitter=s,t.Log=B,t.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]=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+=`${T.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+=`${T.tag(t)}=${T.tag(e)}`)}});let n=this.time;return n=t&&t.convertTime?t.convertTime(n):$(n),`${T.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)}},t.RequestTimedOutError=f,t.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!c.includes(t.code)))},t.chunksToLines=r,t.consoleLogger=L,t.convertTimeToNanos=$,t.createFluxTableColumn=function(t){var e,r;const s=new n;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},t.createFluxTableMetaData=m,t.createTextDecoderCombiner=e,t.currentTime=A,t.dateToProtocolTimestamp=j,t.escape=T,t.flux=function(t,...e){if(1==t.length&&0===e.length)return k(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=I(l);else if(a=z(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[F]))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 k(r.join(""))},t.fluxBool=function(t){return new P("true"===t||"false"===t?t:(!!t).toString())},t.fluxDateTime=function(t){return new P(function(t){return`time(v: "${I(t)}")`}(t))},t.fluxDuration=function(t){return new P(`duration(v: "${I(t)}")`)},t.fluxExpression=k,t.fluxFloat=function(t){return new P(M(t))},t.fluxInteger=function(t){const e=M(t);for(const t of e)if("."===t)throw new Error("not a flux integer: "+e);return new P(e)},t.fluxRegExp=function(t){return new P(N(t))},t.fluxString=function(t){return new P(`"${I(t)}"`)},t.getRetryDelay=h,t.isStatusCodeRetriable=l,t.linesToTables=w,t.newFluxTableColumn=i,t.sanitizeFloat=M,t.serializeDateTimeAsDate=function(){g["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},t.serializeDateTimeAsNumber=function(){g["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},t.serializeDateTimeAsString=function(){g["dateTime:RFC3339"]=t=>""===t?null:t},t.setLogger=function(t){const e=_;return _=t,e},t.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()},t.symbolObservable=U,t.toFluxValue=z,t.typeSerializers=g,t.useProcessHrtime=function(t){return!1},Object.defineProperty(t,"__esModule",{value:!0})}));
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}(r,["method","headers"]),o=`${this.url}${t}`,l=Object.assign({method:s,body:"GET"===s||"HEAD"===s?void 0:"string"==typeof e?e:JSON.stringify(e),headers:Object.assign(Object.assign({},this.defaultHeaders),n),credentials:"omit"},i);return this.requestDecorator(l,r,o),fetch(o,l)}}const Y={header:!0,delimiter:",",quoteChar:'"',commentPrefix:"#",annotations:["datatype","group","default"]};class K{constructor(t,e,r){this.transport=t,this.createCSVResponse=e,this.options="string"==typeof r?{org:r}:r}with(t){return new K(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:Y,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:Y,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 Q{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 Z(){}class tt{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):Z,error:r?r.bind(t):Z,complete:s?s.bind(t):Z}}("object"!=typeof t||null===t?{next:t,error:e,complete:r}:t);return new Q(this.decorator(s),this.executor)}[U](){return this}}function et(t,e){return e.toObject(t)}class rt{constructor(t,e){this.executor=t,this.chunkCombiner=e}lines(){return new tt(this.executor,t=>r(t,this.chunkCombiner))}rows(){return new tt(this.executor,t=>r(w({next(e,r){t.next({values:e,tableMeta:r})},error(e){t.error(e)},complete(){t.complete()}}),this.chunkCombiner))}consumeLines(t){this.executor(r(t,this.chunkCombiner))}consumeRows(t){this.executor(r(w(t),this.chunkCombiner))}collectRows(t=et){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)}})})}}t.AbortError=d,t.DEFAULT_ConnectionOptions={timeout:1e4},t.DEFAULT_RetryDelayStrategyOptions=b,t.DEFAULT_WriteOptions=x,t.FLUX_VALUE=F,t.HttpError=u,t.IllegalArgumentError=a,t.InfluxDB=class{constructor(t){var e;if("string"==typeof t)this._options={url:t};else{if(null===t||"object"!=typeof t)throw new a("No url or configuration specified!");this._options=t}const r=this._options.url;if("string"!=typeof r)throw new a("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 X(this._options),this.processCSVResponse=t=>new rt(t,this.transport.chunkCombiner)}getWriteApi(t,e,r="ns",s){return new J(this.transport,t,e,r,null!=s?s:this._options.writeOptions)}getQueryApi(t){return new K(this.transport,this.processCSVResponse,t)}},t.LineSplitter=s,t.Log=B,t.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]=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+=`${T.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+=`${T.tag(t)}=${T.tag(e)}`)}});let n=this.time;return n=t&&t.convertTime?t.convertTime(n):j(n),`${T.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)}},t.RequestTimedOutError=f,t.canRetryHttpCall=function(t){return!!t&&("function"==typeof t.canRetry?!!t.canRetry():!(!t.code||!c.includes(t.code)))},t.chunksToLines=r,t.consoleLogger=L,t.convertTimeToNanos=j,t.createFluxTableColumn=function(t){var e,r;const s=new n;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},t.createFluxTableMetaData=m,t.createTextDecoderCombiner=e,t.currentTime=A,t.dateToProtocolTimestamp=$,t.escape=T,t.flux=function(t,...e){if(1==t.length&&0===e.length)return k(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=I(l);else if(a=z(l),""===a&&("object"!=typeof(n=l)||"function"!=typeof n[F]))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 k(r.join(""))},t.fluxBool=function(t){return new P("true"===t||"false"===t?t:(!!t).toString())},t.fluxDateTime=function(t){return new P(function(t){return`time(v: "${I(t)}")`}(t))},t.fluxDuration=function(t){return new P(`duration(v: "${I(t)}")`)},t.fluxExpression=k,t.fluxFloat=function(t){return new P(M(t))},t.fluxInteger=function(t){const e=M(t);for(const t of e)if("."===t)throw new Error("not a flux integer: "+e);return new P(e)},t.fluxRegExp=function(t){return new P(N(t))},t.fluxString=function(t){return new P(`"${I(t)}"`)},t.getRetryDelay=h,t.isStatusCodeRetriable=l,t.linesToTables=w,t.newFluxTableColumn=i,t.sanitizeFloat=M,t.serializeDateTimeAsDate=function(){g["dateTime:RFC3339"]=t=>""===t?null:new Date(Date.parse(t))},t.serializeDateTimeAsNumber=function(){g["dateTime:RFC3339"]=t=>""===t?null:Date.parse(t)},t.serializeDateTimeAsString=function(){g["dateTime:RFC3339"]=t=>""===t?null:t},t.setLogger=function(t){const e=_;return _=t,e},t.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()},t.symbolObservable=U,t.toFluxValue=z,t.typeSerializers=g,t.useProcessHrtime=function(t){return!1},Object.defineProperty(t,"__esModule",{value:!0})}));
17
17
  //# sourceMappingURL=index.browser.js.map
Binary file