@things-factory/integration-base 9.0.20 → 9.0.25
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/analyzer/analyze-integration.js +2 -2
- package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/engine/connection-manager.d.ts +13 -1
- package/dist-server/engine/connection-manager.js +105 -7
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/headless-connector.d.ts +8 -0
- package/dist-server/engine/connector/headless-connector.js +4 -2
- package/dist-server/engine/connector/headless-connector.js.map +1 -1
- package/dist-server/engine/connector/mqtt-connector.d.ts +1 -0
- package/dist-server/engine/connector/mqtt-connector.js +4 -2
- package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
- package/dist-server/engine/connector/mssql-connector.d.ts +4 -0
- package/dist-server/engine/connector/mssql-connector.js +4 -2
- package/dist-server/engine/connector/mssql-connector.js.map +1 -1
- package/dist-server/engine/connector/mysql-connector.d.ts +10 -2
- package/dist-server/engine/connector/mysql-connector.js +23 -18
- package/dist-server/engine/connector/mysql-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.d.ts +8 -2
- package/dist-server/engine/connector/operato-connector.js +2 -1
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.d.ts +3 -0
- package/dist-server/engine/connector/oracle-connector.js +4 -2
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/postgresql-connector.d.ts +13 -2
- package/dist-server/engine/connector/postgresql-connector.js +14 -6
- package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
- package/dist-server/engine/connector/pyrun-connector.d.ts +1 -0
- package/dist-server/engine/connector/pyrun-connector.js +3 -3
- package/dist-server/engine/connector/pyrun-connector.js.map +1 -1
- package/dist-server/engine/edge-client.d.ts +1 -1
- package/dist-server/engine/edge-client.js.map +1 -1
- package/dist-server/engine/task/database-query.js +1 -1
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/echo-receive.js +1 -1
- package/dist-server/engine/task/echo-receive.js.map +1 -1
- package/dist-server/engine/task/echo-send.js +1 -1
- package/dist-server/engine/task/echo-send.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.js +1 -1
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.js +1 -1
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/headless-post.js +1 -1
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +1 -1
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/http-get.js +1 -1
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +1 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +1 -1
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/engine/task/mssql-procedure.js +1 -1
- package/dist-server/engine/task/mssql-procedure.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.js +1 -1
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/pyrun-execute.js +1 -1
- package/dist-server/engine/task/pyrun-execute.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js +1 -1
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +3 -1
- package/dist-server/service/connection/connection-mutation.js +62 -22
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.d.ts +2 -1
- package/dist-server/service/connection/connection-query.js +14 -13
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +6 -4
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +10 -99
- package/dist-server/service/connection/connection-type.js +36 -182
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connection/connection.d.ts +119 -0
- package/dist-server/service/connection/connection.js +239 -0
- package/dist-server/service/connection/connection.js.map +1 -0
- package/dist-server/service/connection/index.d.ts +1 -1
- package/dist-server/service/connection/index.js +2 -2
- package/dist-server/service/connection/index.js.map +1 -1
- package/dist-server/service/connector/connector-query.js +2 -2
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/property-spec.d.ts +1 -0
- package/dist-server/service/property-spec.js +8 -1
- package/dist-server/service/property-spec.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +1 -1
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +3 -3
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +4 -1
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario/scenario.js +1 -1
- package/dist-server/service/scenario/scenario.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +2 -2
- package/dist-server/service/task-type/task-type-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
@@ -4,10 +4,18 @@ export declare class mysqlConnector implements Connector {
|
|
4
4
|
ready(connectionConfigs: InputConnection[]): Promise<void>;
|
5
5
|
connect(connection: InputConnection): Promise<void>;
|
6
6
|
disconnect(connection: InputConnection): Promise<void>;
|
7
|
-
get parameterSpec(): {
|
7
|
+
get parameterSpec(): ({
|
8
8
|
type: string;
|
9
9
|
name: string;
|
10
10
|
label: string;
|
11
|
-
|
11
|
+
description: string;
|
12
|
+
useDomainAttribute: boolean;
|
13
|
+
} | {
|
14
|
+
type: string;
|
15
|
+
name: string;
|
16
|
+
label: string;
|
17
|
+
description: string;
|
18
|
+
useDomainAttribute?: undefined;
|
19
|
+
})[];
|
12
20
|
get taskPrefixes(): string[];
|
13
21
|
}
|
@@ -7,20 +7,20 @@ const connection_manager_1 = require("../connection-manager");
|
|
7
7
|
class mysqlConnector {
|
8
8
|
async ready(connectionConfigs) {
|
9
9
|
await Promise.all(connectionConfigs.map(this.connect));
|
10
|
-
connection_manager_1.ConnectionManager.logger.info(
|
10
|
+
connection_manager_1.ConnectionManager.logger.info('mysql-connector connections are ready');
|
11
11
|
}
|
12
12
|
async connect(connection) {
|
13
|
-
const { endpoint, params: { user, password, database }
|
14
|
-
let [host, port = '3306'] = endpoint.split(
|
13
|
+
const { endpoint, params: { user, password, database } } = connection;
|
14
|
+
let [host, port = '3306'] = endpoint.split(':');
|
15
15
|
if (!promise_1.default) {
|
16
|
-
throw new Error(
|
16
|
+
throw new Error('mysql module loading failed');
|
17
17
|
}
|
18
18
|
let pool = await promise_1.default.createPool({
|
19
19
|
user,
|
20
20
|
password,
|
21
21
|
host,
|
22
22
|
port: Number(port),
|
23
|
-
database
|
23
|
+
database
|
24
24
|
});
|
25
25
|
const client = await pool.getConnection();
|
26
26
|
connection_manager_1.ConnectionManager.addConnectionInstance(connection, {
|
@@ -37,7 +37,7 @@ class mysqlConnector {
|
|
37
37
|
}
|
38
38
|
return result;
|
39
39
|
},
|
40
|
-
close: client.end()
|
40
|
+
close: client.end()
|
41
41
|
});
|
42
42
|
connection_manager_1.ConnectionManager.logger.info(`mysql Database(${connection.name}:${database}) at ${endpoint} connected.`);
|
43
43
|
}
|
@@ -55,26 +55,31 @@ class mysqlConnector {
|
|
55
55
|
get parameterSpec() {
|
56
56
|
return [
|
57
57
|
{
|
58
|
-
type:
|
59
|
-
name:
|
60
|
-
label:
|
58
|
+
type: 'string',
|
59
|
+
name: 'user',
|
60
|
+
label: 'user',
|
61
|
+
description: 'Database username',
|
62
|
+
useDomainAttribute: true
|
61
63
|
},
|
62
64
|
{
|
63
|
-
type:
|
64
|
-
name:
|
65
|
-
label:
|
65
|
+
type: 'password', // ✅ 기존 password 타입 사용
|
66
|
+
name: 'password',
|
67
|
+
label: 'password',
|
68
|
+
description: 'Database password',
|
69
|
+
useDomainAttribute: true // 🔐 Domain attributes 사용
|
66
70
|
},
|
67
71
|
{
|
68
|
-
type:
|
69
|
-
name:
|
70
|
-
label:
|
71
|
-
|
72
|
+
type: 'string',
|
73
|
+
name: 'database',
|
74
|
+
label: 'database',
|
75
|
+
description: 'Database name'
|
76
|
+
}
|
72
77
|
];
|
73
78
|
}
|
74
79
|
get taskPrefixes() {
|
75
|
-
return [
|
80
|
+
return ['database'];
|
76
81
|
}
|
77
82
|
}
|
78
83
|
exports.mysqlConnector = mysqlConnector;
|
79
|
-
connection_manager_1.ConnectionManager.registerConnector(
|
84
|
+
connection_manager_1.ConnectionManager.registerConnector('mysql-connector', new mysqlConnector());
|
80
85
|
//# sourceMappingURL=mysql-connector.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mysql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mysql-connector.ts"],"names":[],"mappings":";;;;AAAA,
|
1
|
+
{"version":3,"file":"mysql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mysql-connector.ts"],"names":[],"mappings":";;;;AAAA,qEAAkC;AAGlC,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACrC,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,IAA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MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;YACpB,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,UAAU,CAAC,IAAI,WAAW,CAAC,CAAA;QAC7E,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnC,CAAC;QAED,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,UAAU,EAAE,sBAAsB;gBACxC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI,CAAC,0BAA0B;aACpD;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,eAAe;aAC7B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;CACF;AAtFD,wCAsFC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import Mysql from 'mysql2/promise'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class mysqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('mysql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database }\n } = connection\n\n let [host, port = '3306'] = endpoint.split(':')\n\n if (!Mysql) {\n throw new Error('mysql module loading failed')\n }\n\n let pool = await Mysql.createPool({\n user,\n password,\n host,\n port: Number(port),\n database\n })\n\n const client = await pool.getConnection()\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result\n try {\n const results = await client.query(query)\n if (results && results.length > 0) {\n result = results[0]\n }\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n return result\n },\n close: client.end()\n })\n\n ConnectionManager.logger.info(`mysql Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n try {\n await client.close()\n ConnectionManager.logger.info(`mysql Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'password', // ✅ 기존 password 타입 사용\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n}\n\nConnectionManager.registerConnector('mysql-connector', new mysqlConnector())\n"]}
|
@@ -15,11 +15,17 @@ export declare class OperatoConnector implements Connector {
|
|
15
15
|
connect(connection: InputConnection): Promise<void>;
|
16
16
|
disconnect(connection: InputConnection): Promise<void>;
|
17
17
|
runScenario(subscriptions: SubscriberData[], variables: any): Promise<ScenarioInstance>;
|
18
|
-
get parameterSpec(): {
|
18
|
+
get parameterSpec(): ({
|
19
19
|
type: string;
|
20
20
|
name: string;
|
21
21
|
label: string;
|
22
|
-
|
22
|
+
useDomainAttribute: boolean;
|
23
|
+
} | {
|
24
|
+
type: string;
|
25
|
+
name: string;
|
26
|
+
label: string;
|
27
|
+
useDomainAttribute?: undefined;
|
28
|
+
})[];
|
23
29
|
get taskPrefixes(): string[];
|
24
30
|
get help(): string;
|
25
31
|
get description(): string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"operato-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/operato-connector.ts"],"names":[],"mappings":";;;;AAAA,gCAA6B;AAE7B,8CAAwF;AACxF,yDAAwD;AAExD,oDAA0B;AAC1B,2CAAyC;AACzC,qEAAiE;AACjE,wDAA4D;AAC5D,sEAA6B;AAE7B,8DAAyD;AAIzD,8DAA0D;AAC1D,mGAAyF;AAEzF,iDAAiF;AACjF,yDAAkE;AAElE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AAEnF,MAAM,cAAc,GAAQ;IAC1B,UAAU,EAAE;QACV,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,UAAU,EAAE,gBAAgB;QACzC,WAAW,EAAE,KAAK;KACnB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,KAAK;KACnB;CACF,CAAA;AAEY,QAAA,WAAW,GAAG,UAAU,CAAA;AACxB,QAAA,gBAAgB,GAAG,mBAAW,CAAA;AAQ3C,MAAa,gBAAgB;IAG3B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjE,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAA;IAC1E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EAAE,GAAG,EACb,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,GAAG,EAAE,EAAE,EACvD,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,OAA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D,IAAI;YACJ,MAAM;YACN,SAAS;YACT,MAAM,EAAE,0BAAkB,CAAC,MAAM;SAClC,CAAC,CAAA;QAEF,eAAe;QACf,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAA;QACpB,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,sBAAsB;gBAC5B,KAAK,EAAE,uBAAuB;aAC/B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,yCAAyC,CAAA;IAClD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,2BAA2B,CAAA;IACpC,CAAC;CACF;AAvND,4CAuNC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["import 'cross-fetch/polyfill'\n\nimport { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client/core'\nimport { setContext } from '@apollo/client/link/context'\n\nimport WebSocket from 'ws'\nimport { createClient } from 'graphql-ws'\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions'\nimport { getMainDefinition } from '@apollo/client/utilities'\nimport gql from 'graphql-tag'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nimport { Scenario } from '../../service/scenario/scenario'\nimport { ScenarioInstance } from '../../service/scenario-instance/scenario-instance-type'\n\nimport { getRepository, GraphqlLocalClient, Domain } from '@things-factory/shell'\nimport { User, checkUserHasRole } from '@things-factory/auth-base'\n\nconst debug = require('debug')('things-factory:integration-base:operato-connector')\n\nconst defaultOptions: any = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache', //'network-only'\n errorPolicy: 'all'\n },\n mutate: {\n errorPolicy: 'all'\n }\n}\n\nexport const GRAPHQL_URI = '/graphql'\nexport const SUBSCRIPTION_URI = GRAPHQL_URI\n\ninterface SubscriberData {\n tag: string\n scenario: any\n subscriptionObserver: any\n}\n\nexport class OperatoConnector implements Connector {\n private context: any\n\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('operato-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint: uri,\n params: { authKey, domain, subscriptionHandlers = {} }\n } = connection\n\n if (!authKey || !domain) {\n throw new Error('some connection paramter missing.')\n }\n\n const domainOwner = await getRepository(User).findOne({\n where: {\n id: connection.domain.owner\n }\n })\n\n this.context = {\n domain: connection.domain,\n user: domainOwner\n /* TODO: domainOwner 대신 특정 유저를 지정할 수 있도록 개선해야함. 모든 커넥션에 유저를 지정하는 기능으로 일반화할 필요가 있는 지 고민해야함 */\n }\n\n const httpLink = createHttpLink({\n uri: uri\n })\n\n /* \n CHECKPOINT: \n 1. GraphqQLWsLink를 사용하면 setContext를 통한 추가 헤더 설정이 무시됩니다.\n 따라서, GraphQLWsLink를 사용하려면, connectionParams를 통해 헤더를 설정해야 합니다.\n \n 2. 서버에서 실행시, webSocketImpl을 명시적으로 지정해야 합니다.\n */\n const wsLink = new GraphQLWsLink(\n createClient({\n url: uri.replace(/^http/, 'ws'),\n keepAlive: 10_000,\n retryAttempts: 1_000_000,\n shouldRetry: e => true,\n webSocketImpl: WebSocket,\n connectionParams: {\n headers: {\n 'x-things-factory-domain': domain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n })\n )\n\n const splitLink = split(\n ({ query }) => {\n const def = getMainDefinition(query)\n return def.kind === 'OperationDefinition' && def.operation === 'subscription'\n },\n wsLink,\n setContext((_, { headers }) => {\n return {\n headers: {\n ...headers,\n 'x-things-factory-domain': domain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n }).concat(httpLink)\n )\n\n const cache = new InMemoryCache({\n addTypename: false\n })\n\n const client = new ApolloClient({\n defaultOptions,\n cache,\n link: splitLink\n })\n\n const subscriptions: SubscriberData[] = []\n Object.keys(subscriptionHandlers).forEach(async tag => {\n if (!tag || !subscriptionHandlers[tag]) return\n\n const scenarioName = subscriptionHandlers[tag]\n\n // fetch a scenario\n const selectedScenario = await getRepository(Scenario).findOne({\n where: {\n name: scenarioName\n },\n relations: ['steps', 'domain']\n })\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n data(tag: \"${tag}\") {\n tag\n data\n }\n }\n `\n })\n\n const subscriptionObserver = subscription.subscribe({\n next: async data => {\n debug('received pubsub msg.:', data?.data)\n await this.runScenario(subscriptions, data?.data?.data)\n },\n error: error => {\n ConnectionManager.logger.error(`(${connection.name}:${connection.endpoint}) subscription error`, error)\n },\n complete: () => {\n ConnectionManager.logger.info(`(${connection.name}:${connection.endpoint}) subscription complete`)\n }\n })\n\n ConnectionManager.logger.info(\n `(${connection.name}:${connection.endpoint}) subscription closed flag: ${subscriptionObserver.closed}`\n )\n\n subscriptions.push({\n tag,\n scenario: selectedScenario,\n subscriptionObserver\n })\n ConnectionManager.logger.info(`(${tag}:${scenarioName}) subscription closed flag: ${subscriptionObserver.closed}`)\n })\n\n client['subscriptions'] = subscriptions\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `operato-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection: InputConnection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n const subscriptions: SubscriberData[] = client['subscriptions']\n subscriptions.forEach(subscription => subscription.subscriptionObserver.unsubscribe())\n client.stop()\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`operato-connector connection(${connection.name}) is disconnected`)\n }\n\n async runScenario(subscriptions: SubscriberData[], variables: any): Promise<ScenarioInstance> {\n const { domain, user } = this.context\n const { tag } = variables\n\n if (!tag) {\n throw new Error(`tag is invalid - ${tag}`)\n }\n\n const scenario = subscriptions.find(subscription => subscription.tag === tag)?.scenario\n if (!scenario) {\n throw new Error(`scenario is not found - ${tag}`)\n }\n\n if (!(await checkUserHasRole(scenario.roleId, domain, user))) {\n throw new Error(`Unauthorized! ${scenario.name} doesn't have required role.`)\n }\n\n /* create a scenario instance */\n const instanceName = scenario.name + '-' + String(Date.now())\n const instance = new ScenarioInstance(instanceName, scenario, {\n user,\n domain,\n variables,\n client: GraphqlLocalClient.client\n })\n\n // run scenario\n await instance.run()\n return instance\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'authKey',\n label: 'auth-key'\n },\n {\n type: 'string',\n name: 'domain',\n label: 'domain'\n },\n {\n type: 'tag-scenarios',\n name: 'subscriptionHandlers',\n label: 'subscription-handlers'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['graphql']\n }\n\n get help() {\n return 'integration/connector/operato-connector'\n }\n\n get description() {\n return 'Operato Graphql Connector'\n }\n}\n\nConnectionManager.registerConnector('operato-connector', new OperatoConnector())\n"]}
|
1
|
+
{"version":3,"file":"operato-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/operato-connector.ts"],"names":[],"mappings":";;;;AAAA,gCAA6B;AAE7B,8CAAwF;AACxF,yDAAwD;AAExD,oDAA0B;AAC1B,2CAAyC;AACzC,qEAAiE;AACjE,wDAA4D;AAC5D,sEAA6B;AAE7B,8DAAyD;AAIzD,8DAA0D;AAC1D,mGAAyF;AAEzF,iDAAiF;AACjF,yDAAkE;AAElE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AAEnF,MAAM,cAAc,GAAQ;IAC1B,UAAU,EAAE;QACV,WAAW,EAAE,UA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C;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,yCAAyC,CAAA;IAClD,CAAC;IAED,IAAI,WAAW;QACb,OAAO,2BAA2B,CAAA;IACpC,CAAC;CACF;AAxND,4CAwNC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["import 'cross-fetch/polyfill'\n\nimport { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client/core'\nimport { setContext } from '@apollo/client/link/context'\n\nimport WebSocket from 'ws'\nimport { createClient } from 'graphql-ws'\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions'\nimport { getMainDefinition } from '@apollo/client/utilities'\nimport gql from 'graphql-tag'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nimport { Scenario } from '../../service/scenario/scenario'\nimport { ScenarioInstance } from '../../service/scenario-instance/scenario-instance-type'\n\nimport { getRepository, GraphqlLocalClient, Domain } from '@things-factory/shell'\nimport { User, checkUserHasRole } from '@things-factory/auth-base'\n\nconst debug = require('debug')('things-factory:integration-base:operato-connector')\n\nconst defaultOptions: any = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache', //'network-only'\n errorPolicy: 'all'\n },\n mutate: {\n errorPolicy: 'all'\n }\n}\n\nexport const GRAPHQL_URI = '/graphql'\nexport const SUBSCRIPTION_URI = GRAPHQL_URI\n\ninterface SubscriberData {\n tag: string\n scenario: any\n subscriptionObserver: any\n}\n\nexport class OperatoConnector implements Connector {\n private context: any\n\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('operato-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint: uri,\n params: { authKey, domain, subscriptionHandlers = {} }\n } = connection\n\n if (!authKey || !domain) {\n throw new Error('some connection paramter missing.')\n }\n\n const domainOwner = await getRepository(User).findOne({\n where: {\n id: connection.domain.owner\n }\n })\n\n this.context = {\n domain: connection.domain,\n user: domainOwner\n /* TODO: domainOwner 대신 특정 유저를 지정할 수 있도록 개선해야함. 모든 커넥션에 유저를 지정하는 기능으로 일반화할 필요가 있는 지 고민해야함 */\n }\n\n const httpLink = createHttpLink({\n uri: uri\n })\n\n /* \n CHECKPOINT: \n 1. GraphqQLWsLink를 사용하면 setContext를 통한 추가 헤더 설정이 무시됩니다.\n 따라서, GraphQLWsLink를 사용하려면, connectionParams를 통해 헤더를 설정해야 합니다.\n \n 2. 서버에서 실행시, webSocketImpl을 명시적으로 지정해야 합니다.\n */\n const wsLink = new GraphQLWsLink(\n createClient({\n url: uri.replace(/^http/, 'ws'),\n keepAlive: 10_000,\n retryAttempts: 1_000_000,\n shouldRetry: e => true,\n webSocketImpl: WebSocket,\n connectionParams: {\n headers: {\n 'x-things-factory-domain': domain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n })\n )\n\n const splitLink = split(\n ({ query }) => {\n const def = getMainDefinition(query)\n return def.kind === 'OperationDefinition' && def.operation === 'subscription'\n },\n wsLink,\n setContext((_, { headers }) => {\n return {\n headers: {\n ...headers,\n 'x-things-factory-domain': domain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n }).concat(httpLink)\n )\n\n const cache = new InMemoryCache({\n addTypename: false\n })\n\n const client = new ApolloClient({\n defaultOptions,\n cache,\n link: splitLink\n })\n\n const subscriptions: SubscriberData[] = []\n Object.keys(subscriptionHandlers).forEach(async tag => {\n if (!tag || !subscriptionHandlers[tag]) return\n\n const scenarioName = subscriptionHandlers[tag]\n\n // fetch a scenario\n const selectedScenario = await getRepository(Scenario).findOne({\n where: {\n name: scenarioName\n },\n relations: ['steps', 'domain']\n })\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n data(tag: \"${tag}\") {\n tag\n data\n }\n }\n `\n })\n\n const subscriptionObserver = subscription.subscribe({\n next: async data => {\n debug('received pubsub msg.:', data?.data)\n await this.runScenario(subscriptions, data?.data?.data)\n },\n error: error => {\n ConnectionManager.logger.error(`(${connection.name}:${connection.endpoint}) subscription error`, error)\n },\n complete: () => {\n ConnectionManager.logger.info(`(${connection.name}:${connection.endpoint}) subscription complete`)\n }\n })\n\n ConnectionManager.logger.info(\n `(${connection.name}:${connection.endpoint}) subscription closed flag: ${subscriptionObserver.closed}`\n )\n\n subscriptions.push({\n tag,\n scenario: selectedScenario,\n subscriptionObserver\n })\n ConnectionManager.logger.info(`(${tag}:${scenarioName}) subscription closed flag: ${subscriptionObserver.closed}`)\n })\n\n client['subscriptions'] = subscriptions\n ConnectionManager.addConnectionInstance(connection, client)\n\n ConnectionManager.logger.info(\n `operato-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection: InputConnection) {\n const client = ConnectionManager.getConnectionInstance(connection)\n const subscriptions: SubscriberData[] = client['subscriptions']\n subscriptions.forEach(subscription => subscription.subscriptionObserver.unsubscribe())\n client.stop()\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`operato-connector connection(${connection.name}) is disconnected`)\n }\n\n async runScenario(subscriptions: SubscriberData[], variables: any): Promise<ScenarioInstance> {\n const { domain, user } = this.context\n const { tag } = variables\n\n if (!tag) {\n throw new Error(`tag is invalid - ${tag}`)\n }\n\n const scenario = subscriptions.find(subscription => subscription.tag === tag)?.scenario\n if (!scenario) {\n throw new Error(`scenario is not found - ${tag}`)\n }\n\n if (!(await checkUserHasRole(scenario.roleId, domain, user))) {\n throw new Error(`Unauthorized! ${scenario.name} doesn't have required role.`)\n }\n\n /* create a scenario instance */\n const instanceName = scenario.name + '-' + String(Date.now())\n const instance = new ScenarioInstance(instanceName, scenario, {\n user,\n domain,\n variables,\n client: GraphqlLocalClient.client\n })\n\n // run scenario\n await instance.run()\n return instance\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'authKey',\n label: 'auth-key',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'domain',\n label: 'domain'\n },\n {\n type: 'tag-scenarios',\n name: 'subscriptionHandlers',\n label: 'subscription-handlers'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['graphql']\n }\n\n get help() {\n return 'integration/connector/operato-connector'\n }\n\n get description() {\n return 'Operato Graphql Connector'\n }\n}\n\nConnectionManager.registerConnector('operato-connector', new OperatoConnector())\n"]}
|
@@ -9,6 +9,7 @@ export declare class OracleConnector implements Connector {
|
|
9
9
|
type: string;
|
10
10
|
name: string;
|
11
11
|
label: string;
|
12
|
+
useDomainAttribute: boolean;
|
12
13
|
placeholder?: undefined;
|
13
14
|
value?: undefined;
|
14
15
|
} | {
|
@@ -16,6 +17,7 @@ export declare class OracleConnector implements Connector {
|
|
16
17
|
name: string;
|
17
18
|
placeholder: string;
|
18
19
|
label: string;
|
20
|
+
useDomainAttribute?: undefined;
|
19
21
|
value?: undefined;
|
20
22
|
} | {
|
21
23
|
type: string;
|
@@ -23,6 +25,7 @@ export declare class OracleConnector implements Connector {
|
|
23
25
|
placeholder: string;
|
24
26
|
label: string;
|
25
27
|
value: number;
|
28
|
+
useDomainAttribute?: undefined;
|
26
29
|
})[];
|
27
30
|
get taskPrefixes(): string[];
|
28
31
|
get help(): string;
|
@@ -135,12 +135,14 @@ class OracleConnector {
|
|
135
135
|
{
|
136
136
|
type: 'string',
|
137
137
|
name: 'user',
|
138
|
-
label: 'user'
|
138
|
+
label: 'user',
|
139
|
+
useDomainAttribute: true
|
139
140
|
},
|
140
141
|
{
|
141
142
|
type: 'password',
|
142
143
|
name: 'password',
|
143
|
-
label: 'password'
|
144
|
+
label: 'password',
|
145
|
+
useDomainAttribute: true
|
144
146
|
},
|
145
147
|
{
|
146
148
|
type: 'string',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["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CAAA;IACxD,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;aACd;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,6BAA6B;gBAC1C,KAAK,EAAE,gBAAgB;gBACvB,KAAK,EAAE,CAAC;aACT;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,wCAAwC,CAAA;IACjD,CAAC;CACF;AArMD,0CAqMC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AACzH,4DAA4D;AAE5D,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async recreatePool(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n await oracledb.getPool(poolAlias).close(10)\n await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} recreated.`)\n }\n\n async connect(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n\n var enableStatistics = true\n const pool = await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias,\n enableStatistics\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n dbConnection = await oracledb.getConnection(poolAlias)\n\n taskResult = (\n await dbConnection.execute(query, params, {\n outFormat: oracledb.OBJECT\n })\n ).rows\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n }\n return taskResult\n },\n execute: async (procedure, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n // TODO: need to check if this is available when procedure string is a common query.\n procedure = `BEGIN\n ${procedure}\n END;`\n dbConnection = await oracledb.getConnection(poolAlias)\n\n // console.log('\\n************* stat after get ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n\n const result = await dbConnection.execute(procedure, params, {\n outFormat: oracledb.OBJECT\n })\n\n let paramKeys = Object.keys(params)\n\n for (const paramKey of paramKeys) {\n if (params[paramKey].dir === oracledb?.BIND_OUT) {\n if (params[paramKey].type === oracledb?.CURSOR) {\n const resultSetTemp = result.outBinds[paramKey]\n taskResult[paramKey] = await resultSetTemp.getRows()\n await resultSetTemp.close()\n } else {\n taskResult[paramKey] = result.outBinds[paramKey]\n }\n }\n }\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n\n // console.log('\\n************* stat after close ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n }\n return taskResult\n },\n close: async () => {\n await oracledb.getPool(poolAlias).close(10)\n }\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n\n try {\n await client.close()\n ConnectionManager.logger.info(`Oracle Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user'\n },\n {\n type: 'password',\n name: 'password',\n label: 'password'\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'number',\n name: 'poolIncrement',\n placeholder: 'connection incremental size',\n label: 'pool-increment',\n value: 1\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'oracle']\n }\n\n get help() {\n return 'integration/connector/oracle-connector'\n }\n}\n\nConnectionManager.registerConnector('oracle-connector', new OracleConnector())\n\n// need reference:\n// https://download.oracle.com/otn_software/mac/instantclient/193000/instantclient-basiclite-macos.x64-19.3.0.0.0dbru.zip\n// https://node-oracledb.readthedocs.io/en/latest/index.html\n\n// docker pull store/oracle/database-instantclient:12.2.0.1\n"]}
|
1
|
+
{"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/oracle-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,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;AAED,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAA;IACzE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,UAA2B;QAC5C,MAAM,EACJ,IAAI,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,EACrE,MAAM,EACP,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,MAAM,SAAS,GAAG,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,CAAA;QAC1C,MAAM,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC3C,MAAM,QAAQ,CAAC,UAAU,CAAC;YACxB,IAA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AAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AACzH,4DAA4D;AAE5D,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async recreatePool(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n await oracledb.getPool(poolAlias).close(10)\n await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} recreated.`)\n }\n\n async connect(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n\n var enableStatistics = true\n const pool = await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias,\n enableStatistics\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n dbConnection = await oracledb.getConnection(poolAlias)\n\n taskResult = (\n await dbConnection.execute(query, params, {\n outFormat: oracledb.OBJECT\n })\n ).rows\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n }\n return taskResult\n },\n execute: async (procedure, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n // TODO: need to check if this is available when procedure string is a common query.\n procedure = `BEGIN\n ${procedure}\n END;`\n dbConnection = await oracledb.getConnection(poolAlias)\n\n // console.log('\\n************* stat after get ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n\n const result = await dbConnection.execute(procedure, params, {\n outFormat: oracledb.OBJECT\n })\n\n let paramKeys = Object.keys(params)\n\n for (const paramKey of paramKeys) {\n if (params[paramKey].dir === oracledb?.BIND_OUT) {\n if (params[paramKey].type === oracledb?.CURSOR) {\n const resultSetTemp = result.outBinds[paramKey]\n taskResult[paramKey] = await resultSetTemp.getRows()\n await resultSetTemp.close()\n } else {\n taskResult[paramKey] = result.outBinds[paramKey]\n }\n }\n }\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n\n // console.log('\\n************* stat after close ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n }\n return taskResult\n },\n close: async () => {\n await oracledb.getPool(poolAlias).close(10)\n }\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n\n try {\n await client.close()\n ConnectionManager.logger.info(`Oracle Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n useDomainAttribute: true\n },\n {\n type: 'password',\n name: 'password',\n label: 'password',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'number',\n name: 'poolIncrement',\n placeholder: 'connection incremental size',\n label: 'pool-increment',\n value: 1\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'oracle']\n }\n\n get help() {\n return 'integration/connector/oracle-connector'\n }\n}\n\nConnectionManager.registerConnector('oracle-connector', new OracleConnector())\n\n// need reference:\n// https://download.oracle.com/otn_software/mac/instantclient/193000/instantclient-basiclite-macos.x64-19.3.0.0.0dbru.zip\n// https://node-oracledb.readthedocs.io/en/latest/index.html\n\n// docker pull store/oracle/database-instantclient:12.2.0.1\n"]}
|
@@ -8,12 +8,23 @@ export declare class PostgresqlConnector implements Connector {
|
|
8
8
|
type: string;
|
9
9
|
name: string;
|
10
10
|
label: string;
|
11
|
-
|
11
|
+
description: string;
|
12
|
+
useDomainAttribute: boolean;
|
13
|
+
placeholder?: undefined;
|
12
14
|
} | {
|
13
15
|
type: string;
|
14
16
|
name: string;
|
15
17
|
label: string;
|
16
|
-
|
18
|
+
description: string;
|
19
|
+
useDomainAttribute?: undefined;
|
20
|
+
placeholder?: undefined;
|
21
|
+
} | {
|
22
|
+
type: string;
|
23
|
+
name: string;
|
24
|
+
label: string;
|
25
|
+
description: string;
|
26
|
+
placeholder: string;
|
27
|
+
useDomainAttribute?: undefined;
|
17
28
|
})[];
|
18
29
|
get taskPrefixes(): string[];
|
19
30
|
get help(): string;
|
@@ -93,34 +93,42 @@ class PostgresqlConnector {
|
|
93
93
|
{
|
94
94
|
type: 'string',
|
95
95
|
name: 'user',
|
96
|
-
label: 'user'
|
96
|
+
label: 'user',
|
97
|
+
description: 'Database username',
|
98
|
+
useDomainAttribute: true
|
97
99
|
},
|
98
100
|
{
|
99
101
|
type: 'password',
|
100
102
|
name: 'password',
|
101
|
-
label: 'password'
|
103
|
+
label: 'password',
|
104
|
+
description: 'Database password',
|
105
|
+
useDomainAttribute: true // 🔐 Domain attributes 사용
|
102
106
|
},
|
103
107
|
{
|
104
108
|
type: 'string',
|
105
109
|
name: 'database',
|
106
|
-
label: 'database'
|
110
|
+
label: 'database',
|
111
|
+
description: 'Database name'
|
107
112
|
},
|
108
113
|
{
|
109
114
|
type: 'number',
|
110
115
|
name: 'maxPoolConnection',
|
111
|
-
label: 'maxPoolConnection'
|
116
|
+
label: 'maxPoolConnection',
|
117
|
+
description: 'Maximum pool connections'
|
112
118
|
},
|
113
119
|
{
|
114
120
|
type: 'number',
|
115
121
|
name: 'idleTimeoutMillis',
|
116
122
|
label: 'idleTimeoutMillis',
|
117
|
-
|
123
|
+
description: 'Idle timeout in milliseconds',
|
124
|
+
placeholder: 'milli-seconds'
|
118
125
|
},
|
119
126
|
{
|
120
127
|
type: 'number',
|
121
128
|
name: 'connectionTimeoutMillis',
|
122
129
|
label: 'connectionTimeoutMillis',
|
123
|
-
|
130
|
+
description: 'Connection timeout in milliseconds',
|
131
|
+
placeholder: 'milli-seconds'
|
124
132
|
}
|
125
133
|
];
|
126
134
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"postgresql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/postgresql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC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,EAAE,CAAC;YACX,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAC5B,wBAAwB,UAAU,CAAC,IAAI,IAAI,QAAQ,QAAQ,QAAQ,iBAAiB,EACpF,CAAC,CACF,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAA2B;QAC1C,IAAI,kBAAkB,GAAG,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAC5E,IAAI,CAAC;YACH,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAA;YAChC,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,UAAU,CAAC,IAAI,WAAW,CAAC,CAAA;QACnF,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnC,CAAC;QACD,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;
|
1
|
+
{"version":3,"file":"postgresql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/postgresql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,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BAC1B,WAAW,EAAE,8BAA8B;gBAC3C,WAAW,EAAE,eAAe;aAC7B;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,yBAAyB;gBAC/B,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EAAE,oCAAoC;gBACjD,WAAW,EAAE,eAAe;aAC7B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,4CAA4C,CAAA;IACrD,CAAC;CACF;AAjJD,kDAiJC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var { Client, Pool } = require('pg')\n} catch (err) {\n logger.error('postgresql module loading failed', err)\n}\n\nexport class PostgresqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('postgresql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database, maxPoolConnection, idleTimeoutMillis, connectionTimeoutMillis }\n } = connection\n const [host, port = 5432] = endpoint.split(':')\n\n if (!Pool) {\n throw new Error('postgresql module loading failed')\n }\n\n // create a new pool\n const pool = new Pool({\n user,\n host,\n database,\n password,\n port: Number(port),\n max: maxPoolConnection || 10,\n idleTimeoutMillis: idleTimeoutMillis || 30000,\n connectionTimeoutMillis: connectionTimeoutMillis || 2000\n })\n\n pool.on('error', (err, client) => {\n logger.error('unexpected error on postgres pool.', err)\n })\n\n try {\n // try to connect to database to check the connection at initial time\n const entryConnection = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n entryConnection.release()\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n try {\n // get a connection from the pool\n var client = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n\n client?.on('error', async err => {\n logger.error('unexpected error on postgres client.', err)\n ConnectionManager.logger.error(err)\n })\n\n // try to query\n var result = (await client.query(query, params)).rows\n } catch (e) {\n ConnectionManager.logger.error(e)\n throw e\n } finally {\n // release the connection back to the pool\n client?.release()\n }\n return result\n },\n close: async () => {\n // close the pool\n await pool?.end()\n }\n })\n\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} connected.`)\n } catch (e) {\n ConnectionManager.logger.error(\n `PostgresSQL Database(${connection.name}:${database}) at ${endpoint} not connected.`,\n e\n )\n }\n }\n\n async disconnect(connection: InputConnection) {\n var connectionInstance = ConnectionManager.getConnectionInstance(connection)\n try {\n await connectionInstance.close()\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'password',\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n },\n {\n type: 'number',\n name: 'maxPoolConnection',\n label: 'maxPoolConnection',\n description: 'Maximum pool connections'\n },\n {\n type: 'number',\n name: 'idleTimeoutMillis',\n label: 'idleTimeoutMillis',\n description: 'Idle timeout in milliseconds',\n placeholder: 'milli-seconds'\n },\n {\n type: 'number',\n name: 'connectionTimeoutMillis',\n label: 'connectionTimeoutMillis',\n description: 'Connection timeout in milliseconds',\n placeholder: 'milli-seconds'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n\n get help() {\n return 'integration/connector/postgresql-connector'\n }\n}\n\nConnectionManager.registerConnector('postgresql-connector', new PostgresqlConnector())\n"]}
|
@@ -36,9 +36,9 @@ class PyrunConnector {
|
|
36
36
|
}
|
37
37
|
get parameterSpec() {
|
38
38
|
return [
|
39
|
-
{ type: 'string', name: 'username', label: 'username', required: false },
|
40
|
-
{ type: 'password', name: 'password', label: 'password', required: false },
|
41
|
-
{ type: 'string', name: 'token', label: 'token', required: false }
|
39
|
+
{ type: 'string', name: 'username', label: 'username', required: false, useDomainAttribute: true },
|
40
|
+
{ type: 'password', name: 'password', label: 'password', required: false, useDomainAttribute: true },
|
41
|
+
{ type: 'string', name: 'token', label: 'token', required: false, useDomainAttribute: true }
|
42
42
|
];
|
43
43
|
}
|
44
44
|
get taskPrefixes() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pyrun-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/pyrun-connector.ts"],"names":[],"mappings":";;;AACA,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjE,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,MAAM,CAAA;QAErD,IAAI,CAAC,KAAK,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACnC,oCAAoC;YACpC,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,QAAQ,aAAa,CAAA;YACpD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;gBAChC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,E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ACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACjG,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE;YAClG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE;YACpG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE;SAC7F,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,yCAAyC,CAAA;IAClD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AAzDD,wCAyDC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class PyrunConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n ConnectionManager.logger.info('pyrun-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n var { username, password, token } = connection.params\n\n if (!token && username && password) {\n // /auth/login 엔드포인트로 로그인하여 토큰 발급 시도\n const loginUrl = `${connection.endpoint}/auth/login`\n const res = await fetch(loginUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ username, password })\n })\n if (!res.ok) {\n const error = await res.text()\n throw new Error(`pyrun-connector 인증 실패: ${res.status} ${error}`)\n }\n\n var data = await res.json()\n token = data.access_token\n }\n\n ConnectionManager.addConnectionInstance(connection, {\n ...connection,\n token\n })\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection: InputConnection) {\n ConnectionManager.removeConnectionInstance(connection)\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n { type: 'string', name: 'username', label: 'username', required: false, useDomainAttribute: true },\n { type: 'password', name: 'password', label: 'password', required: false, useDomainAttribute: true },\n { type: 'string', name: 'token', label: 'token', required: false, useDomainAttribute: true }\n ]\n }\n\n get taskPrefixes() {\n return ['pyrun']\n }\n\n get description() {\n return 'Python Runner(pyrun) REST API Connector'\n }\n\n get help() {\n return 'integration/connector/pyrun-connector'\n }\n}\n\nConnectionManager.registerConnector('pyrun-connector', new PyrunConnector())\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"edge-client.js","sourceRoot":"","sources":["../../server/engine/edge-client.ts"],"names":[],"mappings":";;AA0BA,0BAEC;AAED,0CAEC;AAED,gDAEC;AAED,sDAEC;AAED,sCAEC;AAjCD,IAAI,UAAU,GAAe;IAC3B,KAAK,CAAC,OAAO,CAAC,IAAU,EAAE,eAAwB;QAChD,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,WAAyB,EAAE,OAAwB;QACvE,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,kBAAkB,CAAC,WAAyB,EAAE,OAAwB;QAC1E,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,qBAAqB,CAAC,WAAyB,EAAE,OAAwB;QAC7E,MAAM,0BAA0B,CAAA;IAClC,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,OAAO,CAAC,IAAU,EAAE,eAAwB;IAChE,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;AACxD,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,WAAyB,EAAE,OAAyB;IACxF,OAAO,MAAM,UAAU,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC;AAEM,KAAK,UAAU,kBAAkB,CAAC,WAAyB,EAAE,OAAyB;IAC3F,OAAO,MAAM,UAAU,CAAC,kBAAkB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAClE,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,WAAyB,EAAE,OAAyB;IAC9F,OAAO,MAAM,UAAU,CAAC,qBAAqB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AACrE,CAAC;AAED,SAAgB,aAAa,CAAC,IAAgB;IAC5C,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC","sourcesContent":["import { Connection } from '../service/connection/connection
|
1
|
+
{"version":3,"file":"edge-client.js","sourceRoot":"","sources":["../../server/engine/edge-client.ts"],"names":[],"mappings":";;AA0BA,0BAEC;AAED,0CAEC;AAED,gDAEC;AAED,sDAEC;AAED,sCAEC;AAjCD,IAAI,UAAU,GAAe;IAC3B,KAAK,CAAC,OAAO,CAAC,IAAU,EAAE,eAAwB;QAChD,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,eAAe,CAAC,WAAyB,EAAE,OAAwB;QACvE,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,kBAAkB,CAAC,WAAyB,EAAE,OAAwB;QAC1E,MAAM,0BAA0B,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,qBAAqB,CAAC,WAAyB,EAAE,OAAwB;QAC7E,MAAM,0BAA0B,CAAA;IAClC,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,OAAO,CAAC,IAAU,EAAE,eAAwB;IAChE,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;AACxD,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,WAAyB,EAAE,OAAyB;IACxF,OAAO,MAAM,UAAU,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC;AAEM,KAAK,UAAU,kBAAkB,CAAC,WAAyB,EAAE,OAAyB;IAC3F,OAAO,MAAM,UAAU,CAAC,kBAAkB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAClE,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,WAAyB,EAAE,OAAyB;IAC9F,OAAO,MAAM,UAAU,CAAC,qBAAqB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AACrE,CAAC;AAED,SAAgB,aAAa,CAAC,IAAgB;IAC5C,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC","sourcesContent":["import { Connection } from '../service/connection/connection'\nimport { Step } from '../service/step/step-type'\nimport { Context, TaskHandler } from './types'\n\nexport type EdgeClient = {\n handler: TaskHandler\n syncConnections(connections: Connection[], context?: ResolverContext): Promise<any>\n connectConnections(connections: Connection[], context?: ResolverContext): Promise<any>\n disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any>\n}\n\nvar edgeClient: EdgeClient = {\n async handler(step: Step, scenarioContext: Context) {\n throw 'edgeClient not supported'\n },\n async syncConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n throw 'edgeClient not supported'\n },\n async connectConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n throw 'edgeClient not supported'\n },\n async disconnectConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n throw 'edgeClient not supported'\n }\n}\n\nexport async function handler(step: Step, scenarioContext: Context) {\n return await edgeClient.handler(step, scenarioContext)\n}\n\nexport async function syncConnections(connections: Connection[], context?: ResolverContext): Promise<any> {\n return await edgeClient.syncConnections(connections, context)\n}\n\nexport async function connectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {\n return await edgeClient.connectConnections(connections, context)\n}\n\nexport async function disconnectConnections(connections: Connection[], context?: ResolverContext): Promise<any> {\n return await edgeClient.disconnectConnections(connections, context)\n}\n\nexport function setEdgeClient(edge: EdgeClient) {\n edgeClient = edge\n}\n"]}
|
@@ -6,7 +6,7 @@ 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
|
-
var dbconnection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
9
|
+
var dbconnection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
10
10
|
const compartment = new Compartment({
|
11
11
|
domain,
|
12
12
|
user,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database-query.js","sourceRoot":"","sources":["../../../server/engine/task/database-query.ts"],"names":[],"mappings":";;AAAA,8DAAyD;AACzD,oDAA+C;AAG/C,eAAY;AAEZ,KAAK,UAAU,aAAa,CAAC,IAAe,EAAE,OAAgB;IAC5D,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IACpD,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,KAAK,EAAE,EAClB,GAAG,IAAI,CAAA;IAER,IAAI,YAAY,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"database-query.js","sourceRoot":"","sources":["../../../server/engine/task/database-query.ts"],"names":[],"mappings":";;AAAA,8DAAyD;AACzD,oDAA+C;AAG/C,eAAY;AAEZ,KAAK,UAAU,aAAa,CAAC,IAAe,EAAE,OAAgB;IAC5D,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IACpD,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,KAAK,EAAE,EAClB,GAAG,IAAI,CAAA;IAER,IAAI,YAAY,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAE9F,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,WAAW,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAEzD,OAAO;QACL,IAAI,EAAE,WAAW;KAClB,CAAA;AACH,CAAC;AAED,aAAa,CAAC,aAAa,GAAG;IAC5B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE;YACR,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,IAAI;SACtB;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG;SACV;KACF;CACF,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,iCAAiC,CAAA;AAEtD,4BAAY,CAAC,mBAAmB,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 = await 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"]}
|
@@ -4,7 +4,7 @@ const task_registry_1 = require("../task-registry");
|
|
4
4
|
const connection_manager_1 = require("../connection-manager");
|
5
5
|
async function EchoReceive(step, { logger, domain }) {
|
6
6
|
var { connection: connectionName } = step;
|
7
|
-
var connection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
7
|
+
var connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
8
8
|
var message = await connection.read();
|
9
9
|
return {
|
10
10
|
data: message.toString()
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"echo-receive.js","sourceRoot":"","sources":["../../../server/engine/task/echo-receive.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAKzD,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAW;IACrE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAEzC,IAAI,UAAU,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"echo-receive.js","sourceRoot":"","sources":["../../../server/engine/task/echo-receive.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAKzD,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAW;IACrE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAEzC,IAAI,UAAU,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAE5F,IAAI,OAAO,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAA;IAErC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;KACzB,CAAA;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG,EAAE,CAAA;AAE9B,4BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\n\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function EchoReceive(step: InputStep, { logger, domain }: Context) {\n var { connection: connectionName } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n var message = await connection.read()\n\n return {\n data: message.toString()\n }\n}\n\nEchoReceive.parameterSpec = []\n\nTaskRegistry.registerTaskHandler('echo-receive', EchoReceive)\n"]}
|
@@ -4,7 +4,7 @@ const task_registry_1 = require("../task-registry");
|
|
4
4
|
const connection_manager_1 = require("../connection-manager");
|
5
5
|
async function EchoSend(step, { logger, domain }) {
|
6
6
|
var { connection: connectionName, params: { message } } = step;
|
7
|
-
var connection = connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
7
|
+
var connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
8
8
|
if (!connection) {
|
9
9
|
throw Error(`connection is not found : ${connectionName}`);
|
10
10
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"echo-send.js","sourceRoot":"","sources":["../../../server/engine/task/echo-send.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAIzD,KAAK,UAAU,QAAQ,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAW;IAClE,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,OAAO,EAAE,EACpB,GAAG,IAAI,CAAA;IAER,IAAI,UAAU,GAAG,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"echo-send.js","sourceRoot":"","sources":["../../../server/engine/task/echo-send.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAIzD,KAAK,UAAU,QAAQ,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAW;IAClE,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,OAAO,EAAE,EACpB,GAAG,IAAI,CAAA;IAER,IAAI,UAAU,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,6BAA6B,cAAc,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,IAAI,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAE1C,OAAO;QACL,IAAI;KACL,CAAA;AACH,CAAC;AAED,QAAQ,CAAC,aAAa,GAAG;IACvB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;CACF,CAAA;AAED,4BAAY,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function EchoSend(step: InputStep, { logger, domain }: Context) {\n var {\n connection: connectionName,\n params: { message }\n } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw Error(`connection is not found : ${connectionName}`)\n }\n\n var data = await connection.write(message)\n\n return {\n data\n }\n}\n\nEchoSend.parameterSpec = [\n {\n type: 'string',\n name: 'message',\n label: 'message'\n }\n]\n\nTaskRegistry.registerTaskHandler('echo-send', EchoSend)\n"]}
|
@@ -25,7 +25,7 @@ async function GraphqlMutate(step, context) {
|
|
25
25
|
catch (err) {
|
26
26
|
throw new Error(`Failed to evaluate mutation: ${err.message}`);
|
27
27
|
}
|
28
|
-
var client = connection_manager_1.ConnectionManager.getConnectionInstanceByName(context.domain, connectionName);
|
28
|
+
var client = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(context.domain, connectionName);
|
29
29
|
const queryVariables = Object.keys(variablesAccessorMap || {}).reduce((variables, key) => {
|
30
30
|
const accessor = variablesAccessorMap[key];
|
31
31
|
variables[key] = (0, utils_1.access)(accessor, data);
|