@things-factory/integration-influxdb 7.0.0-alpha.30 → 7.0.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.
- package/client/editors/things-editor-influxdb-point-scheme.ts +21 -17
- package/dist-client/editors/things-editor-influxdb-point-scheme.d.ts +1 -1
- package/dist-client/editors/things-editor-influxdb-point-scheme.js +14 -14
- package/dist-client/editors/things-editor-influxdb-point-scheme.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/engine/connector/index.d.ts +1 -0
- package/dist-server/engine/connector/influxdb.d.ts +14 -0
- package/dist-server/engine/connector/influxdb.js +2 -2
- package/dist-server/engine/connector/influxdb.js.map +1 -1
- package/dist-server/engine/index.d.ts +2 -0
- package/dist-server/engine/task/index.d.ts +2 -0
- package/dist-server/engine/task/influxdb-query.d.ts +1 -0
- package/dist-server/engine/task/influxdb-query.js +24 -13
- package/dist-server/engine/task/influxdb-query.js.map +1 -1
- package/dist-server/engine/task/influxdb-write-point.d.ts +1 -0
- package/dist-server/engine/task/influxdb-write-point.js.map +1 -1
- package/dist-server/index.d.ts +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/server/engine/connector/influxdb.ts +5 -2
- package/server/engine/task/influxdb-query.ts +23 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-influxdb",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@influxdata/influxdb-client": "^1.33.2",
|
|
30
|
-
"@things-factory/integration-base": "^7.0.0
|
|
30
|
+
"@things-factory/integration-base": "^7.0.0",
|
|
31
|
+
"ses": "^1.5.0"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "00f3917ca132679e3571f3f4fd16f4caf84f488e"
|
|
33
34
|
}
|
|
@@ -32,13 +32,16 @@ export class InfluxDBConnector implements Connector {
|
|
|
32
32
|
|
|
33
33
|
ConnectionManager.logger.info(`influxdb connection(${connection.name}:${connection.endpoint}) is connected`)
|
|
34
34
|
} catch (ex) {
|
|
35
|
-
ConnectionManager.logger.info(
|
|
35
|
+
ConnectionManager.logger.info(
|
|
36
|
+
`influxdb connection(${connection.name}:${connection.endpoint}) failed to connect`,
|
|
37
|
+
ex
|
|
38
|
+
)
|
|
36
39
|
throw ex
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
async disconnect(connection: Connection) {
|
|
41
|
-
var
|
|
44
|
+
var client = ConnectionManager.removeConnectionInstance(connection)
|
|
42
45
|
client.close()
|
|
43
46
|
|
|
44
47
|
ConnectionManager.logger.info(`influxdb connection(${connection.name}) is disconnected`)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import 'ses'
|
|
1
2
|
import { InfluxDB, FluxTableMetaData } from '@influxdata/influxdb-client'
|
|
2
|
-
import { VM } from 'vm2'
|
|
3
|
-
|
|
4
3
|
import { ConnectionManager, Context, TaskRegistry } from '@things-factory/integration-base'
|
|
5
4
|
|
|
6
5
|
const debug = require('debug')('things-factory:influxdb-query')
|
|
@@ -25,8 +24,7 @@ interface InfluxRaw {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
function processInfluxData(raws: InfluxRaw[]): InfluxData[] {
|
|
28
|
-
|
|
29
|
-
var result: { [time: string]: InfluxData } = {}
|
|
27
|
+
const result: { [time: string]: InfluxData } = {}
|
|
30
28
|
|
|
31
29
|
raws.forEach(raw => {
|
|
32
30
|
const { _time, _field, _value, _measurement, _start, _stop, result: _result, table, ...tags } = raw
|
|
@@ -56,17 +54,21 @@ async function influxdbQuery(step, { domain, user, data, variables, lng }: Conte
|
|
|
56
54
|
throw new Error(`no connection : ${connection}`)
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
57
|
+
const compartment = new Compartment({
|
|
58
|
+
domain,
|
|
59
|
+
user,
|
|
60
|
+
lng,
|
|
61
|
+
data,
|
|
62
|
+
variables,
|
|
63
|
+
console
|
|
67
64
|
})
|
|
68
65
|
|
|
69
|
-
|
|
66
|
+
let fluxQuery
|
|
67
|
+
try {
|
|
68
|
+
fluxQuery = compartment.evaluate('`' + query + '`')
|
|
69
|
+
} catch (err) {
|
|
70
|
+
throw new Error(`Failed to evaluate query: ${err.message}`)
|
|
71
|
+
}
|
|
70
72
|
|
|
71
73
|
const queryApi = client.getQueryApi(organization)
|
|
72
74
|
|
|
@@ -86,7 +88,14 @@ influxdbQuery.parameterSpec = [
|
|
|
86
88
|
{
|
|
87
89
|
type: 'textarea',
|
|
88
90
|
name: 'query',
|
|
89
|
-
label: 'influxdb.query'
|
|
91
|
+
label: 'influxdb.query',
|
|
92
|
+
property: {
|
|
93
|
+
language: 'text',
|
|
94
|
+
showLineNumbers: true
|
|
95
|
+
},
|
|
96
|
+
styles: {
|
|
97
|
+
flex: '1'
|
|
98
|
+
}
|
|
90
99
|
}
|
|
91
100
|
]
|
|
92
101
|
|