@things-factory/integration-base 7.0.1-rc.5 → 7.0.1-rc.8
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,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const vm2_1 = require("vm2");
|
4
3
|
const env_1 = require("@things-factory/env");
|
5
4
|
const utils_1 = require("@things-factory/utils");
|
6
5
|
const connection_manager_1 = require("../connection-manager");
|
7
6
|
const task_registry_1 = require("../task-registry");
|
7
|
+
require("ses");
|
8
8
|
try {
|
9
9
|
var oracledb = require('oracledb');
|
10
10
|
}
|
@@ -30,19 +30,25 @@ async function OracleProcedure(step, context) {
|
|
30
30
|
var { connection: connectionName, params } = step;
|
31
31
|
var { code = '', parameters = [] } = params.parameters;
|
32
32
|
var dbconnection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
33
|
-
const vm = new vm2_1.VM({
|
34
|
-
sandbox: {
|
35
|
-
domain,
|
36
|
-
user,
|
37
|
-
lng,
|
38
|
-
data,
|
39
|
-
variables
|
40
|
-
}
|
41
|
-
});
|
42
33
|
if (!code) {
|
43
34
|
throw 'procedure code not defined';
|
44
35
|
}
|
45
|
-
|
36
|
+
const compartment = new Compartment({
|
37
|
+
domain,
|
38
|
+
user,
|
39
|
+
lng,
|
40
|
+
data,
|
41
|
+
variables,
|
42
|
+
console
|
43
|
+
});
|
44
|
+
let evalCode;
|
45
|
+
try {
|
46
|
+
evalCode = compartment.evaluate('`' + code + '`');
|
47
|
+
}
|
48
|
+
catch (err) {
|
49
|
+
throw new Error(`Failed to evaluate code: ${err.message}`);
|
50
|
+
}
|
51
|
+
code = evalCode;
|
46
52
|
const procedureParameters = parameters &&
|
47
53
|
parameters.reduce((sum, { name, val, dir, type, accessor, maxSize }) => {
|
48
54
|
sum[name] = {
|
@@ -52,7 +58,7 @@ async function OracleProcedure(step, context) {
|
|
52
58
|
const calculated = accessor ? (0, utils_1.access)(accessor, data) || val : val;
|
53
59
|
if (calculated !== undefined) {
|
54
60
|
sum[name].val =
|
55
|
-
type
|
61
|
+
type === 'Date'
|
56
62
|
? new Date(calculated)
|
57
63
|
: type == 'Number'
|
58
64
|
? Number(calculated)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oracle-procedure.js","sourceRoot":"","sources":["../../../server/engine/task/oracle-procedure.ts"],"names":[],"mappings":";;AAAA,
|
1
|
+
{"version":3,"file":"oracle-procedure.js","sourceRoot":"","sources":["../../../server/engine/task/oracle-procedure.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,iDAA8C;AAC9C,8DAAyD;AACzD,oDAA+C;AAG/C,eAAY;AAEZ,IAAI,CAAC;IACH,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AACpC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAA;AACrD,CAAC;AAiBD,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;IACxB,MAAM,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;IACxB,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;IACpB,MAAM,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;IACxB,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;IACpB,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;IACpB,M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AA;AAE1D,4BAAY,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\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'\nimport 'ses'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\ntype ProcedureParameterType = {\n name: string\n dir: string\n type: string\n val?: any\n accessor?: string\n maxSize?: number\n}\n\ntype ValueType = {\n code?: string\n procedure?: string\n parameters?: ProcedureParameterType[]\n}\n\nconst TYPES = {\n Number: oracledb?.NUMBER,\n String: oracledb?.STRING,\n Date: oracledb?.DATE,\n Buffer: oracledb?.BUFFER,\n Blob: oracledb?.BLOB,\n Clob: oracledb?.CLOB,\n Cursor: oracledb?.CURSOR\n}\n\nconst DIR = {\n In: oracledb?.BIND_IN,\n Inout: oracledb?.BIND_INOUT,\n Out: oracledb?.BIND_OUT\n}\n\nasync function OracleProcedure(step: InputStep, context: Context) {\n var { domain, user, data, variables, lng } = context\n var { connection: connectionName, params } = step\n\n var { code = '', parameters = [] } = params.parameters as ValueType\n\n var dbconnection = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!code) {\n throw 'procedure code not defined'\n }\n\n const compartment = new Compartment({\n domain,\n user,\n lng,\n data,\n variables,\n console\n })\n\n let evalCode\n try {\n evalCode = compartment.evaluate('`' + code + '`')\n } catch (err) {\n throw new Error(`Failed to evaluate code: ${err.message}`)\n }\n\n code = evalCode\n\n const procedureParameters =\n parameters &&\n parameters.reduce((sum, { name, val, dir, type, accessor, maxSize }) => {\n sum[name] = {\n dir: DIR[dir],\n type: TYPES[type]\n }\n\n const calculated = accessor ? access(accessor, data) || val : val\n\n if (calculated !== undefined) {\n sum[name].val =\n type === 'Date'\n ? new Date(calculated)\n : type == 'Number'\n ? Number(calculated)\n : type == 'String'\n ? String(calculated)\n : calculated\n }\n\n if (maxSize) {\n sum[name].maxSize = maxSize\n }\n\n return sum\n }, {})\n\n const result = await dbconnection.execute(code, procedureParameters)\n\n return {\n data: result\n }\n}\n\nOracleProcedure.parameterSpec = [\n {\n type: 'procedure-parameters',\n name: 'parameters',\n label: ''\n }\n]\n\nOracleProcedure.help = 'integration/task/oracle-procedure'\n\nTaskRegistry.registerTaskHandler('oracle-procedure', OracleProcedure)\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
import 'ses';
|
@@ -1,27 +1,39 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const task_registry_1 = require("../task-registry");
|
4
|
-
|
4
|
+
require("ses");
|
5
5
|
async function Script(step, context) {
|
6
|
-
|
6
|
+
const { params: { script } } = step;
|
7
7
|
const { domain, user, data, variables, lng, logger } = context;
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
const compartment = new Compartment({
|
9
|
+
domain,
|
10
|
+
user,
|
11
|
+
data,
|
12
|
+
variables,
|
13
|
+
logger,
|
14
|
+
lng,
|
15
|
+
console,
|
16
|
+
Math,
|
17
|
+
JSON,
|
18
|
+
Date,
|
19
|
+
setTimeout,
|
20
|
+
setInterval,
|
21
|
+
clearTimeout,
|
22
|
+
clearInterval
|
20
23
|
});
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
24
|
+
const scriptSource = `
|
25
|
+
(async () => {
|
26
|
+
${script}
|
27
|
+
})();
|
28
|
+
`;
|
29
|
+
try {
|
30
|
+
return {
|
31
|
+
data: await compartment.evaluate(scriptSource)
|
32
|
+
};
|
33
|
+
}
|
34
|
+
catch (err) {
|
35
|
+
throw new Error(`Script execution failed: ${err.message}`);
|
36
|
+
}
|
25
37
|
}
|
26
38
|
Script.parameterSpec = [
|
27
39
|
{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../../server/engine/task/script.ts"],"names":[],"mappings":";;AAAA,oDAA+C;
|
1
|
+
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../../server/engine/task/script.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAG/C,eAAY;AAEZ,KAAK,UAAU,MAAM,CAAC,IAAe,EAAE,OAAgB;IACrD,MAAM,EACJ,MAAM,EAAE,EAAE,MAAM,EAAE,EACnB,GAAG,IAAI,CAAA;IAER,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAE9D,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC;QAClC,MAAM;QACN,IAAI;QACJ,IAAI;QACJ,SAAS;QACT,MAAM;QACN,GAAG;QACH,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,UAAU;QACV,WAAW;QACX,YAAY;QACZ,aAAa;KACd,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG;;QAEf,MAAM;;GAEX,CAAA;IAED,IAAI,CAAC;QACH,OAAO;YACL,IAAI,EAAE,MAAM,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC;SAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,CAAC,aAAa,GAAG;IACrB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE;YACR,QAAQ,EAAE,YAAY;YACtB,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG;SACV;KACF;CACF,CAAA;AAED,MAAM,CAAC,aAAa,GAAG,IAAI,CAAA;AAC3B,MAAM,CAAC,IAAI,GAAG,yBAAyB,CAAA;AAEvC,4BAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '../task-registry'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\nimport 'ses'\n\nasync function Script(step: InputStep, context: Context) {\n const {\n params: { script }\n } = step\n\n const { domain, user, data, variables, lng, logger } = context\n\n const compartment = new Compartment({\n domain,\n user,\n data,\n variables,\n logger,\n lng,\n console,\n Math,\n JSON,\n Date,\n setTimeout,\n setInterval,\n clearTimeout,\n clearInterval\n })\n\n const scriptSource = `\n (async () => {\n ${script}\n })();\n `\n\n try {\n return {\n data: await compartment.evaluate(scriptSource)\n }\n } catch (err) {\n throw new Error(`Script execution failed: ${err.message}`)\n }\n}\n\nScript.parameterSpec = [\n {\n type: 'textarea',\n name: 'script',\n label: 'script',\n property: {\n language: 'javascript',\n showLineNumbers: true\n },\n styles: {\n flex: '1'\n }\n }\n]\n\nScript.connectorFree = true\nScript.help = 'integration/task/script'\n\nTaskRegistry.registerTaskHandler('script', Script)\n"]}
|
@@ -11,7 +11,7 @@ export * from './payload-log/payload-log';
|
|
11
11
|
export * from './state-register/state-register';
|
12
12
|
export declare const entities: any[];
|
13
13
|
export declare const schema: {
|
14
|
-
resolverClasses: (typeof import("./connection/connection-query").ConnectionQuery | typeof import("./connection/connection-mutation").ConnectionMutation | typeof import("./connection/connection-subscription").ConnectionSubscription | typeof import("./connector/connector-query").ConnectorQuery | typeof import("./scenario/scenario-query").ScenarioQuery | typeof import("./scenario/scenario-mutation").ScenarioMutation | typeof import("./scenario-instance/scenario-instance-query").ScenarioInstanceQuery | typeof import("./scenario-instance/scenario-instance-mutation").ScenarioInstanceMutation | typeof import("./scenario-instance/scenario-instance-subscription").ScenarioInstanceSubscription | typeof import("./scenario-queue/scenario-queue-subscription").ScenarioQueueSubscription | typeof import("./step/step-query").StepQuery | typeof import("./step/step-mutation").StepMutation | typeof import("./task-type/task-type-query").TaskTypeQuery | typeof import("./
|
14
|
+
resolverClasses: (typeof import("./connection/connection-query").ConnectionQuery | typeof import("./connection/connection-mutation").ConnectionMutation | typeof import("./connection/connection-subscription").ConnectionSubscription | typeof import("./connector/connector-query").ConnectorQuery | typeof import("./scenario/scenario-query").ScenarioQuery | typeof import("./scenario/scenario-mutation").ScenarioMutation | typeof import("./scenario-instance/scenario-instance-query").ScenarioInstanceQuery | typeof import("./scenario-instance/scenario-instance-mutation").ScenarioInstanceMutation | typeof import("./scenario-instance/scenario-instance-subscription").ScenarioInstanceSubscription | typeof import("./scenario-queue/scenario-queue-subscription").ScenarioQueueSubscription | typeof import("./step/step-query").StepQuery | typeof import("./step/step-mutation").StepMutation | typeof import("./task-type/task-type-query").TaskTypeQuery | typeof import("./payload-log/payload-log-query").PayloadLogQuery | typeof import("./payload-log/payload-log-mutation").PayloadLogMutation | typeof import("./state-register/state-register-query").StateRegisterQuery | typeof import("./state-register/state-register-mutation").StateRegisterMutation | typeof import("./analysis/analysis-query").IntegrationAnalysisQuery)[];
|
15
15
|
};
|
16
16
|
export { PayloadType } from './payload-log/payload-log';
|
17
17
|
export { createPayloadLog } from './payload-log/payload-log-mutation';
|