@influxdata/influxdb3-client-browser 0.3.0 → 0.3.1

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.
@@ -0,0 +1,947 @@
1
+ /** IllegalArgumentError is thrown when illegal argument is supplied. */
2
+ declare class IllegalArgumentError extends Error {
3
+ constructor(message: string);
4
+ }
5
+ /**
6
+ * A general HTTP error.
7
+ */
8
+ declare class HttpError extends Error {
9
+ readonly statusCode: number;
10
+ readonly statusMessage: string | undefined;
11
+ readonly body?: string | undefined;
12
+ readonly contentType?: string | null | undefined;
13
+ /** application error code, when available */
14
+ code: string | undefined;
15
+ /** json error response */
16
+ json: any;
17
+ constructor(statusCode: number, statusMessage: string | undefined, body?: string | undefined, contentType?: string | null | undefined, message?: string);
18
+ }
19
+ /** RequestTimedOutError indicates request timeout in the communication with the server */
20
+ declare class RequestTimedOutError extends Error {
21
+ constructor();
22
+ }
23
+ /** AbortError indicates that the communication with the server was aborted */
24
+ declare class AbortError extends Error {
25
+ constructor();
26
+ }
27
+
28
+ /**
29
+ * ChunkCombiner is a simplified platform-neutral manipulation of Uint8arrays
30
+ * that allows to process text data on the fly. The implementation can be optimized
31
+ * for the target platform (node vs browser).
32
+ */
33
+ interface ChunkCombiner {
34
+ /**
35
+ * Concatenates first and second chunk.
36
+ * @param first - first chunk
37
+ * @param second - second chunk
38
+ * @returns first + second
39
+ */
40
+ concat(first: Uint8Array, second: Uint8Array): Uint8Array;
41
+ /**
42
+ * Converts chunk into a string.
43
+ * @param chunk - chunk
44
+ * @param start - start index
45
+ * @param end - end index
46
+ * @returns string representation of chunk slice
47
+ */
48
+ toUtf8String(chunk: Uint8Array, start: number, end: number): string;
49
+ /**
50
+ * Creates a new chunk from the supplied chunk.
51
+ * @param chunk - chunk to copy
52
+ * @param start - start index
53
+ * @param end - end index
54
+ * @returns a copy of a chunk slice
55
+ */
56
+ copy(chunk: Uint8Array, start: number, end: number): Uint8Array;
57
+ }
58
+ /**
59
+ * Creates a chunk combiner instance that uses UTF-8
60
+ * TextDecoder to decode Uint8Arrays into strings.
61
+ */
62
+ declare function createTextDecoderCombiner(): ChunkCombiner;
63
+
64
+ /**
65
+ * Allows to cancel a running execution.
66
+ */
67
+ interface Cancellable {
68
+ /**
69
+ * Cancels execution.
70
+ */
71
+ cancel(): void;
72
+ isCancelled(): boolean;
73
+ }
74
+
75
+ /**
76
+ * Type of HTTP headers.
77
+ */
78
+ type HttpHeaders = {
79
+ [header: string]: string | string[] | undefined;
80
+ };
81
+
82
+ /**
83
+ * Informs about a start of response processing.
84
+ * @param headers - response HTTP headers
85
+ * @param statusCode - response status code
86
+ */
87
+ type ResponseStartedFn = (headers: HttpHeaders, statusCode?: number) => void;
88
+ /**
89
+ * Observes communication with the server.
90
+ */
91
+ interface CommunicationObserver<T> {
92
+ /**
93
+ * Data chunk received, can be called multiple times.
94
+ * @param data - data
95
+ * @returns when `false` value is returned and {@link CommunicationObserver.useResume} is defined,
96
+ * future calls to `next` are paused until resume is called.
97
+ */
98
+ next(data: T): void | boolean;
99
+ /**
100
+ * Communication ended with an error.
101
+ */
102
+ error(error: Error): void;
103
+ /**
104
+ * Communication was successful.
105
+ */
106
+ complete(): void;
107
+ /**
108
+ * Informs about a start of response processing.
109
+ */
110
+ responseStarted?: ResponseStartedFn;
111
+ /**
112
+ * Setups cancelllable for this communication.
113
+ */
114
+ useCancellable?: (cancellable: Cancellable) => void;
115
+ /**
116
+ * Setups a callback that resumes reading of next data, it is called whenever
117
+ * {@link CommunicationObserver.next} returns `false`.
118
+ *
119
+ * @param resume - a function that will resume reading of next data when called
120
+ */
121
+ useResume?: (resume: () => void) => void;
122
+ }
123
+
124
+ /**
125
+ * Options for sending a request message.
126
+ */
127
+ interface SendOptions {
128
+ /** HTTP method (POST, PUT, GET, PATCH ...) */
129
+ method: string;
130
+ /** Request HTTP headers. */
131
+ headers?: {
132
+ [key: string]: string;
133
+ };
134
+ /** When specified, message body larger than the treshold is gzipped */
135
+ gzipThreshold?: number;
136
+ /** Abort signal */
137
+ signal?: AbortSignal;
138
+ }
139
+ /**
140
+ * Simpified platform-neutral transport layer for communication with InfluxDB.
141
+ */
142
+ interface Transport {
143
+ /**
144
+ * Send data to the server and receive communication events via callbacks.
145
+ *
146
+ * @param path - HTTP request path
147
+ * @param requestBody - HTTP request body
148
+ * @param options - send options
149
+ * @param callbacks - communication callbacks to received data in Uint8Array
150
+ */
151
+ send(path: string, requestBody: string, options: SendOptions, callbacks?: Partial<CommunicationObserver<Uint8Array>>): void;
152
+ /**
153
+ * Sends data to the server and receives decoded result. The type of the result depends on
154
+ * response's content-type (deserialized json, text).
155
+
156
+ * @param path - HTTP request path
157
+ * @param requestBody - request body
158
+ * @param options - send options
159
+ * @returns response data
160
+ */
161
+ request(path: string, requestBody: any, options: SendOptions, responseStarted?: ResponseStartedFn): Promise<any>;
162
+ /**
163
+ * Sends requestBody and returns response chunks in an async iterable
164
+ * that can be easily consumed in an `for-await` loop.
165
+ *
166
+ * @param path - HTTP request path
167
+ * @param requestBody - request body
168
+ * @param options - send options
169
+ * @returns async iterable
170
+ */
171
+ iterate(path: string, requestBody: any, options: SendOptions): AsyncIterableIterator<Uint8Array>;
172
+ }
173
+
174
+ /**
175
+ * Option for the communication with InfluxDB server.
176
+ */
177
+ interface ConnectionOptions {
178
+ /** base host URL */
179
+ host: string;
180
+ /** authentication token */
181
+ token?: string;
182
+ /**
183
+ * socket timeout, 10000 milliseconds by default in node.js
184
+ * @defaultValue 10000
185
+ */
186
+ timeout?: number;
187
+ /**
188
+ * default database for write query if not present as argument.
189
+ */
190
+ database?: string;
191
+ /**
192
+ * TransportOptions supply extra options for the transport layer, they differ between node.js and browser/deno.
193
+ * Node.js transport accepts options specified in {@link https://nodejs.org/api/http.html#http_http_request_options_callback | http.request } or
194
+ * {@link https://nodejs.org/api/https.html#https_https_request_options_callback | https.request }. For example, an `agent` property can be set to
195
+ * {@link https://www.npmjs.com/package/proxy-http-agent | setup HTTP/HTTPS proxy }, {@link https://nodejs.org/api/tls.html#tls_tls_connect_options_callback | rejectUnauthorized }
196
+ * property can disable TLS server certificate verification. Additionally,
197
+ * {@link https://github.com/follow-redirects/follow-redirects | follow-redirects } property can be also specified
198
+ * in order to follow redirects in node.js.
199
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch | fetch } is used under the hood in browser/deno.
200
+ * For example,
201
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch | redirect } property can be set to 'error' to abort request if a redirect occurs.
202
+ */
203
+ transportOptions?: {
204
+ [key: string]: any;
205
+ };
206
+ /**
207
+ * Default HTTP headers to send with every request.
208
+ */
209
+ headers?: Record<string, string>;
210
+ /**
211
+ * Full HTTP web proxy URL including schema, for example http://your-proxy:8080.
212
+ */
213
+ proxyUrl?: string;
214
+ }
215
+ /** default connection options */
216
+ declare const DEFAULT_ConnectionOptions: Partial<ConnectionOptions>;
217
+ /**
218
+ * Options used by {@link InfluxDBClient.write} .
219
+ */
220
+ interface WriteOptions {
221
+ /** Precision to use in writes for timestamp. default ns */
222
+ precision: WritePrecision;
223
+ /** HTTP headers that will be sent with every write request */
224
+ headers?: {
225
+ [key: string]: string;
226
+ };
227
+ /** When specified, write bodies larger than the threshold are gzipped */
228
+ gzipThreshold?: number;
229
+ /** InfluxDB Enterprise write consistency as explained in https://docs.influxdata.com/enterprise_influxdb/v1.9/concepts/clustering/#write-consistency */
230
+ consistency?: 'any' | 'one' | 'quorum' | 'all';
231
+ }
232
+ /** default writeOptions */
233
+ declare const DEFAULT_WriteOptions: WriteOptions;
234
+ type QueryType = 'sql' | 'influxql';
235
+ /**
236
+ * Options used by {@link InfluxDBClient} .
237
+ */
238
+ interface ClientOptions extends ConnectionOptions {
239
+ /** supplies and overrides default writing options */
240
+ writeOptions?: Partial<WriteOptions>;
241
+ /** specifies custom transport */
242
+ transport?: Transport;
243
+ }
244
+ /**
245
+ * Timestamp precision used in write operations.
246
+ * See {@link https://docs.influxdata.com/influxdb/latest/api/#operation/PostWrite }
247
+ */
248
+ type WritePrecision = 'ns' | 'us' | 'ms' | 's';
249
+
250
+ /**
251
+ * Logging interface.
252
+ */
253
+ interface Logger {
254
+ error(message: string, err?: any): void;
255
+ warn(message: string, err?: any): void;
256
+ }
257
+ /**
258
+ * Logger that logs to console.out
259
+ */
260
+ declare const consoleLogger: Logger;
261
+ declare const Log: Logger;
262
+ /**
263
+ * Sets custom logger.
264
+ * @param logger - logger to use
265
+ * @returns previous logger
266
+ */
267
+ declare function setLogger(logger: Logger): Logger;
268
+
269
+ /**
270
+ * Provides functions escape specific parts in InfluxDB line protocol.
271
+ */
272
+ declare const escape: {
273
+ /**
274
+ * Measurement escapes measurement names.
275
+ */
276
+ measurement: (value: string) => string;
277
+ /**
278
+ * Quoted escapes quoted values, such as database names.
279
+ */
280
+ quoted: (value: string) => string;
281
+ /**
282
+ * TagEscaper escapes tag keys, tag values, and field keys.
283
+ */
284
+ tag: (value: string) => string;
285
+ };
286
+
287
+ declare function useProcessHrtime(use: boolean): boolean;
288
+ /**
289
+ * Exposes functions that creates strings that represent a timestamp that
290
+ * can be used in the line protocol. Micro and nano timestamps are emulated
291
+ * depending on the js platform in use.
292
+ */
293
+ declare const currentTime: {
294
+ s: () => string;
295
+ ms: () => string;
296
+ us: () => string;
297
+ ns: () => string;
298
+ seconds: () => string;
299
+ millis: () => string;
300
+ micros: () => string;
301
+ nanos: () => string;
302
+ };
303
+ /**
304
+ * dateToProtocolTimestamp provides converters for JavaScript Date to InfluxDB Write Protocol Timestamp. Keys are supported precisions.
305
+ */
306
+ declare const dateToProtocolTimestamp: {
307
+ s: (d: Date) => string;
308
+ ms: (d: Date) => string;
309
+ us: (d: Date) => string;
310
+ ns: (d: Date) => string;
311
+ };
312
+ /**
313
+ * convertTimeToNanos converts Point's timestamp to a string.
314
+ * @param value - supported timestamp value
315
+ * @returns line protocol value
316
+ */
317
+ declare function convertTimeToNanos(value: string | number | Date | undefined): string | undefined;
318
+ declare const convertTime: (value: string | number | Date | undefined, precision?: WritePrecision) => string | undefined;
319
+
320
+ interface TimeConverter {
321
+ (value: string | number | Date | undefined): string | undefined;
322
+ }
323
+
324
+ type PointFieldType = 'float' | 'integer' | 'uinteger' | 'string' | 'boolean';
325
+ declare class GetFieldTypeMissmatchError extends Error {
326
+ constructor(fieldName: string, expectedType: PointFieldType, actualType: PointFieldType);
327
+ }
328
+ /**
329
+ * Point defines values of a single measurement.
330
+ */
331
+ declare class PointValues {
332
+ private _name;
333
+ private _time;
334
+ private _tags;
335
+ private _fields;
336
+ /**
337
+ * Create an empty PointValues.
338
+ */
339
+ constructor();
340
+ /**
341
+ * Get measurement name. Can be undefined if not set.
342
+ *
343
+ * @returns measurement name or undefined
344
+ */
345
+ getMeasurement(): string | undefined;
346
+ /**
347
+ * Sets point's measurement.
348
+ *
349
+ * @param name - measurement name
350
+ * @returns this
351
+ */
352
+ setMeasurement(name: string): PointValues;
353
+ /**
354
+ * Get timestamp. Can be undefined if not set.
355
+ *
356
+ * @returns timestamp or undefined
357
+ */
358
+ getTimestamp(): Date | number | string | undefined;
359
+ /**
360
+ * Sets point timestamp. Timestamp can be specified as a Date (preferred), number, string
361
+ * or an undefined value. An undefined value instructs to assign a local timestamp using
362
+ * the client's clock. An empty string can be used to let the server assign
363
+ * the timestamp. A number value represents time as a count of time units since epoch, the
364
+ * exact time unit then depends on the {@link InfluxDBClient.write | precision} of the API
365
+ * that writes the point.
366
+ *
367
+ * Beware that the current time in nanoseconds can't precisely fit into a JS number,
368
+ * which can hold at most 2^53 integer number. Nanosecond precision numbers are thus supplied as
369
+ * a (base-10) string. An application can also use ES2020 BigInt to represent nanoseconds,
370
+ * BigInt's `toString()` returns the required high-precision string.
371
+ *
372
+ * Note that InfluxDB requires the timestamp to fit into int64 data type.
373
+ *
374
+ * @param value - point time
375
+ * @returns this
376
+ */
377
+ setTimestamp(value: Date | number | string | undefined): PointValues;
378
+ /**
379
+ * Gets value of tag with given name. Returns undefined if tag not found.
380
+ *
381
+ * @param name - tag name
382
+ * @returns tag value or undefined
383
+ */
384
+ getTag(name: string): string | undefined;
385
+ /**
386
+ * Sets a tag. The caller has to ensure that both name and value are not empty
387
+ * and do not end with backslash.
388
+ *
389
+ * @param name - tag name
390
+ * @param value - tag value
391
+ * @returns this
392
+ */
393
+ setTag(name: string, value: string): PointValues;
394
+ /**
395
+ * Removes a tag with the specified name if it exists; otherwise, it does nothing.
396
+ *
397
+ * @param name - The name of the tag to be removed.
398
+ * @returns this
399
+ */
400
+ removeTag(name: string): PointValues;
401
+ /**
402
+ * Gets an array of tag names.
403
+ *
404
+ * @returns An array of tag names.
405
+ */
406
+ getTagNames(): string[];
407
+ /**
408
+ * Gets the float field value associated with the specified name.
409
+ * Throws if actual type of field with given name is not float.
410
+ * If the field is not present, returns undefined.
411
+ *
412
+ * @param name - field name
413
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match float type.
414
+ * @returns The float field value or undefined.
415
+ */
416
+ getFloatField(name: string): number | undefined;
417
+ /**
418
+ * Sets a number field.
419
+ *
420
+ * @param name - field name
421
+ * @param value - field value
422
+ * @returns this
423
+ * @throws NaN/Infinity/-Infinity is supplied
424
+ */
425
+ setFloatField(name: string, value: number | any): PointValues;
426
+ /**
427
+ * Gets the integer field value associated with the specified name.
428
+ * Throws if actual type of field with given name is not integer.
429
+ * If the field is not present, returns undefined.
430
+ *
431
+ * @param name - field name
432
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match integer type.
433
+ * @returns The integer field value or undefined.
434
+ */
435
+ getIntegerField(name: string): number | undefined;
436
+ /**
437
+ * Sets an integer field.
438
+ *
439
+ * @param name - field name
440
+ * @param value - field value
441
+ * @returns this
442
+ * @throws NaN or out of int64 range value is supplied
443
+ */
444
+ setIntegerField(name: string, value: number | any): PointValues;
445
+ /**
446
+ * Gets the uint field value associated with the specified name.
447
+ * Throws if actual type of field with given name is not uint.
448
+ * If the field is not present, returns undefined.
449
+ *
450
+ * @param name - field name
451
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match uint type.
452
+ * @returns The uint field value or undefined.
453
+ */
454
+ getUintegerField(name: string): number | undefined;
455
+ /**
456
+ * Sets an unsigned integer field.
457
+ *
458
+ * @param name - field name
459
+ * @param value - field value
460
+ * @returns this
461
+ * @throws NaN out of range value is supplied
462
+ */
463
+ setUintegerField(name: string, value: number | any): PointValues;
464
+ /**
465
+ * Gets the string field value associated with the specified name.
466
+ * Throws if actual type of field with given name is not string.
467
+ * If the field is not present, returns undefined.
468
+ *
469
+ * @param name - field name
470
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match string type.
471
+ * @returns The string field value or undefined.
472
+ */
473
+ getStringField(name: string): string | undefined;
474
+ /**
475
+ * Sets a string field.
476
+ *
477
+ * @param name - field name
478
+ * @param value - field value
479
+ * @returns this
480
+ */
481
+ setStringField(name: string, value: string | any): PointValues;
482
+ /**
483
+ * Gets the boolean field value associated with the specified name.
484
+ * Throws if actual type of field with given name is not boolean.
485
+ * If the field is not present, returns undefined.
486
+ *
487
+ * @param name - field name
488
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match boolean type.
489
+ * @returns The boolean field value or undefined.
490
+ */
491
+ getBooleanField(name: string): boolean | undefined;
492
+ /**
493
+ * Sets a boolean field.
494
+ *
495
+ * @param name - field name
496
+ * @param value - field value
497
+ * @returns this
498
+ */
499
+ setBooleanField(name: string, value: boolean | any): PointValues;
500
+ /**
501
+ * Get field of numeric type.
502
+ * Throws if actual type of field with given name is not given numeric type.
503
+ * If the field is not present, returns undefined.
504
+ *
505
+ * @param name - field name
506
+ * @param type - field numeric type
507
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided numeric type.
508
+ * @returns this
509
+ */
510
+ getField(name: string, type: 'float' | 'integer' | 'uinteger'): number | undefined;
511
+ /**
512
+ * Get field of string type.
513
+ * Throws if actual type of field with given name is not string.
514
+ * If the field is not present, returns undefined.
515
+ *
516
+ * @param name - field name
517
+ * @param type - field string type
518
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided 'string' type.
519
+ * @returns this
520
+ */
521
+ getField(name: string, type: 'string'): string | undefined;
522
+ /**
523
+ * Get field of boolean type.
524
+ * Throws if actual type of field with given name is not boolean.
525
+ * If the field is not present, returns undefined.
526
+ *
527
+ * @param name - field name
528
+ * @param type - field boolean type
529
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match provided 'boolean' type.
530
+ * @returns this
531
+ */
532
+ getField(name: string, type: 'boolean'): boolean | undefined;
533
+ /**
534
+ * Get field without type check.
535
+ * If the field is not present, returns undefined.
536
+ *
537
+ * @param name - field name
538
+ * @returns this
539
+ */
540
+ getField(name: string): number | string | boolean | undefined;
541
+ /**
542
+ * Gets the type of field with given name, if it exists.
543
+ * If the field is not present, returns undefined.
544
+ *
545
+ * @param name - field name
546
+ * @returns The field type or undefined.
547
+ */
548
+ getFieldType(name: string): PointFieldType | undefined;
549
+ /**
550
+ * Sets field based on provided type.
551
+ *
552
+ * @param name - field name
553
+ * @param value - field value
554
+ * @param type - field type
555
+ * @returns this
556
+ */
557
+ setField(name: string, value: any, type?: PointFieldType): PointValues;
558
+ /**
559
+ * Add fields according to their type. All numeric type is considered float
560
+ *
561
+ * @param fields - name-value map
562
+ * @returns this
563
+ */
564
+ setFields(fields: {
565
+ [key: string]: number | boolean | string;
566
+ }): PointValues;
567
+ /**
568
+ * Removes a field with the specified name if it exists; otherwise, it does nothing.
569
+ *
570
+ * @param name - The name of the field to be removed.
571
+ * @returns this
572
+ */
573
+ removeField(name: string): PointValues;
574
+ /**
575
+ * Gets an array of field names associated with this object.
576
+ *
577
+ * @returns An array of field names.
578
+ */
579
+ getFieldNames(): string[];
580
+ /**
581
+ * Checks if this object has any fields.
582
+ *
583
+ * @returns true if fields are present, false otherwise.
584
+ */
585
+ hasFields(): boolean;
586
+ /**
587
+ * Creates a copy of this object.
588
+ *
589
+ * @returns A new instance with same values.
590
+ */
591
+ copy(): PointValues;
592
+ /**
593
+ * Creates new Point with this as values.
594
+ *
595
+ * @returns Point from this values.
596
+ */
597
+ asPoint(measurement?: string): Point;
598
+ }
599
+
600
+ /**
601
+ * Point defines values of a single measurement.
602
+ */
603
+ declare class Point {
604
+ private readonly _values;
605
+ /**
606
+ * Create a new Point with specified a measurement name.
607
+ *
608
+ * @param measurementName - the measurement name
609
+ */
610
+ private constructor();
611
+ /**
612
+ * Create a new Point with given values.
613
+ * After creating Point, it's values shouldn't be modified directly by PointValues object.
614
+ *
615
+ * @param values - point values
616
+ */
617
+ private constructor();
618
+ /**
619
+ * Creates new Point with given measurement.
620
+ *
621
+ * @param name - measurement name
622
+ * @returns new Point
623
+ */
624
+ static measurement(name: string): Point;
625
+ /**
626
+ * Creates new point from PointValues object.
627
+ * Can throw error if measurement missing.
628
+ *
629
+ * @param values - point values object with measurement
630
+ * @throws missing measurement
631
+ * @returns new point from values
632
+ */
633
+ static fromValues(values: PointValues): Point;
634
+ /**
635
+ * Get measurement name.
636
+ *
637
+ * @returns measurement name
638
+ */
639
+ getMeasurement(): string;
640
+ /**
641
+ * Sets point's measurement.
642
+ *
643
+ * @param name - measurement name
644
+ * @returns this
645
+ */
646
+ setMeasurement(name: string): Point;
647
+ /**
648
+ * Get timestamp. Can be undefined if not set.
649
+ *
650
+ * @returns timestamp or undefined
651
+ */
652
+ getTimestamp(): Date | number | string | undefined;
653
+ /**
654
+ * Sets point timestamp. Timestamp can be specified as a Date (preferred), number, string
655
+ * or an undefined value. An undefined value instructs to assign a local timestamp using
656
+ * the client's clock. An empty string can be used to let the server assign
657
+ * the timestamp. A number value represents time as a count of time units since epoch, the
658
+ * exact time unit then depends on the {@link InfluxDBClient.write | precision} of the API
659
+ * that writes the point.
660
+ *
661
+ * Beware that the current time in nanoseconds can't precisely fit into a JS number,
662
+ * which can hold at most 2^53 integer number. Nanosecond precision numbers are thus supplied as
663
+ * a (base-10) string. An application can also use ES2020 BigInt to represent nanoseconds,
664
+ * BigInt's `toString()` returns the required high-precision string.
665
+ *
666
+ * Note that InfluxDB requires the timestamp to fit into int64 data type.
667
+ *
668
+ * @param value - point time
669
+ * @returns this
670
+ */
671
+ setTimestamp(value: Date | number | string | undefined): Point;
672
+ /**
673
+ * Gets value of tag with given name. Returns undefined if tag not found.
674
+ *
675
+ * @param name - tag name
676
+ * @returns tag value or undefined
677
+ */
678
+ getTag(name: string): string | undefined;
679
+ /**
680
+ * Sets a tag. The caller has to ensure that both name and value are not empty
681
+ * and do not end with backslash.
682
+ *
683
+ * @param name - tag name
684
+ * @param value - tag value
685
+ * @returns this
686
+ */
687
+ setTag(name: string, value: string): Point;
688
+ /**
689
+ * Removes a tag with the specified name if it exists; otherwise, it does nothing.
690
+ *
691
+ * @param name - The name of the tag to be removed.
692
+ * @returns this
693
+ */
694
+ removeTag(name: string): Point;
695
+ /**
696
+ * Gets an array of tag names.
697
+ *
698
+ * @returns An array of tag names.
699
+ */
700
+ getTagNames(): string[];
701
+ /**
702
+ * Gets the float field value associated with the specified name.
703
+ * Throws if actual type of field with given name is not float.
704
+ * If the field is not present, returns undefined.
705
+ *
706
+ * @param name - field name
707
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match float type.
708
+ * @returns The float field value or undefined.
709
+ */
710
+ getFloatField(name: string): number | undefined;
711
+ /**
712
+ * Sets a number field.
713
+ *
714
+ * @param name - field name
715
+ * @param value - field value
716
+ * @returns this
717
+ * @throws NaN/Infinity/-Infinity is supplied
718
+ */
719
+ setFloatField(name: string, value: number | any): Point;
720
+ /**
721
+ * Gets the integer field value associated with the specified name.
722
+ * Throws if actual type of field with given name is not integer.
723
+ * If the field is not present, returns undefined.
724
+ *
725
+ * @param name - field name
726
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match integer type.
727
+ * @returns The integer field value or undefined.
728
+ */
729
+ getIntegerField(name: string): number | undefined;
730
+ /**
731
+ * Sets an integer field.
732
+ *
733
+ * @param name - field name
734
+ * @param value - field value
735
+ * @returns this
736
+ * @throws NaN or out of int64 range value is supplied
737
+ */
738
+ setIntegerField(name: string, value: number | any): Point;
739
+ /**
740
+ * Gets the uint field value associated with the specified name.
741
+ * Throws if actual type of field with given name is not uint.
742
+ * If the field is not present, returns undefined.
743
+ *
744
+ * @param name - field name
745
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match uint type.
746
+ * @returns The uint field value or undefined.
747
+ */
748
+ getUintegerField(name: string): number | undefined;
749
+ /**
750
+ * Sets an unsigned integer field.
751
+ *
752
+ * @param name - field name
753
+ * @param value - field value
754
+ * @returns this
755
+ * @throws NaN out of range value is supplied
756
+ */
757
+ setUintegerField(name: string, value: number | any): Point;
758
+ /**
759
+ * Gets the string field value associated with the specified name.
760
+ * Throws if actual type of field with given name is not string.
761
+ * If the field is not present, returns undefined.
762
+ *
763
+ * @param name - field name
764
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match string type.
765
+ * @returns The string field value or undefined.
766
+ */
767
+ getStringField(name: string): string | undefined;
768
+ /**
769
+ * Sets a string field.
770
+ *
771
+ * @param name - field name
772
+ * @param value - field value
773
+ * @returns this
774
+ */
775
+ setStringField(name: string, value: string | any): Point;
776
+ /**
777
+ * Gets the boolean field value associated with the specified name.
778
+ * Throws if actual type of field with given name is not boolean.
779
+ * If the field is not present, returns undefined.
780
+ *
781
+ * @param name - field name
782
+ * @throws {@link GetFieldTypeMissmatchError} Actual type of field doesn't match boolean type.
783
+ * @returns The boolean field value or undefined.
784
+ */
785
+ getBooleanField(name: string): boolean | undefined;
786
+ /**
787
+ * Sets a boolean field.
788
+ *
789
+ * @param name - field name
790
+ * @param value - field value
791
+ * @returns this
792
+ */
793
+ setBooleanField(name: string, value: boolean | any): Point;
794
+ /**
795
+ * Get field of numeric type.
796
+ *
797
+ * @param name - field name
798
+ * @param type - field numeric type
799
+ * @throws Field type doesn't match actual type
800
+ * @returns this
801
+ */
802
+ getField(name: string, type: 'float' | 'integer' | 'uinteger'): number | undefined;
803
+ /**
804
+ * Get field of string type.
805
+ *
806
+ * @param name - field name
807
+ * @param type - field string type
808
+ * @throws Field type doesn't match actual type
809
+ * @returns this
810
+ */
811
+ getField(name: string, type: 'string'): string | undefined;
812
+ /**
813
+ * Get field of boolean type.
814
+ *
815
+ * @param name - field name
816
+ * @param type - field boolean type
817
+ * @throws Field type doesn't match actual type
818
+ * @returns this
819
+ */
820
+ getField(name: string, type: 'boolean'): boolean | undefined;
821
+ /**
822
+ * Get field without type check.
823
+ *
824
+ * @param name - field name
825
+ * @returns this
826
+ */
827
+ getField(name: string): number | string | boolean | undefined;
828
+ /**
829
+ * Gets the type of field with given name, if it exists.
830
+ * If the field is not present, returns undefined.
831
+ *
832
+ * @param name - field name
833
+ * @returns The field type or undefined.
834
+ */
835
+ getFieldType(name: string): PointFieldType | undefined;
836
+ /**
837
+ * Sets field based on provided type.
838
+ *
839
+ * @param name - field name
840
+ * @param value - field value
841
+ * @param type - field type
842
+ * @returns this
843
+ */
844
+ setField(name: string, value: any, type?: PointFieldType): Point;
845
+ /**
846
+ * Add fields according to their type. All numeric type is considered float
847
+ *
848
+ * @param fields - name-value map
849
+ * @returns this
850
+ */
851
+ setFields(fields: {
852
+ [key: string]: number | boolean | string;
853
+ }): Point;
854
+ /**
855
+ * Removes a field with the specified name if it exists; otherwise, it does nothing.
856
+ *
857
+ * @param name - The name of the field to be removed.
858
+ * @returns this
859
+ */
860
+ removeField(name: string): Point;
861
+ /**
862
+ * Gets an array of field names associated with this object.
863
+ *
864
+ * @returns An array of field names.
865
+ */
866
+ getFieldNames(): string[];
867
+ /**
868
+ * Checks if this object has any fields.
869
+ *
870
+ * @returns true if fields are present, false otherwise.
871
+ */
872
+ hasFields(): boolean;
873
+ /**
874
+ * Creates a copy of this object.
875
+ *
876
+ * @returns A new instance with same values.
877
+ */
878
+ copy(): Point;
879
+ /**
880
+ * Creates an InfluxDB protocol line out of this instance.
881
+ * @param convertTimePrecision - settings control serialization of a point timestamp and can also add default tags,
882
+ * nanosecond timestamp precision is used when no `settings` or no `settings.convertTime` is supplied.
883
+ * @returns an InfluxDB protocol line out of this instance
884
+ */
885
+ toLineProtocol(convertTimePrecision?: TimeConverter | WritePrecision): string | undefined;
886
+ toString(): string;
887
+ }
888
+
889
+ /**
890
+ * The `WritableData` type represents different types of data that can be written.
891
+ * The data can either be a uniform ArrayLike collection or a single value of the following types:
892
+ *
893
+ * - `Point`: Represents a {@link Point} object.
894
+ *
895
+ * - `string`: Represents lines of the [Line Protocol](https://bit.ly/2QL99fu).
896
+ */
897
+ type WritableData = ArrayLike<string> | ArrayLike<Point> | string | Point;
898
+ declare const writableDataToLineProtocol: (data: WritableData) => string[];
899
+
900
+ declare const collectAll: <T>(generator: AsyncGenerator<T, any, any>) => Promise<T[]>;
901
+
902
+ /**
903
+ * `InfluxDBClient` for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
904
+ */
905
+ declare class InfluxDBClient {
906
+ private readonly _options;
907
+ private readonly _writeApi;
908
+ private readonly _queryApi;
909
+ /**
910
+ * Creates a new instance of the `InfluxDBClient` for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
911
+ * @param options - client options
912
+ */
913
+ constructor(options: ClientOptions);
914
+ private _mergeWriteOptions;
915
+ /**
916
+ * Write data into specified database.
917
+ * @param data - data to write
918
+ * @param database - database to write into
919
+ * @param org - organization to write into
920
+ * @param writeOptions - write options
921
+ */
922
+ write(data: WritableData, database?: string, org?: string, writeOptions?: Partial<WriteOptions>): Promise<void>;
923
+ /**
924
+ * Execute a query and return the results as an async generator.
925
+ *
926
+ * @param query - The query string.
927
+ * @param database - The name of the database to query.
928
+ * @param queryType - The type of query (default: 'sql').
929
+ * @returns An async generator that yields maps of string keys to any values.
930
+ */
931
+ query(query: string, database?: string, queryType?: QueryType): AsyncGenerator<Record<string, any>, void, void>;
932
+ /**
933
+ * Execute a query and return the results as an async generator.
934
+ *
935
+ * @param query - The query string.
936
+ * @param database - The name of the database to query.
937
+ * @param queryType - The type of query (default: 'sql').
938
+ * @returns An async generator that yields PointValues object.
939
+ */
940
+ queryPoints(query: string, database?: string, queryType?: QueryType): AsyncGenerator<PointValues, void, void>;
941
+ /**
942
+ * Closes the client and all its resources (connections, ...)
943
+ */
944
+ close(): Promise<void>;
945
+ }
946
+
947
+ export { AbortError, Cancellable, ChunkCombiner, ClientOptions, CommunicationObserver, ConnectionOptions, DEFAULT_ConnectionOptions, DEFAULT_WriteOptions, GetFieldTypeMissmatchError, HttpHeaders as Headers, HttpError, HttpHeaders, IllegalArgumentError, InfluxDBClient, Log, Logger, Point, PointFieldType, PointValues, QueryType, RequestTimedOutError, ResponseStartedFn, SendOptions, TimeConverter, Transport, WritableData, WriteOptions, WritePrecision, collectAll, consoleLogger, convertTime, convertTimeToNanos, createTextDecoderCombiner, currentTime, dateToProtocolTimestamp, escape, setLogger, useProcessHrtime, writableDataToLineProtocol };