influx 5.9.7 → 5.11.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.
@@ -0,0 +1,15 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ - package-ecosystem: "github-actions"
13
+ directory: "/" # Location of package manifests
14
+ schedule:
15
+ interval: "weekly"
@@ -3,20 +3,20 @@ name: CI
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- lint:
7
- name: Check Code Style
8
- runs-on: ubuntu-latest
6
+ # lint:
7
+ # name: Check Code Style
8
+ # runs-on: ubuntu-latest
9
9
 
10
- steps:
11
- - uses: actions/checkout@v3
10
+ # steps:
11
+ # - uses: actions/checkout@v4
12
12
 
13
- - name: Prettier
14
- uses: creyD/prettier_action@v4.3
15
- with:
16
- prettier_options: --write **/*.{tsx,ts,md}
17
- commit_message: "style: prettier code"
18
- env:
19
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13
+ # - name: Prettier
14
+ # uses: creyD/prettier_action@v4.3
15
+ # with:
16
+ # prettier_options: --write **/*.{tsx,ts,md}
17
+ # commit_message: "style: prettier code"
18
+ # env:
19
+ # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20
20
 
21
21
  test-browser:
22
22
  name: "Testing Browser"
@@ -25,7 +25,7 @@ jobs:
25
25
 
26
26
  steps:
27
27
  - name: Checkout
28
- uses: actions/checkout@v3
28
+ uses: actions/checkout@v4
29
29
 
30
30
  - name: Reconfigure Git to use HTTP authentication
31
31
  run: >
@@ -33,7 +33,7 @@ jobs:
33
33
  ssh://git@github.com/
34
34
 
35
35
  - name: Setup Node.js
36
- uses: actions/setup-node@v3
36
+ uses: actions/setup-node@v4
37
37
  with:
38
38
  node-version: "16"
39
39
 
@@ -55,11 +55,11 @@ jobs:
55
55
  fail-fast: false
56
56
 
57
57
  matrix:
58
- node: ["16", "17", "18", "19"]
58
+ node: ["18", "20", "22"]
59
59
 
60
60
  steps:
61
61
  - name: Checkout
62
- uses: actions/checkout@v3
62
+ uses: actions/checkout@v4
63
63
 
64
64
  - name: Reconfigure Git to use HTTP authentication
65
65
  run: >
@@ -67,7 +67,7 @@ jobs:
67
67
  ssh://git@github.com/
68
68
 
69
69
  - name: Setup node ${{ matrix.node }}
70
- uses: actions/setup-node@v3
70
+ uses: actions/setup-node@v4
71
71
  with:
72
72
  node-version: ${{ matrix.node }}
73
73
 
@@ -81,17 +81,16 @@ jobs:
81
81
  run: npm run test:ci
82
82
 
83
83
  - name: Coveralls GitHub Action
84
- uses: coverallsapp/github-action@1.1.3
84
+ uses: coverallsapp/github-action@v2
85
85
  with:
86
86
  github-token: ${{ secrets.GITHUB_TOKEN }}
87
87
  parallel: true
88
88
 
89
-
90
89
  finish:
91
90
  needs: test-node
92
91
  runs-on: ubuntu-latest
93
92
  steps:
94
93
  - name: Close parallel build
95
- uses: coverallsapp/github-action@v1
94
+ uses: coverallsapp/github-action@v2
96
95
  with:
97
96
  parallel-finished: true
@@ -1,8 +1,5 @@
1
1
  name: Release
2
- on:
3
- push:
4
- branches:
5
- - master # or main
2
+ on: workflow_dispatch
6
3
 
7
4
  permissions:
8
5
  contents: read # for checkout
@@ -157,6 +157,10 @@ export interface IQueryOptions {
157
157
  * to avoid injection attacks.
158
158
  */
159
159
  placeholders?: Record<string, string | number>;
160
+ /**
161
+ * Execute a query as a HTTP GET or POST request
162
+ */
163
+ method?: "GET" | "POST";
160
164
  }
