@things-factory/integration-influxdb 7.0.0-alpha.13

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +0 -0
  3. package/client/bootstrap.ts +9 -0
  4. package/client/editors/property-editor.ts +20 -0
  5. package/client/editors/things-editor-influxdb-point-scheme.ts +305 -0
  6. package/client/index.ts +0 -0
  7. package/dist-server/engine/connector/index.js +4 -0
  8. package/dist-server/engine/connector/index.js.map +1 -0
  9. package/dist-server/engine/connector/influxdb.js +56 -0
  10. package/dist-server/engine/connector/influxdb.js.map +1 -0
  11. package/dist-server/engine/index.js +5 -0
  12. package/dist-server/engine/index.js.map +1 -0
  13. package/dist-server/engine/task/index.js +5 -0
  14. package/dist-server/engine/task/index.js.map +1 -0
  15. package/dist-server/engine/task/influxdb-query.js +59 -0
  16. package/dist-server/engine/task/influxdb-query.js.map +1 -0
  17. package/dist-server/engine/task/influxdb-write-point.js +70 -0
  18. package/dist-server/engine/task/influxdb-write-point.js.map +1 -0
  19. package/dist-server/index.js +4 -0
  20. package/dist-server/index.js.map +1 -0
  21. package/dist-server/tsconfig.tsbuildinfo +1 -0
  22. package/helps/integration/connector/influxdb-connector.ja.md +17 -0
  23. package/helps/integration/connector/influxdb-connector.ko.md +17 -0
  24. package/helps/integration/connector/influxdb-connector.md +17 -0
  25. package/helps/integration/connector/influxdb-connector.ms.md +17 -0
  26. package/helps/integration/connector/influxdb-connector.zh.md +17 -0
  27. package/helps/integration/task/influxdb-query.ja.md +15 -0
  28. package/helps/integration/task/influxdb-query.ko.md +15 -0
  29. package/helps/integration/task/influxdb-query.md +15 -0
  30. package/helps/integration/task/influxdb-query.ms.md +15 -0
  31. package/helps/integration/task/influxdb-query.zh.md +15 -0
  32. package/helps/integration/task/influxdb-write-point.ja.md +28 -0
  33. package/helps/integration/task/influxdb-write-point.ko.md +28 -0
  34. package/helps/integration/task/influxdb-write-point.md +28 -0
  35. package/helps/integration/task/influxdb-write-point.ms.md +28 -0
  36. package/helps/integration/task/influxdb-write-point.zh.md +28 -0
  37. package/package.json +32 -0
  38. package/server/engine/connector/index.ts +1 -0
  39. package/server/engine/connector/influxdb.ts +66 -0
  40. package/server/engine/index.ts +2 -0
  41. package/server/engine/task/index.ts +2 -0
  42. package/server/engine/task/influxdb-query.ts +95 -0
  43. package/server/engine/task/influxdb-write-point.ts +89 -0
  44. package/server/index.ts +1 -0
  45. package/things-factory.config.js +5 -0
  46. package/translations/en.json +7 -0
  47. package/translations/ja.json +7 -0
  48. package/translations/ko.json +7 -0
  49. package/translations/ms.json +7 -0
  50. package/translations/zh.json +7 -0
@@ -0,0 +1,89 @@
1
+ import { Point } from '@influxdata/influxdb-client'
2
+
3
+ import { access } from '@things-factory/utils'
4
+ import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
5
+
6
+ const debug = require('debug')('things-factory:influxdb-write-point')
7
+
8
+ type InfluxDBPointScheme = {
9
+ name: string
10
+ type: string
11
+ val?: any
12
+ accessor?: string
13
+ }
14
+
15
+ async function influxdbWritePoint(step, { logger, domain, data }) {
16
+ const {
17
+ connection,
18
+ params: { organization, bucket, measurement, scheme }
19
+ } = step
20
+
21
+ const client = ConnectionManager.getConnectionInstanceByName(domain, connection)
22
+ if (!client) {
23
+ debug(`no connection : ${connection}`)
24
+ throw new Error(`no connection : ${connection}`)
25
+ }
26
+
27
+ const writeClient = client.getWriteApi(organization, bucket, 'ns')
28
+ const point = new Point(measurement)
29
+
30
+ scheme.forEach((field: InfluxDBPointScheme) => {
31
+ const { name, val, type, accessor } = field
32
+ const calculated = accessor ? access(accessor, data) || val : val
33
+
34
+ switch (type) {
35
+ case 'Tag':
36
+ point.tag(name, calculated)
37
+ break
38
+ case 'String':
39
+ point.stringField(name, calculated)
40
+ break
41
+ case 'Integer':
42
+ point.intField(name, calculated)
43
+ break
44
+ case 'Unsigned':
45
+ point.uintField(name, calculated)
46
+ break
47
+ case 'Float':
48
+ point.floatField(name, calculated)
49
+ break
50
+ case 'Boolean':
51
+ point.booleanField(name, calculated)
52
+ break
53
+ }
54
+ })
55
+
56
+ await writeClient.writePoint(point)
57
+ await writeClient.close()
58
+
59
+ return {
60
+ data: point.fields
61
+ }
62
+ }
63
+
64
+ influxdbWritePoint.parameterSpec = [
65
+ {
66
+ type: 'string',
67
+ name: 'organization',
68
+ label: 'influxdb.organization'
69
+ },
70
+ {
71
+ type: 'string',
72
+ name: 'bucket',
73
+ label: 'influxdb.bucket'
74
+ },
75
+ {
76
+ type: 'string',
77
+ name: 'measurement',
78
+ label: 'influxdb.measurement'
79
+ },
80
+ {
81
+ type: 'influxdb-point-scheme',
82
+ name: 'scheme',
83
+ label: 'influxdb.point-scheme'
84
+ }
85
+ ]
86
+
87
+ influxdbWritePoint.help = 'integration/task/influxdb-write-point'
88
+
89
+ TaskRegistry.registerTaskHandler('influxdb-write-point', influxdbWritePoint)
@@ -0,0 +1 @@
1
+ import './engine'
@@ -0,0 +1,5 @@
1
+ import bootstrap from './dist-client/bootstrap'
2
+
3
+ export default {
4
+ bootstrap
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "label.influxdb.organization": "organization",
3
+ "label.influxdb.query": "query",
4
+ "label.influxdb.bucket": "bucket",
5
+ "label.influxdb.measurement": "measurement",
6
+ "label.influxdb.point-scheme": "point scheme"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "label.influxdb.organization": "organization",
3
+ "label.influxdb.query": "query",
4
+ "label.influxdb.bucket": "bucket",
5
+ "label.influxdb.measurement": "measurement",
6
+ "label.influxdb.point-scheme": "point scheme"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "label.influxdb.organization": "organization",
3
+ "label.influxdb.query": "query",
4
+ "label.influxdb.bucket": "bucket",
5
+ "label.influxdb.measurement": "measurement",
6
+ "label.influxdb.point-scheme": "point scheme"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "label.influxdb.organization": "organization",
3
+ "label.influxdb.query": "query",
4
+ "label.influxdb.bucket": "bucket",
5
+ "label.influxdb.measurement": "measurement",
6
+ "label.influxdb.point-scheme": "point scheme"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "label.influxdb.organization": "organization",
3
+ "label.influxdb.query": "query",
4
+ "label.influxdb.bucket": "bucket",
5
+ "label.influxdb.measurement": "measurement",
6
+ "label.influxdb.point-scheme": "point scheme"
7
+ }