@things-factory/integration-base 7.0.1-rc.5 → 7.0.1-rc.7
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/database-query.d.ts +1 -1
- package/dist-server/engine/task/database-query.js +16 -11
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.d.ts +1 -1
- package/dist-server/engine/task/graphql-mutate.js +16 -11
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.d.ts +1 -1
- package/dist-server/engine/task/graphql-query.js +16 -11
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/http-get.d.ts +1 -1
- package/dist-server/engine/task/http-get.js +28 -12
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.d.ts +1 -1
- package/dist-server/engine/task/http-post.js +22 -11
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.d.ts +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js +16 -10
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.d.ts +1 -1
- package/dist-server/engine/task/local-graphql-query.js +16 -10
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/log.d.ts +1 -1
- package/dist-server/engine/task/log.js +15 -11
- package/dist-server/engine/task/log.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.d.ts +1 -1
- package/dist-server/engine/task/oracle-procedure.js +18 -12
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/script.d.ts +1 -1
- package/dist-server/engine/task/script.js +30 -18
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/server/engine/task/database-query.ts +16 -11
- package/server/engine/task/graphql-mutate.ts +16 -12
- package/server/engine/task/graphql-query.ts +15 -12
- package/server/engine/task/http-get.ts +26 -12
- package/server/engine/task/http-post.ts +22 -11
- package/server/engine/task/local-graphql-mutate.ts +16 -10
- package/server/engine/task/local-graphql-query.ts +16 -10
- package/server/engine/task/log.ts +14 -11
- package/server/engine/task/oracle-procedure.ts +19 -13
- package/server/engine/task/script.ts +28 -18
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -1,23 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const vm2_1 = require("vm2");
|
4
3
|
const connection_manager_1 = require("../connection-manager");
|
5
4
|
const task_registry_1 = require("../task-registry");
|
5
|
+
require("ses");
|
6
6
|
async function DatabaseQuery(step, context) {
|
7
7
|
var { domain, user, data, variables, lng } = context;
|
8
8
|
var { connection: connectionName, params: { query } } = step;
|
9
9
|
var dbconnection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
10
|
+
const compartment = new Compartment({
|
11
|
+
domain,
|
12
|
+
user,
|
13
|
+
lng,
|
14
|
+
data,
|
15
|
+
variables,
|
16
|
+
console
|
18
17
|
});
|
19
|
-
|
20
|
-
|
18
|
+
let evalQuery;
|
19
|
+
try {
|
20
|
+
evalQuery = compartment.evaluate('`' + query + '`');
|
21
|
+
}
|
22
|
+
catch (err) {
|
23
|
+
throw new Error(`Failed to evaluate query: ${err.message}`);
|
24
|
+
}
|
25
|
+
var queryResult = await dbconnection.query(evalQuery, []);
|
21
26
|
return {
|
22
27
|
data: queryResult
|
23
28
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database-query.js","sourceRoot":"","sources":["../../../server/engine/task/database-query.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"database-query.js","sourceRoot":"","sources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BAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import { ConnectionManager } from '../connection-manager'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\nimport 'ses'\n\nasync function DatabaseQuery(step: InputStep, context: Context) {\n var { domain, user, data, variables, lng } = context\n var {\n connection: connectionName,\n params: { query }\n } = step\n\n var dbconnection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalQuery\n try {\n evalQuery = compartment.evaluate('`' + query + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate query: ${err.message}`)\n }\n\n var queryResult = await dbconnection.query(evalQuery, [])\n\n return {\n data: queryResult\n }\n}\n\nDatabaseQuery.parameterSpec = [\n {\n type: 'textarea',\n name: 'query',\n label: 'query',\n property: {\n language: 'sql',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n }\n]\n\nDatabaseQuery.help = 'integration/task/database-query'\n\nTaskRegistry.registerTaskHandler('database-query', DatabaseQuery)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
5
|
-
|
5
|
+
require("ses");
|
6
6
|
const utils_1 = require("@things-factory/utils");
|
7
7
|
const connection_manager_1 = require("../connection-manager");
|
8
8
|
const task_registry_1 = require("../task-registry");
|
@@ -10,16 +10,21 @@ async function GraphqlMutate(step, context) {
|
|
10
10
|
var { connection: connectionName, params: stepOptions } = step;
|
11
11
|
var { mutation, variables: variablesAccessorMap, headers } = stepOptions || {};
|
12
12
|
var { domain, user, data, variables, lng } = context;
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
13
|
+
const compartment = new Compartment({
|
14
|
+
domain,
|
15
|
+
user,
|
16
|
+
lng,
|
17
|
+
data,
|
18
|
+
variables,
|
19
|
+
console
|
21
20
|
});
|
22
|
-
|
21
|
+
let evalMutation;
|
22
|
+
try {
|
23
|
+
evalMutation = compartment.evaluate('`' + mutation + '`');
|
24
|
+
}
|
25
|
+
catch (err) {
|
26
|
+
throw new Error(`Failed to evaluate mutation: ${err.message}`);
|
27
|
+
}
|
23
28
|
var client = connection_manager_1.ConnectionManager.getConnectionInstanceByName(context.domain, connectionName);
|
24
29
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
25
30
|
const accessor = variablesAccessorMap[key];
|
@@ -28,7 +33,7 @@ async function GraphqlMutate(step, context) {
|
|
28
33
|
}, {});
|
29
34
|
var { data: mutateResult } = await client.mutate({
|
30
35
|
mutation: (0, graphql_tag_1.default) `
|
31
|
-
${
|
36
|
+
${evalMutation}
|
32
37
|
`,
|
33
38
|
variables: queryVariables,
|
34
39
|
headers
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"graphql-mutate.js","sourceRoot":"","sources":["../../../server/engine/task/graphql-mutate.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,
|
1
|
+
{"version":3,"file":"graphql-mutate.js","sourceRoot":"","sources":["../../../server/engine/task/graphql-mutate.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,eAAY;AAEZ,iDAA8C;AAC9C,8DAAyD;AACzD,oDAA+C;AAI/C,KAAK,UAAU,aAAa,CAAC,IAAe,EAAE,OAAgB;IAC5D,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAE9E,IAAI,EAAE,MAAM,EAAE,IAAI,E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,EAAE;YACR,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;SACR;KACF;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,iCAAiC,CAAA;AAEtD,4BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport 'ses'\n\nimport { access } from '@things-factory/utils'\nimport { ConnectionManager } from '../connection-manager'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function GraphqlMutate(step: InputStep, context: Context) {\n var { connection: connectionName, params: stepOptions } = step\n var { mutation, variables: variablesAccessorMap, headers } = stepOptions || {}\n\n var { domain, user, data, variables, lng } = context\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalMutation\n try {\n evalMutation = compartment.evaluate('`' + mutation + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate mutation: ${err.message}`)\n }\n\n var client = ConnectionManager.getConnectionInstanceByName(context.domain, connectionName)\n\n const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {\n const accessor = variablesAccessorMap[key]\n variables[key] = access(accessor, data)\n return variables\n }, {})\n\n var { data: mutateResult } = await client.mutate({\n mutation: gql`\n ${evalMutation}\n `,\n variables: queryVariables,\n headers\n })\n\n return {\n data: mutateResult\n }\n}\n\nGraphqlMutate.parameterSpec = [\n {\n type: 'graphql',\n name: 'mutation',\n label: 'mutation',\n property: {\n showLineNumbers: true\n },\n styles: {\n flex: 1\n }\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables'\n },\n {\n type: 'key-values',\n name: 'headers',\n label: 'headers'\n }\n]\n\nGraphqlMutate.help = 'integration/task/graphql-mutate'\n\nTaskRegistry.registerTaskHandler('graphql-mutate', GraphqlMutate)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
5
|
-
|
5
|
+
require("ses");
|
6
6
|
const utils_1 = require("@things-factory/utils");
|
7
7
|
const connection_manager_1 = require("../connection-manager");
|
8
8
|
const task_registry_1 = require("../task-registry");
|
@@ -10,16 +10,21 @@ async function GraphqlQuery(step, context) {
|
|
10
10
|
var { connection: connectionName, params: stepOptions } = step;
|
11
11
|
var { query, variables: variablesAccessorMap, headers } = stepOptions || {};
|
12
12
|
var { domain, user, data, variables, lng } = context;
|
13
|
-
const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
13
|
+
const compartment = new Compartment({
|
14
|
+
domain,
|
15
|
+
user,
|
16
|
+
lng,
|
17
|
+
data,
|
18
|
+
variables,
|
19
|
+
console
|
21
20
|
});
|
22
|
-
|
21
|
+
let evalQuery;
|
22
|
+
try {
|
23
|
+
evalQuery = compartment.evaluate('`' + query + '`');
|
24
|
+
}
|
25
|
+
catch (err) {
|
26
|
+
throw new Error(`Failed to evaluate query: ${err.message}`);
|
27
|
+
}
|
23
28
|
var client = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
24
29
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
25
30
|
const accessor = variablesAccessorMap[key];
|
@@ -28,7 +33,7 @@ async function GraphqlQuery(step, context) {
|
|
28
33
|
}, {});
|
29
34
|
var { data: queryResult } = await client.query({
|
30
35
|
query: (0, graphql_tag_1.default) `
|
31
|
-
${
|
36
|
+
${evalQuery}
|
32
37
|
`,
|
33
38
|
variables: queryVariables,
|
34
39
|
headers
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"graphql-query.js","sourceRoot":"","sources":["../../../server/engine/task/graphql-query.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,
|
1
|
+
{"version":3,"file":"graphql-query.js","sourceRoot":"","sources":["../../../server/engine/task/graphql-query.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,eAAY;AAEZ,iDAA8C;AAC9C,8DAAyD;AACzD,oDAA+C;AAI/C,KAAK,UAAU,YAAY,CAAC,IAAe,EAAE,OAAgB;IAC3D,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9D,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAC3E,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IAEpD,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,IAAI,MAAM,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAElF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE;QACvF,MAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAA;QAC1C,SAAS,CAAC,GAAG,CAAC,GAAG,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QACvC,OAAO,SAAS,CAAA;IAClB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;QAC7C,KAAK,EAAE,IAAA,qBAAG,EAAA;QACN,SAAS;KACZ;QACD,SAAS,EAAE,cAAc;QACzB,OAAO;KACR,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,WAAW;KAClB,CAAA;AACH,CAAC;AAED,YAAY,CAAC,aAAa,GAAG;IAC3B;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE;YACR,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;SACR;KACF;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAED,YAAY,CAAC,IAAI,GAAG,gCAAgC,CAAA;AAEpD,4BAAY,CAAC,mBAAmB,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport 'ses'\n\nimport { access } from '@things-factory/utils'\nimport { ConnectionManager } from '../connection-manager'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function GraphqlQuery(step: InputStep, context: Context) {\n var { connection: connectionName, params: stepOptions } = step\n var { query, variables: variablesAccessorMap, headers } = stepOptions || {}\n var { domain, user, data, variables, lng } = context\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalQuery\n try {\n evalQuery = compartment.evaluate('`' + query + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate query: ${err.message}`)\n }\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {\n const accessor = variablesAccessorMap[key]\n variables[key] = access(accessor, data)\n return variables\n }, {})\n\n var { data: queryResult } = await client.query({\n query: gql`\n ${evalQuery}\n `,\n variables: queryVariables,\n headers\n })\n\n return {\n data: queryResult\n }\n}\n\nGraphqlQuery.parameterSpec = [\n {\n type: 'graphql',\n name: 'query',\n label: 'query',\n property: {\n showLineNumbers: true\n },\n styles: {\n flex: 1\n }\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables'\n },\n {\n type: 'key-values',\n name: 'headers',\n label: 'headers'\n }\n]\n\nGraphqlQuery.help = 'integration/task/graphql-query'\n\nTaskRegistry.registerTaskHandler('graphql-query', GraphqlQuery)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
5
|
-
|
5
|
+
require("ses");
|
6
6
|
const url_1 = require("url");
|
7
7
|
const https_1 = tslib_1.__importDefault(require("https"));
|
8
8
|
const task_registry_1 = require("../task-registry");
|
@@ -16,26 +16,42 @@ async function HttpGet(step, { logger, data, domain, user, variables, lng }) {
|
|
16
16
|
throw new Error(`connection '${connectionName}' is not established.`);
|
17
17
|
}
|
18
18
|
var { endpoint, params: connectionParams, authHeaders = {} } = connection;
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
19
|
+
const compartment = new Compartment({
|
20
|
+
domain,
|
21
|
+
user,
|
22
|
+
lng,
|
23
|
+
data,
|
24
|
+
variables,
|
25
|
+
console
|
27
26
|
});
|
28
|
-
|
27
|
+
let evalPath;
|
28
|
+
try {
|
29
|
+
evalPath = compartment.evaluate('`' + path + '`');
|
30
|
+
}
|
31
|
+
catch (err) {
|
32
|
+
throw new Error(`Failed to evaluate path: ${err.message}`);
|
33
|
+
}
|
34
|
+
path = evalPath;
|
29
35
|
requestHeaders =
|
30
36
|
requestHeaders &&
|
31
37
|
Object.entries(requestHeaders).reduce((sum, [key, value]) => {
|
32
|
-
|
38
|
+
try {
|
39
|
+
sum[key] = compartment.evaluate('`' + value + '`');
|
40
|
+
}
|
41
|
+
catch (err) {
|
42
|
+
throw new Error(`Failed to evaluate header value: ${err.message}`);
|
43
|
+
}
|
33
44
|
return sum;
|
34
45
|
}, {});
|
35
46
|
searchParams =
|
36
47
|
searchParams &&
|
37
48
|
Object.entries(searchParams).reduce((sum, [key, value]) => {
|
38
|
-
|
49
|
+
try {
|
50
|
+
sum[key] = compartment.evaluate('`' + value + '`');
|
51
|
+
}
|
52
|
+
catch (err) {
|
53
|
+
throw new Error(`Failed to evaluate search param value: ${err.message}`);
|
54
|
+
}
|
39
55
|
return sum;
|
40
56
|
}, {});
|
41
57
|
var url = new url_1.URL(path, endpoint);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"http-get.js","sourceRoot":"","sources":["../../../server/engine/task/http-get.ts"],"names":[],"mappings":";;;AAAA,oEAA8B;AAC9B,
|
1
|
+
{"version":3,"file":"http-get.js","sourceRoot":"","sources":["../../../server/engine/task/http-get.ts"],"names":[],"mappings":";;;AAAA,oEAA8B;AAC9B,eAAY;AACZ,6BAAyB;AACzB,0DAAyB;AACzB,oDAA+C;AAC/C,8DAAyD;AACzD,mDAA+C;AAI/C,KAAK,UAAU,OAAO,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,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AK,CAAC;YACjC,kBAAkB;SACnB,CAAC,CAAA;QACF,YAAY,CAAC,KAAK,GAAG,UAAU,CAAA;IACjC,CAAC;IAED,IAAI,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAE7C,OAAO;QACL,IAAI,EACF,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAC9E,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE;YACvB,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE;KAC5B,CAAA;AACH,CAAC;AAED,OAAO,CAAC,aAAa,GAAG;IACtB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,eAAe;KACvB;CACF,CAAA;AAED,OAAO,CAAC,IAAI,GAAG,2BAA2B,CAAA;AAE1C,4BAAY,CAAC,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA","sourcesContent":["import fetch from 'node-fetch'\nimport 'ses'\nimport { URL } from 'url'\nimport https from 'https'\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport { substitute } from './utils/substitute'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function HttpGet(step: InputStep, { logger, data, domain, user, variables, lng }: Context) {\n var { connection: connectionName, params: stepOptions } = step\n var { headers: requestHeaders, searchParams = {}, path } = stepOptions || {}\n var connection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { endpoint, params: connectionParams, authHeaders = {} } = connection\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalPath\n try {\n evalPath = compartment.evaluate('`' + path + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate path: ${err.message}`)\n }\n\n path = evalPath\n\n requestHeaders =\n requestHeaders &&\n Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {\n try {\n sum[key] = compartment.evaluate('`' + value + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate header value: ${err.message}`)\n }\n return sum\n }, {})\n\n searchParams =\n searchParams &&\n Object.entries(searchParams as { [key: string]: string }).reduce((sum, [key, value]) => {\n try {\n sum[key] = compartment.evaluate('`' + value + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate search param value: ${err.message}`)\n }\n return sum\n }, {})\n\n var url = new URL(path, endpoint)\n if (searchParams) {\n Object.keys(searchParams).forEach(key => {\n let value = substitute(searchParams[key], data)\n url.searchParams.append(key, value)\n })\n }\n\n var fetchOptions: any = {\n method: 'GET',\n headers: {\n ...requestHeaders,\n ...authHeaders\n }\n }\n\n var { rejectUnauthorized } = connectionParams\n\n if (!rejectUnauthorized) {\n const httpsAgent = new https.Agent({\n rejectUnauthorized\n })\n fetchOptions.agent = httpsAgent\n }\n\n var response = await fetch(url, fetchOptions)\n\n return {\n data:\n response.ok && response.headers.get('content-type').includes('application/json')\n ? await response.json()\n : await response.text()\n }\n}\n\nHttpGet.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'http-headers',\n name: 'headers',\n label: 'headers'\n },\n {\n type: 'http-parameters',\n name: 'searchParams',\n label: 'search-params'\n }\n]\n\nHttpGet.help = 'integration/task/http-get'\n\nTaskRegistry.registerTaskHandler('http-get', HttpGet)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
5
5
|
const url_1 = require("url");
|
6
|
-
|
6
|
+
require("ses");
|
7
7
|
const utils_1 = require("@things-factory/utils");
|
8
8
|
const task_registry_1 = require("../task-registry");
|
9
9
|
const connection_manager_1 = require("../connection-manager");
|
@@ -16,20 +16,31 @@ async function HttpPost(step, { logger, data, domain, user, variables, lng }) {
|
|
16
16
|
throw new Error(`connection '${connectionName}' is not established.`);
|
17
17
|
}
|
18
18
|
var { endpoint, params: connectionParams, authHeaders = {} } = connection;
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
19
|
+
const compartment = new Compartment({
|
20
|
+
domain,
|
21
|
+
user,
|
22
|
+
lng,
|
23
|
+
data,
|
24
|
+
variables,
|
25
|
+
console
|
27
26
|
});
|
28
|
-
|
27
|
+
let evalPath;
|
28
|
+
try {
|
29
|
+
evalPath = compartment.evaluate('`' + path + '`');
|
30
|
+
}
|
31
|
+
catch (err) {
|
32
|
+
throw new Error(`Failed to evaluate path: ${err.message}`);
|
33
|
+
}
|
34
|
+
path = evalPath;
|
29
35
|
requestHeaders =
|
30
36
|
requestHeaders &&
|
31
37
|
Object.entries(requestHeaders).reduce((sum, [key, value]) => {
|
32
|
-
|
38
|
+
try {
|
39
|
+
sum[key] = compartment.evaluate('`' + value + '`');
|
40
|
+
}
|
41
|
+
catch (err) {
|
42
|
+
throw new Error(`Failed to evaluate header value: ${err.message}`);
|
43
|
+
}
|
33
44
|
return sum;
|
34
45
|
}, {});
|
35
46
|
var url = new url_1.URL(path, endpoint);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"http-post.js","sourceRoot":"","sources":["../../../server/engine/task/http-post.ts"],"names":[],"mappings":";;;AAAA,oEAA8B;AAC9B,6BAAyB;AACzB,
|
1
|
+
{"version":3,"file":"http-post.js","sourceRoot":"","sources":["../../../server/engine/task/http-post.ts"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E,UAAU;KAClB;CACF,CAAA;AAED,QAAQ,CAAC,IAAI,GAAG,4BAA4B,CAAA;AAE5C,4BAAY,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import fetch from 'node-fetch'\nimport { URL } from 'url'\nimport 'ses'\nimport { access } from '@things-factory/utils'\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport https from 'https'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function HttpPost(step: InputStep, { logger, data, domain, user, variables, lng }: Context) {\n var { connection: connectionName, params: stepOptions } = step\n var { headers: requestHeaders, contentType, path, accessor } = stepOptions || {}\n\n var connection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!connection) {\n throw new Error(`connection '${connectionName}' is not established.`)\n }\n\n var { endpoint, params: connectionParams, authHeaders = {} } = connection\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalPath\n try {\n evalPath = compartment.evaluate('`' + path + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate path: ${err.message}`)\n }\n\n path = evalPath\n\n requestHeaders =\n requestHeaders &&\n Object.entries(requestHeaders as { [key: string]: string }).reduce((sum, [key, value]) => {\n try {\n sum[key] = compartment.evaluate('`' + value + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate header value: ${err.message}`)\n }\n return sum\n }, {})\n\n var url = new URL(path, endpoint)\n var headers = {\n ...authHeaders,\n ...requestHeaders\n }\n\n var body = access(accessor, data)\n if (contentType && body) {\n headers['content-type'] = contentType\n switch (contentType) {\n case 'text/plain':\n body = JSON.stringify(body)\n break\n case 'application/json':\n body = JSON.stringify(body)\n break\n case 'application/x-www-form-urlencoded':\n const searchParams = new URLSearchParams()\n for (const prop in body) {\n searchParams.set(prop, body[prop])\n }\n body = searchParams\n break\n }\n }\n\n var fetchOptions: any = {\n method: 'POST',\n headers,\n body\n }\n\n var { rejectUnauthorized } = connectionParams\n\n if (!rejectUnauthorized) {\n const httpsAgent = new https.Agent({\n rejectUnauthorized\n })\n fetchOptions.agent = httpsAgent\n }\n\n var response = await fetch(url, fetchOptions)\n\n return {\n data:\n response.ok && response.headers.get('content-type').includes('application/json')\n ? await response.json()\n : await response.text()\n }\n}\n\nHttpPost.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'http-headers',\n name: 'headers',\n label: 'headers'\n },\n {\n type: 'select',\n name: 'contentType',\n label: 'content-type',\n property: {\n options: [\n {\n display: '',\n value: ''\n },\n {\n display: 'application/json',\n value: 'application/json'\n },\n {\n display: 'text/plain',\n value: 'text/plain'\n },\n {\n display: 'application/x-www-form-urlencoded',\n value: 'application/x-www-form-urlencoded'\n }\n ]\n }\n },\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n }\n]\n\nHttpPost.help = 'integration/task/http-post'\n\nTaskRegistry.registerTaskHandler('http-post', HttpPost)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
5
|
-
|
5
|
+
require("ses");
|
6
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
8
8
|
const utils_1 = require("@things-factory/utils");
|
@@ -17,16 +17,22 @@ async function LocalGraphqlMutate(step, context) {
|
|
17
17
|
where: { id: updaterId },
|
18
18
|
relations: ['domains']
|
19
19
|
}));
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
20
|
+
const compartment = new Compartment({
|
21
|
+
domain,
|
22
|
+
user,
|
23
|
+
lng,
|
24
|
+
data,
|
25
|
+
variables,
|
26
|
+
console
|
28
27
|
});
|
29
|
-
|
28
|
+
let evalMutation;
|
29
|
+
try {
|
30
|
+
evalMutation = compartment.evaluate('`' + mutation + '`');
|
31
|
+
}
|
32
|
+
catch (err) {
|
33
|
+
throw new Error(`Failed to evaluate mutation: ${err.message}`);
|
34
|
+
}
|
35
|
+
mutation = evalMutation;
|
30
36
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
31
37
|
const accessor = variablesAccessorMap[key];
|
32
38
|
variables[key] = (0, utils_1.access)(accessor, data);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local-graphql-mutate.js","sourceRoot":"","sources":["../../../server/engine/task/local-graphql-mutate.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,
|
1
|
+
{"version":3,"file":"local-graphql-mutate.js","sourceRoot":"","sources":["../../../server/engine/task/local-graphql-mutate.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,eAAY;AAEZ,yDAAgD;AAChD,iDAAqD;AACrD,iDAA8C;AAE9C,oDAA+C;AAI/C,KAAK,UAAU,kBAAkB,CAAC,IAAe,EAAE,OAAgB;IACjE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;IAChC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IACzE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IAEpE,IAAI;QACF,IAAI;YACJ,CAAC,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;gBACjC,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;gBACxB,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB,CAAC,CAAC,CAAA;IAEL,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;QAClC,MAAM;QAC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IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE;YACR,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC;SACR;KACF;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAED,kBAAkB,CAAC,aAAa,GAAG,IAAI,CAAA;AACvC,kBAAkB,CAAC,IAAI,GAAG,uCAAuC,CAAA;AAEjE,4BAAY,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport 'ses'\n\nimport { User } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\nimport { access } from '@things-factory/utils'\n\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function LocalGraphqlMutate(step: InputStep, context: Context) {\n var { params, updaterId } = step\n var { mutation, variables: variablesAccessorMap, headers } = params || {}\n var { logger, client, domain, user, data, variables, lng } = context\n\n user =\n user ||\n (await getRepository(User).findOne({\n where: { id: updaterId },\n relations: ['domains']\n }))\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalMutation\n try {\n evalMutation = compartment.evaluate('`' + mutation + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate mutation: ${err.message}`)\n }\n\n mutation = evalMutation\n\n const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {\n const accessor = variablesAccessorMap[key]\n variables[key] = access(accessor, data)\n return variables\n }, {})\n\n var { data: mutateResult, errors } = await client.mutate({\n mutation: gql`\n ${mutation}\n `,\n variables: queryVariables,\n headers,\n context: {\n state: {\n domain,\n user\n }\n }\n })\n\n if (errors) {\n errors.forEach(error => {\n logger.error('GraphQL Error: %s', error)\n })\n }\n\n return {\n data: mutateResult\n }\n}\n\nLocalGraphqlMutate.parameterSpec = [\n {\n type: 'graphql',\n name: 'mutation',\n label: 'mutation',\n property: {\n showLineNumbers: true\n },\n styles: {\n flex: 1\n }\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables'\n },\n {\n type: 'key-values',\n name: 'headers',\n label: 'headers'\n }\n]\n\nLocalGraphqlMutate.connectorFree = true\nLocalGraphqlMutate.help = 'integration/task/local-graphql-mutate'\n\nTaskRegistry.registerTaskHandler('local-graphql-mutate', LocalGraphqlMutate)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
5
|
-
|
5
|
+
require("ses");
|
6
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
8
8
|
const utils_1 = require("@things-factory/utils");
|
@@ -17,16 +17,22 @@ async function LocalGraphqlQuery(step, context) {
|
|
17
17
|
where: { id: updaterId },
|
18
18
|
relations: ['domains']
|
19
19
|
}));
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
20
|
+
const compartment = new Compartment({
|
21
|
+
domain,
|
22
|
+
user,
|
23
|
+
lng,
|
24
|
+
data,
|
25
|
+
variables,
|
26
|
+
console
|
28
27
|
});
|
29
|
-
|
28
|
+
let evalQuery;
|
29
|
+
try {
|
30
|
+
evalQuery = compartment.evaluate('`' + query + '`');
|
31
|
+
}
|
32
|
+
catch (err) {
|
33
|
+
throw new Error(`Failed to evaluate query: ${err.message}`);
|
34
|
+
}
|
35
|
+
query = evalQuery;
|
30
36
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
31
37
|
const accessor = variablesAccessorMap[key];
|
32
38
|
variables[key] = (0, utils_1.access)(accessor, data);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local-graphql-query.js","sourceRoot":"","sources":["../../../server/engine/task/local-graphql-query.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,
|
1
|
+
{"version":3,"file":"local-graphql-query.js","sourceRoot":"","sources":["../../../server/engine/task/local-graphql-query.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,eAAY;AAEZ,yDAAgD;AAChD,iDAAqD;AACrD,iDAA8C;AAE9C,oDAA+C;AAI/C,KAAK,UAAU,iBAAiB,CAAC,IAAe,EAAE,OAAgB;IAChE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;IAChC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IACtE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IAEpE,IAAI;QACF,IAAI;YACJ,CAAC,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;gBACjC,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;gBACxB,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB,CAAC,CAAC,CAAA;IAEL,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,OAA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EAAE,WAAW;KACnB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAED,iBAAiB,CAAC,aAAa,GAAG,IAAI,CAAA;AACtC,iBAAiB,CAAC,IAAI,GAAG,sCAAsC,CAAA;AAE/D,4BAAY,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport 'ses'\n\nimport { User } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\nimport { access } from '@things-factory/utils'\n\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function LocalGraphqlQuery(step: InputStep, context: Context) {\n var { params, updaterId } = step\n var { query, variables: variablesAccessorMap, headers } = params || {}\n var { logger, client, domain, user, data, variables, lng } = context\n\n user =\n user ||\n (await getRepository(User).findOne({\n where: { id: updaterId },\n relations: ['domains']\n }))\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalQuery\n try {\n evalQuery = compartment.evaluate('`' + query + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate query: ${err.message}`)\n }\n\n query = evalQuery\n\n const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {\n const accessor = variablesAccessorMap[key]\n variables[key] = access(accessor, data)\n return variables\n }, {})\n\n var { data: queryResult, errors } = await client.query({\n query: gql`\n ${query}\n `,\n variables: queryVariables,\n headers,\n context: {\n state: {\n domain,\n user\n }\n }\n })\n\n if (errors) {\n errors.forEach(error => {\n logger.error('GraphQL Error: %s', error)\n })\n }\n\n return {\n data: queryResult\n }\n}\n\nLocalGraphqlQuery.parameterSpec = [\n {\n type: 'graphql',\n name: 'query',\n label: 'query',\n property: {\n showLineNumbers: true\n },\n styles: {\n flex: 1\n }\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables'\n },\n {\n type: 'key-values',\n name: 'headers',\n label: 'headers'\n }\n]\n\nLocalGraphqlQuery.connectorFree = true\nLocalGraphqlQuery.help = 'integration/task/local-graphql-query'\n\nTaskRegistry.registerTaskHandler('local-graphql-query', LocalGraphqlQuery)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -1,25 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@things-factory/utils");
|
4
|
-
|
4
|
+
require("ses");
|
5
5
|
const task_registry_1 = require("../task-registry");
|
6
6
|
async function Log(step, { logger, data, variables, domain, user, lng }) {
|
7
7
|
var { params: { message, accessor, level = 'info' } } = step;
|
8
8
|
if ((0, utils_1.hasTemplateExpression)(message)) {
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
9
|
+
const compartment = new Compartment({
|
10
|
+
domain,
|
11
|
+
user,
|
12
|
+
lng,
|
13
|
+
data,
|
14
|
+
variables,
|
15
|
+
console
|
17
16
|
});
|
18
|
-
|
17
|
+
try {
|
18
|
+
message = compartment.evaluate('`' + message + '`');
|
19
|
+
}
|
20
|
+
catch (err) {
|
21
|
+
throw new Error(`Failed to evaluate message: ${err.message}`);
|
22
|
+
}
|
19
23
|
}
|
20
24
|
accessor = (0, utils_1.access)(accessor, data);
|
21
25
|
if (accessor) {
|
22
|
-
if (accessor !== 'string') {
|
26
|
+
if (typeof accessor !== 'string') {
|
23
27
|
accessor = JSON.stringify(accessor, null, 2);
|
24
28
|
}
|
25
29
|
message += ': ' + accessor;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../server/engine/task/log.ts"],"names":[],"mappings":";;AAAA,iDAAqE;AACrE,
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../server/engine/task/log.ts"],"names":[],"mappings":";;AAAA,iDAAqE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;IAED,OAAO;QACL,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC;AAED,GAAG,CAAC,aAAa,GAAG;IAClB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;SACnC;KACF;CACF,CAAA;AAED,GAAG,CAAC,aAAa,GAAG,IAAI,CAAA;AACxB,GAAG,CAAC,IAAI,GAAG,sBAAsB,CAAA;AAEjC,4BAAY,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA","sourcesContent":["import { access, hasTemplateExpression } from '@things-factory/utils'\nimport 'ses'\nimport { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function Log(step: InputStep, { logger, data, variables, domain, user, lng }: Context) {\n var {\n params: { message, accessor, level = 'info' }\n } = step\n\n if (hasTemplateExpression(message)) {\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n try {\n message = compartment.evaluate('`' + message + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate message: ${err.message}`)\n }\n }\n\n accessor = access(accessor, data)\n\n if (accessor) {\n if (typeof accessor !== 'string') {\n accessor = JSON.stringify(accessor, null, 2)\n }\n message += ': ' + accessor\n }\n\n switch (level) {\n case 'error':\n logger.error(message)\n return\n case 'warn':\n logger.warn(message)\n return\n default:\n logger.info(message)\n }\n\n return {\n data: message\n }\n}\n\nLog.parameterSpec = [\n {\n type: 'string',\n name: 'message',\n label: 'message'\n },\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'select',\n name: 'level',\n label: 'level',\n property: {\n options: ['info', 'warn', 'error']\n }\n }\n]\n\nLog.connectorFree = true\nLog.help = 'integration/task/log'\n\nTaskRegistry.registerTaskHandler('log', Log)\n"]}
|