161
165
  export interface IParseOptions {
162
166
  /**
package/lib/src/index.js CHANGED
@@ -16,6 +16,7 @@ exports.InfluxDB = exports.ResultError = exports.toNanoDate = exports.escape = e
16
16
  const url = require("url");
17
17
  const b = require("./builder");
18
18
  const grammar = require("./grammar");
19
+ const querystring = require("querystring");
19
20
  const pool_1 = require("./pool");
20
21
  const results_1 = require("./results");
21
22
  const schema_1 = require("./schema");
@@ -857,11 +858,12 @@ class InfluxDB {
857
858
  path: "/write",
858
859
  query: {
859
860
  db: database,
860
- p: this._options.password,
861
861
  precision,
862
862
  rp: retentionPolicy,
863
- u: this._options.username,
864
863
  },
864
+ auth: typeof this._options.username === "string"
865
+ ? `${this._options.username}:${this._options.password || ""}`
866
+ : undefined,
865
867
  });
866
868
  }
867
869
  /**
@@ -998,7 +1000,7 @@ class InfluxDB {
998
1000
  q: query,
999
1001
  rp: retentionPolicy,
1000
1002
  params: JSON.stringify(placeholders),
1001
- }));
1003
+ }, options.method, true));
1002
1004
  }
1003
1005
  /**
1004
1006
  * Pings all available hosts, collecting online status and version info.
@@ -1038,12 +1040,27 @@ class InfluxDB {
1038
1040
  * Creates options to be passed into the pool to query databases.
1039
1041
  * @private
1040
1042
  */
1041
- _getQueryOpts(params, method = "GET") {
1042
- return {
1043
- method,
1044
- path: "/query",
1045
- query: Object.assign({ p: this._options.password, u: this._options.username }, params),
1046
- };
1043
+ _getQueryOpts(params, method = "GET", partOfBody = false) {
1044
+ let auth = undefined;
1045
+ if (typeof this._options.username === "string") {
1046
+ auth = `${this._options.username}:${this._options.password || ""}`;
1047
+ }
1048
+ if (method === "POST" && partOfBody) {
1049
+ return {
1050
+ method,
1051
+ path: "/query",
1052
+ auth,
1053
+ body: querystring.stringify(params),
1054
+ };
1055
+ }
1056
+ else {
1057
+ return {
1058
+ method,
1059
+ path: "/query",
1060
+ auth,
1061
+ query: Object.assign({}, params),
1062
+ };
1063
+ }
1047
1064
  }
1048
1065
  /**
1049
1066
  * Creates specified measurement schema
package/lib/src/pool.d.ts CHANGED
@@ -43,6 +43,15 @@ export interface IPoolRequestOptions {
43
43
  * running this request.
44
44
  */
45
45
  retries?: number;
46
+ /**
47
+ * Optional Basic auth in the form `username:password`.
48
+ * When provided, Pool will set the `Authorization: Basic ...` header.
49
+ */
50
+ auth?: string;
51
+ /**
52
+ * Optional extra headers to include in the request.
53
+ */
54
+ headers?: http.OutgoingHttpHeaders;
46
55
  }
47
56
  /**
48
57
  * An ServiceNotAvailableError is returned as an error from requests that
package/lib/src/pool.js CHANGED
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.Pool = exports.RequestError = exports.ServiceNotAvailableError = void 0;
4
15
  const exponential_1 = require("./backoff/exponential");
@@ -241,9 +252,18 @@ class Pool {
241
252
  if (options.query) {
242
253
  path += "?" + querystring.stringify(options.query);
243
254
  }
244
- const req = request(Object.assign({ headers: {
245
- "content-length": options.body ? Buffer.from(options.body).length : 0,
246
- }, hostname: host.url.hostname, method: options.method, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, host.options), once((res) => {
255
+ // Merge headers from defaults, host options, and call options.
256
+ const hostHeaders = (host.options && host.options.headers) || {};
257
+ const defaultHeaders = Object.assign({ "content-length": options.body ? Buffer.from(options.body).length : 0 }, (options.body && options.path === "/query"
258
+ ? { "Content-Type": "application/x-www-form-urlencoded" }
259
+ : {}));
260
+ const mergedHeaders = Object.assign(Object.assign(Object.assign({}, hostHeaders), defaultHeaders), (options.headers || {}));
261
+ if (typeof options.auth !== "undefined") {
262
+ const encodedAuth = Buffer.from(options.auth).toString("base64");
263
+ mergedHeaders["Authorization"] = `Basic ${encodedAuth}`;
264
+ }
265
+ const _a = (host.options || {}), { headers: _ignoredHostHeaders } = _a, hostReqOptions = __rest(_a, ["headers"]);
266
+ const req = request(Object.assign({ headers: mergedHeaders, hostname: host.url.hostname, method: options.method, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, hostReqOptions), once((res) => {
247
267
  res.setEncoding("utf8");
248
268
  if (res.statusCode >= 500) {
249
269
  res.on("data", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "influx",
3
- "version": "5.9.7",
3
+ "version": "5.11.0",
4
4
  "description": "InfluxDB Client",
5
5
  "main": "./lib/src/index.js",
6
6
  "typings": "./lib/src/index",
@@ -16,7 +16,7 @@
16
16
  "test:integrate": "mocha --require ts-node/register --timeout 20000 test/integrate/*.test.ts",
17
17
  "test:lint": "prettier -c .",
18
18
  "test:ci": "npm-run-all clean test:unit test:integrate build:dist && istanbul cover _mocha --report lcovonly -- lib/test/unit/*.test.js",
19
- "test:unit": "mocha --require ts-node/register test/unit/*.test.ts",
19
+ "test:unit": "mocha --require ts-node/register --timeout 20000 test/unit/*.test.ts",
20
20
  "test:watch": "mocha -R min --watch --require ts-node/register test/unit/*.test.ts",
21
21
  "semantic-release": "semantic-release"
22
22
  },
@@ -41,7 +41,7 @@
41
41
  "license": "MIT",
42
42
  "devDependencies": {
43
43
  "@types/chai": "^4.2.11",
44
- "@types/freeport": "1.0.22",
44
+ "@types/freeport": "1.0.24",
45
45
  "@types/mocha": "^10.0.0",
46
46
  "@types/node": "^18.0.0",
47
47
  "@types/sinon": "^10.0.0",
@@ -58,16 +58,16 @@
58
58
  "karma-chrome-launcher": "^3.1.0",
59
59
  "karma-mocha": "^2.0.1",
60
60
  "karma-mocha-reporter": "2.2.5",
61
- "karma-sourcemap-loader": "0.3.8",
61
+ "karma-sourcemap-loader": "0.4.0",
62
62
  "karma-webpack": "^5.0.0-alpha.5",
63
63
  "lodash": "4.17.21",
64
- "mocha": "^10.0.0",
65
- "node-fetch": "3.3.0",
64
+ "mocha": "^11.1.0",
65
+ "node-fetch": "3.3.2",
66
66
  "npm-run-all": "4.1.5",
67
- "open-cli": "^7.0.0",
68
- "prettier": "^2.3.0",
69
- "puppeteer": "^19.0.0",
70
- "semantic-release": "^20.0.0",
67
+ "open-cli": "^8.0.0",
68
+ "prettier": "^3.4.2",
69
+ "puppeteer": "^24.1.1",
70
+ "semantic-release": "^24.2.1",
71
71
  "sinon": "^15.0.0",
72
72
  "sinon-chai": "^3.5.0",
73
73
  "stream-http": "github:node-influx/stream-http",
package/renovate.json CHANGED
@@ -1,3 +1,7 @@
1
1
  {
2
- "extends": ["config:base", ":preserveSemverRanges", ":disableDependencyDashboard"]
2
+ "extends": [
3
+ "config:base",
4
+ ":preserveSemverRanges",
5
+ ":disableDependencyDashboard"
6
+ ]
3
7
  }