@things-factory/integration-base 9.2.29 → 9.2.31

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.
@@ -15,25 +15,6 @@ class EchoBack {
15
15
  let [host, port = 8124] = connection.endpoint.split(':');
16
16
  try {
17
17
  await socket.connect(Number(port), host);
18
- // 수신 메시지 큐 + idle-flush 버퍼링.
19
- // TCP는 바이트 스트림이라 메시지가 여러 청크로 쪼개지거나 합쳐져 도착할 수 있으므로,
20
- // 마지막 수신 후 IDLE_MS 동안 추가 데이터가 없으면 그때까지 모인 바이트를 응답 1건으로 간주한다.
21
- // 종료문자/길이를 몰라도 동작하며(끝 문자가 매번 달라도 무관), Buffer로 누적하므로 끝의 바이너리(체크섬 등)도 보존된다.
22
- const IDLE_MS = 80;
23
- socket.__messages__ = [];
24
- let chunks = [];
25
- let timer = null;
26
- socket.socket.on('data', (data) => {
27
- chunks.push(data);
28
- if (timer)
29
- clearTimeout(timer);
30
- timer = setTimeout(() => {
31
- ;
32
- socket.__messages__.push(Buffer.concat(chunks));
33
- chunks = [];
34
- timer = null;
35
- }, IDLE_MS);
36
- });
37
18
  connection_manager_1.ConnectionManager.addConnectionInstance(connection, socket);
38
19
  connection_manager_1.ConnectionManager.logger.info(`echo-back-connector connection(${connection.name}:${connection.endpoint}) is connected`);
39
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"echo-back-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/echo-back-connector.ts"],"names":[],"mappings":";;;;AAAA,sDAAqB;AACrB,4EAA0C;AAG1C,8DAAyD;AAGzD,MAAa,QAAQ;IACnB,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,CAAC,IAAI,CAAC,iCAAiC,CA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O,CAAC,EAAE,CAAC;YACX,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAC5B,kCAAkC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,qBAAqB,EAC7F,CAAC,CACF,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAA2B;QAC1C,IAAI,MAAM,GAAG,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEnE,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QAEtB,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACrG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;CACF;AA7DD,4BA6DC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,WAAW,EAAE,IAAI,QAAQ,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport PromiseSocket from 'promise-socket'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class EchoBack implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('echo-back connections are ready')\n }\n\n async connect(connection: InputConnection) {\n let socket = new PromiseSocket(new net.Socket())\n let [host, port = 8124] = connection.endpoint.split(':')\n\n try {\n await socket.connect(Number(port), host)\n\n // 수신 메시지 큐 + idle-flush 버퍼링.\n // TCP는 바이트 스트림이라 메시지가 여러 청크로 쪼개지거나 합쳐져 도착할 수 있으므로,\n // 마지막 수신 후 IDLE_MS 동안 추가 데이터가 없으면 그때까지 모인 바이트를 응답 1건으로 간주한다.\n // 종료문자/길이를 몰라도 동작하며(끝 문자가 매번 달라도 무관), Buffer로 누적하므로 끝의 바이너리(체크섬 등)도 보존된다.\n const IDLE_MS = 80\n ;(socket as any).__messages__ = []\n let chunks: Buffer[] = []\n let timer: NodeJS.Timeout | null = null\n\n ;(socket as any).socket.on('data', (data: Buffer) => {\n chunks.push(data)\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => {\n ;(socket as any).__messages__.push(Buffer.concat(chunks))\n chunks = []\n timer = null\n }, IDLE_MS)\n })\n\n ConnectionManager.addConnectionInstance(connection, socket)\n\n ConnectionManager.logger.info(\n `echo-back-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n } catch (e) {\n ConnectionManager.logger.error(\n `echo-back-connector connection(${connection.name}:${connection.endpoint}) is not connected.`,\n e\n )\n }\n }\n\n async disconnect(connection: InputConnection) {\n let socket = ConnectionManager.removeConnectionInstance(connection)\n\n await socket.destroy()\n\n ConnectionManager.logger.info(`echo-back-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['echo']\n }\n}\n\nConnectionManager.registerConnector('echo-back', new EchoBack())\n"]}
1
+ {"version":3,"file":"echo-back-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/echo-back-connector.ts"],"names":[],"mappings":";;;;AAAA,sDAAqB;AACrB,4EAA0C;AAG1C,8DAAyD;AAGzD,MAAa,QAAQ;IACnB,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,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;IAClE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,IAAI,MAAM,GAAG,IAAI,wBAAa,CAAC,IAAI,aAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QAChD,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAExD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;YACxC,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAE3D,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAC3B,kCAAkC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CACzF,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAC5B,kCAAkC,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,qBAAqB,EAC7F,CAAC,CACF,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAA2B;QAC1C,IAAI,MAAM,GAAG,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEnE,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QAEtB,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACrG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;CACF;AAzCD,4BAyCC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,WAAW,EAAE,IAAI,QAAQ,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport PromiseSocket from 'promise-socket'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class EchoBack implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('echo-back connections are ready')\n }\n\n async connect(connection: InputConnection) {\n let socket = new PromiseSocket(new net.Socket())\n let [host, port = 8124] = connection.endpoint.split(':')\n\n try {\n await socket.connect(Number(port), host)\n ConnectionManager.addConnectionInstance(connection, socket)\n\n ConnectionManager.logger.info(\n `echo-back-connector connection(${connection.name}:${connection.endpoint}) is connected`\n )\n } catch (e) {\n ConnectionManager.logger.error(\n `echo-back-connector connection(${connection.name}:${connection.endpoint}) is not connected.`,\n e\n )\n }\n }\n\n async disconnect(connection: InputConnection) {\n let socket = ConnectionManager.removeConnectionInstance(connection)\n\n await socket.destroy()\n\n ConnectionManager.logger.info(`echo-back-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['echo']\n }\n}\n\nConnectionManager.registerConnector('echo-back', new EchoBack())\n"]}
@@ -12,11 +12,17 @@ class EchoBack {
12
12
  }
13
13
  async connect(config) {
14
14
  var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':');
