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/schema.js
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var grammar_1 = require("./grammar");
|
|
4
|
-
/**
|
|
5
|
-
* The Schema provides information and utilities for an InfluxDB measurement.
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
var Schema = (function () {
|
|
9
|
-
function Schema(options) {
|
|
10
|
-
var _this = this;
|
|
11
|
-
this.options = options;
|
|
12
|
-
this.tagHash = {};
|
|
13
|
-
// fieldNames are sorted for performance: when coerceFields is run the
|
|
14
|
-
// fields will be added to the output in order.
|
|
15
|
-
this.fieldNames = Object.keys(options.fields).sort();
|
|
16
|
-
options.tags.forEach(function (tag) { _this.tagHash[tag] = true; });
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* coerceFields converts a map of field values to a strings which
|
|
20
|
-
* can be injected into the line protocol without further escaping.
|
|
21
|
-
* The output is given in [key, value] pairs.
|
|
22
|
-
*/
|
|
23
|
-
Schema.prototype.coerceFields = function (fields) {
|
|
24
|
-
var _this = this;
|
|
25
|
-
var consumed = 0;
|
|
26
|
-
var output = [];
|
|
27
|
-
this.fieldNames.forEach(function (field) {
|
|
28
|
-
if (!fields.hasOwnProperty(field)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
var value = fields[field];
|
|
32
|
-
var typ = typeof value;
|
|
33
|
-
consumed += 1;
|
|
34
|
-
if (value == null) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
var coerced;
|
|
38
|
-
switch (_this.options.fields[field]) {
|
|
39
|
-
case grammar_1.FieldType.STRING:
|
|
40
|
-
coerced = grammar_1.escape.quoted(String(value));
|
|
41
|
-
break;
|
|
42
|
-
case grammar_1.FieldType.INTEGER:
|
|
43
|
-
if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
|
|
44
|
-
throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
|
|
45
|
-
}
|
|
46
|
-
coerced = String(Math.floor(value)) + 'i';
|
|
47
|
-
break;
|
|
48
|
-
case grammar_1.FieldType.FLOAT:
|
|
49
|
-
if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
|
|
50
|
-
throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
|
|
51
|
-
}
|
|
52
|
-
coerced = String(value);
|
|
53
|
-
break;
|
|
54
|
-
case grammar_1.FieldType.BOOLEAN:
|
|
55
|
-
if (typ !== 'boolean') {
|
|
56
|
-
throw new Error("Expected boolean value for " + _this.ref(field) + ", but got a " + typ + "!");
|
|
57
|
-
}
|
|
58
|
-
coerced = value ? 'T' : 'F';
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
throw new Error("Unknown field type " + _this.options.fields[field] + " for " + field + " in " +
|
|
62
|
-
(_this.ref() + ". Please ensure that your configuration is correct."));
|
|
63
|
-
}
|
|
64
|
-
output.push([field, coerced]);
|
|
65
|
-
});
|
|
66
|
-
var keys = Object.keys(fields);
|
|
67
|
-
if (consumed !== keys.length) {
|
|
68
|
-
var extraneous = keys.filter(function (f) { return _this.fieldNames.indexOf(f) === -1; });
|
|
69
|
-
throw new Error("Extraneous fields detected for writing InfluxDB point in " +
|
|
70
|
-
(this.ref() + ": `" + extraneous.join('`, `') + "`."));
|
|
71
|
-
}
|
|
72
|
-
return output;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Throws an error if the tags include values other than
|
|
76
|
-
* what was specified in the schema. It returns a list of tag names.
|
|
77
|
-
*/
|
|
78
|
-
Schema.prototype.checkTags = function (tags) {
|
|
79
|
-
var _this = this;
|
|
80
|
-
var names = Object.keys(tags);
|
|
81
|
-
var extraneous = names.filter(function (tag) { return !_this.tagHash[tag]; });
|
|
82
|
-
if (extraneous.length > 0) {
|
|
83
|
-
throw new Error("Extraneous tags detected for writing InfluxDB point in " +
|
|
84
|
-
(this.ref() + ": `" + extraneous.join('`, `') + "`."));
|
|
85
|
-
}
|
|
86
|
-
return names;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Returns the 'db'.'measurement'[.'field'] referencing the current schema.
|
|
90
|
-
*/
|
|
91
|
-
Schema.prototype.ref = function (field) {
|
|
92
|
-
var out = this.options.database + '.' + this.options.measurement;
|
|
93
|
-
if (field) {
|
|
94
|
-
out += '.' + field;
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
};
|
|
98
|
-
return Schema;
|
|
99
|
-
}());
|
|
100
|
-
exports.Schema = Schema;
|
|
101
|
-
/**
|
|
102
|
-
* Coerces the field map to a set of writable values, a la coerceFields,
|
|
103
|
-
* using native guesses based on the field datatypes.
|
|
104
|
-
* @private
|
|
105
|
-
*/
|
|
106
|
-
function coerceBadly(fields) {
|
|
107
|
-
return Object.keys(fields).sort().map(function (field) {
|
|
108
|
-
var value = fields[field];
|
|
109
|
-
if (typeof value === 'string') {
|
|
110
|
-
return [field, grammar_1.escape.quoted(value)];
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return [field, String(value)];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
exports.coerceBadly = coerceBadly;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var grammar_1 = require("./grammar");
|
|
4
|
+
/**
|
|
5
|
+
* The Schema provides information and utilities for an InfluxDB measurement.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
var Schema = (function () {
|
|
9
|
+
function Schema(options) {
|
|
10
|
+
var _this = this;
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.tagHash = {};
|
|
13
|
+
// fieldNames are sorted for performance: when coerceFields is run the
|
|
14
|
+
// fields will be added to the output in order.
|
|
15
|
+
this.fieldNames = Object.keys(options.fields).sort();
|
|
16
|
+
options.tags.forEach(function (tag) { _this.tagHash[tag] = true; });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* coerceFields converts a map of field values to a strings which
|
|
20
|
+
* can be injected into the line protocol without further escaping.
|
|
21
|
+
* The output is given in [key, value] pairs.
|
|
22
|
+
*/
|
|
23
|
+
Schema.prototype.coerceFields = function (fields) {
|
|
24
|
+
var _this = this;
|
|
25
|
+
var consumed = 0;
|
|
26
|
+
var output = [];
|
|
27
|
+
this.fieldNames.forEach(function (field) {
|
|
28
|
+
if (!fields.hasOwnProperty(field)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
var value = fields[field];
|
|
32
|
+
var typ = typeof value;
|
|
33
|
+
consumed += 1;
|
|
34
|
+
if (value == null) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var coerced;
|
|
38
|
+
switch (_this.options.fields[field]) {
|
|
39
|
+
case grammar_1.FieldType.STRING:
|
|
40
|
+
coerced = grammar_1.escape.quoted(String(value));
|
|
41
|
+
break;
|
|
42
|
+
case grammar_1.FieldType.INTEGER:
|
|
43
|
+
if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
|
|
44
|
+
throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
|
|
45
|
+
}
|
|
46
|
+
coerced = String(Math.floor(value)) + 'i';
|
|
47
|
+
break;
|
|
48
|
+
case grammar_1.FieldType.FLOAT:
|
|
49
|
+
if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
|
|
50
|
+
throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
|
|
51
|
+
}
|
|
52
|
+
coerced = String(value);
|
|
53
|
+
break;
|
|
54
|
+
case grammar_1.FieldType.BOOLEAN:
|
|
55
|
+
if (typ !== 'boolean') {
|
|
56
|
+
throw new Error("Expected boolean value for " + _this.ref(field) + ", but got a " + typ + "!");
|
|
57
|
+
}
|
|
58
|
+
coerced = value ? 'T' : 'F';
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
throw new Error("Unknown field type " + _this.options.fields[field] + " for " + field + " in " +
|
|
62
|
+
(_this.ref() + ". Please ensure that your configuration is correct."));
|
|
63
|
+
}
|
|
64
|
+
output.push([field, coerced]);
|
|
65
|
+
});
|
|
66
|
+
var keys = Object.keys(fields);
|
|
67
|
+
if (consumed !== keys.length) {
|
|
68
|
+
var extraneous = keys.filter(function (f) { return _this.fieldNames.indexOf(f) === -1; });
|
|
69
|
+
throw new Error("Extraneous fields detected for writing InfluxDB point in " +
|
|
70
|
+
(this.ref() + ": `" + extraneous.join('`, `') + "`."));
|
|
71
|
+
}
|
|
72
|
+
return output;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Throws an error if the tags include values other than
|
|
76
|
+
* what was specified in the schema. It returns a list of tag names.
|
|
77
|
+
*/
|
|
78
|
+
Schema.prototype.checkTags = function (tags) {
|
|
79
|
+
var _this = this;
|
|
80
|
+
var names = Object.keys(tags);
|
|
81
|
+
var extraneous = names.filter(function (tag) { return !_this.tagHash[tag]; });
|
|
82
|
+
if (extraneous.length > 0) {
|
|
83
|
+
throw new Error("Extraneous tags detected for writing InfluxDB point in " +
|
|
84
|
+
(this.ref() + ": `" + extraneous.join('`, `') + "`."));
|
|
85
|
+
}
|
|
86
|
+
return names;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Returns the 'db'.'measurement'[.'field'] referencing the current schema.
|
|
90
|
+
*/
|
|
91
|
+
Schema.prototype.ref = function (field) {
|
|
92
|
+
var out = this.options.database + '.' + this.options.measurement;
|
|
93
|
+
if (field) {
|
|
94
|
+
out += '.' + field;
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
};
|
|
98
|
+
return Schema;
|
|
99
|
+
}());
|
|
100
|
+
exports.Schema = Schema;
|
|
101
|
+
/**
|
|
102
|
+
* Coerces the field map to a set of writable values, a la coerceFields,
|
|
103
|
+
* using native guesses based on the field datatypes.
|
|
104
|
+
* @private
|
|
105
|
+
*/
|
|
106
|
+
function coerceBadly(fields) {
|
|
107
|
+
return Object.keys(fields).sort().map(function (field) {
|
|
108
|
+
var value = fields[field];
|
|
109
|
+
if (typeof value === 'string') {
|
|
110
|
+
return [field, grammar_1.escape.quoted(value)];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return [field, String(value)];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.coerceBadly = coerceBadly;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "influx",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7",
|
|
4
4
|
"description": "InfluxDB Client",
|
|
5
5
|
"main": "./lib/src/index.js",
|
|
6
6
|
"typings": "./lib/src/index",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"stream-http": "github:node-influx/stream-http",
|
|
67
67
|
"ts-node": "^2.1.0",
|
|
68
68
|
"tslint": "^4.5.1",
|
|
69
|
-
"tslint-microsoft-contrib": "
|
|
69
|
+
"tslint-microsoft-contrib": "4.0.0",
|
|
70
70
|
"typescript": "^2.2.1",
|
|
71
71
|
"webpack": "^2.2.1"
|
|
72
72
|
}
|