influx 5.0.3 → 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.
@@ -1,58 +1,58 @@
1
- import { FieldType } from './grammar';
2
- export interface ISchemaOptions {
3
- /**
4
- * The measurement name this schema is describing.
5
- */
6
- measurement: string;
7
- /**
8
- * The database the measurement lives under. Uses the default database
9
- * if one is provided.
10
- */
11
- database?: string;
12
- /**
13
- * Columns is the map of column type definitions on the database.
14
- */
15
- fields: {
16
- [column: string]: FieldType;
17
- };
18
- /**
19
- * A list of schema tag names.
20
- */
21
- tags: string[];
22
- }
23
- export declare type FieldMap = {
24
- [name: string]: string | number | boolean;
25
- };
26
- /**
27
- * The Schema provides information and utilities for an InfluxDB measurement.
28
- * @private
29
- */
30
- export declare class Schema {
31
- private options;
32
- private fieldNames;
33
- private tagHash;
34
- constructor(options: ISchemaOptions);
35
- /**
36
- * coerceFields converts a map of field values to a strings which
37
- * can be injected into the line protocol without further escaping.
38
- * The output is given in [key, value] pairs.
39
- */
40
- coerceFields(fields: FieldMap): [string, string][];
41
- /**
42
- * Throws an error if the tags include values other than
43
- * what was specified in the schema. It returns a list of tag names.
44
- */
45
- checkTags(tags: {
46
- [tag: string]: string;
47
- }): string[];
48
- /**
49
- * Returns the 'db'.'measurement'[.'field'] referencing the current schema.
50
- */
51
- private ref(field?);
52
- }
53
- /**
54
- * Coerces the field map to a set of writable values, a la coerceFields,
55
- * using native guesses based on the field datatypes.
56
- * @private
57
- */
58
- export declare function coerceBadly(fields: FieldMap): [string, string][];
1
+ import { FieldType } from './grammar';
2
+ export interface ISchemaOptions {
3
+ /**
4
+ * The measurement name this schema is describing.
5
+ */
6
+ measurement: string;
7
+ /**
8
+ * The database the measurement lives under. Uses the default database
9
+ * if one is provided.
10
+ */
11
+ database?: string;
12
+ /**
13
+ * Columns is the map of column type definitions on the database.
14
+ */
15
+ fields: {
16
+ [column: string]: FieldType;
17
+ };
18
+ /**
19
+ * A list of schema tag names.
20
+ */
21
+ tags: string[];
22
+ }
23
+ export declare type FieldMap = {
24
+ [name: string]: string | number | boolean;
25
+ };
26
+ /**
27
+ * The Schema provides information and utilities for an InfluxDB measurement.
28
+ * @private
29
+ */
30
+ export declare class Schema {
31
+ private options;
32
+ private fieldNames;
33
+ private tagHash;
34
+ constructor(options: ISchemaOptions);
35
+ /**
36
+ * coerceFields converts a map of field values to a strings which
37
+ * can be injected into the line protocol without further escaping.
38
+ * The output is given in [key, value] pairs.
39
+ */
40
+ coerceFields(fields: FieldMap): [string, string][];
41
+ /**
42
+ * Throws an error if the tags include values other than
43
+ * what was specified in the schema. It returns a list of tag names.
44
+ */
45
+ checkTags(tags: {
46
+ [tag: string]: string;
47
+ }): string[];
48
+ /**
49
+ * Returns the 'db'.'measurement'[.'field'] referencing the current schema.
50
+ */
51
+ private ref(field?);
52
+ }
53
+ /**
54
+ * Coerces the field map to a set of writable values, a la coerceFields,
55
+ * using native guesses based on the field datatypes.
56
+ * @private
57
+ */
58
+ export declare function coerceBadly(fields: FieldMap): [string, string][];
package/lib/src/schema.js CHANGED
@@ -1,116 +1,117 @@
1
- "use strict";
2
- var grammar_1 = require('./grammar');
3
- /**
4
- * The Schema provides information and utilities for an InfluxDB measurement.
5
- * @private
6
- */
7
- var Schema = (function () {
8
- function Schema(options) {
9
- var _this = this;
10
- this.options = options;
11
- this.tagHash = {};
12
- // fieldNames are sorted for performance: when coerceFields is run the
13
- // fields will be added to the output in order.
14
- this.fieldNames = Object.keys(options.fields).sort();
15
- options.tags.forEach(function (tag) { _this.tagHash[tag] = true; });
16
- }
17
- /**
18
- * coerceFields converts a map of field values to a strings which
19
- * can be injected into the line protocol without further escaping.
20
- * The output is given in [key, value] pairs.
21
- */
22
- Schema.prototype.coerceFields = function (fields) {
23
- var _this = this;
24
- var consumed = 0;
25
- var output = [];
26
- this.fieldNames.forEach(function (field) {
27
- if (!fields.hasOwnProperty(field)) {
28
- return;
29
- }
30
- var value = fields[field];
31
- var typ = typeof value;
32
- consumed += 1;
33
- if (value == null) {
34
- return;
35
- }
36
- var coerced;
37
- switch (_this.options.fields[field]) {
38
- case grammar_1.FieldType.STRING:
39
- coerced = grammar_1.escape.quoted(String(value));
40
- break;
41
- case grammar_1.FieldType.INTEGER:
42
- if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
43
- throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
44
- }
45
- coerced = String(Math.floor(value)) + 'i';
46
- break;
47
- case grammar_1.FieldType.FLOAT:
48
- if (typ !== 'number' && !grammar_1.isNumeric(String(value))) {
49
- throw new Error("Expected numeric value for " + _this.ref(field) + ", but got '" + value + "'!");
50
- }
51
- coerced = String(value);
52
- break;
53
- case grammar_1.FieldType.BOOLEAN:
54
- if (typ !== 'boolean') {
55
- throw new Error("Expected boolean value for " + _this.ref(field) + ", but got a " + typ + "!");
56
- }
57
- coerced = value ? 'T' : 'F';
58
- break;
59
- default:
60
- throw new Error(("Unknown field type " + _this.options.fields[field] + " for " + field + " in ") +
61
- (_this.ref() + ". Please ensure that your configuration is correct."));
62
- }
63
- output.push([field, coerced]);
64
- });
65
- var keys = Object.keys(fields);
66
- if (consumed !== keys.length) {
67
- var extraneous = keys.filter(function (f) { return _this.fieldNames.indexOf(f) === -1; });
68
- throw new Error("Extraneous fields detected for writing InfluxDB point in" +
69
- (this.ref() + ": `" + extraneous.join('`, `') + "`."));
70
- }
71
- return output;
72
- };
73
- /**
74
- * Throws an error if the tags include values other than
75
- * what was specified in the schema. It returns a list of tag names.
76
- */
77
- Schema.prototype.checkTags = function (tags) {
78
- var _this = this;
79
- var names = Object.keys(tags);
80
- var extraneous = names.filter(function (tag) { return !_this.tagHash[tag]; });
81
- if (extraneous.length > 0) {
82
- throw new Error("Extraneous tags detected for writing InfluxDB point in" +
83
- (this.ref() + ": `" + extraneous.join('`, `') + "`."));
84
- }
85
- return names;
86
- };
87
- /**
88
- * Returns the 'db'.'measurement'[.'field'] referencing the current schema.
89
- */
90
- Schema.prototype.ref = function (field) {
91
- var out = this.options.database + '.' + this.options.measurement;
92
- if (field) {
93
- out += '.' + field;
94
- }
95
- return out;
96
- };
97
- return Schema;
98
- }());
99
- exports.Schema = Schema;
100
- /**
101
- * Coerces the field map to a set of writable values, a la coerceFields,
102
- * using native guesses based on the field datatypes.
103
- * @private
104
- */
105
- function coerceBadly(fields) {
106
- return Object.keys(fields).sort().map(function (field) {
107
- var value = fields[field];
108
- if (typeof value === 'string') {
109
- return [field, grammar_1.escape.quoted(value)];
110
- }
111
- else {
112
- return [field, String(value)];
113
- }
114
- });
115
- }
116
- 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",
3
+ "version": "5.0.7",
4
4
  "description": "InfluxDB Client",