15
+ var clientIPs = new Set();
15
16
  return new Promise((resolve, reject) => {
16
17
  var server = net_1.default.createServer(socket => {
18
+ const remoteIP = `${socket.remoteAddress}:${socket.remotePort}`;
19
+ clientIPs.add(remoteIP);
17
20
  socket.on('data', function (data) {
18
21
  socket.write(data.toString());
19
22
  });
23
+ socket.on('close', function () {
24
+ clientIPs.delete(remoteIP);
25
+ });
20
26
  socket.on('error', function (err) {
21
27
  connection_manager_1.ConnectionManager.logger.error(err);
22
28
  reject(err);
@@ -31,6 +37,7 @@ class EchoBack {
31
37
  let promiseSocket = new promise_socket_1.default(socket);
32
38
  await promiseSocket.connect(Number(port), 'localhost');
33
39
  promiseSocket['__server__'] = server;
40
+ promiseSocket['__clients__'] = clientIPs;
34
41
  connection_manager_1.ConnectionManager.addConnectionInstance(config, promiseSocket);
35
42
  connection_manager_1.ConnectionManager.logger.info(`echo-back-server connection(${config.name}:${config.endpoint}) is connected`);
36
43
  resolve();
@@ -1 +1 @@
1
- {"version":3,"file":"echo-back-server.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ACX,CAAC;CACF;AA9DD,4BA8DC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,QAAQ,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport PromiseSocket from 'promise-socket'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class EchoBack implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('echo-back-servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n\n return new Promise((resolve, reject) => {\n var server = net.createServer(socket => {\n socket.on('data', function (data) {\n socket.write(data.toString())\n })\n\n socket.on('error', function (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`Echo-back server listening on ${host}:${port}`)\n\n /* default client connection */\n let socket = new net.Socket()\n socket.on('error', console.error)\n\n try {\n let promiseSocket = new PromiseSocket(socket)\n await promiseSocket.connect(Number(port), 'localhost')\n promiseSocket['__server__'] = server\n\n ConnectionManager.addConnectionInstance(config, promiseSocket)\n\n ConnectionManager.logger.info(`echo-back-server connection(${config.name}:${config.endpoint}) is connected`)\n\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(\n `echo-back-server connection(${config.name}:${config.endpoint}) is connected.\\ncause: ${err}`\n )\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let socket = ConnectionManager.removeConnectionInstance(connection)\n var server = socket['__server__']\n\n await socket.destroy()\n server && (await server.close())\n\n ConnectionManager.logger.info(`echo-back-server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n}\n\nConnectionManager.registerConnector('echo-back-server', new EchoBack())\n"]}
1
+ {"version":3,"file":"echo-back-server.js","sourceRoot":"","sources":["../../../server/engine/connector/echo-back-server.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CAAA;QACnE,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;QAEjC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;QACtB,MAAM,IAAI,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QAEhC,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IAClG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAvED,4BAuEC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,QAAQ,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport PromiseSocket from 'promise-socket'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class EchoBack implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('echo-back-servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n var clientIPs = new Set<string>()\n\n return new Promise((resolve, reject) => {\n var server = net.createServer(socket => {\n const remoteIP = `${socket.remoteAddress}:${socket.remotePort}`\n clientIPs.add(remoteIP)\n\n socket.on('data', function (data) {\n socket.write(data.toString())\n })\n\n socket.on('close', function () {\n clientIPs.delete(remoteIP)\n })\n\n socket.on('error', function (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`Echo-back server listening on ${host}:${port}`)\n\n /* default client connection */\n let socket = new net.Socket()\n socket.on('error', console.error)\n\n try {\n let promiseSocket = new PromiseSocket(socket)\n await promiseSocket.connect(Number(port), 'localhost')\n promiseSocket['__server__'] = server\n promiseSocket['__clients__'] = clientIPs\n\n ConnectionManager.addConnectionInstance(config, promiseSocket)\n\n ConnectionManager.logger.info(`echo-back-server connection(${config.name}:${config.endpoint}) is connected`)\n\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(\n `echo-back-server connection(${config.name}:${config.endpoint}) is connected.\\ncause: ${err}`\n )\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let socket = ConnectionManager.removeConnectionInstance(connection)\n var server = socket['__server__']\n\n await socket.destroy()\n server && (await server.close())\n\n ConnectionManager.logger.info(`echo-back-server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n}\n\nConnectionManager.registerConnector('echo-back-server', new EchoBack())\n"]}
@@ -55,6 +55,7 @@ class SocketServer {
55
55
  /* default client connection */
56
56
  try {
57
57
  em['__server__'] = server;
58
+ em['__clients__'] = clientIPs;
58
59
  connection_manager_1.ConnectionManager.addConnectionInstance(config, em);
59
60
  connection_manager_1.ConnectionManager.logger.info(`socket server connection(${config.name}:${config.endpoint}) is connected`);
60
61
  resolve();
@@ -1 +1 @@
1
- {"version":3,"file":"socket-server.js","sourceRoot":"","sources":["../../../server/engine/connector/socket-server.ts"],"names":[],"mappings":";;;;AAAA,sDAAqB;AACrB,mCAAqC;AAGrC,8DAAyD;AAGzD,MAAa,YAAY;IACvB,cAAc;IAEd,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAuB;QACnC,IAAI,EAAE,GAAG,IAAI,qBAAY,EAAE,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChE,IAAI,SAAS,GA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CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;CACF;AA1FD,oCA0FC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,eAAe,EAAE,IAAI,YAAY,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport { EventEmitter } from 'events'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class SocketServer implements Connector {\n // socket: any\n\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('socket servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var em = new EventEmitter()\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n var clientIPs = new Set<string>()\n return new Promise((resolve, reject) => {\n var server = net.createServer(tcp => {\n const remoteIP = `${tcp.remoteAddress}:${tcp.remotePort}`\n clientIPs.add(remoteIP)\n ConnectionManager.logger.info('Client connection: ')\n ConnectionManager.logger.info(' local = %s:%s', tcp.localAddress, tcp.localPort)\n ConnectionManager.logger.info(' remote = %s:%s', tcp.remoteAddress, tcp.remotePort)\n console.log(\n `[socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n tcp.on('data', (data: any) => {\n em['__tcp__'] = tcp\n var message = data.toString()\n message = message.replace('SB#', '')\n message = message.replace(/(\\r\\n|\\n|\\r)/gm, '')\n // IP 정보를 함께 전달한다\n em.emit('socket-message-arrive', message, tcp.remoteAddress)\n ConnectionManager.logger.info(`socket ${message}`)\n tcp.write('ok')\n })\n\n tcp.on('close', hadError => {\n ConnectionManager.logger.info('Client disconnected')\n if (hadError) {\n ConnectionManager.logger.info('Client disconnected with error: ' + hadError)\n }\n clientIPs.delete(remoteIP)\n console.log(\n `[socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n })\n\n tcp.on('error', ex => {\n ConnectionManager.logger.info('Server socket error: ')\n var logger = ConnectionManager.logger\n let message = ex.stack ? ex.stack : ex\n let msg = typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n logger.error(msg, ex)\n reject(ex)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`tcp echo server listening on ${host}:${port}`)\n\n /* default client connection */\n try {\n em['__server__'] = server\n ConnectionManager.addConnectionInstance(config, em)\n ConnectionManager.logger.info(`socket server connection(${config.name}:${config.endpoint}) is connected`)\n\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let em = ConnectionManager.removeConnectionInstance(connection)\n var tcp = em['__tcp__']\n var server = em['__server__']\n\n tcp && (await tcp.destroy())\n server && (await server.close())\n\n ConnectionManager.logger.info(`socket server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['socket']\n }\n}\n\nConnectionManager.registerConnector('socket-server', new SocketServer())\n"]}
1
+ {"version":3,"file":"socket-server.js","sourceRoot":"","sources":["../../../server/engine/connector/socket-server.ts"],"names":[],"mappings":";;;;AAAA,sDAAqB;AACrB,mCAAqC;AAGrC,8DAAyD;AAGzD,MAAa,YAAY;IACvB,cAAc;IAEd,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAuB;QACnC,IAAI,EAAE,GAAG,IAAI,qBAAY,EAAE,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,SAAS,EAAE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AM,IAAI,CAAC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QAEhC,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IAC/F,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;CACF;AA3FD,oCA2FC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,eAAe,EAAE,IAAI,YAAY,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport { EventEmitter } from 'events'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class SocketServer implements Connector {\n // socket: any\n\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('socket servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var em = new EventEmitter()\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n var clientIPs = new Set<string>()\n return new Promise((resolve, reject) => {\n var server = net.createServer(tcp => {\n const remoteIP = `${tcp.remoteAddress}:${tcp.remotePort}`\n clientIPs.add(remoteIP)\n ConnectionManager.logger.info('Client connection: ')\n ConnectionManager.logger.info(' local = %s:%s', tcp.localAddress, tcp.localPort)\n ConnectionManager.logger.info(' remote = %s:%s', tcp.remoteAddress, tcp.remotePort)\n console.log(\n `[socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n tcp.on('data', (data: any) => {\n em['__tcp__'] = tcp\n var message = data.toString()\n message = message.replace('SB#', '')\n message = message.replace(/(\\r\\n|\\n|\\r)/gm, '')\n // IP 정보를 함께 전달한다\n em.emit('socket-message-arrive', message, tcp.remoteAddress)\n ConnectionManager.logger.info(`socket ${message}`)\n tcp.write('ok')\n })\n\n tcp.on('close', hadError => {\n ConnectionManager.logger.info('Client disconnected')\n if (hadError) {\n ConnectionManager.logger.info('Client disconnected with error: ' + hadError)\n }\n clientIPs.delete(remoteIP)\n console.log(\n `[socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n })\n\n tcp.on('error', ex => {\n ConnectionManager.logger.info('Server socket error: ')\n var logger = ConnectionManager.logger\n let message = ex.stack ? ex.stack : ex\n let msg = typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n logger.error(msg, ex)\n reject(ex)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`tcp echo server listening on ${host}:${port}`)\n\n /* default client connection */\n try {\n em['__server__'] = server\n em['__clients__'] = clientIPs\n ConnectionManager.addConnectionInstance(config, em)\n ConnectionManager.logger.info(`socket server connection(${config.name}:${config.endpoint}) is connected`)\n\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let em = ConnectionManager.removeConnectionInstance(connection)\n var tcp = em['__tcp__']\n var server = em['__server__']\n\n tcp && (await tcp.destroy())\n server && (await server.close())\n\n ConnectionManager.logger.info(`socket server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['socket']\n }\n}\n\nConnectionManager.registerConnector('socket-server', new SocketServer())\n"]}
@@ -68,6 +68,7 @@ class StreamSocketServer {
68
68
  connection_manager_1.ConnectionManager.logger.info(`stream tcp socket server listening on ${host}:${port}`);
69
69
  try {
70
70
  em['__server__'] = server;
71
+ em['__clients__'] = clientIPs;
71
72
  connection_manager_1.ConnectionManager.addConnectionInstance(config, em);
72
73
  connection_manager_1.ConnectionManager.logger.info(`stream socket server connection(${config.name}:${config.endpoint}) is connected`);
73
74
  resolve();
@@ -1 +1 @@
1
- {"version":3,"file":"stream-socket-server.js","sourceRoot":"","sources":["../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,sBAAsB,EAAE,IAAI,kBAAkB,EAAE,CAAC,CAAA","sourcesContent":["import net from 'net'\nimport { EventEmitter } from 'events'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\n/**\n * \\r\\n 구분자 기반 스트림 버퍼링 소켓 서버 커넥터.\n * TCP 스트림 단편화(fragmentation)로 인해 메시지가 여러 청크로 나뉘어 수신될 때,\n * \\r\\n이 도착할 때까지 버퍼에 누적한 뒤 완전한 메시지만 socket-message-arrive 이벤트로 emit한다.\n */\nexport class StreamSocketServer implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('stream socket servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var em = new EventEmitter()\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n var clientIPs = new Set<string>()\n\n return new Promise((resolve, reject) => {\n var server = net.createServer(tcp => {\n const remoteIP = `${tcp.remoteAddress}:${tcp.remotePort}`\n clientIPs.add(remoteIP)\n ConnectionManager.logger.info('Client connection: ')\n ConnectionManager.logger.info(' local = %s:%s', tcp.localAddress, tcp.localPort)\n ConnectionManager.logger.info(' remote = %s:%s', tcp.remoteAddress, tcp.remotePort)\n console.log(\n `[stream-socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n\n // TCP 스트림은 청크 단위로 수신되므로 \\r\\n 구분자가 올 때까지 버퍼링한다\n let buffer = ''\n tcp.on('data', (data: any) => {\n em['__tcp__'] = tcp\n buffer += data.toString()\n\n // 완전한 메시지(\\r\\n 또는 \\n 종료)가 수신될 때마다 처리\n let newlineIndex: number\n while ((newlineIndex = buffer.search(/\\r\\n|\\n|\\r/)) !== -1) {\n const eolLength = buffer[newlineIndex] === '\\r' && buffer[newlineIndex + 1] === '\\n' ? 2 : 1\n let message = buffer.substring(0, newlineIndex)\n buffer = buffer.substring(newlineIndex + eolLength)\n\n message = message.replace('SB#', '')\n if (!message) continue\n\n // IP 정보를 함께 전달한다\n em.emit('socket-message-arrive', message, tcp.remoteAddress)\n ConnectionManager.logger.info(`stream-socket ${message}`)\n tcp.write('ok')\n }\n })\n\n tcp.on('close', hadError => {\n ConnectionManager.logger.info('Client disconnected')\n if (hadError) {\n ConnectionManager.logger.info('Client disconnected with error: ' + hadError)\n }\n clientIPs.delete(remoteIP)\n console.log(\n `[stream-socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n })\n\n tcp.on('error', ex => {\n ConnectionManager.logger.info('Server socket error: ')\n var logger = ConnectionManager.logger\n let message = ex.stack ? ex.stack : ex\n let msg = typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n logger.error(msg, ex)\n reject(ex)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`stream tcp socket server listening on ${host}:${port}`)\n\n try {\n em['__server__'] = server\n ConnectionManager.addConnectionInstance(config, em)\n ConnectionManager.logger.info(\n `stream socket server connection(${config.name}:${config.endpoint}) is connected`\n )\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let em = ConnectionManager.removeConnectionInstance(connection)\n var tcp = em['__tcp__']\n var server = em['__server__']\n\n tcp && (await tcp.destroy())\n server && (await server.close())\n\n ConnectionManager.logger.info(`stream socket server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['socket']\n }\n}\n\nConnectionManager.registerConnector('stream-socket-server', new StreamSocketServer())\n"]}
1
+ {"version":3,"file":"stream-socket-server.js","sourceRoot":"","sources":["../../../server/engine/connector/stream-socket-server.ts"],"names":[],"mappings":";;;;AAAA,sDAAqB;AACrB,mCAAqC;AAGrC,8DAAyD;AAGzD;;;;GAIG;AACH,MAAa,kBAAkB;IAC7B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} from 'events'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\n/**\n * \\r\\n 구분자 기반 스트림 버퍼링 소켓 서버 커넥터.\n * TCP 스트림 단편화(fragmentation)로 인해 메시지가 여러 청크로 나뉘어 수신될 때,\n * \\r\\n이 도착할 때까지 버퍼에 누적한 뒤 완전한 메시지만 socket-message-arrive 이벤트로 emit한다.\n */\nexport class StreamSocketServer implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('stream socket servers are ready')\n }\n\n async connect(config: InputConnection): Promise<void> {\n var em = new EventEmitter()\n var [host = '0.0.0.0', port = 8124] = config.endpoint.split(':')\n var clientIPs = new Set<string>()\n\n return new Promise((resolve, reject) => {\n var server = net.createServer(tcp => {\n const remoteIP = `${tcp.remoteAddress}:${tcp.remotePort}`\n clientIPs.add(remoteIP)\n ConnectionManager.logger.info('Client connection: ')\n ConnectionManager.logger.info(' local = %s:%s', tcp.localAddress, tcp.localPort)\n ConnectionManager.logger.info(' remote = %s:%s', tcp.remoteAddress, tcp.remotePort)\n console.log(\n `[stream-socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n\n // TCP 스트림은 청크 단위로 수신되므로 \\r\\n 구분자가 올 때까지 버퍼링한다\n let buffer = ''\n tcp.on('data', (data: any) => {\n em['__tcp__'] = tcp\n buffer += data.toString()\n\n // 완전한 메시지(\\r\\n 또는 \\n 종료)가 수신될 때마다 처리\n let newlineIndex: number\n while ((newlineIndex = buffer.search(/\\r\\n|\\n|\\r/)) !== -1) {\n const eolLength = buffer[newlineIndex] === '\\r' && buffer[newlineIndex + 1] === '\\n' ? 2 : 1\n let message = buffer.substring(0, newlineIndex)\n buffer = buffer.substring(newlineIndex + eolLength)\n\n message = message.replace('SB#', '')\n if (!message) continue\n\n // IP 정보를 함께 전달한다\n em.emit('socket-message-arrive', message, tcp.remoteAddress)\n ConnectionManager.logger.info(`stream-socket ${message}`)\n tcp.write('ok')\n }\n })\n\n tcp.on('close', hadError => {\n ConnectionManager.logger.info('Client disconnected')\n if (hadError) {\n ConnectionManager.logger.info('Client disconnected with error: ' + hadError)\n }\n clientIPs.delete(remoteIP)\n console.log(\n `[stream-socket-server] ${config.name} clients: ${clientIPs.size}\\n${[...clientIPs].sort().map(ip => ` - ${ip}`).join('\\n')}`\n )\n })\n\n tcp.on('error', ex => {\n ConnectionManager.logger.info('Server socket error: ')\n var logger = ConnectionManager.logger\n let message = ex.stack ? ex.stack : ex\n let msg = typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n logger.error(msg, ex)\n reject(ex)\n })\n })\n\n server.listen(port, async () => {\n ConnectionManager.logger.info(`stream tcp socket server listening on ${host}:${port}`)\n\n try {\n em['__server__'] = server\n em['__clients__'] = clientIPs\n ConnectionManager.addConnectionInstance(config, em)\n ConnectionManager.logger.info(\n `stream socket server connection(${config.name}:${config.endpoint}) is connected`\n )\n resolve()\n } catch (err) {\n ConnectionManager.logger.error(err)\n reject(err)\n }\n })\n })\n }\n\n async disconnect(connection: InputConnection) {\n let em = ConnectionManager.removeConnectionInstance(connection)\n var tcp = em['__tcp__']\n var server = em['__server__']\n\n tcp && (await tcp.destroy())\n server && (await server.close())\n\n ConnectionManager.logger.info(`stream socket server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['socket']\n }\n}\n\nConnectionManager.registerConnector('stream-socket-server', new StreamSocketServer())\n"]}
@@ -1,35 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@things-factory/utils");
4
3
  const task_registry_1 = require("../task-registry");
5
4
  const connection_manager_1 = require("../connection-manager");
6
- const RECEIVE_TIMEOUT_MS = 5000; // 응답 대기 최대 시간 (초과 시 에러)
7
- const POLL_MS = 50;
8
- // 커넥터가 idle-flush로 큐(__messages__)에 적재한 완성 응답 1건을 꺼내 hex로 반환한다.
9
- // read()를 직접 호출하지 않으므로 이후 send가 막히지 않고, 끝의 바이너리(체크섬 등)도 손실 없이 보존된다.
10
- async function EchoReceive(step, { domain }) {
5
+ async function EchoReceive(step, { logger, domain }) {
11
6
  var { connection: connectionName } = step;
12
7
  var connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
13
- if (!connection) {
14
- throw Error(`connection is not found : ${connectionName}`);
15
- }
16
- const queue = connection.__messages__;
17
- if (!queue) {
18
- throw Error(`connection(${connectionName}) does not support buffered receive`);
19
- }
20
- // 완성된 응답 1건이 큐에 들어올 때까지 대기 (무한 대기 방지를 위한 타임아웃 포함)
21
- let waited = 0;
22
- while (queue.length === 0) {
23
- if (waited >= RECEIVE_TIMEOUT_MS) {
24
- throw Error(`echo-receive timeout: no response within ${RECEIVE_TIMEOUT_MS}ms`);
25
- }
26
- await (0, utils_1.sleep)(POLL_MS);
27
- waited += POLL_MS;
28
- }
29
- const message = queue.shift();
8
+ var message = await connection.read();
30
9
  return {
31
- data: message.toString('hex'), // 무손실 hex (끝 바이너리/체크섬 보존)
32
- ascii: message.toString('latin1') // 참고용 (1바이트=1문자, 손실 없음)
10
+ data: message.toString()
33
11
  };
34
12
  }
35
13
  EchoReceive.parameterSpec = [];
@@ -1 +1 @@
1
- {"version":3,"file":"echo-receive.js","sourceRoot":"","sources":["../../../server/engine/task/echo-receive.ts"],"names":[],"mappings":";;AAAA,iDAA6C;AAE7C,oDAA+C;AAC/C,8DAAyD;AAKzD,MAAM,kBAAkB,GAAG,IAAI,CAAA,CAAC,wBAAwB;AACxD,MAAM,OAAO,GAAG,EAAE,CAAA;AAElB,gEAAgE;AAChE,oEAAoE;AACpE,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,EAAE,MAAM,EAAW;IAC7D,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAEzC,IAAI,UAAU,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,6BAA6B,cAAc,EAAE,CAAC,CAAA;IAC5D,CAAC;IAED,MAAM,KAAK,GAAc,UAAkB,CAAC,YAAY,CAAA;IACxD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,cAAc,cAAc,qCAAqC,CAAC,CAAA;IAChF,CAAC;IAED,kDAAkD;IAClD,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,IAAI,MAAM,IAAI,kBAAkB,EAAE,CAAC;YACjC,MAAM,KAAK,CAAC,4CAA4C,kBAAkB,IAAI,CAAC,CAAA;QACjF,CAAC;QACD,MAAM,IAAA,aAAK,EAAC,OAAO,CAAC,CAAA;QACpB,MAAM,IAAI,OAAO,CAAA;IACnB,CAAC;IAED,MAAM,OAAO,GAAW,KAAK,CAAC,KAAK,EAAY,CAAA;IAE/C,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,0BAA0B;QACzD,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,wBAAwB;KAC3D,CAAA;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG,EAAE,CAAA;AAE9B,4BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { sleep } from '@things-factory/utils'\n\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\n\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nconst RECEIVE_TIMEOUT_MS = 5000 // 응답 대기 최대 시간 (초과 시 에러)\nconst POLL_MS = 50\n\n// 커넥터가 idle-flush로 큐(__messages__)에 적재한 완성 응답 1건을 꺼내 hex로 반환한다.\n// read()를 직접 호출하지 않으므로 이후 send가 막히지 않고, 끝의 바이너리(체크섬 등)도 손실 없이 보존된다.\nasync function EchoReceive(step: InputStep, { domain }: Context) {\n var { connection: connectionName } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n if (!connection) {\n throw Error(`connection is not found : ${connectionName}`)\n }\n\n const queue: Buffer[] = (connection as any).__messages__\n if (!queue) {\n throw Error(`connection(${connectionName}) does not support buffered receive`)\n }\n\n // 완성된 응답 1건이 큐에 들어올 때까지 대기 (무한 대기 방지를 위한 타임아웃 포함)\n let waited = 0\n while (queue.length === 0) {\n if (waited >= RECEIVE_TIMEOUT_MS) {\n throw Error(`echo-receive timeout: no response within ${RECEIVE_TIMEOUT_MS}ms`)\n }\n await sleep(POLL_MS)\n waited += POLL_MS\n }\n\n const message: Buffer = queue.shift() as Buffer\n\n return {\n data: message.toString('hex'), // 무손실 hex (끝 바이너리/체크섬 보존)\n ascii: message.toString('latin1') // 참고용 (1바이트=1문자, 손실 없음)\n }\n}\n\nEchoReceive.parameterSpec = []\n\nTaskRegistry.registerTaskHandler('echo-receive', EchoReceive)\n"]}
1
+ {"version":3,"file":"echo-receive.js","sourceRoot":"","sources":["../../../server/engine/task/echo-receive.ts"],"names":[],"mappings":";;AAAA,oDAA+C;AAC/C,8DAAyD;AAKzD,KAAK,UAAU,WAAW,CAAC,IAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAW;IACrE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;IAEzC,IAAI,UAAU,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAE5F,IAAI,OAAO,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAA;IAErC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;KACzB,CAAA;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG,EAAE,CAAA;AAE9B,4BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\n\nimport { InputStep } from '../../service/step/step-type'\nimport { Context } from '../types'\n\nasync function EchoReceive(step: InputStep, { logger, domain }: Context) {\n var { connection: connectionName } = step\n\n var connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n var message = await connection.read()\n\n return {\n data: message.toString()\n }\n}\n\nEchoReceive.parameterSpec = []\n\nTaskRegistry.registerTaskHandler('echo-receive', EchoReceive)\n"]}
@@ -1,7 +1,7 @@
1
1
  import { Appliance, User } from '@things-factory/auth-base';
2
2
  import { Domain, ListParam } from '@things-factory/shell';
3
3
  import { Connection } from './connection';
4
- import { ConnectionList, ConnectionState } from './connection-type';
4
+ import { ConnectedClientList, ConnectionList, ConnectionState } from './connection-type';
5
5
  /**
6
6
  * @description Provides GraphQL resolvers for the Connection entity.
7
7
  */
@@ -9,6 +9,7 @@ export declare class ConnectionQuery {
9
9
  connection(name: string, context: ResolverContext): Promise<Connection>;
10
10
  connections(params: ListParam, context: ResolverContext): Promise<ConnectionList>;
11
11
  fetchConnectionState(name: string, context: ResolverContext): ConnectionState;
12
+ connectedClients(context: ResolverContext): ConnectedClientList;
12
13
  edge(connection: Connection): Promise<Appliance>;
13
14
  domain(connection: Connection): Promise<Domain>;
14
15
  updater(connection: Connection): Promise<User>;
@@ -50,6 +50,25 @@ let ConnectionQuery = class ConnectionQuery {
50
50
  state: connection ? connection_1.ConnectionStatus.CONNECTED : connection_1.ConnectionStatus.DISCONNECTED
51
51
  };
52
52
  }
53
+ connectedClients(context) {
54
+ const { domain } = context.state;
55
+ const instances = connection_manager_1.ConnectionManager.getConnectionInstances(domain);
56
+ const entities = connection_manager_1.ConnectionManager.getConnectionInstanceEntities(domain);
57
+ // 서버형 커넥터 인스턴스에 노출된 __clients__(접속 클라이언트 Set)를 평탄화하여 반환한다
58
+ const items = Object.entries(instances).flatMap(([name, instance]) => {
59
+ const clients = instance?.['__clients__'];
60
+ if (!clients)
61
+ return [];
62
+ const entity = entities[name];
63
+ return [...clients].sort().map(remote => ({
64
+ connectionName: name,
65
+ connectionType: entity?.type,
66
+ endpoint: entity?.endpoint,
67
+ remote
68
+ }));
69
+ });
70
+ return { items, total: items.length };
71
+ }
53
72
  async edge(connection) {
54
73
  return connection.edgeId && (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOneBy({ id: connection.edgeId }));
55
74
  }
@@ -95,6 +114,16 @@ tslib_1.__decorate([
95
114
  tslib_1.__metadata("design:paramtypes", [String, Object]),
96
115
  tslib_1.__metadata("design:returntype", connection_type_1.ConnectionState)
97
116
  ], ConnectionQuery.prototype, "fetchConnectionState", null);
117
+ tslib_1.__decorate([
118
+ (0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
119
+ (0, type_graphql_1.Query)(returns => connection_type_1.ConnectedClientList, {
120
+ description: 'Fetches TCP clients currently connected to all server-type connections.'
121
+ }),
122
+ tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
123
+ tslib_1.__metadata("design:type", Function),
124
+ tslib_1.__metadata("design:paramtypes", [Object]),
125
+ tslib_1.__metadata("design:returntype", connection_type_1.ConnectedClientList)
126
+ ], ConnectionQuery.prototype, "connectedClients", null);
98
127
  tslib_1.__decorate([
99
128
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
100
129
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmE;AAEnE;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,KAAK,CAA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ACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;0BAnFU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,eAAe,CAoF3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionList, ConnectionState } from './connection-type'\n\n/**\n * @description Provides GraphQL resolvers for the Connection entity.\n */\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, {\n description: 'Fetches a single connection by its name, including its current state.'\n })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, {\n description: 'Fetches a paginated list of connections, including their current states.'\n })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'Fetches the current state of a single connection by its name.' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAwF;AAExF;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,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C,uBAAU,CAAC;GACR,eAAe,CA+G3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectedClientList, ConnectionList, ConnectionState } from './connection-type'\n\n/**\n * @description Provides GraphQL resolvers for the Connection entity.\n */\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, {\n description: 'Fetches a single connection by its name, including its current state.'\n })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, {\n description: 'Fetches a paginated list of connections, including their current states.'\n })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'Fetches the current state of a single connection by its name.' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectedClientList, {\n description: 'Fetches TCP clients currently connected to all server-type connections.'\n })\n connectedClients(@Ctx() context: ResolverContext): ConnectedClientList {\n const { domain } = context.state\n\n const instances = ConnectionManager.getConnectionInstances(domain)\n const entities = ConnectionManager.getConnectionInstanceEntities(domain)\n\n // 서버형 커넥터 인스턴스에 노출된 __clients__(접속 클라이언트 Set)를 평탄화하여 반환한다\n const items = Object.entries(instances).flatMap(([name, instance]) => {\n const clients: Set<string> = instance?.['__clients__']\n if (!clients) return []\n\n const entity = entities[name]\n return [...clients].sort().map(remote => ({\n connectionName: name,\n connectionType: entity?.type,\n endpoint: entity?.endpoint,\n remote\n }))\n })\n\n return { items, total: items.length }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
@@ -49,6 +49,16 @@ export declare class ConnectionPatch {
49
49
  };
50
50
  cuFlag?: string;
51
51
  }
52
+ export declare class ConnectedClient {
53
+ connectionName: string;
54
+ connectionType?: string;
55
+ endpoint?: string;
56
+ remote: string;
57
+ }
58
+ export declare class ConnectedClientList {
59
+ items: ConnectedClient[];
60
+ total: number;
61
+ }
52
62
  export declare class ConnectionList {
53
63
  items: Connection[];
54
64
  total: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionList = exports.ConnectionPatch = exports.NewConnection = exports.ConnectionState = void 0;
3
+ exports.ConnectionList = exports.ConnectedClientList = exports.ConnectedClient = exports.ConnectionPatch = exports.NewConnection = exports.ConnectionState = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const auth_base_1 = require("@things-factory/auth-base");
@@ -151,6 +151,42 @@ tslib_1.__decorate([
151
151
  exports.ConnectionPatch = ConnectionPatch = tslib_1.__decorate([
152
152
  (0, type_graphql_1.InputType)({ description: 'Input for updating (patching) an existing connection.' })
153
153
  ], ConnectionPatch);
154
+ let ConnectedClient = class ConnectedClient {
155
+ };
156
+ exports.ConnectedClient = ConnectedClient;
157
+ tslib_1.__decorate([
158
+ (0, type_graphql_1.Field)({ description: 'The name of the server-type connection.' }),
159
+ tslib_1.__metadata("design:type", String)
160
+ ], ConnectedClient.prototype, "connectionName", void 0);
161
+ tslib_1.__decorate([
162
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The connector type of the connection.' }),
163
+ tslib_1.__metadata("design:type", String)
164
+ ], ConnectedClient.prototype, "connectionType", void 0);
165
+ tslib_1.__decorate([
166
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The listening endpoint of the connection.' }),
167
+ tslib_1.__metadata("design:type", String)
168
+ ], ConnectedClient.prototype, "endpoint", void 0);
169
+ tslib_1.__decorate([
170
+ (0, type_graphql_1.Field)({ description: 'The remote address(ip:port) of the connected client.' }),
171
+ tslib_1.__metadata("design:type", String)
172
+ ], ConnectedClient.prototype, "remote", void 0);
173
+ exports.ConnectedClient = ConnectedClient = tslib_1.__decorate([
174
+ (0, type_graphql_1.ObjectType)({ description: 'A TCP client currently connected to a server-type connection.' })
175
+ ], ConnectedClient);
176
+ let ConnectedClientList = class ConnectedClientList {
177
+ };
178
+ exports.ConnectedClientList = ConnectedClientList;
179
+ tslib_1.__decorate([
180
+ (0, type_graphql_1.Field)(type => [ConnectedClient], { description: 'The list of connected clients.' }),
181
+ tslib_1.__metadata("design:type", Array)
182
+ ], ConnectedClientList.prototype, "items", void 0);
183
+ tslib_1.__decorate([
184
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of connected clients.' }),
185
+ tslib_1.__metadata("design:type", Number)
186
+ ], ConnectedClientList.prototype, "total", void 0);
187
+ exports.ConnectedClientList = ConnectedClientList = tslib_1.__decorate([
188
+ (0, type_graphql_1.ObjectType)({ description: 'A list of connected TCP clients.' })
189
+ ], ConnectedClientList);
154
190
  let ConnectionList = class ConnectionList {
155
191
  };
156
192
  exports.ConnectionList = ConnectionList;
@@ -1 +1 @@
1
- {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAqD;AACrD,iDAAuE;AAEvE,6CAAyC;AACzC,6CAA+C;AAYxC,IAAM,eAAe,GAArB,MAAM,eAAe;CA8B3B,CAAA;AA9BY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC/D,cAAM;+CAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;2CACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAGb;IADC,IAAA,oBAAK,EAAC,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AC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;sCACjG,qBAAS;6CAAA;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;iDAC9D;AAMjB;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,8DAA8D;KAC5E,CAAC;;+CACc;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;+CACxE;AAM/B;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,iFAAiF;KAC/F,CAAC;;+CACa;0BAtCJ,eAAe;IAD3B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;GACvE,eAAe,CAuC3B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uBAAU,CAAC,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;6CAC3D;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3D;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Appliance } from '@things-factory/auth-base'\nimport { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Connection } from './connection'\nimport { ConnectionStatus } from './connection'\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: { [key: string]: any }\n}\n\n@ObjectType({ description: 'Represents the state of a connection at a point in time.' })\nexport class ConnectionState {\n @Field(type => Domain, { description: 'The domain of the connection.' })\n domain?: Domain\n\n @Field({ nullable: true, description: 'The unique identifier of the connection.' })\n id?: string\n\n @Field({ nullable: true, description: 'The name of the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The description of the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand?: boolean\n\n @Field(type => Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The current status of the connection.' })\n state?: ConnectionStatus\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n timestamp?: Date\n}\n\n@InputType({ description: 'Input for creating a new connection.' })\nexport class NewConnection {\n @Field({ description: 'The name for the new connection.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The endpoint URL or address for the new connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' })\n params?: { [key: string]: any }\n}\n\n@InputType({ description: 'Input for updating (patching) an existing connection.' })\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the connection to update.' })\n id: string\n\n @Field({ nullable: true, description: 'The new name for the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The new endpoint for the connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'The new parameters for the connection.' })\n params?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the connection is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of connections.' })\nexport class ConnectionList {\n @Field(type => [Connection], { description: 'The list of connection items.' })\n items: Connection[]\n\n @Field(type => Int, { description: 'The total number of connections.' })\n total: number\n}\n"]}
1
+ {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAqD;AACrD,iDAAuE;AAEvE,6CAAyC;AACzC,6CAA+C;AAYxC,IAAM,eAAe,GAArB,MAAM,eAAe;CA8B3B,CAAA;AA9BY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC/D,cAAM;+CAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;2CACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAGb;I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,GAAzB,MAAM,mBAAmB;CAM/B,CAAA;AANY,kDAAmB;AAE9B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,eAAe,CAAC,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;kDAC5D;AAGxB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;kDACjE;8BALF,mBAAmB;IAD/B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,mBAAmB,CAM/B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uBAAU,CAAC,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;6CAC3D;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3D;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Appliance } from '@things-factory/auth-base'\nimport { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Connection } from './connection'\nimport { ConnectionStatus } from './connection'\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: { [key: string]: any }\n}\n\n@ObjectType({ description: 'Represents the state of a connection at a point in time.' })\nexport class ConnectionState {\n @Field(type => Domain, { description: 'The domain of the connection.' })\n domain?: Domain\n\n @Field({ nullable: true, description: 'The unique identifier of the connection.' })\n id?: string\n\n @Field({ nullable: true, description: 'The name of the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The description of the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand?: boolean\n\n @Field(type => Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The current status of the connection.' })\n state?: ConnectionStatus\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n timestamp?: Date\n}\n\n@InputType({ description: 'Input for creating a new connection.' })\nexport class NewConnection {\n @Field({ description: 'The name for the new connection.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The endpoint URL or address for the new connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' })\n params?: { [key: string]: any }\n}\n\n@InputType({ description: 'Input for updating (patching) an existing connection.' })\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the connection to update.' })\n id: string\n\n @Field({ nullable: true, description: 'The new name for the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the connection.' })\n type?: string\n\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The new endpoint for the connection.' })\n endpoint?: string\n\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'The new parameters for the connection.' })\n params?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the connection is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A TCP client currently connected to a server-type connection.' })\nexport class ConnectedClient {\n @Field({ description: 'The name of the server-type connection.' })\n connectionName: string\n\n @Field({ nullable: true, description: 'The connector type of the connection.' })\n connectionType?: string\n\n @Field({ nullable: true, description: 'The listening endpoint of the connection.' })\n endpoint?: string\n\n @Field({ description: 'The remote address(ip:port) of the connected client.' })\n remote: string\n}\n\n@ObjectType({ description: 'A list of connected TCP clients.' })\nexport class ConnectedClientList {\n @Field(type => [ConnectedClient], { description: 'The list of connected clients.' })\n items: ConnectedClient[]\n\n @Field(type => Int, { description: 'The total number of connected clients.' })\n total: number\n}\n\n@ObjectType({ description: 'A paginated list of connections.' })\nexport class ConnectionList {\n @Field(type => [Connection], { description: 'The list of connection items.' })\n items: Connection[]\n\n @Field(type => Int, { description: 'The total number of connections.' })\n total: number\n}\n"]}
@@ -12,7 +12,7 @@ export * from './payload-log/payload-log';
12
12
  export * from './state-register/state-register';
