influx 5.0.6 → 5.0.7
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/lib/src/backoff/backoff.d.ts +15 -15
- package/lib/src/backoff/backoff.js +2 -2
- package/lib/src/backoff/exponential.d.ts +52 -52
- package/lib/src/backoff/exponential.js +40 -40
- package/lib/src/builder.d.ts +265 -265
- package/lib/src/builder.js +366 -366
- package/lib/src/doc.d.ts +315 -315
- package/lib/src/doc.js +340 -340
- package/lib/src/grammar/ds.d.ts +45 -45
- package/lib/src/grammar/ds.js +56 -56
- package/lib/src/grammar/escape.d.ts +25 -25
- package/lib/src/grammar/escape.js +108 -108
- package/lib/src/grammar/index.d.ts +3 -3
- package/lib/src/grammar/index.js +8 -8
- package/lib/src/grammar/times.d.ts +74 -74
- package/lib/src/grammar/times.js +325 -325
- package/lib/src/host.d.ts +26 -26
- package/lib/src/host.js +34 -34
- package/lib/src/index.d.ts +659 -659
- package/lib/src/index.js +870 -870
- package/lib/src/pool.d.ts +149 -149
- package/lib/src/pool.js +344 -344
- package/lib/src/results.d.ts +118 -118
- package/lib/src/results.js +146 -146
- package/lib/src/schema.d.ts +58 -58
- package/lib/src/schema.js +117 -117
- package/package.json +2 -2
package/lib/src/grammar/ds.d.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FieldType is an enumeration of InfluxDB field data types.
|
|
3
|
-
* @typedef {Number} FieldType
|
|
4
|
-
* @example
|
|
5
|
-
* import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType
|
|
6
|
-
*
|
|
7
|
-
* const schema = {
|
|
8
|
-
* measurement: 'my_measurement',
|
|
9
|
-
* fields: {
|
|
10
|
-
* my_int: FieldType.INTEGER,
|
|
11
|
-
* my_float: FieldType.FLOAT,
|
|
12
|
-
* my_string: FieldType.STRING,
|
|
13
|
-
* my_boolean: FieldType.BOOLEAN,
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
*/
|
|
17
|
-
export declare enum FieldType {
|
|
18
|
-
FLOAT = 0,
|
|
19
|
-
INTEGER = 1,
|
|
20
|
-
STRING = 2,
|
|
21
|
-
BOOLEAN = 3,
|
|
22
|
-
}
|
|
23
|
-
export declare function isNumeric(value: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* You can provide Raw values to Influx methods to prevent it from escaping
|
|
26
|
-
* your provided string.
|
|
27
|
-
* @class
|
|
28
|
-
* @example
|
|
29
|
-
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
30
|
-
*/
|
|
31
|
-
export declare class Raw {
|
|
32
|
-
private value;
|
|
33
|
-
/**
|
|
34
|
-
* Wraps a string so that it is not escaped in Influx queries.
|
|
35
|
-
* @param {String} value
|
|
36
|
-
* @example
|
|
37
|
-
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
38
|
-
*/
|
|
39
|
-
constructor(value: string);
|
|
40
|
-
/**
|
|
41
|
-
* Returns the wrapped string.
|
|
42
|
-
* @return {String}
|
|
43
|
-
*/
|
|
44
|
-
getValue(): string;
|
|
45
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* FieldType is an enumeration of InfluxDB field data types.
|
|
3
|
+
* @typedef {Number} FieldType
|
|
4
|
+
* @example
|
|
5
|
+
* import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType
|
|
6
|
+
*
|
|
7
|
+
* const schema = {
|
|
8
|
+
* measurement: 'my_measurement',
|
|
9
|
+
* fields: {
|
|
10
|
+
* my_int: FieldType.INTEGER,
|
|
11
|
+
* my_float: FieldType.FLOAT,
|
|
12
|
+
* my_string: FieldType.STRING,
|
|
13
|
+
* my_boolean: FieldType.BOOLEAN,
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare enum FieldType {
|
|
18
|
+
FLOAT = 0,
|
|
19
|
+
INTEGER = 1,
|
|
20
|
+
STRING = 2,
|
|
21
|
+
BOOLEAN = 3,
|
|
22
|
+
}
|
|
23
|
+
export declare function isNumeric(value: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* You can provide Raw values to Influx methods to prevent it from escaping
|
|
26
|
+
* your provided string.
|
|
27
|
+
* @class
|
|
28
|
+
* @example
|
|
29
|
+
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
30
|
+
*/
|
|
31
|
+
export declare class Raw {
|
|
32
|
+
private value;
|
|
33
|
+
/**
|
|
34
|
+
* Wraps a string so that it is not escaped in Influx queries.
|
|
35
|
+
* @param {String} value
|
|
36
|
+
* @example
|
|
37
|
+
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
38
|
+
*/
|
|
39
|
+
constructor(value: string);
|
|
40
|
+
/**
|
|
41
|
+
* Returns the wrapped string.
|
|
42
|
+
* @return {String}
|
|
43
|
+
*/
|
|
44
|
+
getValue(): string;
|
|
45
|
+
}
|
package/lib/src/grammar/ds.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* FieldType is an enumeration of InfluxDB field data types.
|
|
5
|
-
* @typedef {Number} FieldType
|
|
6
|
-
* @example
|
|
7
|
-
* import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType
|
|
8
|
-
*
|
|
9
|
-
* const schema = {
|
|
10
|
-
* measurement: 'my_measurement',
|
|
11
|
-
* fields: {
|
|
12
|
-
* my_int: FieldType.INTEGER,
|
|
13
|
-
* my_float: FieldType.FLOAT,
|
|
14
|
-
* my_string: FieldType.STRING,
|
|
15
|
-
* my_boolean: FieldType.BOOLEAN,
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*/
|
|
19
|
-
var FieldType;
|
|
20
|
-
(function (FieldType) {
|
|
21
|
-
FieldType[FieldType["FLOAT"] = 0] = "FLOAT";
|
|
22
|
-
FieldType[FieldType["INTEGER"] = 1] = "INTEGER";
|
|
23
|
-
FieldType[FieldType["STRING"] = 2] = "STRING";
|
|
24
|
-
FieldType[FieldType["BOOLEAN"] = 3] = "BOOLEAN";
|
|
25
|
-
})(FieldType = exports.FieldType || (exports.FieldType = {}));
|
|
26
|
-
function isNumeric(value) {
|
|
27
|
-
return !Number.isNaN(Number(value));
|
|
28
|
-
}
|
|
29
|
-
exports.isNumeric = isNumeric;
|
|
30
|
-
/**
|
|
31
|
-
* You can provide Raw values to Influx methods to prevent it from escaping
|
|
32
|
-
* your provided string.
|
|
33
|
-
* @class
|
|
34
|
-
* @example
|
|
35
|
-
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
36
|
-
*/
|
|
37
|
-
var Raw = (function () {
|
|
38
|
-
/**
|
|
39
|
-
* Wraps a string so that it is not escaped in Influx queries.
|
|
40
|
-
* @param {String} value
|
|
41
|
-
* @example
|
|
42
|
-
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
43
|
-
*/
|
|
44
|
-
function Raw(value) {
|
|
45
|
-
this.value = value;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns the wrapped string.
|
|
49
|
-
* @return {String}
|
|
50
|
-
*/
|
|
51
|
-
Raw.prototype.getValue = function () {
|
|
52
|
-
return this.value;
|
|
53
|
-
};
|
|
54
|
-
return Raw;
|
|
55
|
-
}());
|
|
56
|
-
exports.Raw = Raw;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* FieldType is an enumeration of InfluxDB field data types.
|
|
5
|
+
* @typedef {Number} FieldType
|
|
6
|
+
* @example
|
|
7
|
+
* import { FieldType } from 'influx'; // or const FieldType = require('influx').FieldType
|
|
8
|
+
*
|
|
9
|
+
* const schema = {
|
|
10
|
+
* measurement: 'my_measurement',
|
|
11
|
+
* fields: {
|
|
12
|
+
* my_int: FieldType.INTEGER,
|
|
13
|
+
* my_float: FieldType.FLOAT,
|
|
14
|
+
* my_string: FieldType.STRING,
|
|
15
|
+
* my_boolean: FieldType.BOOLEAN,
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
var FieldType;
|
|
20
|
+
(function (FieldType) {
|
|
21
|
+
FieldType[FieldType["FLOAT"] = 0] = "FLOAT";
|
|
22
|
+
FieldType[FieldType["INTEGER"] = 1] = "INTEGER";
|
|
23
|
+
FieldType[FieldType["STRING"] = 2] = "STRING";
|
|
24
|
+
FieldType[FieldType["BOOLEAN"] = 3] = "BOOLEAN";
|
|
25
|
+
})(FieldType = exports.FieldType || (exports.FieldType = {}));
|
|
26
|
+
function isNumeric(value) {
|
|
27
|
+
return !Number.isNaN(Number(value));
|
|
28
|
+
}
|
|
29
|
+
exports.isNumeric = isNumeric;
|
|
30
|
+
/**
|
|
31
|
+
* You can provide Raw values to Influx methods to prevent it from escaping
|
|
32
|
+
* your provided string.
|
|
33
|
+
* @class
|
|
34
|
+
* @example
|
|
35
|
+
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
36
|
+
*/
|
|
37
|
+
var Raw = (function () {
|
|
38
|
+
/**
|
|
39
|
+
* Wraps a string so that it is not escaped in Influx queries.
|
|
40
|
+
* @param {String} value
|
|
41
|
+
* @example
|
|
42
|
+
* influx.createDatabase(new Influx.Raw('This won\'t be escaped!'));
|
|
43
|
+
*/
|
|
44
|
+
function Raw(value) {
|
|
45
|
+
this.value = value;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the wrapped string.
|
|
49
|
+
* @return {String}
|
|
50
|
+
*/
|
|
51
|
+
Raw.prototype.getValue = function () {
|
|
52
|
+
return this.value;
|
|
53
|
+
};
|
|
54
|
+
return Raw;
|
|
55
|
+
}());
|
|
56
|
+
exports.Raw = Raw;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
3
|
-
* @type {Object}
|
|
4
|
-
* @property {function(s: string): string } quoted Escapes and wraps quoted
|
|
5
|
-
* values, such as database names.
|
|
6
|
-
* @property {function(s: string): string } stringLit Escapes and
|
|
7
|
-
* wraps string literals.
|
|
8
|
-
* @property {function(s: string): string } measurement Escapes measurement
|
|
9
|
-
* names on the line protocol.
|
|
10
|
-
* @property {function(s: string): string } tag Escapes tag keys, take values,
|
|
11
|
-
* and field keys on the line protocol.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* console.log(escape.quoted('my_"db')); // => "my_\"db"
|
|
15
|
-
* console.log(escape.stringLit('hello\'world')); // => 'hello\'world'
|
|
16
|
-
*
|
|
17
|
-
* console.log(escape.measurement('my measurement')); // => my\ measurement
|
|
18
|
-
* console.log(escape.tag('my tag=')); // => my\ tag\=
|
|
19
|
-
*/
|
|
20
|
-
export declare const escape: {
|
|
21
|
-
measurement: (val: string) => string;
|
|
22
|
-
quoted: (val: string) => string;
|
|
23
|
-
stringLit: (val: string) => string;
|
|
24
|
-
tag: (val: string) => string;
|
|
25
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
3
|
+
* @type {Object}
|
|
4
|
+
* @property {function(s: string): string } quoted Escapes and wraps quoted
|
|
5
|
+
* values, such as database names.
|
|
6
|
+
* @property {function(s: string): string } stringLit Escapes and
|
|
7
|
+
* wraps string literals.
|
|
8
|
+
* @property {function(s: string): string } measurement Escapes measurement
|
|
9
|
+
* names on the line protocol.
|
|
10
|
+
* @property {function(s: string): string } tag Escapes tag keys, take values,
|
|
11
|
+
* and field keys on the line protocol.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* console.log(escape.quoted('my_"db')); // => "my_\"db"
|
|
15
|
+
* console.log(escape.stringLit('hello\'world')); // => 'hello\'world'
|
|
16
|
+
*
|
|
17
|
+
* console.log(escape.measurement('my measurement')); // => my\ measurement
|
|
18
|
+
* console.log(escape.tag('my tag=')); // => my\ tag\=
|
|
19
|
+
*/
|
|
20
|
+
export declare const escape: {
|
|
21
|
+
measurement: (val: string) => string;
|
|
22
|
+
quoted: (val: string) => string;
|
|
23
|
+
stringLit: (val: string) => string;
|
|
24
|
+
tag: (val: string) => string;
|
|
25
|
+
};
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var ds_1 = require("./ds");
|
|
4
|
-
var reEscape = /[-|\\{()[\]^$+*?.]/g;
|
|
5
|
-
/**
|
|
6
|
-
* The Escaper escapes the special characters in the provided list
|
|
7
|
-
* with backslashes. Much of the code here is inspired by that in the
|
|
8
|
-
* sqlstring packet found here: https://github.com/mysqljs/sqlstring
|
|
9
|
-
*
|
|
10
|
-
* Instances of the Escaper are derived from the documentation of escape
|
|
11
|
-
* sequences found here: https://aka.ms/co1m4k
|
|
12
|
-
*
|
|
13
|
-
* sqlstring is made available under the following license:
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
|
16
|
-
*
|
|
17
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
-
* in the Software without restriction, including without limitation the rights
|
|
20
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
-
* furnished to do so, subject to the following conditions:
|
|
23
|
-
*
|
|
24
|
-
* The above copyright notice and this permission notice shall be included in
|
|
25
|
-
* all copies or substantial portions of the Software.
|
|
26
|
-
*
|
|
27
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
33
|
-
* THE SOFTWARE.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
var Escaper = (function () {
|
|
37
|
-
function Escaper(chars, wrap, escaper) {
|
|
38
|
-
if (wrap === void 0) { wrap = ''; }
|
|
39
|
-
if (escaper === void 0) { escaper = '\\'; }
|
|
40
|
-
this.wrap = wrap;
|
|
41
|
-
this.escaper = escaper;
|
|
42
|
-
var patterns = chars.join('').replace(reEscape, '\\$&');
|
|
43
|
-
this.re = new RegExp('[' + patterns + '\\\\]', 'g');
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Escape replaces occurrences of special characters within the target
|
|
47
|
-
* string with the necessary escape codes.
|
|
48
|
-
*/
|
|
49
|
-
Escaper.prototype.escape = function (val) {
|
|
50
|
-
if (val instanceof ds_1.Raw) {
|
|
51
|
-
return val.getValue();
|
|
52
|
-
}
|
|
53
|
-
var chunkIndex = this.re.lastIndex = 0;
|
|
54
|
-
var escapedVal = '';
|
|
55
|
-
var match = this.re.exec(val);
|
|
56
|
-
while (match) {
|
|
57
|
-
escapedVal += val.slice(chunkIndex, match.index) + this.escaper + match[0];
|
|
58
|
-
chunkIndex = this.re.lastIndex;
|
|
59
|
-
match = this.re.exec(val);
|
|
60
|
-
}
|
|
61
|
-
if (chunkIndex === 0) {
|
|
62
|
-
return this.wrap + val + this.wrap;
|
|
63
|
-
}
|
|
64
|
-
if (chunkIndex < val.length) {
|
|
65
|
-
return this.wrap + escapedVal + val.slice(chunkIndex) + this.wrap;
|
|
66
|
-
}
|
|
67
|
-
return this.wrap + escapedVal + this.wrap;
|
|
68
|
-
};
|
|
69
|
-
return Escaper;
|
|
70
|
-
}());
|
|
71
|
-
var bindEsc = function (e) { return e.escape.bind(e); };
|
|
72
|
-
/**
|
|
73
|
-
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
74
|
-
* @type {Object}
|
|
75
|
-
* @property {function(s: string): string } quoted Escapes and wraps quoted
|
|
76
|
-
* values, such as database names.
|
|
77
|
-
* @property {function(s: string): string } stringLit Escapes and
|
|
78
|
-
* wraps string literals.
|
|
79
|
-
* @property {function(s: string): string } measurement Escapes measurement
|
|
80
|
-
* names on the line protocol.
|
|
81
|
-
* @property {function(s: string): string } tag Escapes tag keys, take values,
|
|
82
|
-
* and field keys on the line protocol.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* console.log(escape.quoted('my_"db')); // => "my_\"db"
|
|
86
|
-
* console.log(escape.stringLit('hello\'world')); // => 'hello\'world'
|
|
87
|
-
*
|
|
88
|
-
* console.log(escape.measurement('my measurement')); // => my\ measurement
|
|
89
|
-
* console.log(escape.tag('my tag=')); // => my\ tag\=
|
|
90
|
-
*/
|
|
91
|
-
exports.escape = {
|
|
92
|
-
/**
|
|
93
|
-
* measurement escapes measurement names.
|
|
94
|
-
*/
|
|
95
|
-
measurement: bindEsc(new Escaper([',', ' '])),
|
|
96
|
-
/**
|
|
97
|
-
* quoted escapes quoted values, such as database names.
|
|
98
|
-
*/
|
|
99
|
-
quoted: bindEsc(new Escaper(['"'], '"')),
|
|
100
|
-
/**
|
|
101
|
-
* stringLitEscaper escapes single quotes in string literals.
|
|
102
|
-
*/
|
|
103
|
-
stringLit: bindEsc(new Escaper(['\''], '\'')),
|
|
104
|
-
/**
|
|
105
|
-
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
106
|
-
*/
|
|
107
|
-
tag: bindEsc(new Escaper([',', '=', ' '])),
|
|
108
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var ds_1 = require("./ds");
|
|
4
|
+
var reEscape = /[-|\\{()[\]^$+*?.]/g;
|
|
5
|
+
/**
|
|
6
|
+
* The Escaper escapes the special characters in the provided list
|
|
7
|
+
* with backslashes. Much of the code here is inspired by that in the
|
|
8
|
+
* sqlstring packet found here: https://github.com/mysqljs/sqlstring
|
|
9
|
+
*
|
|
10
|
+
* Instances of the Escaper are derived from the documentation of escape
|
|
11
|
+
* sequences found here: https://aka.ms/co1m4k
|
|
12
|
+
*
|
|
13
|
+
* sqlstring is made available under the following license:
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in
|
|
25
|
+
* all copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
33
|
+
* THE SOFTWARE.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
var Escaper = (function () {
|
|
37
|
+
function Escaper(chars, wrap, escaper) {
|
|
38
|
+
if (wrap === void 0) { wrap = ''; }
|
|
39
|
+
if (escaper === void 0) { escaper = '\\'; }
|
|
40
|
+
this.wrap = wrap;
|
|
41
|
+
this.escaper = escaper;
|
|
42
|
+
var patterns = chars.join('').replace(reEscape, '\\$&');
|
|
43
|
+
this.re = new RegExp('[' + patterns + '\\\\]', 'g');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Escape replaces occurrences of special characters within the target
|
|
47
|
+
* string with the necessary escape codes.
|
|
48
|
+
*/
|
|
49
|
+
Escaper.prototype.escape = function (val) {
|
|
50
|
+
if (val instanceof ds_1.Raw) {
|
|
51
|
+
return val.getValue();
|
|
52
|
+
}
|
|
53
|
+
var chunkIndex = this.re.lastIndex = 0;
|
|
54
|
+
var escapedVal = '';
|
|
55
|
+
var match = this.re.exec(val);
|
|
56
|
+
while (match) {
|
|
57
|
+
escapedVal += val.slice(chunkIndex, match.index) + this.escaper + match[0];
|
|
58
|
+
chunkIndex = this.re.lastIndex;
|
|
59
|
+
match = this.re.exec(val);
|
|
60
|
+
}
|
|
61
|
+
if (chunkIndex === 0) {
|
|
62
|
+
return this.wrap + val + this.wrap;
|
|
63
|
+
}
|
|
64
|
+
if (chunkIndex < val.length) {
|
|
65
|
+
return this.wrap + escapedVal + val.slice(chunkIndex) + this.wrap;
|
|
66
|
+
}
|
|
67
|
+
return this.wrap + escapedVal + this.wrap;
|
|
68
|
+
};
|
|
69
|
+
return Escaper;
|
|
70
|
+
}());
|
|
71
|
+
var bindEsc = function (e) { return e.escape.bind(e); };
|
|
72
|
+
/**
|
|
73
|
+
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
74
|
+
* @type {Object}
|
|
75
|
+
* @property {function(s: string): string } quoted Escapes and wraps quoted
|
|
76
|
+
* values, such as database names.
|
|
77
|
+
* @property {function(s: string): string } stringLit Escapes and
|
|
78
|
+
* wraps string literals.
|
|
79
|
+
* @property {function(s: string): string } measurement Escapes measurement
|
|
80
|
+
* names on the line protocol.
|
|
81
|
+
* @property {function(s: string): string } tag Escapes tag keys, take values,
|
|
82
|
+
* and field keys on the line protocol.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* console.log(escape.quoted('my_"db')); // => "my_\"db"
|
|
86
|
+
* console.log(escape.stringLit('hello\'world')); // => 'hello\'world'
|
|
87
|
+
*
|
|
88
|
+
* console.log(escape.measurement('my measurement')); // => my\ measurement
|
|
89
|
+
* console.log(escape.tag('my tag=')); // => my\ tag\=
|
|
90
|
+
*/
|
|
91
|
+
exports.escape = {
|
|
92
|
+
/**
|
|
93
|
+
* measurement escapes measurement names.
|
|
94
|
+
*/
|
|
95
|
+
measurement: bindEsc(new Escaper([',', ' '])),
|
|
96
|
+
/**
|
|
97
|
+
* quoted escapes quoted values, such as database names.
|
|
98
|
+
*/
|
|
99
|
+
quoted: bindEsc(new Escaper(['"'], '"')),
|
|
100
|
+
/**
|
|
101
|
+
* stringLitEscaper escapes single quotes in string literals.
|
|
102
|
+
*/
|
|
103
|
+
stringLit: bindEsc(new Escaper(['\''], '\'')),
|
|
104
|
+
/**
|
|
105
|
+
* tagEscaper escapes tag keys, tag values, and field keys.
|
|
106
|
+
*/
|
|
107
|
+
tag: bindEsc(new Escaper([',', '=', ' '])),
|
|
108
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './escape';
|
|
2
|
-
export * from './ds';
|
|
3
|
-
export * from './times';
|
|
1
|
+
export * from './escape';
|
|
2
|
+
export * from './ds';
|
|
3
|
+
export * from './times';
|
package/lib/src/grammar/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
__export(require("./escape"));
|
|
7
|
-
__export(require("./ds"));
|
|
8
|
-
__export(require("./times"));
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
__export(require("./escape"));
|
|
7
|
+
__export(require("./ds"));
|
|
8
|
+
__export(require("./times"));
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
export interface INanoDate extends Date {
|
|
2
|
-
/**
|
|
3
|
-
* Returns the unix nanoseconds timestamp as a string.
|
|
4
|
-
*/
|
|
5
|
-
getNanoTime(): string;
|
|
6
|
-
/**
|
|
7
|
-
* Formats the date as an ISO RFC3339 timestamp with nanosecond precision.
|
|
8
|
-
*/
|
|
9
|
-
toNanoISOString(): string;
|
|
10
|
-
}
|
|
11
|
-
export declare type TimePrecision = 'n' | 'u' | 'ms' | 's' | 'm' | 'h';
|
|
12
|
-
/**
|
|
13
|
-
* Precision is a map of available Influx time precisions.
|
|
14
|
-
* @type {Object.<String, String>}
|
|
15
|
-
* @example
|
|
16
|
-
* console.log(Precision.Hours); // => 'h'
|
|
17
|
-
* console.log(Precision.Minutes); // => 'm'
|
|
18
|
-
* console.log(Precision.Seconds); // => 's'
|
|
19
|
-
* console.log(Precision.Milliseconds); // => 'ms'
|
|
20
|
-
* console.log(Precision.Microseconds); // => 'u'
|
|
21
|
-
* console.log(Precision.Nanoseconds); // => 'ns'
|
|
22
|
-
*/
|
|
23
|
-
export declare const Precision: Readonly<{
|
|
24
|
-
Hours: string;
|
|
25
|
-
Microseconds: string;
|
|
26
|
-
Milliseconds: string;
|
|
27
|
-
Minutes: string;
|
|
28
|
-
Nanoseconds: string;
|
|
29
|
-
Seconds: string;
|
|
30
|
-
}>;
|
|
31
|
-
/**
|
|
32
|
-
* Covers a nanoseconds unix timestamp to a INanoDate for node-influx. The
|
|
33
|
-
* timestamp is provided as a string to prevent precision loss.
|
|
34
|
-
*
|
|
35
|
-
* Please see [A Moment for Times](https://node-influx.github.io/manual/
|
|
36
|
-
* usage.html#a-moment-for-times) for a more complete and eloquent explanation
|
|
37
|
-
* of time handling in this module.
|
|
38
|
-
*
|
|
39
|
-
* @param {String} timestamp
|
|
40
|
-
* @returns {INanoDate}
|
|
41
|
-
* @example
|
|
42
|
-
* const date = toNanoDate('1475985480231035600')
|
|
43
|
-
*
|
|
44
|
-
* // You can use the returned Date as a normal date:
|
|
45
|
-
* expect(date.getTime()).to.equal(1475985480231);
|
|
46
|
-
*
|
|
47
|
-
* // We decorate it with two additional methods to read
|
|
48
|
-
* // nanosecond-precision results:
|
|
49
|
-
* expect(date.getNanoTime()).to.equal('1475985480231035600');
|
|
50
|
-
* expect(date.toNanoISOString()).to.equal('2016-10-09T03:58:00.231035600Z');
|
|
51
|
-
*/
|
|
52
|
-
export declare function toNanoDate(timestamp: string): INanoDate;
|
|
53
|
-
/**
|
|
54
|
-
* formatDate converts the Date instance to Influx's date query format.
|
|
55
|
-
* @private
|
|
56
|
-
*/
|
|
57
|
-
export declare function formatDate(date: Date): string;
|
|
58
|
-
/**
|
|
59
|
-
* Converts a Date instance to a timestamp with the specified time precision.
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
export declare function dateToTime(date: Date | INanoDate, precision: TimePrecision): string;
|
|
63
|
-
/**
|
|
64
|
-
* Converts an ISO-formatted data or unix timestamp to a Date instance. If
|
|
65
|
-
* the precision is finer than 'ms' the returned value will be a INanoDate.
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
export declare function isoOrTimeToDate(stamp: string | number, precision?: TimePrecision): INanoDate;
|
|
69
|
-
/**
|
|
70
|
-
* Converts a timestamp to a string with the correct precision. Assumes
|
|
71
|
-
* that raw number and string instances are already in the correct precision.
|
|
72
|
-
* @private
|
|
73
|
-
*/
|
|
74
|
-
export declare function castTimestamp(timestamp: string | number | Date, precision: TimePrecision): string;
|
|
1
|
+
export interface INanoDate extends Date {
|
|
2
|
+
/**
|
|
3
|
+
* Returns the unix nanoseconds timestamp as a string.
|
|
4
|
+
*/
|
|
5
|
+
getNanoTime(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Formats the date as an ISO RFC3339 timestamp with nanosecond precision.
|
|
8
|
+
*/
|
|
9
|
+
toNanoISOString(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare type TimePrecision = 'n' | 'u' | 'ms' | 's' | 'm' | 'h';
|
|
12
|
+
/**
|
|
13
|
+
* Precision is a map of available Influx time precisions.
|
|
14
|
+
* @type {Object.<String, String>}
|
|
15
|
+
* @example
|
|
16
|
+
* console.log(Precision.Hours); // => 'h'
|
|
17
|
+
* console.log(Precision.Minutes); // => 'm'
|
|
18
|
+
* console.log(Precision.Seconds); // => 's'
|
|
19
|
+
* console.log(Precision.Milliseconds); // => 'ms'
|
|
20
|
+
* console.log(Precision.Microseconds); // => 'u'
|
|
21
|
+
* console.log(Precision.Nanoseconds); // => 'ns'
|
|
22
|
+
*/
|
|
23
|
+
export declare const Precision: Readonly<{
|
|
24
|
+
Hours: string;
|
|
25
|
+
Microseconds: string;
|
|
26
|
+
Milliseconds: string;
|
|
27
|
+
Minutes: string;
|
|
28
|
+
Nanoseconds: string;
|
|
29
|
+
Seconds: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Covers a nanoseconds unix timestamp to a INanoDate for node-influx. The
|
|
33
|
+
* timestamp is provided as a string to prevent precision loss.
|
|
34
|
+
*
|
|
35
|
+
* Please see [A Moment for Times](https://node-influx.github.io/manual/
|
|
36
|
+
* usage.html#a-moment-for-times) for a more complete and eloquent explanation
|
|
37
|
+
* of time handling in this module.
|
|
38
|
+
*
|
|
39
|
+
* @param {String} timestamp
|
|
40
|
+
* @returns {INanoDate}
|
|
41
|
+
* @example
|
|
42
|
+
* const date = toNanoDate('1475985480231035600')
|
|
43
|
+
*
|
|
44
|
+
* // You can use the returned Date as a normal date:
|
|
45
|
+
* expect(date.getTime()).to.equal(1475985480231);
|
|
46
|
+
*
|
|
47
|
+
* // We decorate it with two additional methods to read
|
|
48
|
+
* // nanosecond-precision results:
|
|
49
|
+
* expect(date.getNanoTime()).to.equal('1475985480231035600');
|
|
50
|
+
* expect(date.toNanoISOString()).to.equal('2016-10-09T03:58:00.231035600Z');
|
|
51
|
+
*/
|
|
52
|
+
export declare function toNanoDate(timestamp: string): INanoDate;
|
|
53
|
+
/**
|
|
54
|
+
* formatDate converts the Date instance to Influx's date query format.
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatDate(date: Date): string;
|
|
58
|
+
/**
|
|
59
|
+
* Converts a Date instance to a timestamp with the specified time precision.
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
export declare function dateToTime(date: Date | INanoDate, precision: TimePrecision): string;
|
|
63
|
+
/**
|
|
64
|
+
* Converts an ISO-formatted data or unix timestamp to a Date instance. If
|
|
65
|
+
* the precision is finer than 'ms' the returned value will be a INanoDate.
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
export declare function isoOrTimeToDate(stamp: string | number, precision?: TimePrecision): INanoDate;
|
|
69
|
+
/**
|
|
70
|
+
* Converts a timestamp to a string with the correct precision. Assumes
|
|
71
|
+
* that raw number and string instances are already in the correct precision.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
export declare function castTimestamp(timestamp: string | number | Date, precision: TimePrecision): string;
|