@things-factory/integration-base 9.0.0-beta.7 → 9.0.0-beta.70
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 +1 -1
- package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/engine/connection-manager.js +1 -8
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/index.d.ts +2 -2
- package/dist-server/engine/index.js +2 -2
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +29 -6
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +172 -64
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/index.d.ts +6 -6
- package/dist-server/index.js +10 -10
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +8 -7
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +3 -1
- package/dist-server/service/connection/connection-mutation.js +17 -5
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +3 -0
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +14 -3
- package/dist-server/service/connection/connection-type.js +26 -15
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +1 -1
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +1 -8
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/step/step-type.d.ts +11 -3
- package/dist-server/service/step/step-type.js +24 -5
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
@@ -63,7 +63,7 @@ async function analyzeIntegration(domain) {
|
|
63
63
|
scenarios.forEach(scenario => {
|
64
64
|
const tags = (0, uniq_1.default)(scenario.steps
|
65
65
|
.filter(step => !step.connection && step.task == 'publish')
|
66
|
-
.map(step => { var _a; return (_a =
|
66
|
+
.map(step => { var _a; return (_a = step.params) === null || _a === void 0 ? void 0 : _a.tag; })
|
67
67
|
.filter(Boolean));
|
68
68
|
for (const tag of tags) {
|
69
69
|
if (tagNames.includes(tag)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"analyze-integration.js","sourceRoot":"","sources":["../../../server/engine/analyzer/analyze-integration.ts"],"names":[],"mappings":";;AAMA,gDA4GC;;AAlHD,+DAA8B;AAE9B,iDAA6D;AAC7D,8DAA0D;AAC1D,8EAAqE;AAE9D,KAAK,UAAU,kBAAkB,CAAC,MAAc;IACrD,MAAM,QAAQ,GAAG,EAAE,CAAA;IAEnB,MAAM,KAAK,GAAG;QACZ,KAAK,EAAE,EAAE;QACT,aAAa,EAAE,EAAE;KAClB,CAAA;IAED,IAAI,EAAE,GAAG,CAAC,CAAA;IAEV,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,IAAI,CAAC;QACnD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE;QACpC,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,IAAI,CAAC;QACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE;KACrC,CAAC,CAAA;IAEF,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAC9B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QACvB,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,MAAM,EAAE,CAAC,UAAU,CAAC;YACpB,IAAI,EAAE,QAAQ,CAAC,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ACtB,OAAO,EAAE,OAAO,GAAG,EAAE;gBACrB,UAAU,EAAE,EAAE;aACf,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACjE,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import uniq from 'lodash/uniq'\n\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { Scenario } from '../../service/scenario/scenario'\nimport { Connection } from '../../service/connection/connection-type'\n\nexport async function analyzeIntegration(domain: Domain) {\n const tagNames = []\n\n const model = {\n nodes: [],\n relationships: []\n }\n\n var id = 0\n\n const scenarios = await getRepository(Scenario).find({\n where: { domain: { id: domain.id } },\n relations: ['steps']\n })\n\n const connections = await getRepository(Connection).find({\n where: { domain: { id: domain.id } }\n })\n\n model.nodes = model.nodes.concat(\n scenarios.map(scenario => {\n return {\n id: scenario.id,\n labels: ['Scenario'],\n text: scenario.name,\n icon: 'settings',\n properties: {\n name: scenario.name,\n description: scenario.description\n }\n }\n })\n )\n\n model.nodes = model.nodes.concat(\n connections.map(connection => {\n return {\n id: connection.id,\n labels: ['Connection'],\n text: connection.name,\n icon: 'link',\n properties: {\n name: connection.name,\n description: connection.description\n }\n }\n })\n )\n\n scenarios.forEach(scenario => {\n const connectionNames = uniq(scenario.steps.map(step => step.connection).filter(Boolean))\n const connectionList = connectionNames\n .map(connectionName => connections.find(connection => connection.name == connectionName))\n .filter(Boolean)\n\n const relationships = connectionList.map(connection => {\n return {\n id: ++id,\n type: 'using',\n startNode: scenario.id,\n endNode: connection.id,\n properties: {}\n }\n })\n\n model.relationships = model.relationships.concat(relationships)\n })\n\n scenarios.forEach(scenario => {\n const tags = uniq(\n scenario.steps\n .filter(step => !step.connection && step.task == 'publish')\n .map(step => step.params?.tag)\n .filter(Boolean)\n )\n\n for (const tag of tags) {\n if (tagNames.includes(tag)) {\n continue\n }\n\n model.nodes.push({\n id: `tag-${tag}`,\n labels: ['Tag'],\n text: tag,\n icon: 'label',\n properties: {\n tag\n }\n })\n\n tagNames.push(tag)\n }\n\n const relationships = tags.map(tag => {\n return {\n id: ++id,\n type: 'publish',\n startNode: scenario.id,\n endNode: `tag-${tag}`,\n properties: {}\n }\n })\n\n model.relationships = model.relationships.concat(relationships)\n })\n\n return model\n}\n"]}
|
@@ -34,14 +34,7 @@ class ConnectionManager {
|
|
34
34
|
where: { active: true },
|
35
35
|
relations: ['domain', 'edge', 'creator', 'updater']
|
36
36
|
})).map(connection => {
|
37
|
-
|
38
|
-
try {
|
39
|
-
params = JSON.parse(connection.params || '{}');
|
40
|
-
}
|
41
|
-
catch (ex) {
|
42
|
-
ConnectionManager.logger.error(`connection '${connection.name}' params should be JSON format`, ex);
|
43
|
-
}
|
44
|
-
return Object.assign(Object.assign({}, connection), { params });
|
37
|
+
return Object.assign(Object.assign({}, connection), { params: connection.params || {} });
|
45
38
|
});
|
46
39
|
ConnectionManager.logger.info('Initializing ConnectionManager...');
|
47
40
|
return await Promise.all([...Object.keys(ConnectionManager.connectors), 'proxy-connector'].map(type => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../server/engine/connection-manager.ts"],"names":[],"mappings":";;;;AAAA,8EAAoC;AACpC,qCAA0D;AAE1D,iDAAyF;AAEzF,wCAAyD;AAEzD,iEAA4D;AAE5D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AACjD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,CAAA;AAE7E,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAA;QACjE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,C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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'\nimport { ProxyConnector } from './connector/proxy-connector'\n\nconst { combine, splat, printf, errors } = format\nconst debug = require('debug')('things-factory:integration-base:connections')\n\nfunction getSystemTimeZone() {\n try {\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone\n if (!timeZone) {\n throw new Error('Unable to resolve timeZone')\n }\n return timeZone\n } catch (e) {\n console.warn('Failed to get system timeZone, falling back to UTC.', e)\n return 'UTC'\n }\n}\n\nconst SYSTEM_TZ = getSystemTimeZone()\nconst systemTimestamp = format((info, opts: { tz?: string }) => {\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: { [domainId: string]: { [name: string]: any } } = {}\n private static entities = {}\n private static logFormat = printf(({ level, message, timestamp, stack }) => {\n return `${timestamp} ${level}: ${stack || message}`\n })\n\n public static logger = createLogger({\n format: combine(errors({ stack: true }), 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', 'edge', '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`, 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), 'proxy-connector'].map(type => {\n const connector = type == 'proxy-connector' ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n\n ConnectionManager.logger.info(`Connector '${type}' started to ready`)\n\n return connector\n .ready(\n CONNECTIONS.filter(connection => {\n if (type == 'proxy-connector') {\n return !!connection.edge\n } else {\n return !connection.edge && connection.type == type\n }\n }) as any\n )\n .catch(error => {\n ConnectionManager.logger.error(error)\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 getConnections() {\n return ConnectionManager.connections\n }\n\n static getEntities() {\n return ConnectionManager.entities\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 const connections = ConnectionManager.connections[domain.id]\n const connection = connections?.[name]\n\n if (!connection) {\n throw `The connection with the given name(${name}) cannot be found`\n }\n\n return connection\n }\n\n static getConnectionInstanceEntityByName(domain: Domain, name: string): any {\n const connection = ConnectionManager.entities[domain.id]?.[name]\n if (connection) {\n return connection\n }\n\n if (domain.parentId) {\n return ConnectionManager.entities[domain.id]?.[name]\n }\n }\n\n static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {\n const connections = ConnectionManager.connections[domain.id]\n const parentConnections = domain.parentId && ConnectionManager.connections[domain.parentId]\n\n return {\n ...parentConnections,\n ...connections\n }\n }\n\n static getConnectionInstanceEntities(domain: Domain): { [connectionName: string]: any } {\n const connections = ConnectionManager.entities[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 var entities = ConnectionManager.entities[domain.id]\n if (!entities) {\n entities = ConnectionManager.entities[domain.id] = {}\n }\n\n connections[name] = instance\n entities[name] = connection\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 entities = ConnectionManager.entities[domain.id]\n\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 delete entities[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 private static async publishState(connection: Connection, state) {\n const { domain, id, name, description, type, edge } = connection\n\n pubsub.publish('connection-state', {\n connectionState: {\n domain,\n id,\n name,\n description,\n type,\n edge,\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,iDAAyF;AAEzF,wCAAyD;AAEzD,iEAA4D;AAE5D,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AACjD,MAAM,KAAK,GAAG,OAAO,CAAC,OA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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'\nimport { ProxyConnector } from './connector/proxy-connector'\n\nconst { combine, splat, printf, errors } = format\nconst debug = require('debug')('things-factory:integration-base:connections')\n\nfunction getSystemTimeZone() {\n try {\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone\n if (!timeZone) {\n throw new Error('Unable to resolve timeZone')\n }\n return timeZone\n } catch (e) {\n console.warn('Failed to get system timeZone, falling back to UTC.', e)\n return 'UTC'\n }\n}\n\nconst SYSTEM_TZ = getSystemTimeZone()\nconst systemTimestamp = format((info, opts: { tz?: string }) => {\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: { [domainId: string]: { [name: string]: any } } = {}\n private static entities = {}\n private static logFormat = printf(({ level, message, timestamp, stack }) => {\n return `${timestamp} ${level}: ${stack || message}`\n })\n\n public static logger = createLogger({\n format: combine(errors({ stack: true }), 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', 'edge', 'creator', 'updater']\n })\n ).map(connection => {\n return {\n ...connection,\n params: connection.params || {}\n }\n })\n\n ConnectionManager.logger.info('Initializing ConnectionManager...')\n\n return await Promise.all(\n [...Object.keys(ConnectionManager.connectors), 'proxy-connector'].map(type => {\n const connector = type == 'proxy-connector' ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n\n ConnectionManager.logger.info(`Connector '${type}' started to ready`)\n\n return connector\n .ready(\n CONNECTIONS.filter(connection => {\n if (type == 'proxy-connector') {\n return !!connection.edge\n } else {\n return !connection.edge && connection.type == type\n }\n }) as any\n )\n .catch(error => {\n ConnectionManager.logger.error(error)\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 getConnections() {\n return ConnectionManager.connections\n }\n\n static getEntities() {\n return ConnectionManager.entities\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 const connections = ConnectionManager.connections[domain.id]\n const connection = connections?.[name]\n\n if (!connection) {\n throw `The connection with the given name(${name}) cannot be found`\n }\n\n return connection\n }\n\n static getConnectionInstanceEntityByName(domain: Domain, name: string): any {\n const connection = ConnectionManager.entities[domain.id]?.[name]\n if (connection) {\n return connection\n }\n\n if (domain.parentId) {\n return ConnectionManager.entities[domain.id]?.[name]\n }\n }\n\n static getConnectionInstances(domain: Domain): { [connectionName: string]: any } {\n const connections = ConnectionManager.connections[domain.id]\n const parentConnections = domain.parentId && ConnectionManager.connections[domain.parentId]\n\n return {\n ...parentConnections,\n ...connections\n }\n }\n\n static getConnectionInstanceEntities(domain: Domain): { [connectionName: string]: any } {\n const connections = ConnectionManager.entities[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 var entities = ConnectionManager.entities[domain.id]\n if (!entities) {\n entities = ConnectionManager.entities[domain.id] = {}\n }\n\n connections[name] = instance\n entities[name] = connection\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 entities = ConnectionManager.entities[domain.id]\n\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 delete entities[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 private static async publishState(connection: Connection, state) {\n const { domain, id, name, description, type, edge } = connection\n\n pubsub.publish('connection-state', {\n connectionState: {\n domain,\n id,\n name,\n description,\n type,\n edge,\n state,\n timestamp: new Date()\n }\n })\n }\n}\n"]}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
-
require("./connector");
|
5
|
-
require("./task");
|
4
|
+
require("./connector/index.js");
|
5
|
+
require("./task/index.js");
|
6
6
|
tslib_1.__exportStar(require("./connection-manager"), exports);
|
7
7
|
tslib_1.__exportStar(require("./scenario-engine"), exports);
|
8
8
|
tslib_1.__exportStar(require("./task-registry"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAC7B,2BAAwB;AAExB,+DAAoC;AACpC,4DAAiC;AACjC,0DAA+B;AAC/B,yEAA8C;AAC9C,wDAA6B;AAC7B,0DAA+B","sourcesContent":["import './connector/index.js'\nimport './task/index.js'\n\nexport * from './connection-manager'\nexport * from './scenario-engine'\nexport * from './task-registry'\nexport * from './analyzer/analyze-integration'\nexport * from './edge-client'\nexport * from './resource-pool'\n\nexport { Connector, Context, TaskHandler } from './types'\n"]}
|
@@ -1,18 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const utils_1 = require("@things-factory/utils");
|
4
|
-
const
|
5
|
-
const
|
4
|
+
const task_registry_js_1 = require("../task-registry.js");
|
5
|
+
const connection_manager_js_1 = require("../connection-manager.js");
|
6
6
|
async function MqttPublish(step, { logger, data, domain }) {
|
7
|
-
var { connection: connectionName, params: { topic, accessor } } = step;
|
8
|
-
const { client } =
|
7
|
+
var { connection: connectionName, params: { topic, accessor, dataFormat = 'json' } } = step;
|
8
|
+
const { client } = connection_manager_js_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
9
9
|
if (!client) {
|
10
10
|
throw Error(`connection is not found : ${connectionName}`);
|
11
11
|
}
|
12
12
|
if (!topic || !accessor) {
|
13
13
|
throw Error(`topic and accessor should be defined: : topic - '${topic}', accessor - '${accessor}'`);
|
14
14
|
}
|
15
|
-
var message =
|
15
|
+
var message = (0, utils_1.access)(accessor, data);
|
16
|
+
if (dataFormat === 'text') {
|
17
|
+
message = String(message);
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
message = JSON.stringify(message);
|
21
|
+
}
|
16
22
|
await client.publish(topic, message);
|
17
23
|
return {
|
18
24
|
data: message
|
@@ -28,8 +34,25 @@ MqttPublish.parameterSpec = [
|
|
28
34
|
type: 'scenario-step-input',
|
29
35
|
name: 'accessor',
|
30
36
|
label: 'accessor'
|
37
|
+
},
|
38
|
+
{
|
39
|
+
type: 'select',
|
40
|
+
label: 'data-format',
|
41
|
+
name: 'dataFormat',
|
42
|
+
property: {
|
43
|
+
options: [
|
44
|
+
{
|
45
|
+
display: 'Plain Text',
|
46
|
+
value: 'text'
|
47
|
+
},
|
48
|
+
{
|
49
|
+
display: 'JSON',
|
50
|
+
value: 'json'
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
31
54
|
}
|
32
55
|
];
|
33
56
|
MqttPublish.help = 'integration/task/mqtt-publish';
|
34
|
-
|
57
|
+
task_registry_js_1.TaskRegistry.registerTaskHandler('mqtt-publish', MqttPublish);
|
35
58
|
//# sourceMappingURL=mqtt-publish.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mqtt-publish.js","sourceRoot":"","sources":["../../../server/engine/task/mqtt-publish.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,
|
1
|
+
{"version":3,"file":"mqtt-publish.js","sourceRoot":"","sources":["../../../server/engine/task/mqtt-publish.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,0DAAkD;AAClD,oEAA4D;AAI5D,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAW;IAC3E,IAAI,EACF,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,EAAE,EACjD,GAAG,IAAI,CAAA;IAER,MAAM,EAAE,MAAM,EAAE,GAAG,yCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,KAAK,CAAC,6BAA6B,cAAc,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,oDAAoD,KAAK,kBAAkB,QAAQ,GAAG,CAAC,CAAA;IACrG,CAAC;IAED,IAAI,OAAO,GAAG,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAEpC,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QAC1B,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAEpC,OAAO;QACL,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG;IAC1B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP;oBACE,OAAO,EAAE,YAAY;oBACrB,KAAK,EAAE,MAAM;iBACd;gBACD;oBACE,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,MAAM;iBACd;aACF;SACF;KACF;CACF,CAAA;AAED,WAAW,CAAC,IAAI,GAAG,+BAA+B,CAAA;AAElD,+BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { access } from '@things-factory/utils'\nimport { TaskRegistry } from '../task-registry.js'\nimport { ConnectionManager } from '../connection-manager.js'\nimport { InputStep } from '../../service/step/step-type.js'\nimport { Context } from '../types.js'\n\nasync function MqttPublish(step: InputStep, { logger, data, domain }: Context) {\n var {\n connection: connectionName,\n params: { topic, accessor, dataFormat = 'json' }\n } = step\n\n const { client } = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!client) {\n throw Error(`connection is not found : ${connectionName}`)\n }\n\n if (!topic || !accessor) {\n throw Error(`topic and accessor should be defined: : topic - '${topic}', accessor - '${accessor}'`)\n }\n\n var message = access(accessor, data)\n\n if (dataFormat === 'text') {\n message = String(message)\n } else {\n message = JSON.stringify(message)\n }\n\n await client.publish(topic, message)\n\n return {\n data: message\n }\n}\n\nMqttPublish.parameterSpec = [\n {\n type: 'string',\n name: 'topic',\n label: 'topic'\n },\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n },\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n {\n display: 'Plain Text',\n value: 'text'\n },\n {\n display: 'JSON',\n value: 'json'\n }\n ]\n }\n }\n]\n\nMqttPublish.help = 'integration/task/mqtt-publish'\n\nTaskRegistry.registerTaskHandler('mqtt-publish', MqttPublish)\n"]}
|
@@ -2,87 +2,195 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
const async_mqtt_1 = tslib_1.__importDefault(require("async-mqtt"));
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const utils_1 = require("@things-factory/utils");
|
5
|
+
const task_registry_js_1 = require("../task-registry.js");
|
6
|
+
const connection_manager_js_1 = require("../connection-manager.js");
|
8
7
|
function convertDataFormat(data, format) {
|
9
8
|
if (format == 'json') {
|
10
|
-
|
9
|
+
try {
|
10
|
+
return JSON.parse(data);
|
11
|
+
}
|
12
|
+
catch (e) {
|
13
|
+
console.error('JSON 파싱 오류:', e.message);
|
14
|
+
return data.toString();
|
15
|
+
}
|
11
16
|
}
|
12
17
|
else {
|
13
18
|
return data.toString();
|
14
19
|
}
|
15
20
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
// MQTT 연결을 위한 브로커 관리 클래스
|
22
|
+
class MqttBrokerManager {
|
23
|
+
// 브로커 연결 (또는 기존 연결 반환)
|
24
|
+
static async getBroker(uri, options) {
|
25
|
+
const brokerKey = `${uri}_${JSON.stringify(options || {})}`;
|
26
|
+
if (!this.brokers[brokerKey]) {
|
27
|
+
const client = await async_mqtt_1.default.connectAsync(uri, options);
|
28
|
+
this.brokers[brokerKey] = {
|
29
|
+
client,
|
30
|
+
topics: new Set(),
|
31
|
+
messageHandlers: new Map()
|
32
|
+
};
|
33
|
+
// 메시지 수신 핸들러
|
34
|
+
client.on('message', (topic, message) => {
|
35
|
+
// 해당 토픽에 등록된 핸들러가 있으면 호출
|
36
|
+
this.brokers[brokerKey].messageHandlers.forEach((handler, handlerId) => {
|
37
|
+
if (handlerId.startsWith(`${topic}:`)) {
|
38
|
+
handler(topic, message);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
});
|
42
|
+
}
|
43
|
+
return this.brokers[brokerKey];
|
44
|
+
}
|
45
|
+
// 토픽 구독 등록
|
46
|
+
static async subscribe(brokerKey, topic) {
|
47
|
+
const broker = this.brokers[brokerKey];
|
48
|
+
if (!broker) {
|
49
|
+
throw new Error(`브로커가 연결되지 않음: ${brokerKey}`);
|
50
|
+
}
|
51
|
+
// 새 토픽인 경우 구독
|
52
|
+
if (!broker.topics.has(topic)) {
|
53
|
+
await broker.client.subscribe(topic);
|
54
|
+
broker.topics.add(topic);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
// 메시지 핸들러 등록
|
58
|
+
static registerMessageHandler(brokerKey, topic, handlerId, handler) {
|
59
|
+
const broker = this.brokers[brokerKey];
|
60
|
+
if (!broker) {
|
61
|
+
throw new Error(`브로커가 연결되지 않음: ${brokerKey}`);
|
62
|
+
}
|
63
|
+
// 핸들러 ID는 topic:handlerId 형식으로 저장
|
64
|
+
const fullHandlerId = `${topic}:${handlerId}`;
|
65
|
+
broker.messageHandlers.set(fullHandlerId, handler);
|
66
|
+
return () => {
|
67
|
+
// 핸들러 제거 함수 반환
|
68
|
+
broker.messageHandlers.delete(fullHandlerId);
|
69
|
+
};
|
70
|
+
}
|
71
|
+
// 연결 종료
|
72
|
+
static async disconnect(brokerKey) {
|
73
|
+
const broker = this.brokers[brokerKey];
|
74
|
+
if (broker) {
|
75
|
+
await broker.client.end();
|
76
|
+
delete this.brokers[brokerKey];
|
77
|
+
}
|
21
78
|
}
|
22
|
-
|
79
|
+
// 브로커 키 생성 유틸리티
|
80
|
+
static getBrokerKey(uri, options) {
|
81
|
+
return `${uri}_${JSON.stringify(options || {})}`;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
MqttBrokerManager.brokers = {};
|
85
|
+
async function MqttSubscribe(step, context) {
|
86
|
+
const { connection: connectionName, params: { topic, dataFormat }, name: stepName } = step;
|
87
|
+
const { domain, logger, closures } = context;
|
88
|
+
// MQTT 브로커 접속 정보 가져오기
|
89
|
+
const connectionInstance = connection_manager_js_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
|
90
|
+
const { client } = connectionInstance;
|
23
91
|
if (!topic) {
|
24
|
-
throw Error(
|
92
|
+
throw Error(`토픽이 지정되지 않음: ${connectionName}`);
|
25
93
|
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
context.__mqtt_subscriber[name] = async () => {
|
48
|
-
while (!MESSAGE) {
|
49
|
-
await (0, utils_1.sleep)(100);
|
50
|
-
}
|
51
|
-
var topic = TOPIC;
|
52
|
-
var message = MESSAGE;
|
53
|
-
TOPIC = null;
|
54
|
-
MESSAGE = null;
|
55
|
-
return {
|
56
|
-
topic,
|
57
|
-
message
|
58
|
-
};
|
59
|
-
};
|
60
|
-
broker.on('message', async (messageTopic, message) => {
|
61
|
-
if (topic !== messageTopic) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
TOPIC = topic;
|
65
|
-
MESSAGE = convertDataFormat(message, dataFormat);
|
66
|
-
// logger.info(`mqtt-subscribe :\n'${message.toString()}'`)
|
67
|
-
});
|
94
|
+
// 구독자 ID 생성 (도메인, 연결명, 토픽, 스텝명 조합)
|
95
|
+
const subscriberId = `${domain}_${connectionName}_${topic}_${stepName}`;
|
96
|
+
try {
|
97
|
+
// 토픽 구독 등록
|
98
|
+
await MqttBrokerManager.subscribe(client, topic);
|
99
|
+
logger.info(`토픽 구독 완료: ${topic}`);
|
100
|
+
// 리졸버 저장소 초기화
|
101
|
+
if (!context.__mqtt_resolvers) {
|
102
|
+
context.__mqtt_resolvers = new Map();
|
103
|
+
}
|
104
|
+
// 클로저에 연결 종료 함수 등록
|
105
|
+
if (!context.__mqtt_connections) {
|
106
|
+
context.__mqtt_connections = new Set();
|
107
|
+
}
|
108
|
+
if (!context.__mqtt_handlers) {
|
109
|
+
context.__mqtt_handlers = new Map();
|
110
|
+
}
|
111
|
+
// 연결 추적 (중복 종료 방지)
|
112
|
+
if (!context.__mqtt_connections.has(connectionName)) {
|
113
|
+
context.__mqtt_connections.add(connectionName);
|
114
|
+
// 연결 종료 함수 등록
|
68
115
|
closures.push(async () => {
|
69
116
|
try {
|
70
|
-
|
71
|
-
|
117
|
+
// 핸들러 모두 제거
|
118
|
+
if (context.__mqtt_handlers) {
|
119
|
+
context.__mqtt_handlers.forEach(removeHandler => {
|
120
|
+
removeHandler();
|
121
|
+
});
|
122
|
+
context.__mqtt_handlers.clear();
|
123
|
+
}
|
124
|
+
// 대기 중인 모든 Promise 해결
|
125
|
+
if (context.__mqtt_resolvers) {
|
126
|
+
context.__mqtt_resolvers.forEach(resolver => {
|
127
|
+
resolver({ data: null, terminated: true });
|
128
|
+
});
|
129
|
+
context.__mqtt_resolvers.clear();
|
130
|
+
}
|
131
|
+
// 브로커 연결 종료는 하지 않음
|
132
|
+
logger.info(`MQTT 구독자 종료: ${connectionName}`);
|
72
133
|
}
|
73
134
|
catch (e) {
|
74
|
-
logger.error(e);
|
135
|
+
logger.error(`MQTT 구독자 종료 오류: ${e.message}`);
|
75
136
|
}
|
76
137
|
});
|
77
138
|
}
|
78
|
-
|
79
|
-
|
80
|
-
|
139
|
+
// Promise로 메시지 수신 대기
|
140
|
+
return new Promise(resolve => {
|
141
|
+
var _a;
|
142
|
+
// 이 태스크의 resolver 저장
|
143
|
+
if (context.__mqtt_resolvers) {
|
144
|
+
context.__mqtt_resolvers.set(subscriberId, resolve);
|
145
|
+
}
|
146
|
+
// 이미 등록된 핸들러가 있으면 제거
|
147
|
+
if ((_a = context.__mqtt_handlers) === null || _a === void 0 ? void 0 : _a.has(subscriberId)) {
|
148
|
+
const removeHandler = context.__mqtt_handlers.get(subscriberId);
|
149
|
+
if (removeHandler) {
|
150
|
+
removeHandler();
|
151
|
+
}
|
152
|
+
}
|
153
|
+
// 새로운 메시지 핸들러 등록
|
154
|
+
const removeHandler = MqttBrokerManager.registerMessageHandler(client, topic, subscriberId, (messageTopic, message) => {
|
155
|
+
var _a, _b;
|
156
|
+
try {
|
157
|
+
// 메시지 변환
|
158
|
+
const convertedMessage = convertDataFormat(message, dataFormat);
|
159
|
+
// resolver 가져오기 및 삭제
|
160
|
+
if ((_a = context.__mqtt_resolvers) === null || _a === void 0 ? void 0 : _a.has(subscriberId)) {
|
161
|
+
const resolver = context.__mqtt_resolvers.get(subscriberId);
|
162
|
+
context.__mqtt_resolvers.delete(subscriberId);
|
163
|
+
// 이 태스크에 대한 핸들러 제거 (한 번만 실행되도록)
|
164
|
+
if ((_b = context.__mqtt_handlers) === null || _b === void 0 ? void 0 : _b.has(subscriberId)) {
|
165
|
+
const removeHandler = context.__mqtt_handlers.get(subscriberId);
|
166
|
+
if (removeHandler) {
|
167
|
+
removeHandler();
|
168
|
+
}
|
169
|
+
context.__mqtt_handlers.delete(subscriberId);
|
170
|
+
}
|
171
|
+
// Promise 해결
|
172
|
+
if (resolver) {
|
173
|
+
resolver({
|
174
|
+
data: convertedMessage
|
175
|
+
});
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
catch (error) {
|
180
|
+
logger.error(`메시지 처리 오류: ${error.message}`);
|
181
|
+
}
|
182
|
+
});
|
183
|
+
// 핸들러 제거 함수 저장
|
184
|
+
if (context.__mqtt_handlers) {
|
185
|
+
context.__mqtt_handlers.set(subscriberId, removeHandler);
|
186
|
+
}
|
187
|
+
logger.info(`MQTT 메시지 대기 중: ${topic}`);
|
188
|
+
});
|
189
|
+
}
|
190
|
+
catch (e) {
|
191
|
+
logger.error(`MQTT 구독 오류: ${e.message}`);
|
192
|
+
throw e;
|
81
193
|
}
|
82
|
-
var { message } = await context.__mqtt_subscriber[name]();
|
83
|
-
return {
|
84
|
-
data: message
|
85
|
-
};
|
86
194
|
}
|
87
195
|
MqttSubscribe.parameterSpec = [
|
88
196
|
{
|
@@ -109,5 +217,5 @@ MqttSubscribe.parameterSpec = [
|
|
109
217
|
}
|
110
218
|
];
|
111
219
|
MqttSubscribe.help = 'integration/task/mqtt-subscribe';
|
112
|
-
|
220
|
+
task_registry_js_1.TaskRegistry.registerTaskHandler('mqtt-subscribe', MqttSubscribe);
|
113
221
|
//# sourceMappingURL=mqtt-subscribe.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mqtt-subscribe.js","sourceRoot":"","sources":["../../../server/engine/task/mqtt-subscribe.ts"],"names":[],"mappings":";;;AAAA,oEAA6B;AAE7B,oDAA+C;AAC/C,8DAAyD;AACzD,iDAA6C;AAI7C,SAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,IAAe,EAAE,OAAgB;IAC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;QACL,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC;AAED,aAAa,CAAC,aAAa,GAAG;IAC5B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE;YACR,OAAO,EAAE;gBACP;oBACE,OAAO,EAAE,YAAY;oBACrB,KAAK,EAAE,MAAM;iBACd;gBACD;oBACE,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,MAAM;iBACd;aACF;SACF;KACF;CACF,CAAA;AAED,aAAa,CAAC,IAAI,GAAG,iCAAiC,CAAA;AAEtD,4BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import mqtt from 'async-mqtt'\n\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\nimport { sleep } from '@things-factory/utils'\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nfunction convertDataFormat(data, format) {\n if (format == 'json') {\n return JSON.parse(data)\n } else {\n return data.toString()\n }\n}\n\nasync function MqttSubscribe(step: InputStep, context: Context) {\n const {\n connection: connectionName,\n params: { topic, dataFormat },\n name\n } = step\n\n const { domain, logger, closures, __mqtt_subscriber } = context\n if (!__mqtt_subscriber) {\n context.__mqtt_subscriber = {}\n }\n\n const {\n connection: {\n endpoint: uri,\n params: { user, password }\n }\n } = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!topic) {\n throw Error(`topic is not found for ${connectionName}`)\n }\n\n /*\n * 1. subscriber list에서 subscriber를 찾는다. 없으면, 생성한다.\n * 2. client.once(...)로 메시지를 취한다.\n *\n * TODO 동일 브로커의 다중 subscribe 태스크에 대해서 완벽한 지원을 해야한다.\n * - 현재는 여러 태스크가 동일 topic을 subscribe 하는 경우에 정상동작하지 않을 것이다.\n */\n if (!context.__mqtt_subscriber[name]) {\n try {\n var broker = null\n if (user && password) {\n broker = await mqtt.connectAsync(uri, { username: user, password: password })\n } else {\n broker = await mqtt.connectAsync(uri)\n }\n\n logger.info(`mqtt-connector connection(${connectionName}:${uri}) is connected`)\n\n await broker.subscribe(topic)\n logger.info(`success subscribing topic '${topic}'`)\n\n var TOPIC\n var MESSAGE\n\n context.__mqtt_subscriber[name] = async () => {\n while (!MESSAGE) {\n await sleep(100)\n }\n\n var topic = TOPIC\n var message = MESSAGE\n\n TOPIC = null\n MESSAGE = null\n\n return {\n topic,\n message\n }\n }\n\n broker.on('message', async (messageTopic, message) => {\n if (topic !== messageTopic) {\n return\n }\n\n TOPIC = topic\n MESSAGE = convertDataFormat(message, dataFormat)\n\n // logger.info(`mqtt-subscribe :\\n'${message.toString()}'`)\n })\n\n closures.push(async () => {\n try {\n broker && (await broker.end())\n logger.info(`mqtt-connector connection(${connectionName}:${uri}) is disconnected`)\n } catch (e) {\n logger.error(e)\n }\n })\n } catch (e) {\n logger.error(e)\n }\n }\n\n var { message } = await context.__mqtt_subscriber[name]()\n\n return {\n data: message\n }\n}\n\nMqttSubscribe.parameterSpec = [\n {\n type: 'string',\n name: 'topic',\n label: 'topic'\n },\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n {\n display: 'Plain Text',\n value: 'text'\n },\n {\n display: 'JSON',\n value: 'json'\n }\n ]\n }\n }\n]\n\nMqttSubscribe.help = 'integration/task/mqtt-subscribe'\n\nTaskRegistry.registerTaskHandler('mqtt-subscribe', MqttSubscribe)\n"]}
|
1
|
+
{"version":3,"file":"mqtt-subscribe.js","sourceRoot":"","sources":["../../../server/engine/task/mqtt-subscribe.ts"],"names":[],"mappings":";;;AAAA,oEAA6B;AAE7B,0DAAkD;AAClD,oEAA4D;AAI5D,SAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACrB,IAAI,CAAC;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AAa,CAAC,CAAA","sourcesContent":["import mqtt from 'async-mqtt'\n\nimport { TaskRegistry } from '../task-registry.js'\nimport { ConnectionManager } from '../connection-manager.js'\nimport { InputStep } from '../../service/step/step-type.js'\nimport { Context } from '../types.js'\n\nfunction convertDataFormat(data, format) {\n if (format == 'json') {\n try {\n return JSON.parse(data)\n } catch (e) {\n console.error('JSON 파싱 오류:', e.message)\n return data.toString()\n }\n } else {\n return data.toString()\n }\n}\n\n// MQTT 연결을 위한 브로커 관리 클래스\nclass MqttBrokerManager {\n private static brokers: Record<\n string,\n {\n client: mqtt.AsyncMqttClient\n topics: Set<string>\n messageHandlers: Map<string, (topic: string, message: Buffer) => void>\n }\n > = {}\n\n // 브로커 연결 (또는 기존 연결 반환)\n static async getBroker(uri: string, options?: mqtt.IClientOptions) {\n const brokerKey = `${uri}_${JSON.stringify(options || {})}`\n\n if (!this.brokers[brokerKey]) {\n const client = await mqtt.connectAsync(uri, options)\n\n this.brokers[brokerKey] = {\n client,\n topics: new Set<string>(),\n messageHandlers: new Map()\n }\n\n // 메시지 수신 핸들러\n client.on('message', (topic, message) => {\n // 해당 토픽에 등록된 핸들러가 있으면 호출\n this.brokers[brokerKey].messageHandlers.forEach((handler, handlerId) => {\n if (handlerId.startsWith(`${topic}:`)) {\n handler(topic, message)\n }\n })\n })\n }\n\n return this.brokers[brokerKey]\n }\n\n // 토픽 구독 등록\n static async subscribe(brokerKey: string, topic: string) {\n const broker = this.brokers[brokerKey]\n if (!broker) {\n throw new Error(`브로커가 연결되지 않음: ${brokerKey}`)\n }\n\n // 새 토픽인 경우 구독\n if (!broker.topics.has(topic)) {\n await broker.client.subscribe(topic)\n broker.topics.add(topic)\n }\n }\n\n // 메시지 핸들러 등록\n static registerMessageHandler(\n brokerKey: string,\n topic: string,\n handlerId: string,\n handler: (topic: string, message: Buffer) => void\n ) {\n const broker = this.brokers[brokerKey]\n if (!broker) {\n throw new Error(`브로커가 연결되지 않음: ${brokerKey}`)\n }\n\n // 핸들러 ID는 topic:handlerId 형식으로 저장\n const fullHandlerId = `${topic}:${handlerId}`\n broker.messageHandlers.set(fullHandlerId, handler)\n\n return () => {\n // 핸들러 제거 함수 반환\n broker.messageHandlers.delete(fullHandlerId)\n }\n }\n\n // 연결 종료\n static async disconnect(brokerKey: string) {\n const broker = this.brokers[brokerKey]\n if (broker) {\n await broker.client.end()\n delete this.brokers[brokerKey]\n }\n }\n\n // 브로커 키 생성 유틸리티\n static getBrokerKey(uri: string, options?: any) {\n return `${uri}_${JSON.stringify(options || {})}`\n }\n}\n\ninterface MqttContext extends Context {\n __mqtt_connections?: Set<string>\n __mqtt_handlers?: Map<string, () => void>\n __mqtt_resolvers?: Map<string, (result: any) => void>\n}\n\nasync function MqttSubscribe(step: InputStep, context: MqttContext) {\n const {\n connection: connectionName,\n params: { topic, dataFormat },\n name: stepName\n } = step\n\n const { domain, logger, closures } = context\n\n // MQTT 브로커 접속 정보 가져오기\n const connectionInstance = ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n const { client } = connectionInstance\n\n if (!topic) {\n throw Error(`토픽이 지정되지 않음: ${connectionName}`)\n }\n\n // 구독자 ID 생성 (도메인, 연결명, 토픽, 스텝명 조합)\n const subscriberId = `${domain}_${connectionName}_${topic}_${stepName}`\n\n try {\n // 토픽 구독 등록\n await MqttBrokerManager.subscribe(client, topic)\n logger.info(`토픽 구독 완료: ${topic}`)\n\n // 리졸버 저장소 초기화\n if (!context.__mqtt_resolvers) {\n context.__mqtt_resolvers = new Map()\n }\n\n // 클로저에 연결 종료 함수 등록\n if (!context.__mqtt_connections) {\n context.__mqtt_connections = new Set()\n }\n\n if (!context.__mqtt_handlers) {\n context.__mqtt_handlers = new Map()\n }\n\n // 연결 추적 (중복 종료 방지)\n if (!context.__mqtt_connections.has(connectionName)) {\n context.__mqtt_connections.add(connectionName)\n\n // 연결 종료 함수 등록\n closures.push(async () => {\n try {\n // 핸들러 모두 제거\n if (context.__mqtt_handlers) {\n context.__mqtt_handlers.forEach(removeHandler => {\n removeHandler()\n })\n context.__mqtt_handlers.clear()\n }\n\n // 대기 중인 모든 Promise 해결\n if (context.__mqtt_resolvers) {\n context.__mqtt_resolvers.forEach(resolver => {\n resolver({ data: null, terminated: true })\n })\n context.__mqtt_resolvers.clear()\n }\n\n // 브로커 연결 종료는 하지 않음\n logger.info(`MQTT 구독자 종료: ${connectionName}`)\n } catch (e) {\n logger.error(`MQTT 구독자 종료 오류: ${e.message}`)\n }\n })\n }\n\n // Promise로 메시지 수신 대기\n return new Promise(resolve => {\n // 이 태스크의 resolver 저장\n if (context.__mqtt_resolvers) {\n context.__mqtt_resolvers.set(subscriberId, resolve)\n }\n\n // 이미 등록된 핸들러가 있으면 제거\n if (context.__mqtt_handlers?.has(subscriberId)) {\n const removeHandler = context.__mqtt_handlers.get(subscriberId)\n if (removeHandler) {\n removeHandler()\n }\n }\n\n // 새로운 메시지 핸들러 등록\n const removeHandler = MqttBrokerManager.registerMessageHandler(\n client,\n topic,\n subscriberId,\n (messageTopic, message) => {\n try {\n // 메시지 변환\n const convertedMessage = convertDataFormat(message, dataFormat)\n\n // resolver 가져오기 및 삭제\n if (context.__mqtt_resolvers?.has(subscriberId)) {\n const resolver = context.__mqtt_resolvers.get(subscriberId)\n context.__mqtt_resolvers.delete(subscriberId)\n\n // 이 태스크에 대한 핸들러 제거 (한 번만 실행되도록)\n if (context.__mqtt_handlers?.has(subscriberId)) {\n const removeHandler = context.__mqtt_handlers.get(subscriberId)\n if (removeHandler) {\n removeHandler()\n }\n context.__mqtt_handlers.delete(subscriberId)\n }\n\n // Promise 해결\n if (resolver) {\n resolver({\n data: convertedMessage\n })\n }\n }\n } catch (error) {\n logger.error(`메시지 처리 오류: ${error.message}`)\n }\n }\n )\n\n // 핸들러 제거 함수 저장\n if (context.__mqtt_handlers) {\n context.__mqtt_handlers.set(subscriberId, removeHandler)\n }\n\n logger.info(`MQTT 메시지 대기 중: ${topic}`)\n })\n } catch (e) {\n logger.error(`MQTT 구독 오류: ${e.message}`)\n throw e\n }\n}\n\nMqttSubscribe.parameterSpec = [\n {\n type: 'string',\n name: 'topic',\n label: 'topic'\n },\n {\n type: 'select',\n label: 'data-format',\n name: 'dataFormat',\n property: {\n options: [\n {\n display: 'Plain Text',\n value: 'text'\n },\n {\n display: 'JSON',\n value: 'json'\n }\n ]\n }\n }\n]\n\nMqttSubscribe.help = 'integration/task/mqtt-subscribe'\n\nTaskRegistry.registerTaskHandler('mqtt-subscribe', MqttSubscribe)\n"]}
|
package/dist-server/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from './migrations';
|
2
|
-
export * from './engine';
|
3
|
-
export * from './controllers';
|
4
|
-
export * from './service';
|
5
|
-
import './routes';
|
6
|
-
import './restful';
|
1
|
+
export * from './migrations/index.js';
|
2
|
+
export * from './engine/index.js';
|
3
|
+
export * from './controllers/index.js';
|
4
|
+
export * from './service/index.js';
|
5
|
+
import './routes.js';
|
6
|
+
import './restful/index.js';
|
package/dist-server/index.js
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
-
tslib_1.__exportStar(require("./migrations"), exports);
|
5
|
-
tslib_1.__exportStar(require("./engine"), exports);
|
6
|
-
tslib_1.__exportStar(require("./controllers"), exports);
|
7
|
-
tslib_1.__exportStar(require("./service"), exports);
|
8
|
-
require("./routes");
|
9
|
-
require("./restful"); /* APIs */
|
10
|
-
const
|
4
|
+
tslib_1.__exportStar(require("./migrations/index.js"), exports);
|
5
|
+
tslib_1.__exportStar(require("./engine/index.js"), exports);
|
6
|
+
tslib_1.__exportStar(require("./controllers/index.js"), exports);
|
7
|
+
tslib_1.__exportStar(require("./service/index.js"), exports);
|
8
|
+
require("./routes.js");
|
9
|
+
require("./restful/index.js"); /* APIs */
|
10
|
+
const index_js_1 = require("./engine/index.js");
|
11
11
|
process.on('bootstrap-module-start', async ({ app, config, client }) => {
|
12
12
|
try {
|
13
|
-
await
|
14
|
-
await
|
13
|
+
await index_js_1.ConnectionManager.ready();
|
14
|
+
await index_js_1.ScenarioEngine.loadAll();
|
15
15
|
console.log('Scenario Engine has just started.');
|
16
16
|
}
|
17
17
|
catch (ex) {
|
18
|
-
|
18
|
+
index_js_1.ConnectionManager.logger.error('Just has failed to start Scenario Engine.', ex);
|
19
19
|
}
|
20
20
|
});
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AACrC,4DAAiC;AACjC,iEAAsC;AACtC,6DAAkC;AAElC,uBAAoB;AACpB,8BAA2B,CAAC,UAAU;AAEtC,gDAAqE;AAErE,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,4BAAiB,CAAC,KAAK,EAAE,CAAA;QAC/B,MAAM,yBAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,4BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,EAAE,CAAC,CAAA;IACjF,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './migrations/index.js'\nexport * from './engine/index.js'\nexport * from './controllers/index.js'\nexport * from './service/index.js'\n\nimport './routes.js'\nimport './restful/index.js' /* APIs */\n\nimport { ConnectionManager, ScenarioEngine } from './engine/index.js'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await ConnectionManager.ready()\n await ScenarioEngine.loadAll()\n\n console.log('Scenario Engine has just started.')\n } catch (ex) {\n ConnectionManager.logger.error('Just has failed to start Scenario Engine.', ex)\n }\n})\n"]}
|