@things-factory/integration-influxdb 9.2.5 → 10.0.0-beta.10
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-server/engine/task/influxdb-query-flat.d.ts +1 -1
- package/dist-server/engine/task/influxdb-query-flat.js +1 -10
- package/dist-server/engine/task/influxdb-query-flat.js.map +1 -1
- package/dist-server/engine/task/influxdb-query.d.ts +1 -1
- package/dist-server/engine/task/influxdb-query.js +1 -10
- package/dist-server/engine/task/influxdb-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("ses");
|
|
4
3
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
5
4
|
const debug = require('debug')('things-factory:influxdb-query-flat');
|
|
6
5
|
async function influxdbQueryFlat(step, { domain, user, data, variables, lng }) {
|
|
@@ -10,17 +9,9 @@ async function influxdbQueryFlat(step, { domain, user, data, variables, lng }) {
|
|
|
10
9
|
debug(`no connection : ${connection}`);
|
|
11
10
|
throw new Error(`no connection : ${connection}`);
|
|
12
11
|
}
|
|
13
|
-
const compartment = new Compartment({
|
|
14
|
-
domain,
|
|
15
|
-
user,
|
|
16
|
-
lng,
|
|
17
|
-
data,
|
|
18
|
-
variables,
|
|
19
|
-
console
|
|
20
|
-
});
|
|
21
12
|
let fluxQuery;
|
|
22
13
|
try {
|
|
23
|
-
fluxQuery =
|
|
14
|
+
fluxQuery = (0, integration_base_1.evaluateTemplate)(query, { domain, user, lng, data, variables, console });
|
|
24
15
|
}
|
|
25
16
|
catch (err) {
|
|
26
17
|
throw new Error(`Failed to evaluate query: ${err.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxdb-query-flat.js","sourceRoot":"","sources":["../../../server/engine/task/influxdb-query-flat.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"influxdb-query-flat.js","sourceRoot":"","sources":["../../../server/engine/task/influxdb-query-flat.ts"],"names":[],"mappings":";;AACA,uEAA6G;AAE7G,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,CAAC,MAAM,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa,CAAA;IACpG,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,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,mCAAgB,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;IACtF,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 { InfluxDB } from '@influxdata/influxdb-client'\nimport { ConnectionManager, Context, TaskRegistry, evaluateTemplate } 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 = (await ConnectionManager.getConnectionInstanceByName(domain, connection)) as InfluxDB\n if (!client) {\n debug(`no connection : ${connection}`)\n throw new Error(`no connection : ${connection}`)\n }\n\n let fluxQuery\n try {\n fluxQuery = evaluateTemplate(query, { domain, user, lng, data, variables, console })\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 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("ses");
|
|
4
3
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
5
4
|
const debug = require('debug')('things-factory:influxdb-query');
|
|
6
5
|
function processInfluxData(raws) {
|
|
@@ -24,17 +23,9 @@ async function influxdbQuery(step, { domain, user, data, variables, lng }) {
|
|
|
24
23
|
debug(`no connection : ${connection}`);
|
|
25
24
|
throw new Error(`no connection : ${connection}`);
|
|
26
25
|
}
|
|
27
|
-
const compartment = new Compartment({
|
|
28
|
-
domain,
|
|
29
|
-
user,
|
|
30
|
-
lng,
|
|
31
|
-
data,
|
|
32
|
-
variables,
|
|
33
|
-
console
|
|
34
|
-
});
|
|
35
26
|
let fluxQuery;
|
|
36
27
|
try {
|
|
37
|
-
fluxQuery =
|
|
28
|
+
fluxQuery = (0, integration_base_1.evaluateTemplate)(query, { domain, user, lng, data, variables, console });
|
|
38
29
|
}
|
|
39
30
|
catch (err) {
|
|
40
31
|
throw new Error(`Failed to evaluate query: ${err.message}`);
|
|
@@ -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":";;AACA,uEAA6G;AAE7G,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,EAA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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 { InfluxDB, FluxTableMetaData } from '@influxdata/influxdb-client'\nimport { ConnectionManager, Context, TaskRegistry, evaluateTemplate } 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 = (await ConnectionManager.getConnectionInstanceByName(domain, connection)) as InfluxDB\n if (!client) {\n debug(`no connection : ${connection}`)\n throw new Error(`no connection : ${connection}`)\n }\n\n let fluxQuery\n try {\n fluxQuery = evaluateTemplate(query, { domain, user, lng, data, variables, console })\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"]}
|