13
13
  export declare const entities: any[];
14
14
  export declare const schema: {
15
- resolverClasses: (typeof import("./task-type/task-type-query").TaskTypeQuery | typeof import("./connector/connector-query").ConnectorQuery | typeof import("./connection/connection-query").ConnectionQuery | typeof import("./connection/connection-mutation").ConnectionMutation | typeof import("./connection/connection-subscription").ConnectionSubscription | typeof import("./scenario/scenario-query").ScenarioQuery | typeof import("./scenario/scenario-mutation").ScenarioMutation | typeof import("./scenario-instance/scenario-instance-query").ScenarioInstanceQuery | typeof import("./scenario-instance/scenario-instance-mutation").ScenarioInstanceMutation | typeof import("./scenario-instance/scenario-instance-subscription").ScenarioInstanceSubscription | typeof import("./scenario-queue/scenario-queue-subscription").ScenarioQueueSubscription | typeof import("./step/step-query").StepQuery | typeof import("./step/step-mutation").StepMutation | typeof import("./payload-log/payload-log-query").PayloadLogQuery | typeof import("./payload-log/payload-log-mutation").PayloadLogMutation | typeof import("./analysis/analysis-query").IntegrationAnalysisQuery | typeof import("./state-register/state-register-query").StateRegisterQuery | typeof import("./state-register/state-register-mutation").StateRegisterMutation | typeof import("./state-register/data-resolver").DataResolver)[];
15
+ resolverClasses: (typeof import("./connection/connection-query").ConnectionQuery | typeof import("./connection/connection-mutation").ConnectionMutation | typeof import("./connection/connection-subscription").ConnectionSubscription | typeof import("./connector/connector-query").ConnectorQuery | typeof import("./scenario/scenario-query").ScenarioQuery | typeof import("./scenario/scenario-mutation").ScenarioMutation | typeof import("./scenario-instance/scenario-instance-query").ScenarioInstanceQuery | typeof import("./scenario-instance/scenario-instance-mutation").ScenarioInstanceMutation | typeof import("./scenario-instance/scenario-instance-subscription").ScenarioInstanceSubscription | typeof import("./scenario-queue/scenario-queue-subscription").ScenarioQueueSubscription | typeof import("./step/step-query").StepQuery | typeof import("./step/step-mutation").StepMutation | typeof import("./task-type/task-type-query").TaskTypeQuery | typeof import("./payload-log/payload-log-query").PayloadLogQuery | typeof import("./payload-log/payload-log-mutation").PayloadLogMutation | typeof import("./state-register/state-register-query").StateRegisterQuery | typeof import("./state-register/state-register-mutation").StateRegisterMutation | typeof import("./state-register/data-resolver").DataResolver | typeof import("./analysis/analysis-query").IntegrationAnalysisQuery)[];
16
16
  };
17
17
  export { PayloadType } from './payload-log/payload-log';
18
18
  export { createPayloadLog } from './payload-log/payload-log-mutation';