5
5
  "main": "./lib/src/index.js",
6
6
  "typings": "./lib/src/index",
@@ -15,7 +15,7 @@
15
15
  "test:integrate": "mocha --compilers ts:ts-node/register --timeout 20000 test/integrate/*.test.ts",
16
16
  "test:lint": "tslint --type-check --project tsconfig.json '{src,test}/**/*.ts'",
17
17
  "test:sauce": "SAUCE=1 karma start test/karma.conf.js",
18
- "test:travis": "npm-run-all --parallel test:sauce test:integrate test:lint build:dist && istanbul cover _mocha --report lcovonly -- lib/test/unit/*.test.js",
18
+ "test:travis": "npm-run-all clean test:lint test:sauce test:integrate build:dist && istanbul cover _mocha --report lcovonly -- lib/test/unit/*.test.js",
19
19
  "test:unit": "mocha --compilers ts:ts-node/register test/unit/*.test.ts",
20
20
  "test:watch": "mocha -R min --watch --compilers ts:ts-node/register test/unit/*.test.ts"
21
21
  },
@@ -43,7 +43,7 @@
43
43
  "@types/node": "^6.0.45",
44
44
  "@types/sinon": "^1.16.31",
45
45
  "@types/sinon-chai": "^2.7.27",
46
- "awesome-typescript-loader": "^2.2.4",
46
+ "awesome-typescript-loader": "^3.0.8",
47
47
  "chai": "^3.5.0",
48
48
  "coveralls": "^2.11.1",
49
49
  "esdoc": "^0.4.8",
@@ -55,19 +55,19 @@
55
55
  "karma-mocha-reporter": "^2.2.0",
56
56
  "karma-sauce-launcher": "^1.0.0",
57
57
  "karma-sourcemap-loader": "^0.3.7",
58
- "karma-webpack": "^1.8.0",
58
+ "karma-webpack": "^2.0.2",
59
59
  "lodash": "^4.16.2",
60
60
  "mocha": "^3.1.0",
61
61
  "node-fetch": "^1.6.3",
62
- "npm-run-all": "^3.1.0",
62
+ "npm-run-all": "^4.0.2",
63
63
  "opn-cli": "^3.1.0",
64
64
  "sinon": "^2.0.0-pre.3",
65
65
  "sinon-chai": "^2.8.0",
66
66
  "stream-http": "github:node-influx/stream-http",
67
- "ts-node": "^1.3.0",
68
- "tslint": "^3.11.0",
69
- "tslint-microsoft-contrib": "^2.0.13",
70
- "typescript": "^2.0.0",
71
- "webpack": "^1.13.2"
67
+ "ts-node": "^2.1.0",
68
+ "tslint": "^4.5.1",
69
+ "tslint-microsoft-contrib": "4.0.0",
70
+ "typescript": "^2.2.1",
71
+ "webpack": "^2.2.1"
72
72
  }
73
73
  }