@things-factory/integration-influxdb 9.0.0-beta.8 → 9.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/dist-client/editors/things-editor-influxdb-point-scheme.js +69 -69
- 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/influxdb.js +1 -2
- package/dist-server/engine/connector/influxdb.js.map +1 -1
- package/dist-server/engine/index.d.ts +2 -2
- package/dist-server/engine/index.js +2 -2
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/index.d.ts +1 -0
- package/dist-server/engine/task/index.js +1 -0
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/engine/task/influxdb-query-flat.d.ts +1 -0
- package/dist-server/engine/task/influxdb-query-flat.js +53 -0
- package/dist-server/engine/task/influxdb-query-flat.js.map +1 -0
- package/dist-server/engine/task/influxdb-query.js +3 -4
- package/dist-server/engine/task/influxdb-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,kCAA+B;AAC/B,4BAAyB","sourcesContent":["import './influxdb-write-point'\nimport './influxdb-query'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,kCAA+B;AAC/B,4BAAyB;AACzB,iCAA8B","sourcesContent":["import './influxdb-write-point'\nimport './influxdb-query'\nimport './influxdb-query-flat'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'ses';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("ses");
|
|
4
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
5
|
+
const debug = require('debug')('things-factory:influxdb-query-flat');
|
|
6
|
+
async function influxdbQueryFlat(step, { domain, user, data, variables, lng }) {
|
|
7
|
+
const { connection, params: { organization, query } } = step;
|
|
8
|
+
const client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
|
|
9
|
+
if (!client) {
|
|
10
|
+
debug(`no connection : ${connection}`);
|
|
11
|
+
throw new Error(`no connection : ${connection}`);
|
|
12
|
+
}
|
|
13
|
+
const compartment = new Compartment({
|
|
14
|
+
domain,
|
|
15
|
+
user,
|
|
16
|
+
lng,
|
|
17
|
+
data,
|
|
18
|
+
variables,
|
|
19
|
+
console
|
|
20
|
+
});
|
|
21
|
+
let fluxQuery;
|
|
22
|
+
try {
|
|
23
|
+
fluxQuery = compartment.evaluate('`' + query + '`');
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
throw new Error(`Failed to evaluate query: ${err.message}`);
|
|
27
|
+
}
|
|
28
|
+
const queryApi = client.getQueryApi(organization);
|
|
29
|
+
const rows = await queryApi.collectRows(fluxQuery);
|
|
30
|
+
return { data: rows };
|
|
31
|
+
}
|
|
32
|
+
influxdbQueryFlat.parameterSpec = [
|
|
33
|
+
{
|
|
34
|
+
type: 'string',
|
|
35
|
+
name: 'organization',
|
|
36
|
+
label: 'influxdb.organization'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'textarea',
|
|
40
|
+
name: 'query',
|
|
41
|
+
label: 'influxdb.query',
|
|
42
|
+
property: {
|
|
43
|
+
language: 'text',
|
|
44
|
+
showLineNumbers: true
|
|
45
|
+
},
|
|
46
|
+
styles: {
|
|
47
|
+
flex: '1'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
influxdbQueryFlat.help = 'integration/task/influxdb-query-flat';
|
|
52
|
+
integration_base_1.TaskRegistry.registerTaskHandler('influxdb-query-flat', influxdbQueryFlat);
|
|
53
|
+
//# sourceMappingURL=influxdb-query-flat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"influxdb-query-flat.js","sourceRoot":"","sources":["../../../server/engine/task/influxdb-query-flat.ts"],"names":[],"mappings":";;AAAA,eAAY;AAEZ,uEAA2F;AAE3F,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,CAAA;AAEpE,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAW;IACpF,MAAM,EACJ,UAAU,EACV,MAAM,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,EAChC,GAAG,IAAI,CAAA;IAER,MAAM,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAa,CAAA;IAC5F,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;QACtC,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;QAClC,MAAM;QACN,IAAI;QACJ,GAAG;QACH,IAAI;QACJ,SAAS;QACT,OAAO;KACR,CAAC,CAAA;IAEF,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAA;IACrD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IACjD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IAElD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AACvB,CAAC;AAED,iBAAiB,CAAC,aAAa,GAAG;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,uBAAuB;KAC/B;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE;YACR,QAAQ,EAAE,MAAM;YAChB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG;SACV;KACF;CACF,CAAA;AAED,iBAAiB,CAAC,IAAI,GAAG,sCAAsC,CAAA;AAE/D,+BAAY,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import 'ses'\nimport { InfluxDB } from '@influxdata/influxdb-client'\nimport { ConnectionManager, Context, TaskRegistry } from '@things-factory/integration-base'\n\nconst debug = require('debug')('things-factory:influxdb-query-flat')\n\nasync function influxdbQueryFlat(step, { domain, user, data, variables, lng }: Context) {\n const {\n connection,\n params: { organization, query }\n } = step\n\n const client = ConnectionManager.getConnectionInstanceByName(domain, connection) as InfluxDB\n if (!client) {\n debug(`no connection : ${connection}`)\n throw new Error(`no connection : ${connection}`)\n }\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let fluxQuery\n try {\n fluxQuery = compartment.evaluate('`' + query + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate query: ${err.message}`)\n }\n\n const queryApi = client.getQueryApi(organization)\n const rows = await queryApi.collectRows(fluxQuery)\n\n return { data: rows }\n}\n\ninfluxdbQueryFlat.parameterSpec = [\n {\n type: 'string',\n name: 'organization',\n label: 'influxdb.organization'\n },\n {\n type: 'textarea',\n name: 'query',\n label: 'influxdb.query',\n property: {\n language: 'text',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n }\n]\n\ninfluxdbQueryFlat.help = 'integration/task/influxdb-query-flat'\n\nTaskRegistry.registerTaskHandler('influxdb-query-flat', influxdbQueryFlat)\n"]}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
require("ses");
|
|
5
4
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
6
5
|
const debug = require('debug')('things-factory:influxdb-query');
|
|
7
6
|
function processInfluxData(raws) {
|
|
8
7
|
const result = {};
|
|
9
8
|
raws.forEach(raw => {
|
|
10
|
-
const { _time, _field, _value, _measurement, _start, _stop, result: _result, table
|
|
11
|
-
result[_time]
|
|
9
|
+
const { _time, _field, _value, _measurement, _start, _stop, result: _result, table, ...tags } = raw;
|
|
10
|
+
result[_time] ||= {
|
|
12
11
|
timestamp: _time,
|
|
13
12
|
measurement: _measurement,
|
|
14
13
|
tags,
|
|
15
14
|
fields: {}
|
|
16
|
-
}
|
|
15
|
+
};
|
|
17
16
|
result[_time].fields[_field] = _value;
|
|
18
17
|
});
|
|
19
18
|
return Object.values(result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxdb-query.js","sourceRoot":"","sources":["../../../server/engine/task/influxdb-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"influxdb-query.js","sourceRoot":"","sources":["../../../server/engine/task/influxdb-query.ts"],"names":[],"mappings":";;AAAA,eAAY;AAEZ,uEAA2F;AAE3F,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,CAAA;AAqB/D,SAAS,iBAAiB,CAAC,IAAiB;IAC1C,MAAM,MAAM,GAAmC,EAAE,CAAA;IAEjD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAA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CAAC,CAAA;IAEjD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IAEpD,OAAO;QACL,IAAI,EAAE,iBAAiB,CAAC,MAAqB,CAAC;KAC/C,CAAA;AACH,CAAC;AAED,aAAa,CAAC,aAAa,GAAG;IAC5B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,uBAAuB;KAC/B;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,gBAAgB;QACvB,QAAQ,EAAE;YACR,QAAQ,EAAE,MAAM;YAChB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG;SACV;KACF;CACF,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,iCAAiC,CAAA;AAEtD,+BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import 'ses'\nimport { InfluxDB, FluxTableMetaData } from '@influxdata/influxdb-client'\nimport { ConnectionManager, Context, TaskRegistry } from '@things-factory/integration-base'\n\nconst debug = require('debug')('things-factory:influxdb-query')\n\ninterface InfluxData {\n measurement: string\n tags: { [key: string]: string }\n fields: { [key: string]: number | string | boolean }\n timestamp: string\n}\n\ninterface InfluxRaw {\n _time: string\n _start: string\n _stop: string\n _measurement: string\n _field: string\n _value: any\n table: any\n result: any\n [tag: string]: string\n}\n\nfunction processInfluxData(raws: InfluxRaw[]): InfluxData[] {\n const result: { [time: string]: InfluxData } = {}\n\n raws.forEach(raw => {\n const { _time, _field, _value, _measurement, _start, _stop, result: _result, table, ...tags } = raw\n\n result[_time] ||= {\n timestamp: _time,\n measurement: _measurement,\n tags,\n fields: {}\n }\n\n result[_time].fields[_field] = _value\n })\n\n return Object.values(result)\n}\n\nasync function influxdbQuery(step, { domain, user, data, variables, lng }: Context) {\n const {\n connection,\n params: { organization, query }\n } = step\n\n const client = ConnectionManager.getConnectionInstanceByName(domain, connection) as InfluxDB\n if (!client) {\n debug(`no connection : ${connection}`)\n throw new Error(`no connection : ${connection}`)\n }\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let fluxQuery\n try {\n fluxQuery = compartment.evaluate('`' + query + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate query: ${err.message}`)\n }\n\n const queryApi = client.getQueryApi(organization)\n\n const result = await queryApi.collectRows(fluxQuery)\n\n return {\n data: processInfluxData(result as InfluxRaw[])\n }\n}\n\ninfluxdbQuery.parameterSpec = [\n {\n type: 'string',\n name: 'organization',\n label: 'influxdb.organization'\n },\n {\n type: 'textarea',\n name: 'query',\n label: 'influxdb.query',\n property: {\n language: 'text',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n }\n]\n\ninfluxdbQuery.help = 'integration/task/influxdb-query'\n\nTaskRegistry.registerTaskHandler('influxdb-query', influxdbQuery)\n"]}
|