@things-factory/integration-base 5.0.11 → 6.0.0-alpha.3
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/connection-manager.js +1 -2
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js +4 -4
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/http-connector.js +3 -3
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js +1 -1
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/scenario-engine.js +1 -2
- package/dist-server/engine/scenario-engine.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js +3 -2
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.js +3 -2
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js +4 -4
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js +3 -3
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js +2 -2
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js +2 -2
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/routers/scenario-view-router.js +6 -5
- package/dist-server/routers/scenario-view-router.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +8 -7
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +7 -9
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +4 -6
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.js +4 -5
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connector/connector-query.js +4 -4
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js +11 -8
- package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-query.js +7 -9
- package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log.js +8 -4
- package/dist-server/service/payload-log/payload-log.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +13 -8
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +9 -11
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +3 -4
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario-flow/scenario-flow.js +1 -2
- package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +4 -5
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-query.js +1 -2
- package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +1 -2
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +3 -3
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-type.js +1 -2
- package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +3 -3
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.js +8 -10
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/service/step/step-type.js +3 -4
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +5 -5
- 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
- package/server/engine/connection-manager.ts +1 -2
- package/server/engine/connector/graphql-connector.ts +5 -5
- package/server/engine/connector/http-connector.ts +5 -5
- package/server/engine/connector/oracle-connector.ts +1 -1
- package/server/engine/scenario-engine.ts +2 -2
- package/server/engine/task/local-graphql-mutate.ts +3 -2
- package/server/engine/task/local-graphql-query.ts +3 -2
- package/server/engine/task/pick-pending-scenario.ts +4 -3
- package/server/engine/task/sub-scenario.ts +3 -2
- package/server/engine/task/switch-range-scenario.ts +1 -2
- package/server/engine/task/switch-scenario.ts +1 -2
- package/server/routers/scenario-view-router.ts +8 -8
- package/server/service/connection/connection-mutation.ts +21 -13
- package/server/service/connection/connection-query.ts +8 -9
- package/server/service/connection/connection-subscription.ts +5 -4
- package/server/service/connector/connector-query.ts +9 -7
- package/server/service/payload-log/payload-log-mutation.ts +25 -21
- package/server/service/payload-log/payload-log-query.ts +7 -8
- package/server/service/payload-log/payload-log.ts +5 -2
- package/server/service/scenario/scenario-mutation.ts +26 -20
- package/server/service/scenario/scenario-query.ts +11 -12
- package/server/service/scenario-instance/scenario-instance-mutation.ts +6 -7
- package/server/service/scenario-instance/scenario-instance-query.ts +5 -2
- package/server/service/step/step-mutation.ts +5 -5
- package/server/service/step/step-query.ts +8 -9
- package/server/service/task-type/task-type-query.ts +10 -8
- package/db.test.sqlite +0 -0
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConnectionManager = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const winston_1 = require("winston");
|
|
8
7
|
const shell_1 = require("@things-factory/shell");
|
|
9
8
|
const service_1 = require("../service");
|
|
@@ -17,7 +16,7 @@ const systemTimestamp = (0, winston_1.format)((info, opts) => {
|
|
|
17
16
|
});
|
|
18
17
|
class ConnectionManager {
|
|
19
18
|
static async ready() {
|
|
20
|
-
const CONNECTIONS = (await (0,
|
|
19
|
+
const CONNECTIONS = (await (0, shell_1.getRepository)(service_1.Connection).find({
|
|
21
20
|
where: { active: true },
|
|
22
21
|
relations: ['domain', 'creator', 'updater']
|
|
23
22
|
})).map(connection => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../server/engine/connection-manager.ts"],"names":[],"mappings":";;;;AAAA,8EAAoC;AACpC,qCAAuC;AACvC,qCAA0D;AAE1D,iDAA0E;AAE1E,wCAAyD;AAGzD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AACpD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,CAAA;AAE7E,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAA;AAClE,MAAM,eAAe,GAAG,IAAA,gBAAM,EAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;IAC5C,IAAI,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,SAAS,GAAG,IAAA,yBAAM,GAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;IAC3D,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA;AAEF,MAAa,iBAAiB;IAwB5B,MAAM,CAAC,KAAK,CAAC,KAAK;QAChB,MAAM,WAAW,GAAG,CAClB,MAAM,IAAA,uBAAa,EAAC,oBAAU,CAAC,CAAC,IAAI,CAAC;YACnC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACvB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;SAC5C,CAAC,CACH,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YACjB,IAAI,MAAM,GAAG,EAAE,CAAA;YACf,IA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F,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,UAAsB,EAAE,KAAK;QAC/C,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;QAE1D,cAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE;YACjC,eAAe,EAAE;gBACf,MAAM;gBACN,EAAE;gBACF,IAAI;gBACJ,WAAW;gBACX,IAAI;gBACJ,KAAK;gBACL,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB;SACF,CAAC,CAAA;IACJ,CAAC;;AAzJH,8CA0JC;AAzJgB,4BAAU,GAAsC,EAAE,CAAA;AAClD,6BAAW,GAAG,EAAE,CAAA;AAChB,2BAAS,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;IAClE,OAAO,GAAG,SAAS,IAAI,KAAK,KAAK,OAAO,EAAE,CAAA;AAC5C,CAAC,CAAC,CAAA;AAEY,wBAAM,GAAG,IAAA,sBAAY,EAAC;IAClC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,iBAAiB,CAAC,SAAS,CAAC;IACzF,UAAU,EAAE;QACV,IAAK,oBAAkB,CAAC,eAAe,CAAC;YACtC,QAAQ,EAAE,6BAA6B;YACvC,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,MAAM;SACd,CAAC;QACF,IAAI,0BAAkB,CAAC;YACrB,KAAK,EAAE,gBAAgB;SACxB,CAAC;KACH;CACF,CAAC,CAAA","sourcesContent":["import moment from 'moment-timezone'\nimport { getRepository } from 'typeorm'\nimport { createLogger, format, transports } from 'winston'\n\nimport { Domain, pubsub, PubSubLogTransport } from '@things-factory/shell'\n\nimport { Connection, ConnectionStatus } from '../service'\nimport { Connector } from './types'\n\nconst { combine, timestamp, splat, printf } = format\nconst debug = require('debug')('things-factory:integration-base:connections')\n\nconst SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone\nconst systemTimestamp = format((info, opts) => {\n if (opts.tz) info.timestamp = moment().tz(opts.tz).format()\n return info\n})\n\nexport class ConnectionManager {\n private static connectors: { [propName: string]: Connector } = {}\n private static connections = {}\n private static logFormat = printf(({ level, message, timestamp }) => {\n return `${timestamp} ${level}: ${message}`\n })\n\n public static logger = createLogger({\n format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), ConnectionManager.logFormat),\n transports: [\n new (transports as any).DailyRotateFile({\n filename: `logs/connections-%DATE%.log`,\n datePattern: 'YYYY-MM-DD-HH',\n zippedArchive: false,\n maxSize: '20m',\n maxFiles: '14d',\n level: 'info'\n }),\n new PubSubLogTransport({\n topic: 'connection-log'\n })\n ]\n })\n\n static async ready() {\n const CONNECTIONS = (\n await getRepository(Connection).find({\n where: { active: true },\n relations: ['domain', 'creator', 'updater']\n })\n ).map(connection => {\n var params = {}\n try {\n params = JSON.parse(connection.params || '{}')\n } catch (ex) {\n ConnectionManager.logger.error(`connection '${connection.name}' params should be JSON format`)\n ConnectionManager.logger.error(ex)\n }\n\n return {\n ...connection,\n params\n }\n })\n\n ConnectionManager.logger.info('Initializing ConnectionManager...')\n\n return await Promise.all(\n Object.keys(ConnectionManager.connectors).map(type => {\n var connector = ConnectionManager.connectors[type]\n ConnectionManager.logger.info(`Connector '${type}' started to ready`)\n\n return connector\n .ready(CONNECTIONS.filter(connection => connection.type == type) as any)\n .catch(error => {\n ConnectionManager.logger.error(error.message)\n })\n .then(() => {\n ConnectionManager.logger.info(`All connector for '${type}' ready`)\n })\n })\n ).then(() => {\n ConnectionManager.logger.info('ConnectionManager initialization done:')\n Object.keys(ConnectionManager.connections).forEach(key => {\n var connections = ConnectionManager.connections[key]\n ConnectionManager.logger.info('For domain(%s) : %s', key, JSON.stringify(Object.keys(connections)))\n })\n })\n }\n\n static registerConnector(type: string, connector: Connector) {\n ConnectionManager.connectors[type] = connector\n }\n\n static getConnector(type: string): Connector {\n return ConnectionManager.connectors[type]\n }\n\n static getConnectors(): { [connectorName: string]: Connector } {\n return {\n ...ConnectionManager.connectors\n }\n }\n\n static unregisterConnector(type: string) {\n delete ConnectionManager.connectors[type]\n }\n\n static getConnectionInstance(connection: Connection): any {\n const { domain, name } = connection\n return ConnectionManager.connections[domain.id]?.[name]\n }\n\n static getConnectionInstanceByName(domain: Domain, name: string) {\n var connections = ConnectionManager.connections[domain.id]\n\n return connections?.[name]\n }\n\n static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {\n var connections = ConnectionManager.connections[domain.id]\n\n return {\n ...connections\n }\n }\n\n static addConnectionInstance(connection: Connection, instance: any) {\n const { domain, name } = connection\n\n var connections = ConnectionManager.connections[domain.id]\n if (!connections) {\n connections = ConnectionManager.connections[domain.id] = {}\n }\n\n connections[name] = instance\n\n ConnectionManager.publishState(connection, ConnectionStatus.CONNECTED)\n debug('add-connection', domain.subdomain, name)\n }\n\n static removeConnectionInstance(connection: Connection): any {\n const { domain, name } = connection\n var connections = ConnectionManager.connections[domain.id]\n var instance = connections?.[name]\n\n if (!connections || !instance) {\n debug('remove-connection', `'${name}' connection not found in domain '${domain.subdomain}'`)\n return\n }\n\n delete connections[name]\n\n ConnectionManager.publishState(connection, ConnectionStatus.DISCONNECTED)\n debug('remove-connection', `'${name}' connection is removed from domain '${domain.subdomain}'`)\n\n return instance\n }\n\n static publishState(connection: Connection, state) {\n const { domain, id, name, description, type } = connection\n\n pubsub.publish('connection-state', {\n connectionState: {\n domain,\n id,\n name,\n description,\n type,\n state,\n timestamp: new Date()\n }\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../server/engine/connection-manager.ts"],"names":[],"mappings":";;;;AAAA,8EAAoC;AACpC,qCAA0D;AAE1D,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E,IAAI,IAAI,EAAE;aACtB;SACF,CAAC,CAAA;IACJ,CAAC;;AAzJH,8CA0JC;AAzJgB,4BAAU,GAAsC,EAAE,CAAA;AAClD,6BAAW,GAAG,EAAE,CAAA;AAChB,2BAAS,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;IAClE,OAAO,GAAG,SAAS,IAAI,KAAK,KAAK,OAAO,EAAE,CAAA;AAC5C,CAAC,CAAC,CAAA;AAEY,wBAAM,GAAG,IAAA,sBAAY,EAAC;IAClC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,iBAAiB,CAAC,SAAS,CAAC;IACzF,UAAU,EAAE;QACV,IAAK,oBAAkB,CAAC,eAAe,CAAC;YACtC,QAAQ,EAAE,6BAA6B;YACvC,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,MAAM;SACd,CAAC;QACF,IAAI,0BAAkB,CAAC;YACrB,KAAK,EAAE,gBAAgB;SACxB,CAAC;KACH;CACF,CAAC,CAAA","sourcesContent":["import moment from 'moment-timezone'\nimport { createLogger, format, transports } from 'winston'\n\nimport { Domain, getRepository, pubsub, PubSubLogTransport } from '@things-factory/shell'\n\nimport { Connection, ConnectionStatus } from '../service'\nimport { Connector } from './types'\n\nconst { combine, timestamp, splat, printf } = format\nconst debug = require('debug')('things-factory:integration-base:connections')\n\nconst SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone\nconst systemTimestamp = format((info, opts) => {\n if (opts.tz) info.timestamp = moment().tz(opts.tz).format()\n return info\n})\n\nexport class ConnectionManager {\n private static connectors: { [propName: string]: Connector } = {}\n private static connections = {}\n private static logFormat = printf(({ level, message, timestamp }) => {\n return `${timestamp} ${level}: ${message}`\n })\n\n public static logger = createLogger({\n format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), ConnectionManager.logFormat),\n transports: [\n new (transports as any).DailyRotateFile({\n filename: `logs/connections-%DATE%.log`,\n datePattern: 'YYYY-MM-DD-HH',\n zippedArchive: false,\n maxSize: '20m',\n maxFiles: '14d',\n level: 'info'\n }),\n new PubSubLogTransport({\n topic: 'connection-log'\n })\n ]\n })\n\n static async ready() {\n const CONNECTIONS = (\n await getRepository(Connection).find({\n where: { active: true },\n relations: ['domain', 'creator', 'updater']\n })\n ).map(connection => {\n var params = {}\n try {\n params = JSON.parse(connection.params || '{}')\n } catch (ex) {\n ConnectionManager.logger.error(`connection '${connection.name}' params should be JSON format`)\n ConnectionManager.logger.error(ex)\n }\n\n return {\n ...connection,\n params\n }\n })\n\n ConnectionManager.logger.info('Initializing ConnectionManager...')\n\n return await Promise.all(\n Object.keys(ConnectionManager.connectors).map(type => {\n var connector = ConnectionManager.connectors[type]\n ConnectionManager.logger.info(`Connector '${type}' started to ready`)\n\n return connector\n .ready(CONNECTIONS.filter(connection => connection.type == type) as any)\n .catch(error => {\n ConnectionManager.logger.error(error.message)\n })\n .then(() => {\n ConnectionManager.logger.info(`All connector for '${type}' ready`)\n })\n })\n ).then(() => {\n ConnectionManager.logger.info('ConnectionManager initialization done:')\n Object.keys(ConnectionManager.connections).forEach(key => {\n var connections = ConnectionManager.connections[key]\n ConnectionManager.logger.info('For domain(%s) : %s', key, JSON.stringify(Object.keys(connections)))\n })\n })\n }\n\n static registerConnector(type: string, connector: Connector) {\n ConnectionManager.connectors[type] = connector\n }\n\n static getConnector(type: string): Connector {\n return ConnectionManager.connectors[type]\n }\n\n static getConnectors(): { [connectorName: string]: Connector } {\n return {\n ...ConnectionManager.connectors\n }\n }\n\n static unregisterConnector(type: string) {\n delete ConnectionManager.connectors[type]\n }\n\n static getConnectionInstance(connection: Connection): any {\n const { domain, name } = connection\n return ConnectionManager.connections[domain.id]?.[name]\n }\n\n static getConnectionInstanceByName(domain: Domain, name: string) {\n var connections = ConnectionManager.connections[domain.id]\n\n return connections?.[name]\n }\n\n static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {\n var connections = ConnectionManager.connections[domain.id]\n\n return {\n ...connections\n }\n }\n\n static addConnectionInstance(connection: Connection, instance: any) {\n const { domain, name } = connection\n\n var connections = ConnectionManager.connections[domain.id]\n if (!connections) {\n connections = ConnectionManager.connections[domain.id] = {}\n }\n\n connections[name] = instance\n\n ConnectionManager.publishState(connection, ConnectionStatus.CONNECTED)\n debug('add-connection', domain.subdomain, name)\n }\n\n static removeConnectionInstance(connection: Connection): any {\n const { domain, name } = connection\n var connections = ConnectionManager.connections[domain.id]\n var instance = connections?.[name]\n\n if (!connections || !instance) {\n debug('remove-connection', `'${name}' connection not found in domain '${domain.subdomain}'`)\n return\n }\n\n delete connections[name]\n\n ConnectionManager.publishState(connection, ConnectionStatus.DISCONNECTED)\n debug('remove-connection', `'${name}' connection is removed from domain '${domain.subdomain}'`)\n\n return instance\n }\n\n static publishState(connection: Connection, state) {\n const { domain, id, name, description, type } = connection\n\n pubsub.publish('connection-state', {\n connectionState: {\n domain,\n id,\n name,\n description,\n type,\n state,\n timestamp: new Date()\n }\n })\n }\n}\n"]}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GraphqlConnector = void 0;
|
|
4
4
|
require("cross-fetch/polyfill");
|
|
5
5
|
const core_1 = require("@apollo/client/core");
|
|
6
|
-
const connection_manager_1 = require("../connection-manager");
|
|
7
|
-
const oauth2_client_1 = require("@things-factory/oauth2-client");
|
|
8
|
-
const typeorm_1 = require("typeorm");
|
|
9
6
|
const error_1 = require("@apollo/client/link/error");
|
|
7
|
+
const oauth2_client_1 = require("@things-factory/oauth2-client");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const connection_manager_1 = require("../connection-manager");
|
|
10
10
|
const defaultOptions = {
|
|
11
11
|
watchQuery: {
|
|
12
12
|
fetchPolicy: 'no-cache',
|
|
@@ -39,7 +39,7 @@ class GraphqlConnector {
|
|
|
39
39
|
connection_manager_1.ConnectionManager.logger.error(`[Network error - ${networkError.statusCode}] ${networkError}`);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
const oauth2Client = await (0,
|
|
42
|
+
const oauth2Client = await (0, shell_1.getRepository)(oauth2_client_1.Oauth2Client).findOneBy({ id: authClient });
|
|
43
43
|
const authMiddleware = new core_1.ApolloLink((operation, forward) => {
|
|
44
44
|
// add the authorization to the headers
|
|
45
45
|
operation.setContext(({ headers = {} }) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/graphql-connector.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAE7B,8CAA6F;
|
|
1
|
+
{"version":3,"file":"graphql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/graphql-connector.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAE7B,8CAA6F;AAC7F,qDAAmD;AACnD,iEAA4D;AAC5D,iDAAqD;AAErD,8DAAyD;AAGzD,MAAM,cAAc,GAAQ;IAC1B,UAAU,EAAE;QACV,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,KAAK;KACnB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,KAAK;KACnB;CACF,CAAA;AAED,MAAM,KAAK,GAAG,IAAI,oBAAa,CAAC;IAC9B,WAAW,EAAE,KAAK;CACnB,CAAC,CAAA;AAEF,MAAa,gBAAgB;IAC3B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjE,sCAAiB,CAAC,MAAM,C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AAc;gBACd,IAAA,eAAO,EAAC,aAAa,CAAC;gBACtB,IAAI,eAAQ,CAAC;oBACX,GAAG;oBACH,WAAW,EAAE,SAAS;iBACvB,CAAC;aACH,CAAC;SACH,CAAC,CACH,CAAA;QAED,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAC3B,gCAAgC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CACvF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,IAAI,MAAM,GAAG,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAChE,MAAM,CAAC,IAAI,EAAE,CAAA;QACb,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACnG,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,aAAa;gBACpB,QAAQ,EAAE;oBACR,SAAS,EAAE,eAAe;iBAC3B;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,SAAS,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,wBAAwB,CAAA;IACjC,CAAC;CACF;AAvFD,4CAuFC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAA","sourcesContent":["import 'cross-fetch/polyfill'\n\nimport { ApolloClient, ApolloLink, from, HttpLink, InMemoryCache } from '@apollo/client/core'\nimport { onError } from '@apollo/client/link/error'\nimport { Oauth2Client } from '@things-factory/oauth2-client'\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\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\nconst cache = new InMemoryCache({\n addTypename: false\n})\n\nexport class GraphqlConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('graphql-connector connections are ready')\n }\n\n async connect(connection) {\n var {\n endpoint: uri,\n params: { authClient }\n } = connection\n\n var ERROR_HANDLER: any = ({ graphQLErrors, networkError }) => {\n if (graphQLErrors)\n graphQLErrors.map(({ message, locations, path }) => {\n ConnectionManager.logger.error(`[GraphQL error] Message: ${message}, Location: ${locations}, Path: ${path}`)\n })\n\n if (networkError) {\n ConnectionManager.logger.error(`[Network error - ${networkError.statusCode}] ${networkError}`)\n }\n }\n\n const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).findOneBy({ id: authClient })\n\n const authMiddleware = new ApolloLink((operation, forward) => {\n // add the authorization to the headers\n operation.setContext(({ headers = {} }) => ({\n headers: {\n ...headers,\n ...oauth2Client.getAuthHeaders()\n }\n }))\n\n return forward(operation)\n })\n\n ConnectionManager.addConnectionInstance(\n connection,\n new ApolloClient({\n defaultOptions,\n cache,\n link: from([\n authMiddleware,\n onError(ERROR_HANDLER),\n new HttpLink({\n uri,\n credentials: 'include'\n })\n ])\n })\n )\n\n ConnectionManager.logger.info(\n `graphql-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n }\n\n async disconnect(connection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n client.stop()\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`graphql-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'entity-selector',\n name: 'authClient',\n label: 'auth-client',\n property: {\n queryName: 'oauth2Clients'\n }\n }\n ]\n }\n\n get taskPrefixes() {\n return ['graphql']\n }\n\n get description() {\n return 'Graphql Http Connector'\n }\n}\n\nConnectionManager.registerConnector('graphql-connector', new GraphqlConnector())\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpConnector = void 0;
|
|
4
|
-
const connection_manager_1 = require("../connection-manager");
|
|
5
|
-
const typeorm_1 = require("typeorm");
|
|
6
4
|
const oauth2_client_1 = require("@things-factory/oauth2-client");
|
|
5
|
+
const shell_1 = require("@things-factory/shell");
|
|
6
|
+
const connection_manager_1 = require("../connection-manager");
|
|
7
7
|
class HttpConnector {
|
|
8
8
|
async ready(connectionConfigs) {
|
|
9
9
|
await Promise.all(connectionConfigs.map(this.connect.bind(this)));
|
|
@@ -13,7 +13,7 @@ class HttpConnector {
|
|
|
13
13
|
var { params } = connection;
|
|
14
14
|
params.rejectUnauthorized = (params.rejectUnauthorized || 'Y') === 'Y';
|
|
15
15
|
if (params.authClient) {
|
|
16
|
-
const oauth2Client = await (0,
|
|
16
|
+
const oauth2Client = await (0, shell_1.getRepository)(oauth2_client_1.Oauth2Client).findOneBy({ id: params.authClient });
|
|
17
17
|
var authHeaders = oauth2Client.getAuthHeaders();
|
|
18
18
|
}
|
|
19
19
|
connection_manager_1.ConnectionManager.addConnectionInstance(connection, Object.assign(Object.assign({}, connection), { authHeaders: authHeaders || {}, params }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/http-connector.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"http-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/http-connector.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,iDAAqD;AAErD,8DAAyD;AAGzD,MAAa,aAAa;IACxB,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IA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,qBAAqB;gBAC5B,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;CACF;AAvDD,sCAuDC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,aAAa,EAAE,CAAC,CAAA","sourcesContent":["import { Oauth2Client } from '@things-factory/oauth2-client'\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\n\nexport class HttpConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('http-connector connections are ready')\n }\n\n async connect(connection) {\n var { params } = connection\n params.rejectUnauthorized = (params.rejectUnauthorized || 'Y') === 'Y'\n\n if (params.authClient) {\n const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).findOneBy({ id: params.authClient })\n var authHeaders = oauth2Client.getAuthHeaders()\n }\n\n ConnectionManager.addConnectionInstance(connection, {\n ...connection,\n authHeaders: authHeaders || {},\n params\n })\n\n ConnectionManager.logger.info(`http-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection) {\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`http-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'entity-selector',\n name: 'authClient',\n label: 'auth-client',\n property: {\n queryName: 'oauth2Clients'\n }\n },\n {\n type: 'select',\n name: 'rejectUnauthorized',\n label: 'reject-unauthorized',\n property: {\n options: ['Y', 'N']\n }\n }\n ]\n }\n\n get taskPrefixes() {\n return ['http']\n }\n}\n\nConnectionManager.registerConnector('http-connector', new HttpConnector())\n"]}
|
|
@@ -19,7 +19,7 @@ class OracleConnector {
|
|
|
19
19
|
if (!Client) {
|
|
20
20
|
throw new Error('oracledb module loading failed');
|
|
21
21
|
}
|
|
22
|
-
//when oracle not using
|
|
22
|
+
//when oracle not using default port must add connection string with port like localhsot:port
|
|
23
23
|
const client = await Client.getConnection({
|
|
24
24
|
user,
|
|
25
25
|
password,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/oracle-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAGzD,IAAI;IACF,IAAI,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACjC;AAAC,OAAO,GAAG,EAAE;IACZ,YAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;CAC/C;AAED,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,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,OAAO,CAAC,UAAU;QACtB,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACrC,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;QAED,6FAA6F;QAC7F,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;YACxC,IAAI;YACJ,QAAQ;YACR,aAAa,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,QAAQ,EAAE;SAChD,CAAC,CAAA;QAEF,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE;YAClD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC7B,OAAO,CACL,MAAM,MAAM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CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AAEzH,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\n\ntry {\n var Client = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed')\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async connect(connection) {\n const {\n endpoint,\n params: { user, password, database }\n } = connection\n\n if (!Client) {\n throw new Error('oracledb module loading failed')\n }\n\n //when oracle not using
|
|
1
|
+
{"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/oracle-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAGzD,IAAI;IACF,IAAI,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACjC;AAAC,OAAO,GAAG,EAAE;IACZ,YAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;CAC/C;AAED,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,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,OAAO,CAAC,UAAU;QACtB,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACrC,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;SAClD;QAED,6FAA6F;QAC7F,MAAM,MAAM,GAAG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gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,UAAU;aAClB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,wCAAwC,CAAA;IACjD,CAAC;CACF;AA9ED,0CA8EC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AAEzH,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\n\ntry {\n var Client = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed')\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async connect(connection) {\n const {\n endpoint,\n params: { user, password, database }\n } = connection\n\n if (!Client) {\n throw new Error('oracledb module loading failed')\n }\n\n //when oracle not using default port must add connection string with port like localhsot:port\n const client = await Client.getConnection({\n user,\n password,\n connectString: `${endpoint.trim()}/${database}`\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n return (\n await client.execute(query, params, {\n outFormat: Client.OBJECT\n })\n ).rows\n },\n close: client.close.bind(client)\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection) {\n var client = ConnectionManager.getConnectionInstance(connection)\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 }\n\n get taskPrefixes() {\n return ['database']\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\n// docker pull store/oracle/database-instantclient:12.2.0.1\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ScenarioEngine = void 0;
|
|
4
|
-
const typeorm_1 = require("typeorm");
|
|
5
4
|
const shell_1 = require("@things-factory/shell");
|
|
6
5
|
const service_1 = require("../service");
|
|
7
6
|
const pending_queue_1 = require("./pending-queue");
|
|
@@ -60,7 +59,7 @@ class ScenarioEngine {
|
|
|
60
59
|
instance.unload();
|
|
61
60
|
}
|
|
62
61
|
static async loadAll() {
|
|
63
|
-
const SCENARIOS = await (0,
|
|
62
|
+
const SCENARIOS = await (0, shell_1.getRepository)(service_1.Scenario).find({
|
|
64
63
|
where: { active: true },
|
|
65
64
|
relations: ['domain', 'steps']
|
|
66
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-engine.js","sourceRoot":"","sources":["../../server/engine/scenario-engine.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"scenario-engine.js","sourceRoot":"","sources":["../../server/engine/scenario-engine.ts"],"names":[],"mappings":";;;AAAA,iDAAiF;AAEjF,wCAAuD;AACvD,mDAA8C;AAE9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iDAAiD,CAAC,CAAA;AAEjF,MAAa,cAAc;IAIlB,MAAM,CAAC,eAAe,CAAC,MAAM;QAClC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,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G,QAAQ,CAAC,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC,CAC5E,CAAA;QAED,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC7E,CAAC;;AArFH,wCAsFC;AArFgB,gCAAiB,GAAG,EAAE,CAAA,CAAC,wBAAwB;AAC/C,4BAAa,GAAG,EAAE,CAAA","sourcesContent":["import { getRepository, GraphqlLocalClient, pubsub } from '@things-factory/shell'\n\nimport { Scenario, ScenarioInstance } from '../service'\nimport { PendingQueue } from './pending-queue'\n\nconst debug = require('debug')('things-factory:integration-base:scenario-engine')\n\nexport class ScenarioEngine {\n private static scenarioInstances = {} // TODO impl. by WeakMap\n private static pendingQueues = {}\n\n public static getPendingQueue(domain) {\n if (!ScenarioEngine.pendingQueues[domain.id]) {\n ScenarioEngine.pendingQueues[domain.id] = new PendingQueue(queue => {\n pubsub.publish('scenario-queue-state', {\n scenarioQueueState: {\n domain,\n queue\n }\n })\n })\n }\n\n return ScenarioEngine.pendingQueues[domain.id]\n }\n\n public static getScenarioInstance(domain, instanceName): ScenarioInstance {\n return ScenarioEngine.scenarioInstances[domain.id]?.[instanceName]\n }\n\n public static getScenarioInstances(domain, scenarioName?): ScenarioInstance[] {\n const instances: ScenarioInstance[] = Object.values(ScenarioEngine.scenarioInstances[domain.id] || {}) || []\n return instances.filter(instance => !scenarioName || instance.scenarioName == scenarioName)\n }\n\n public static async load(instanceName, scenarioConfig, context?) {\n const { domain } = scenarioConfig\n debug('load', domain.subdomain, instanceName)\n\n var scenarioInstances = ScenarioEngine.scenarioInstances[domain.id]\n if (!scenarioInstances) {\n scenarioInstances = ScenarioEngine.scenarioInstances[domain.id] = {}\n }\n\n var scenarioInstance = scenarioInstances[instanceName]\n if (scenarioInstance) {\n debug('load - duplicated', instanceName)\n return scenarioInstance\n }\n\n var instance = new ScenarioInstance(instanceName, scenarioConfig, {\n ...context,\n client: GraphqlLocalClient.client,\n disposer: () => {\n this.unload(domain, instanceName)\n }\n })\n instance.start()\n\n scenarioInstances[instanceName] = instance\n\n return instance\n }\n\n public static async unload(domain, instanceName) {\n var scenarioInstances = ScenarioEngine.scenarioInstances[domain.id]\n if (!scenarioInstances) {\n return\n }\n\n var instance = scenarioInstances[instanceName]\n if (!instance) {\n return\n }\n\n delete scenarioInstances[instanceName]\n\n instance.unload()\n }\n\n public static async loadAll() {\n const SCENARIOS = await getRepository(Scenario).find({\n where: { active: true },\n relations: ['domain', 'steps']\n })\n\n debug(\n 'load-all',\n SCENARIOS.map(scenario => `${scenario.domain.subdomain}: ${scenario.name}`)\n )\n\n SCENARIOS.forEach(scenario => ScenarioEngine.load(scenario.name, scenario))\n }\n}\n"]}
|
|
@@ -2,16 +2,17 @@
|
|
|
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
|
-
const typeorm_1 = require("typeorm");
|
|
6
5
|
const vm2_1 = require("vm2");
|
|
7
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const utils_1 = require("@things-factory/utils");
|
|
9
9
|
const task_registry_1 = require("../task-registry");
|
|
10
10
|
async function LocalGraphqlMutate(step, context) {
|
|
11
11
|
var { params, updaterId } = step;
|
|
12
12
|
var { mutation, variables: variablesAccessorMap } = params || {};
|
|
13
13
|
var { client, domain, data, variables } = context;
|
|
14
|
-
const user = await (0,
|
|
14
|
+
const user = await (0, shell_1.getRepository)(auth_base_1.User).findOne({
|
|
15
|
+
where: { id: updaterId },
|
|
15
16
|
relations: ['domains']
|
|
16
17
|
});
|
|
17
18
|
const vm = new vm2_1.VM({
|
|
@@ -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,6BAAwB;AAExB,yDAAgD;AAChD,iDAAqD;AACrD,iDAA8C;AAE9C,oDAA+C;AAE/C,KAAK,UAAU,kBAAkB,CAAC,IAAI,EAAE,OAAO;IAC7C,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;IAChC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAChE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAEjD,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;QAC7C,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;QACxB,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB,CAAC,CAAA;IAEF,MAAM,EAAE,GAAG,IAAI,QAAE,CAAC;QAChB,OAAO,EAAE;YACP,IAAI;YACJ,SAAS;SACV;KACF,CAAC,CAAA;IAEF,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,QAAQ,GAAG,GAAG,CAAC,CAAA;IAEvC,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,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QAC/C,QAAQ,EAAE,IAAA,qBAAG,EAAA;QACT,QAAQ;KACX;QACD,SAAS,EAAE,cAAc;QACzB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM;gBACN,IAAI;aACL;SACF;KACF,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,YAAY;KACnB,CAAA;AACH,CAAC;AAED,kBAAkB,CAAC,aAAa,GAAG;IACjC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE,CAAC,uBAAuB;SACpC;KACF;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 { VM } from 'vm2'\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'\n\nasync function LocalGraphqlMutate(step, context) {\n var { params, updaterId } = step\n var { mutation, variables: variablesAccessorMap } = params || {}\n var { client, domain, data, variables } = context\n\n const user = await getRepository(User).findOne({\n where: { id: updaterId },\n relations: ['domains']\n })\n\n const vm = new VM({\n sandbox: {\n data,\n variables\n }\n })\n\n mutation = vm.run('`' + mutation + '`')\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 ${mutation}\n `,\n variables: queryVariables,\n context: {\n state: {\n domain,\n user\n }\n }\n })\n\n return {\n data: mutateResult\n }\n}\n\nLocalGraphqlMutate.parameterSpec = [\n {\n type: 'graphql',\n name: 'mutation',\n label: 'mutation'\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables',\n property: {\n options: [] //'scenario-step-input'\n }\n }\n]\n\nLocalGraphqlMutate.connectorFree = true\nLocalGraphqlMutate.help = 'integration/task/local-graphql-mutate'\n\nTaskRegistry.registerTaskHandler('local-graphql-mutate', LocalGraphqlMutate)\n"]}
|
|
@@ -2,16 +2,17 @@
|
|
|
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
|
-
const typeorm_1 = require("typeorm");
|
|
6
5
|
const vm2_1 = require("vm2");
|
|
7
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const utils_1 = require("@things-factory/utils");
|
|
9
9
|
const task_registry_1 = require("../task-registry");
|
|
10
10
|
async function LocalGraphqlQuery(step, context) {
|
|
11
11
|
var { params, updaterId } = step;
|
|
12
12
|
var { query, variables: variablesAccessorMap } = params || {};
|
|
13
13
|
var { client, domain, data, variables } = context;
|
|
14
|
-
const user = await (0,
|
|
14
|
+
const user = await (0, shell_1.getRepository)(auth_base_1.User).findOne({
|
|
15
|
+
where: { id: updaterId },
|
|
15
16
|
relations: ['domains']
|
|
16
17
|
});
|
|
17
18
|
const vm = new vm2_1.VM({
|
|
@@ -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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AAA,qBAAG,EAAA;QACN,KAAK;KACR;QACD,SAAS,EAAE,cAAc;QACzB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM;gBACN,IAAI;aACL;SACF;KACF,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,WAAW;KAClB,CAAA;AACH,CAAC;AAED,iBAAiB,CAAC,aAAa,GAAG;IAChC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE,CAAC,uBAAuB;SACpC;KACF;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 { VM } from 'vm2'\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'\n\nasync function LocalGraphqlQuery(step, context) {\n var { params, updaterId } = step\n var { query, variables: variablesAccessorMap } = params || {}\n var { client, domain, data, variables } = context\n\n const user = await getRepository(User).findOne({\n where: { id: updaterId },\n relations: ['domains']\n })\n\n const vm = new VM({\n sandbox: {\n data,\n variables\n }\n })\n\n query = vm.run('`' + query + '`')\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 ${query}\n `,\n variables: queryVariables,\n context: {\n state: {\n domain,\n user\n }\n }\n })\n\n return {\n data: queryResult\n }\n}\n\nLocalGraphqlQuery.parameterSpec = [\n {\n type: 'graphql',\n name: 'query',\n label: 'query'\n },\n {\n type: 'key-values',\n name: 'variables',\n label: 'variables',\n property: {\n options: [] //'scenario-step-input'\n }\n }\n]\n\nLocalGraphqlQuery.connectorFree = true\nLocalGraphqlQuery.help = 'integration/task/local-graphql-query'\n\nTaskRegistry.registerTaskHandler('local-graphql-query', LocalGraphqlQuery)\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const service_1 = require("../../service");
|
|
5
|
-
const typeorm_1 = require("typeorm");
|
|
3
|
+
const shell_1 = require("@things-factory/shell");
|
|
6
4
|
const utils_1 = require("@things-factory/utils");
|
|
5
|
+
const service_1 = require("../../service");
|
|
7
6
|
const scenario_engine_1 = require("../scenario-engine");
|
|
7
|
+
const task_registry_1 = require("../task-registry");
|
|
8
8
|
const debug = require('debug')('things-factory:integration-base:pick-pending-scenario');
|
|
9
9
|
async function PickPendingScenario(step, context) {
|
|
10
10
|
var { logger, load, domain } = context;
|
|
@@ -29,7 +29,7 @@ async function PickPendingScenario(step, context) {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
var { scenario, variables } = stuff;
|
|
32
|
-
var subscenario = await (0,
|
|
32
|
+
var subscenario = await (0, shell_1.getRepository)(service_1.Scenario).findOne({
|
|
33
33
|
where: {
|
|
34
34
|
id: scenario
|
|
35
35
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick-pending-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/pick-pending-scenario.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"pick-pending-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/pick-pending-scenario.ts"],"names":[],"mappings":";;AAAA,iDAAqD;AACrD,iDAA6C;AAE7C,2CAAwC;AACxC,wDAAmD;AACnD,oDAA+C;AAE/C,MAAM,KAAK,GAAG,OAAO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,EAAE,QAAQ;SACb;QACD,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC/B,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,aAAa,WAAW,CAAC,IAAI,YAAY,CAAC,CAAA;IACtD,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,WAAW,kCACxC,OAAO,KACV,IAAI,EAAE,EAAE,EACR,SAAS,IACT,CAAA;IACF,MAAM,CAAC,IAAI,CAAC,aAAa,WAAW,CAAC,IAAI,SAAS,CAAC,CAAA;IAEnD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAA;AACH,CAAC;AAED,mBAAmB,CAAC,aAAa,GAAG;IAClC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;KACb;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,eAAe;KAC7B;CACF,CAAA;AAED,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAA;AACxC,mBAAmB,CAAC,IAAI,GAAG,wCAAwC,CAAA;AAEnE,4BAAY,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { sleep } from '@things-factory/utils'\n\nimport { Scenario } from '../../service'\nimport { ScenarioEngine } from '../scenario-engine'\nimport { TaskRegistry } from '../task-registry'\n\nconst debug = require('debug')('things-factory:integration-base:pick-pending-scenario')\n\nasync function PickPendingScenario(step, context) {\n var { logger, load, domain } = context\n var { params } = step\n var { tag = '', waitFor = -1 } = params || {}\n\n waitFor = Number(waitFor) || -1\n const till = Date.now() + waitFor\n\n const pendingQueue = ScenarioEngine.getPendingQueue(domain)\n\n // long-term task need to check state whether this scenario is still going.\n while (true && context.checkState()) {\n var { stuff } = pendingQueue.pick(tag) || {}\n if (stuff) {\n break\n }\n\n let toTill = waitFor == -1 ? 1000 : till - Date.now()\n if (toTill <= 0) {\n return {}\n }\n\n await sleep(Math.min(1000, toTill))\n }\n\n if (!stuff) {\n return\n }\n\n var { scenario, variables } = stuff\n\n var subscenario = await getRepository(Scenario).findOne({\n where: {\n id: scenario\n },\n relations: ['steps', 'domain']\n })\n\n logger.info(`Scenario '${subscenario.name}' Started.`)\n var subContext = await load(step, subscenario, {\n ...context,\n data: {},\n variables\n })\n logger.info(`Scenario '${subscenario.name}' done.`)\n\n return {\n data: subContext.data\n }\n}\n\nPickPendingScenario.parameterSpec = [\n {\n type: 'string',\n name: 'tag',\n label: 'tag'\n },\n {\n type: 'number',\n name: 'waitFor',\n label: 'wait-for',\n placeHolder: 'milli-seconds'\n }\n]\n\nPickPendingScenario.connectorFree = true\nPickPendingScenario.help = 'integration/task/pick-pending-scenario'\n\nTaskRegistry.registerTaskHandler('pick-pending-scenario', PickPendingScenario)\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shell_1 = require("@things-factory/shell");
|
|
3
4
|
const utils_1 = require("@things-factory/utils");
|
|
4
|
-
const task_registry_1 = require("../task-registry");
|
|
5
5
|
const service_1 = require("../../service");
|
|
6
|
-
const
|
|
6
|
+
const task_registry_1 = require("../task-registry");
|
|
7
7
|
async function SubScenario(step, context) {
|
|
8
8
|
var { logger, load, data } = context;
|
|
9
9
|
var { params: { scenario, variables } } = step;
|
|
10
|
-
var subscenario = await (0,
|
|
10
|
+
var subscenario = await (0, shell_1.getRepository)(service_1.Scenario).findOne({
|
|
11
11
|
where: {
|
|
12
12
|
id: scenario
|
|
13
13
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/sub-scenario.ts"],"names":[],"mappings":";;AAAA,iDAAyD;
|
|
1
|
+
{"version":3,"file":"sub-scenario.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K,EAAE,WAAW;KACnB;CACF,CAAA;AAED,WAAW,CAAC,aAAa,GAAG,IAAI,CAAA;AAEhC,4BAAY,CAAC,mBAAmB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { access, deepClone } from '@things-factory/utils'\n\nimport { Scenario } from '../../service'\nimport { TaskRegistry } from '../task-registry'\n\nasync function SubScenario(step, context) {\n var { logger, load, data } = context\n var {\n params: { scenario, variables }\n } = step\n\n var subscenario = await getRepository(Scenario).findOne({\n where: {\n id: scenario\n },\n relations: ['steps', 'domain']\n })\n\n logger.info(`Sub Scenario '${subscenario.name}' Started.`)\n var subContext = await load(step, subscenario, {\n ...context,\n data: {},\n /* \n FIXME variables 설정이 안된 경우에 subscenario의 variables는 undefined가 되는 것이 맞겠지만, \n 하위 호환성 유지를 위해서 부모의 variables를 사용함 \n */\n variables: variables ? deepClone(access(variables, data)) : context.variables\n })\n logger.info(`Sub Scenario '${subscenario.name}' done.`)\n\n return {\n data: subContext.data\n }\n}\n\nSubScenario.parameterSpec = [\n {\n type: 'entity-selector',\n name: 'scenario',\n label: 'scenario',\n property: {\n queryName: 'scenarios'\n }\n },\n {\n type: 'scenario-step-input',\n name: 'variables',\n label: 'variables'\n }\n]\n\nSubScenario.connectorFree = true\n\nTaskRegistry.registerTaskHandler('scenario', SubScenario)\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const shell_1 = require("@things-factory/shell");
|
|
4
4
|
const utils_1 = require("@things-factory/utils");
|
|
5
5
|
const service_1 = require("../../service");
|
|
6
6
|
const task_registry_1 = require("../task-registry");
|
|
@@ -17,7 +17,7 @@ async function SwitchRangeScenario(step, context) {
|
|
|
17
17
|
}) || 'default';
|
|
18
18
|
var scenarioName = cases[range];
|
|
19
19
|
logger.info(`switch-range to scenario '${scenarioName}' by value '${value}' .`);
|
|
20
|
-
var subscenario = await (0,
|
|
20
|
+
var subscenario = await (0, shell_1.getRepository)(service_1.Scenario).findOne({
|
|
21
21
|
where: {
|
|
22
22
|
name: scenarioName
|
|
23
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-range-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/switch-range-scenario.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"switch-range-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/switch-range-scenario.ts"],"names":[],"mappings":";;AAAA,iDAAqD;AACrD,iDAAyD;AAEzD,2CAAwC;AACxC,oDAA+C;AAE/C,KAAK,UAAU,mBAAmB,CAAC,IAAI,EAAE,OAAO;IAC9C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;IACpC,IAAI,EACF,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EACvC,GAAG,IAAI,CAAA;IAER,IAAI,KAAK,GAAG,MAAM,CAAC,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;IAE1C,IAAI,KAAK,GACP,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,GAAG,IAAI,SAAS,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAA;IACpD,CAAC,CAAC,IAAI,SAAS,CAAA;IAEjB,IAAI,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IAE/B,MAAM,CAAC,IAAI,CAAC,6BAA6B,YAAY,eAAe,KAAK,KAAK,CAAC,CAAA;IAE/E,IAAI,WAAW,GAAG,MAAM,IAAA,qBAAa,EAAC,kBAAQ,CAAC,CAAC,OAAO,CAAC;QACtD,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;SACnB;QACD,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC/B,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,iBAAiB,WAAW,CAAC,IAAI,YAAY,CAAC,CAAA;IAC1D,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,WAAW,kCACxC,OAAO,KACV,IAAI,EAAE,EAAE;QACR;;;UAGE;QACF,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAA,cAAM,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAC7E,CAAA;IACF,MAAM,CAAC,IAAI,CAAC,iBAAiB,WAAW,CAAC,IAAI,SAAS,CAAC,CAAA;IAEvD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAA;AACH,CAAC;AAED,mBAAmB,CAAC,aAAa,GAAG;IAClC;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE;YACR,SAAS,EAAE,gBAAgB;SAC5B;KACF;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;KACnB;CACF,CAAA;AAED,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAA;AAExC,4BAAY,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { access, deepClone } from '@things-factory/utils'\n\nimport { Scenario } from '../../service'\nimport { TaskRegistry } from '../task-registry'\n\nasync function SwitchRangeScenario(step, context) {\n var { logger, data, load } = context\n var {\n params: { accessor, cases, variables }\n } = step\n\n var value = Number(access(accessor, data))\n\n var range =\n Object.keys(cases).find(key => {\n if (key == 'default') {\n return\n }\n\n var [from, to] = key.split('~')\n\n return Number(from) <= value && Number(to) > value\n }) || 'default'\n\n var scenarioName = cases[range]\n\n logger.info(`switch-range to scenario '${scenarioName}' by value '${value}' .`)\n\n var subscenario = await getRepository(Scenario).findOne({\n where: {\n name: scenarioName\n },\n relations: ['steps', 'domain']\n })\n\n logger.info(`Sub Scenario '${subscenario.name}' started.`)\n var subContext = await load(step, subscenario, {\n ...context,\n data: {},\n /* \n FIXME variables 설정이 안된 경우에 subscenario의 variables는 undefined가 되는 것이 맞겠지만, \n 하위 호환성 유지를 위해서 부모의 variables를 사용함 \n */\n variables: variables ? deepClone(access(variables, data)) : context.variables\n })\n logger.info(`Sub Scenario '${subscenario.name}' done.`)\n\n return {\n data: subContext.data\n }\n}\n\nSwitchRangeScenario.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'range',\n name: 'cases',\n label: 'cases',\n property: {\n valuetype: 'scenario-input'\n }\n },\n {\n type: 'scenario-step-input',\n name: 'variables',\n label: 'variables'\n }\n]\n\nSwitchRangeScenario.connectorFree = true\n\nTaskRegistry.registerTaskHandler('switch-range-scenario', SwitchRangeScenario)\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const shell_1 = require("@things-factory/shell");
|
|
4
4
|
const utils_1 = require("@things-factory/utils");
|
|
5
5
|
const service_1 = require("../../service");
|
|
6
6
|
const task_registry_1 = require("../task-registry");
|
|
@@ -10,7 +10,7 @@ async function SwitchScenario(step, context) {
|
|
|
10
10
|
var value = (0, utils_1.access)(accessor, data);
|
|
11
11
|
var scenarioName = cases[value] || cases['default'];
|
|
12
12
|
logger.info(`switch to scenario '${scenarioName}' by value '${value}' .`);
|
|
13
|
-
var subscenario = await (0,
|
|
13
|
+
var subscenario = await (0, shell_1.getRepository)(service_1.Scenario).findOne({
|
|
14
14
|
where: {
|
|
15
15
|
name: scenarioName
|
|
16
16
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/switch-scenario.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"switch-scenario.js","sourceRoot":"","sources":["../../../server/engine/task/switch-scenario.ts"],"names":[],"mappings":";;AAAA,iDAAqD;AACrD,iDAAyD;AAEzD,2CAAwC;AACxC,oDAA+C;AAE/C,KAAK,UAAU,cAAc,CAAC,IAAI,EAAE,OAAO;IACzC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;IACpC,IAAI,EACF,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EACvC,GAAG,IAAI,CAAA;IAER,IAAI,KAAK,GAAG,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAElC,IAAI,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;IACnD,MAAM,CAAC,IAAI,CAAC,uBAAuB,YAAY,eAAe,KAAK,KAAK,CAAC,CAAA;IAEzE,IAAI,WAAW,GAAG,MAAM,IAAA,qBAAa,EAAC,kBAAQ,CAAC,CAAC,OAAO,CAAC;QACtD,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;SACnB;QACD,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;KAC/B,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,iBAAiB,WAAW,CAAC,IAAI,YAAY,CAAC,CAAA;IAC1D,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,WAAW,kCACxC,OAAO,KACV,IAAI,EAAE,EAAE;QACR;;;UAGE;QACF,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAA,cAAM,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAC7E,CAAA;IACF,MAAM,CAAC,IAAI,CAAC,iBAAiB,WAAW,CAAC,IAAI,SAAS,CAAC,CAAA;IAEvD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;KACtB,CAAA;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE;YACR,SAAS,EAAE,gBAAgB;SAC5B;KACF;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;KACnB;CACF,CAAA;AAED,cAAc,CAAC,aAAa,GAAG,IAAI,CAAA;AAEnC,4BAAY,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { access, deepClone } from '@things-factory/utils'\n\nimport { Scenario } from '../../service'\nimport { TaskRegistry } from '../task-registry'\n\nasync function SwitchScenario(step, context) {\n var { logger, data, load } = context\n var {\n params: { accessor, cases, variables }\n } = step\n\n var value = access(accessor, data)\n\n var scenarioName = cases[value] || cases['default']\n logger.info(`switch to scenario '${scenarioName}' by value '${value}' .`)\n\n var subscenario = await getRepository(Scenario).findOne({\n where: {\n name: scenarioName\n },\n relations: ['steps', 'domain']\n })\n\n logger.info(`Sub Scenario '${subscenario.name}' started.`)\n var subContext = await load(step, subscenario, {\n ...context,\n data: {},\n /* \n FIXME variables 설정이 안된 경우에 subscenario의 variables는 undefined가 되는 것이 맞겠지만, \n 하위 호환성 유지를 위해서 부모의 variables를 사용함 \n */\n variables: variables ? deepClone(access(variables, data)) : context.variables\n })\n logger.info(`Sub Scenario '${subscenario.name}' done.`)\n\n return {\n data: subContext.data\n }\n}\n\nSwitchScenario.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'map',\n name: 'cases',\n label: 'cases',\n property: {\n valuetype: 'scenario-input'\n }\n },\n {\n type: 'scenario-step-input',\n name: 'variables',\n label: 'variables'\n }\n]\n\nSwitchScenario.connectorFree = true\n\nTaskRegistry.registerTaskHandler('switch-scenario', SwitchScenario)\n"]}
|
|
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.scenarioViewRouter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const koa_router_1 = tslib_1.__importDefault(require("koa-router"));
|
|
6
|
-
const
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
7
7
|
const service_1 = require("../service");
|
|
8
8
|
exports.scenarioViewRouter = new koa_router_1.default();
|
|
9
9
|
exports.scenarioViewRouter.get('/scenario-view/:name', async (context, next) => {
|
|
10
10
|
const { domain } = context.state;
|
|
11
11
|
const { name } = context.params;
|
|
12
|
-
const scenario = await (0,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const scenario = await (0, shell_1.getRepository)(service_1.Scenario).findOne({
|
|
13
|
+
where: {
|
|
14
|
+
domain: { id: domain.id },
|
|
15
|
+
name
|
|
16
|
+
},
|
|
16
17
|
relations: ['steps']
|
|
17
18
|
});
|
|
18
19
|
const steps = scenario.steps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-view-router.js","sourceRoot":"","sources":["../../server/routers/scenario-view-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;
|
|
1
|
+
{"version":3,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QACpC,KAAK,EAAE;YACL,KAAK;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Scenario, Step } from '../service'\n\nexport const scenarioViewRouter = new Router()\n\nscenarioViewRouter.get('/scenario-view/:name', async (context, next) => {\n const { domain } = context.state\n const { name } = context.params\n\n const scenario = await getRepository(Scenario).findOne({\n where: {\n domain: { id: domain.id },\n name\n },\n relations: ['steps']\n })\n\n const steps: Step[] = scenario.steps\n const nodes = {}\n const edges = []\n\n steps.forEach(({ id, name }) => {\n nodes[id] = {\n id,\n name\n }\n })\n\n for (let i = 0; i < steps.length - 1; i++) {\n edges.push({\n source: steps[i].id,\n target: steps[i + 1].id\n })\n }\n\n await context.render('scenario-view', {\n model: {\n nodes,\n edges\n }\n })\n})\n"]}
|
|
@@ -4,6 +4,7 @@ exports.ConnectionMutation = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
7
8
|
const connection_manager_1 = require("../../engine/connection-manager");
|
|
8
9
|
const connection_type_1 = require("./connection-type");
|
|
9
10
|
let ConnectionMutation = class ConnectionMutation {
|
|
@@ -15,7 +16,7 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
15
16
|
const { domain, user, tx } = context.state;
|
|
16
17
|
const repository = tx.getRepository(connection_type_1.Connection);
|
|
17
18
|
const connection = await repository.findOne({
|
|
18
|
-
where: { domain, name }
|
|
19
|
+
where: { domain: { id: domain.id }, name }
|
|
19
20
|
});
|
|
20
21
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, connection), patch), { updater: user }));
|
|
21
22
|
}
|
|
@@ -35,7 +36,7 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
35
36
|
if (_updateRecords.length > 0) {
|
|
36
37
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
37
38
|
const newRecord = _updateRecords[i];
|
|
38
|
-
const connection = await connectionRepo.
|
|
39
|
+
const connection = await connectionRepo.findOneBy({ id: newRecord.id });
|
|
39
40
|
const result = await connectionRepo.save(Object.assign(Object.assign(Object.assign({}, connection), newRecord), { updater: user }));
|
|
40
41
|
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
41
42
|
}
|
|
@@ -50,16 +51,16 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
50
51
|
async deleteConnections(names, context) {
|
|
51
52
|
const { domain, tx } = context.state;
|
|
52
53
|
await tx.getRepository(connection_type_1.Connection).delete({
|
|
53
|
-
domain,
|
|
54
|
+
domain: { id: domain.id },
|
|
54
55
|
name: (0, typeorm_1.In)(names)
|
|
55
56
|
});
|
|
56
57
|
return true;
|
|
57
58
|
}
|
|
58
59
|
async connectConnection(name, context) {
|
|
59
60
|
const { domain } = context.state;
|
|
60
|
-
var repository = (0,
|
|
61
|
+
var repository = (0, shell_1.getRepository)(connection_type_1.Connection);
|
|
61
62
|
var connection = await repository.findOne({
|
|
62
|
-
where: { domain: domain, name },
|
|
63
|
+
where: { domain: { id: domain.id }, name },
|
|
63
64
|
relations: ['domain']
|
|
64
65
|
});
|
|
65
66
|
await connection.connect();
|
|
@@ -70,9 +71,9 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
70
71
|
}
|
|
71
72
|
async disconnectConnection(name, context) {
|
|
72
73
|
const { domain } = context.state;
|
|
73
|
-
var repository = (0,
|
|
74
|
+
var repository = (0, shell_1.getRepository)(connection_type_1.Connection);
|
|
74
75
|
var connection = await repository.findOne({
|
|
75
|
-
where: { domain, name },
|
|
76
|
+
where: { domain: { id: domain.id }, name },
|
|
76
77
|
relations: ['domain']
|
|
77
78
|
});
|
|
78
79
|
await connection.disconnect();
|