@things-factory/integration-base 9.0.27 → 9.0.32

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.
Files changed (35) hide show
  1. package/README.md +513 -2
  2. package/dist-server/engine/connector/headless-connector.js +1 -1
  3. package/dist-server/engine/connector/headless-connector.js.map +1 -1
  4. package/dist-server/engine/connector/mqtt-connector.js +1 -1
  5. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  6. package/dist-server/engine/connector/mssql-connector.js +1 -1
  7. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  8. package/dist-server/engine/connector/mysql-connector.js +1 -1
  9. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  10. package/dist-server/engine/connector/oracle-connector.js +1 -1
  11. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  12. package/dist-server/engine/connector/postgresql-connector.js +1 -1
  13. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  14. package/dist-server/engine/connector/pyrun-connector.js +3 -3
  15. package/dist-server/engine/connector/pyrun-connector.js.map +1 -1
  16. package/dist-server/engine/task/headless-delete.d.ts +1 -0
  17. package/dist-server/engine/task/headless-delete.js +95 -0
  18. package/dist-server/engine/task/headless-delete.js.map +1 -0
  19. package/dist-server/engine/task/headless-get.d.ts +1 -0
  20. package/dist-server/engine/task/headless-get.js +96 -0
  21. package/dist-server/engine/task/headless-get.js.map +1 -0
  22. package/dist-server/engine/task/headless-patch.d.ts +1 -0
  23. package/dist-server/engine/task/headless-patch.js +135 -0
  24. package/dist-server/engine/task/headless-patch.js.map +1 -0
  25. package/dist-server/engine/task/headless-post.js +27 -4
  26. package/dist-server/engine/task/headless-post.js.map +1 -1
  27. package/dist-server/engine/task/headless-put.d.ts +1 -0
  28. package/dist-server/engine/task/headless-put.js +135 -0
  29. package/dist-server/engine/task/headless-put.js.map +1 -0
  30. package/dist-server/engine/task/index.d.ts +4 -0
  31. package/dist-server/engine/task/index.js +4 -0
  32. package/dist-server/engine/task/index.js.map +1 -1
  33. package/dist-server/service/index.d.ts +1 -1
  34. package/dist-server/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +8 -3
@@ -84,7 +84,7 @@ class MssqlConnector {
84
84
  useDomainAttribute: true
85
85
  },
86
86
  {
87
- type: 'password',
87
+ type: 'secret',
88
88
  name: 'password',
89
89
  label: 'password',
90
90
  useDomainAttribute: true
@@ -1 +1 @@
1
- {"version":3,"file":"mssql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mssql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;AAClD,CAAC;AAED,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,sBAAsB,EAAE,EACtG,GAAG,UAAU,CAAA;QAEd,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAChD,CAAC;QA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BAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,0BAA0B;gBACjC,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AA3ID,wCA2IC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var mssql = require('mssql')\n} catch (err) {\n logger.error('mssql module loading failed', err)\n}\n\nexport class MssqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('mssql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database, poolMin = 0, poolMax = 4, encrypt = 'Y', trustServerCertificate }\n } = connection\n\n const [host, port = 1433] = endpoint.split(':')\n\n if (!mssql) {\n throw new Error('mssql module loading failed')\n }\n\n const pool = await mssql.connect({\n user,\n password,\n server: host,\n port: Number(port),\n database,\n pool: {\n max: Math.max(2, poolMax),\n min: Math.max(0, poolMin),\n idleTimeoutMillis: 30000\n },\n options: {\n encrypt: encrypt === 'Y',\n trustServerCertificate: trustServerCertificate === 'Y'\n }\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result = await pool.request().query(query)\n return result.recordset\n },\n execute: async (procedure, params) => {\n let request = pool.request()\n\n Object.keys(params).forEach(key => {\n let { dir, type, val } = params[key]\n\n if (dir === 'in' || dir === 'inout') {\n request.input(key, type, val)\n } else if (dir === 'out') {\n request.output(key, type)\n } else {\n console.error(`Invalid parameter direction(${dir}) for mssql stored procedure`)\n }\n })\n\n var result = await request.execute(procedure)\n return result\n },\n close: () => {\n pool.close()\n }\n })\n\n ConnectionManager.logger.info(`MSSql Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n try {\n await client.close()\n ConnectionManager.logger.info(`MSSql Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n useDomainAttribute: true\n },\n {\n type: 'password',\n name: 'password',\n label: 'password',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'select',\n name: 'encrypt',\n label: 'encrypt',\n property: {\n options: ['Y', 'N']\n }\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'select',\n name: 'trustServerCertificate',\n label: 'trust-server-certificate',\n property: {\n options: ['Y', 'N']\n }\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'mssql']\n }\n\n get help() {\n return 'integration/connector/mssql-connector'\n }\n}\n\nConnectionManager.registerConnector('mssql-connector', new MssqlConnector())\n"]}
1
+ {"version":3,"file":"mssql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mssql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;AAClD,CAAC;AAED,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,sBAAsB,EAAE,EACtG,GAAG,UAAU,CAAA;QAEd,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAChD,CAAC;QAED,MAAM,IAAI,GAAG,M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K;gBAClB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,0BAA0B;gBACjC,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AA3ID,wCA2IC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var mssql = require('mssql')\n} catch (err) {\n logger.error('mssql module loading failed', err)\n}\n\nexport class MssqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('mssql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database, poolMin = 0, poolMax = 4, encrypt = 'Y', trustServerCertificate }\n } = connection\n\n const [host, port = 1433] = endpoint.split(':')\n\n if (!mssql) {\n throw new Error('mssql module loading failed')\n }\n\n const pool = await mssql.connect({\n user,\n password,\n server: host,\n port: Number(port),\n database,\n pool: {\n max: Math.max(2, poolMax),\n min: Math.max(0, poolMin),\n idleTimeoutMillis: 30000\n },\n options: {\n encrypt: encrypt === 'Y',\n trustServerCertificate: trustServerCertificate === 'Y'\n }\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result = await pool.request().query(query)\n return result.recordset\n },\n execute: async (procedure, params) => {\n let request = pool.request()\n\n Object.keys(params).forEach(key => {\n let { dir, type, val } = params[key]\n\n if (dir === 'in' || dir === 'inout') {\n request.input(key, type, val)\n } else if (dir === 'out') {\n request.output(key, type)\n } else {\n console.error(`Invalid parameter direction(${dir}) for mssql stored procedure`)\n }\n })\n\n var result = await request.execute(procedure)\n return result\n },\n close: () => {\n pool.close()\n }\n })\n\n ConnectionManager.logger.info(`MSSql Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n try {\n await client.close()\n ConnectionManager.logger.info(`MSSql Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n useDomainAttribute: true\n },\n {\n type: 'secret',\n name: 'password',\n label: 'password',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'select',\n name: 'encrypt',\n label: 'encrypt',\n property: {\n options: ['Y', 'N']\n }\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'select',\n name: 'trustServerCertificate',\n label: 'trust-server-certificate',\n property: {\n options: ['Y', 'N']\n }\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'mssql']\n }\n\n get help() {\n return 'integration/connector/mssql-connector'\n }\n}\n\nConnectionManager.registerConnector('mssql-connector', new MssqlConnector())\n"]}
@@ -62,7 +62,7 @@ class mysqlConnector {
62
62
  useDomainAttribute: true
63
63
  },
64
64
  {
65
- type: 'password', // ✅ 기존 password 타입 사용
65
+ type: 'secret', // ✅ 기존 password 타입 사용
66
66
  name: 'password',
67
67
  label: 'password',
68
68
  description: 'Database password',
@@ -1 +1 @@
1
- {"version":3,"file":"mysql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mysql-connector.ts"],"names":[],"mappings":";;;;AAAA,qEAAkC;AAGlC,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACrC,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/C,IAAI,CAAC,iBAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAChD,CAAC;QAED,IAAI,IAAI,GAAG,MAAM,iBAAK,CAAC,UAAU,CAAC;YAChC,IAAI;YACJ,QAAQ;YACR,IAAI;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI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AED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,UAAU,EAAE,sBAAsB;gBACxC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI,CAAC,0BAA0B;aACpD;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,eAAe;aAC7B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;CACF;AAtFD,wCAsFC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import Mysql from 'mysql2/promise'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class mysqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('mysql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database }\n } = connection\n\n let [host, port = '3306'] = endpoint.split(':')\n\n if (!Mysql) {\n throw new Error('mysql module loading failed')\n }\n\n let pool = await Mysql.createPool({\n user,\n password,\n host,\n port: Number(port),\n database\n })\n\n const client = await pool.getConnection()\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result\n try {\n const results = await client.query(query)\n if (results && results.length > 0) {\n result = results[0]\n }\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n return result\n },\n close: client.end()\n })\n\n ConnectionManager.logger.info(`mysql Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n try {\n await client.close()\n ConnectionManager.logger.info(`mysql Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'password', // ✅ 기존 password 타입 사용\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n}\n\nConnectionManager.registerConnector('mysql-connector', new mysqlConnector())\n"]}
1
+ {"version":3,"file":"mysql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/mysql-connector.ts"],"names":[],"mappings":";;;;AAAA,qEAAkC;AAGlC,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACtD,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACrC,GAAG,UAAU,CAAA;QAEd,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE/C,IAAI,CAAC,iBAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAChD,CAAC;Q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AAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnC,CAAC;QAED,sCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ,EAAE,sBAAsB;gBACtC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,mBAAmB;gBAChC,kBAAkB,EAAE,IAAI,CAAC,0BAA0B;aACpD;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,eAAe;aAC7B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;CACF;AAtFD,wCAsFC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import Mysql from 'mysql2/promise'\n\nimport { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class mysqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n ConnectionManager.logger.info('mysql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database }\n } = connection\n\n let [host, port = '3306'] = endpoint.split(':')\n\n if (!Mysql) {\n throw new Error('mysql module loading failed')\n }\n\n let pool = await Mysql.createPool({\n user,\n password,\n host,\n port: Number(port),\n database\n })\n\n const client = await pool.getConnection()\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result\n try {\n const results = await client.query(query)\n if (results && results.length > 0) {\n result = results[0]\n }\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n return result\n },\n close: client.end()\n })\n\n ConnectionManager.logger.info(`mysql Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n try {\n await client.close()\n ConnectionManager.logger.info(`mysql Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'secret', // ✅ 기존 password 타입 사용\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n}\n\nConnectionManager.registerConnector('mysql-connector', new mysqlConnector())\n"]}
@@ -139,7 +139,7 @@ class OracleConnector {
139
139
  useDomainAttribute: true
140
140
  },
141
141
  {
142
- type: 'password',
142
+ type: 'secret',
143
143
  name: 'password',
144
144
  label: 'password',
145
145
  useDomainAttribute: true
@@ -1 +1 @@
1
- {"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/oracle-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AACpC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAA;AACrD,CAAC;AAED,MAAa,eAAe;IAC1B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAA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B;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,6BAA6B;gBAC1C,KAAK,EAAE,gBAAgB;gBACvB,KAAK,EAAE,CAAC;aACT;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,wCAAwC,CAAA;IACjD,CAAC;CACF;AAvMD,0CAuMC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AACzH,4DAA4D;AAE5D,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async recreatePool(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n await oracledb.getPool(poolAlias).close(10)\n await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} recreated.`)\n }\n\n async connect(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n\n var enableStatistics = true\n const pool = await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias,\n enableStatistics\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n dbConnection = await oracledb.getConnection(poolAlias)\n\n taskResult = (\n await dbConnection.execute(query, params, {\n outFormat: oracledb.OBJECT\n })\n ).rows\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n }\n return taskResult\n },\n execute: async (procedure, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n // TODO: need to check if this is available when procedure string is a common query.\n procedure = `BEGIN\n ${procedure}\n END;`\n dbConnection = await oracledb.getConnection(poolAlias)\n\n // console.log('\\n************* stat after get ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n\n const result = await dbConnection.execute(procedure, params, {\n outFormat: oracledb.OBJECT\n })\n\n let paramKeys = Object.keys(params)\n\n for (const paramKey of paramKeys) {\n if (params[paramKey].dir === oracledb?.BIND_OUT) {\n if (params[paramKey].type === oracledb?.CURSOR) {\n const resultSetTemp = result.outBinds[paramKey]\n taskResult[paramKey] = await resultSetTemp.getRows()\n await resultSetTemp.close()\n } else {\n taskResult[paramKey] = result.outBinds[paramKey]\n }\n }\n }\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n\n // console.log('\\n************* stat after close ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n }\n return taskResult\n },\n close: async () => {\n await oracledb.getPool(poolAlias).close(10)\n }\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n\n try {\n await client.close()\n ConnectionManager.logger.info(`Oracle Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n useDomainAttribute: true\n },\n {\n type: 'password',\n name: 'password',\n label: 'password',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'number',\n name: 'poolIncrement',\n placeholder: 'connection incremental size',\n label: 'pool-increment',\n value: 1\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'oracle']\n }\n\n get help() {\n return 'integration/connector/oracle-connector'\n }\n}\n\nConnectionManager.registerConnector('oracle-connector', new OracleConnector())\n\n// need reference:\n// https://download.oracle.com/otn_software/mac/instantclient/193000/instantclient-basiclite-macos.x64-19.3.0.0.0dbru.zip\n// https://node-oracledb.readthedocs.io/en/latest/index.html\n\n// docker pull store/oracle/database-instantclient:12.2.0.1\n"]}
1
+ {"version":3,"file":"oracle-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/oracle-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;A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;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,kBAAkB,EAAE,IAAI;aACzB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8BAA8B;gBAC3C,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,CAAC;aACT;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,6BAA6B;gBAC1C,KAAK,EAAE,gBAAgB;gBACvB,KAAK,EAAE,CAAC;aACT;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,wCAAwC,CAAA;IACjD,CAAC;CACF;AAvMD,0CAuMC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,IAAI,eAAe,EAAE,CAAC,CAAA;AAE9E,kBAAkB;AAClB,yHAAyH;AACzH,4DAA4D;AAE5D,2DAA2D","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var oracledb = require('oracledb')\n} catch (err) {\n logger.error('oracledb module loading failed', err)\n}\n\nexport class OracleConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('oracle-connector connections are ready')\n }\n\n async recreatePool(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n await oracledb.getPool(poolAlias).close(10)\n await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} recreated.`)\n }\n\n async connect(connection: InputConnection) {\n const {\n name,\n endpoint,\n params: { user, password, database, poolMin, poolMax, poolIncrement },\n domain\n } = connection\n\n if (!oracledb) {\n throw new Error('oracledb module loading failed')\n }\n\n const poolAlias = `${domain.name}-${name}`\n\n var enableStatistics = true\n const pool = await oracledb.createPool({\n user,\n password,\n // when oracle not using default port must add connection string with port like localhost:port\n connectString: `${endpoint.trim()}/${database}`,\n poolMin,\n poolMax,\n poolIncrement,\n poolAlias,\n enableStatistics\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n dbConnection = await oracledb.getConnection(poolAlias)\n\n taskResult = (\n await dbConnection.execute(query, params, {\n outFormat: oracledb.OBJECT\n })\n ).rows\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n }\n return taskResult\n },\n execute: async (procedure, params) => {\n let dbConnection: any = {}\n let taskResult: any = {}\n try {\n // TODO: need to check if this is available when procedure string is a common query.\n procedure = `BEGIN\n ${procedure}\n END;`\n dbConnection = await oracledb.getConnection(poolAlias)\n\n // console.log('\\n************* stat after get ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n\n const result = await dbConnection.execute(procedure, params, {\n outFormat: oracledb.OBJECT\n })\n\n let paramKeys = Object.keys(params)\n\n for (const paramKey of paramKeys) {\n if (params[paramKey].dir === oracledb?.BIND_OUT) {\n if (params[paramKey].type === oracledb?.CURSOR) {\n const resultSetTemp = result.outBinds[paramKey]\n taskResult[paramKey] = await resultSetTemp.getRows()\n await resultSetTemp.close()\n } else {\n taskResult[paramKey] = result.outBinds[paramKey]\n }\n }\n }\n } catch (e) {\n if (e.name === 'Error' && e.message.includes('NJS-040')) {\n await this.recreatePool(connection)\n }\n throw e\n } finally {\n await dbConnection.close()\n\n // console.log('\\n************* stat after close ****************')\n // await oracledb.getPool(poolAlias).logStatistics()\n }\n return taskResult\n },\n close: async () => {\n await oracledb.getPool(poolAlias).close(10)\n }\n })\n\n ConnectionManager.logger.info(`Oracle Database(${connection.name}:${database}) at ${endpoint} connected.`)\n }\n\n async disconnect(connection: InputConnection) {\n var client = ConnectionManager.getConnectionInstance(connection)\n\n try {\n await client.close()\n ConnectionManager.logger.info(`Oracle Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n useDomainAttribute: true\n },\n {\n type: 'secret',\n name: 'password',\n label: 'password',\n useDomainAttribute: true\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'number',\n name: 'poolMin',\n placeholder: 'minimum connection-pool size',\n label: 'pool-min',\n value: 0\n },\n {\n type: 'number',\n name: 'poolMax',\n placeholder: 'maximum connection-pool size',\n label: 'pool-max',\n value: 4\n },\n {\n type: 'number',\n name: 'poolIncrement',\n placeholder: 'connection incremental size',\n label: 'pool-increment',\n value: 1\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database', 'oracle']\n }\n\n get help() {\n return 'integration/connector/oracle-connector'\n }\n}\n\nConnectionManager.registerConnector('oracle-connector', new OracleConnector())\n\n// need reference:\n// https://download.oracle.com/otn_software/mac/instantclient/193000/instantclient-basiclite-macos.x64-19.3.0.0.0dbru.zip\n// https://node-oracledb.readthedocs.io/en/latest/index.html\n\n// docker pull store/oracle/database-instantclient:12.2.0.1\n"]}
@@ -98,7 +98,7 @@ class PostgresqlConnector {
98
98
  useDomainAttribute: true
99
99
  },
100
100
  {
101
- type: 'password',
101
+ type: 'secret',
102
102
  name: 'password',
103
103
  label: 'password',
104
104
  description: 'Database password',
@@ -1 +1 @@
1
- {"version":3,"file":"postgresql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/postgresql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjE,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,EACJ,QAAQ,EACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,EACpG,GAAG,UAAU,CAAA;QACd,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CA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AAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var { Client, Pool } = require('pg')\n} catch (err) {\n logger.error('postgresql module loading failed', err)\n}\n\nexport class PostgresqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('postgresql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database, maxPoolConnection, idleTimeoutMillis, connectionTimeoutMillis }\n } = connection\n const [host, port = 5432] = endpoint.split(':')\n\n if (!Pool) {\n throw new Error('postgresql module loading failed')\n }\n\n // create a new pool\n const pool = new Pool({\n user,\n host,\n database,\n password,\n port: Number(port),\n max: maxPoolConnection || 10,\n idleTimeoutMillis: idleTimeoutMillis || 30000,\n connectionTimeoutMillis: connectionTimeoutMillis || 2000\n })\n\n pool.on('error', (err, client) => {\n logger.error('unexpected error on postgres pool.', err)\n })\n\n try {\n // try to connect to database to check the connection at initial time\n const entryConnection = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n entryConnection.release()\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n try {\n // get a connection from the pool\n var client = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n\n client?.on('error', async err => {\n logger.error('unexpected error on postgres client.', err)\n ConnectionManager.logger.error(err)\n })\n\n // try to query\n var result = (await client.query(query, params)).rows\n } catch (e) {\n ConnectionManager.logger.error(e)\n throw e\n } finally {\n // release the connection back to the pool\n client?.release()\n }\n return result\n },\n close: async () => {\n // close the pool\n await pool?.end()\n }\n })\n\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} connected.`)\n } catch (e) {\n ConnectionManager.logger.error(\n `PostgresSQL Database(${connection.name}:${database}) at ${endpoint} not connected.`,\n e\n )\n }\n }\n\n async disconnect(connection: InputConnection) {\n var connectionInstance = ConnectionManager.getConnectionInstance(connection)\n try {\n await connectionInstance.close()\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'password',\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n },\n {\n type: 'number',\n name: 'maxPoolConnection',\n label: 'maxPoolConnection',\n description: 'Maximum pool connections'\n },\n {\n type: 'number',\n name: 'idleTimeoutMillis',\n label: 'idleTimeoutMillis',\n description: 'Idle timeout in milliseconds',\n placeholder: 'milli-seconds'\n },\n {\n type: 'number',\n name: 'connectionTimeoutMillis',\n label: 'connectionTimeoutMillis',\n description: 'Connection timeout in milliseconds',\n placeholder: 'milli-seconds'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n\n get help() {\n return 'integration/connector/postgresql-connector'\n }\n}\n\nConnectionManager.registerConnector('postgresql-connector', new PostgresqlConnector())\n"]}
1
+ {"version":3,"file":"postgresql-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/postgresql-connector.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,8DAAyD;AAIzD,IAAI,CAAC;IACH,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACtC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,YAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,MAAa,mBAAmB;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,EAAE,mBAAmB;gBACzB,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EAAE,0BAA0B;aACxC;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EAAE,8BAA8B;gBAC3C,WAAW,EAAE,eAAe;aAC7B;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,yBAAyB;gBAC/B,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EAAE,oCAAoC;gBACjD,WAAW,EAAE,eAAe;aAC7B;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,4CAA4C,CAAA;IACrD,CAAC;CACF;AAjJD,kDAiJC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA","sourcesContent":["import { logger } from '@things-factory/env'\n\nimport { ConnectionManager } from '../connection-manager'\nimport { Connector } from '../types'\nimport { InputConnection } from '../../service/connection/connection-type'\n\ntry {\n var { Client, Pool } = require('pg')\n} catch (err) {\n logger.error('postgresql module loading failed', err)\n}\n\nexport class PostgresqlConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('postgresql-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const {\n endpoint,\n params: { user, password, database, maxPoolConnection, idleTimeoutMillis, connectionTimeoutMillis }\n } = connection\n const [host, port = 5432] = endpoint.split(':')\n\n if (!Pool) {\n throw new Error('postgresql module loading failed')\n }\n\n // create a new pool\n const pool = new Pool({\n user,\n host,\n database,\n password,\n port: Number(port),\n max: maxPoolConnection || 10,\n idleTimeoutMillis: idleTimeoutMillis || 30000,\n connectionTimeoutMillis: connectionTimeoutMillis || 2000\n })\n\n pool.on('error', (err, client) => {\n logger.error('unexpected error on postgres pool.', err)\n })\n\n try {\n // try to connect to database to check the connection at initial time\n const entryConnection = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n entryConnection.release()\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n try {\n // get a connection from the pool\n var client = await pool.connect().catch(async e => {\n ConnectionManager.logger.error(e)\n throw e\n })\n\n client?.on('error', async err => {\n logger.error('unexpected error on postgres client.', err)\n ConnectionManager.logger.error(err)\n })\n\n // try to query\n var result = (await client.query(query, params)).rows\n } catch (e) {\n ConnectionManager.logger.error(e)\n throw e\n } finally {\n // release the connection back to the pool\n client?.release()\n }\n return result\n },\n close: async () => {\n // close the pool\n await pool?.end()\n }\n })\n\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}:${database}) at ${endpoint} connected.`)\n } catch (e) {\n ConnectionManager.logger.error(\n `PostgresSQL Database(${connection.name}:${database}) at ${endpoint} not connected.`,\n e\n )\n }\n }\n\n async disconnect(connection: InputConnection) {\n var connectionInstance = ConnectionManager.getConnectionInstance(connection)\n try {\n await connectionInstance.close()\n ConnectionManager.logger.info(`PostgresSQL Database(${connection.name}) closed.`)\n } catch (e) {\n ConnectionManager.logger.error(e)\n }\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'string',\n name: 'user',\n label: 'user',\n description: 'Database username',\n useDomainAttribute: true\n },\n {\n type: 'secret',\n name: 'password',\n label: 'password',\n description: 'Database password',\n useDomainAttribute: true // 🔐 Domain attributes 사용\n },\n {\n type: 'string',\n name: 'database',\n label: 'database',\n description: 'Database name'\n },\n {\n type: 'number',\n name: 'maxPoolConnection',\n label: 'maxPoolConnection',\n description: 'Maximum pool connections'\n },\n {\n type: 'number',\n name: 'idleTimeoutMillis',\n label: 'idleTimeoutMillis',\n description: 'Idle timeout in milliseconds',\n placeholder: 'milli-seconds'\n },\n {\n type: 'number',\n name: 'connectionTimeoutMillis',\n label: 'connectionTimeoutMillis',\n description: 'Connection timeout in milliseconds',\n placeholder: 'milli-seconds'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\n }\n\n get help() {\n return 'integration/connector/postgresql-connector'\n }\n}\n\nConnectionManager.registerConnector('postgresql-connector', new PostgresqlConnector())\n"]}
@@ -36,9 +36,9 @@ class PyrunConnector {
36
36
  }
37
37
  get parameterSpec() {
38
38
  return [
39
- { type: 'string', name: 'username', label: 'username', required: false, useDomainAttribute: true },
40
- { type: 'password', name: 'password', label: 'password', required: false, useDomainAttribute: true },
41
- { type: 'string', name: 'token', label: 'token', required: false, useDomainAttribute: true }
39
+ { type: 'secret', name: 'username', label: 'username', required: false, useDomainAttribute: true },
40
+ { type: 'secret', name: 'password', label: 'password', required: false, useDomainAttribute: true },
41
+ { type: 'secret', name: 'token', label: 'token', required: false, useDomainAttribute: true }
42
42
  ];
43
43
  }
44
44
  get taskPrefixes() {
@@ -1 +1 @@
1
- {"version":3,"file":"pyrun-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/pyrun-connector.ts"],"names":[],"mappings":";;;AACA,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjE,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,MAAM,CAAA;QAErD,IAAI,CAAC,KAAK,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACnC,oCAAoC;YACpC,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,QAAQ,aAAa,CAAA;YACpD,MAAM,GA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AAkB,EAAE,IAAI,EAAE;YACpG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE;SAC7F,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,OAAO,CAAC,CAAA;IAClB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,yCAAyC,CAAA;IAClD,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AAzDD,wCAyDC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class PyrunConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n ConnectionManager.logger.info('pyrun-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n var { username, password, token } = connection.params\n\n if (!token && username && password) {\n // /auth/login 엔드포인트로 로그인하여 토큰 발급 시도\n const loginUrl = `${connection.endpoint}/auth/login`\n const res = await fetch(loginUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ username, password })\n })\n if (!res.ok) {\n const error = await res.text()\n throw new Error(`pyrun-connector 인증 실패: ${res.status} ${error}`)\n }\n\n var data = await res.json()\n token = data.access_token\n }\n\n ConnectionManager.addConnectionInstance(connection, {\n ...connection,\n token\n })\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection: InputConnection) {\n ConnectionManager.removeConnectionInstance(connection)\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n { type: 'string', name: 'username', label: 'username', required: false, useDomainAttribute: true },\n { type: 'password', name: 'password', label: 'password', required: false, useDomainAttribute: true },\n { type: 'string', name: 'token', label: 'token', required: false, useDomainAttribute: true }\n ]\n }\n\n get taskPrefixes() {\n return ['pyrun']\n }\n\n get description() {\n return 'Python Runner(pyrun) REST API Connector'\n }\n\n get help() {\n return 'integration/connector/pyrun-connector'\n }\n}\n\nConnectionManager.registerConnector('pyrun-connector', new PyrunConnector())\n"]}
1
+ {"version":3,"file":"pyrun-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/pyrun-connector.ts"],"names":[],"mappings":";;;AACA,8DAAyD;AAGzD,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjE,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAA;IACxE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,MAAM,CAAA;QAErD,IAAI,CAAC,KAAK,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;YACnC,oCAAoC;YACpC,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,QAAQ,aAAa,CAAA;YACpD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;gBAChC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;aAC7C,CAAC,CAAA;YACF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAA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,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AAzDD,wCAyDC;AAED,sCAAiB,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import { Connector } from '../types'\nimport { ConnectionManager } from '../connection-manager'\nimport { InputConnection } from '../../service/connection/connection-type'\n\nexport class PyrunConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n ConnectionManager.logger.info('pyrun-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n var { username, password, token } = connection.params\n\n if (!token && username && password) {\n // /auth/login 엔드포인트로 로그인하여 토큰 발급 시도\n const loginUrl = `${connection.endpoint}/auth/login`\n const res = await fetch(loginUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ username, password })\n })\n if (!res.ok) {\n const error = await res.text()\n throw new Error(`pyrun-connector 인증 실패: ${res.status} ${error}`)\n }\n\n var data = await res.json()\n token = data.access_token\n }\n\n ConnectionManager.addConnectionInstance(connection, {\n ...connection,\n token\n })\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection: InputConnection) {\n ConnectionManager.removeConnectionInstance(connection)\n ConnectionManager.logger.info(`pyrun-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n { type: 'secret', name: 'username', label: 'username', required: false, useDomainAttribute: true },\n { type: 'secret', name: 'password', label: 'password', required: false, useDomainAttribute: true },\n { type: 'secret', name: 'token', label: 'token', required: false, useDomainAttribute: true }\n ]\n }\n\n get taskPrefixes() {\n return ['pyrun']\n }\n\n get description() {\n return 'Python Runner(pyrun) REST API Connector'\n }\n\n get help() {\n return 'integration/connector/pyrun-connector'\n }\n}\n\nConnectionManager.registerConnector('pyrun-connector', new PyrunConnector())\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const https_1 = tslib_1.__importDefault(require("https"));
5
+ const url_1 = require("url");
6
+ const task_registry_1 = require("../task-registry");
7
+ const connection_manager_1 = require("../connection-manager");
8
+ async function HeadlessDelete(step, { logger, data, domain }) {
9
+ const { connection: connectionName, params: stepOptions } = step;
10
+ const { headers: requestHeaders, path, queryParams } = stepOptions || {};
11
+ const connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
12
+ if (!connection) {
13
+ throw new Error(`Connection '${connectionName}' is not established.`);
14
+ }
15
+ const { endpoint, params: connectionParams, acquireSessionPage, releasePage } = connection;
16
+ const headers = {
17
+ ...requestHeaders
18
+ };
19
+ const options = {
20
+ method: 'DELETE',
21
+ headers
22
+ };
23
+ const { rejectUnauthorized } = connectionParams;
24
+ if (!rejectUnauthorized) {
25
+ const httpsAgent = new https_1.default.Agent({
26
+ rejectUnauthorized
27
+ });
28
+ options.agent = httpsAgent;
29
+ }
30
+ const page = await acquireSessionPage();
31
+ try {
32
+ page.on('console', async (msg) => {
33
+ console.log(`[browser ${msg.type()}] ${msg.text()}`);
34
+ });
35
+ page.on('requestfailed', request => {
36
+ console.log('Request failed:', request.url());
37
+ });
38
+ await page.goto(endpoint, { waitUntil: 'networkidle2' });
39
+ // URL 구성 - queryParams가 있으면 추가
40
+ let requestUrl = new url_1.URL(path, endpoint);
41
+ if (queryParams && typeof queryParams === 'object') {
42
+ Object.keys(queryParams).forEach(key => {
43
+ if (queryParams[key] !== null && queryParams[key] !== undefined) {
44
+ requestUrl.searchParams.append(key, String(queryParams[key]));
45
+ }
46
+ });
47
+ }
48
+ const response = await page.evaluate(async (urlString, options) => {
49
+ const response = await fetch(urlString, options);
50
+ if (!response.ok) {
51
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
52
+ }
53
+ const contentType = response.headers.get('content-type') || '';
54
+ if (contentType.includes('application/json')) {
55
+ return await response.json();
56
+ }
57
+ else if (contentType.includes('text/')) {
58
+ return await response.text();
59
+ }
60
+ else {
61
+ // 응답이 없는 경우 (204 No Content 등)
62
+ return null;
63
+ }
64
+ }, requestUrl.toString(), options);
65
+ return {
66
+ data: response
67
+ };
68
+ }
69
+ catch (error) {
70
+ logger.error('Error in HeadlessDelete:', error);
71
+ throw error;
72
+ }
73
+ finally {
74
+ await releasePage(page);
75
+ }
76
+ }
77
+ HeadlessDelete.parameterSpec = [
78
+ {
79
+ type: 'string',
80
+ name: 'path',
81
+ label: 'path'
82
+ },
83
+ {
84
+ type: 'http-headers',
85
+ name: 'headers',
86
+ label: 'headers'
87
+ },
88
+ {
89
+ type: 'options',
90
+ name: 'queryParams',
91
+ label: 'query-parameters'
92
+ }
93
+ ];
94
+ task_registry_1.TaskRegistry.registerTaskHandler('headless-delete', HeadlessDelete);
95
+ //# sourceMappingURL=headless-delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headless-delete.js","sourceRoot":"","sources":["../../../server/engine/task/headless-delete.ts"],"names":[],"mappings":";;;AAAA,0DAAyB;AACzB,6BAAyB;AAEzB,oDAA+C;AAC/C,8DAAyD;AAEzD,KAAK,UAAU,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAC1D,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAChE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,IAAI,EAAE,CAAA;IAExE,MAAM,UAAU,GAAG,MAAM,sCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAE9F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,eAAe,cAAc,uBAAuB,CAAC,CAAA;IACvE,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB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,CAAC,CAAA;IACzB,CAAC;AACH,CAAC;AAED,cAAc,CAAC,aAAa,GAAG;IAC7B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,kBAAkB;KAC1B;CACF,CAAA;AAED,4BAAY,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAA","sourcesContent":["import https from 'https'\nimport { URL } from 'url'\n\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\n\nasync function HeadlessDelete(step, { logger, data, domain }) {\n const { connection: connectionName, params: stepOptions } = step\n const { headers: requestHeaders, path, queryParams } = stepOptions || {}\n\n const connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!connection) {\n throw new Error(`Connection '${connectionName}' is not established.`)\n }\n\n const { endpoint, params: connectionParams, acquireSessionPage, releasePage } = connection\n\n const headers = {\n ...requestHeaders\n }\n\n const options = {\n method: 'DELETE',\n headers\n } as any\n\n const { rejectUnauthorized } = connectionParams\n\n if (!rejectUnauthorized) {\n const httpsAgent = new https.Agent({\n rejectUnauthorized\n })\n options.agent = httpsAgent\n }\n\n const page = await acquireSessionPage()\n\n try {\n page.on('console', async msg => {\n console.log(`[browser ${msg.type()}] ${msg.text()}`)\n })\n\n page.on('requestfailed', request => {\n console.log('Request failed:', request.url())\n })\n\n await page.goto(endpoint, { waitUntil: 'networkidle2' })\n\n // URL 구성 - queryParams가 있으면 추가\n let requestUrl = new URL(path, endpoint)\n if (queryParams && typeof queryParams === 'object') {\n Object.keys(queryParams).forEach(key => {\n if (queryParams[key] !== null && queryParams[key] !== undefined) {\n requestUrl.searchParams.append(key, String(queryParams[key]))\n }\n })\n }\n\n const response = await page.evaluate(\n async (urlString, options) => {\n const response = await fetch(urlString, options)\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const contentType = response.headers.get('content-type') || ''\n \n if (contentType.includes('application/json')) {\n return await response.json()\n } else if (contentType.includes('text/')) {\n return await response.text()\n } else {\n // 응답이 없는 경우 (204 No Content 등)\n return null\n }\n },\n requestUrl.toString(),\n options\n )\n\n return {\n data: response\n }\n } catch (error) {\n logger.error('Error in HeadlessDelete:', error)\n throw error\n } finally {\n await releasePage(page)\n }\n}\n\nHeadlessDelete.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'http-headers',\n name: 'headers',\n label: 'headers'\n },\n {\n type: 'options',\n name: 'queryParams',\n label: 'query-parameters'\n }\n]\n\nTaskRegistry.registerTaskHandler('headless-delete', HeadlessDelete)"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const https_1 = tslib_1.__importDefault(require("https"));
5
+ const url_1 = require("url");
6
+ const task_registry_1 = require("../task-registry");
7
+ const connection_manager_1 = require("../connection-manager");
8
+ async function HeadlessGet(step, { logger, data, domain }) {
9
+ const { connection: connectionName, params: stepOptions } = step;
10
+ const { headers: requestHeaders, path, queryParams } = stepOptions || {};
11
+ const connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
12
+ if (!connection) {
13
+ throw new Error(`Connection '${connectionName}' is not established.`);
14
+ }
15
+ const { endpoint, params: connectionParams, acquireSessionPage, releasePage } = connection;
16
+ const headers = {
17
+ ...requestHeaders
18
+ };
19
+ const options = {
20
+ method: 'GET',
21
+ headers
22
+ };
23
+ const { rejectUnauthorized } = connectionParams;
24
+ if (!rejectUnauthorized) {
25
+ const httpsAgent = new https_1.default.Agent({
26
+ rejectUnauthorized
27
+ });
28
+ options.agent = httpsAgent;
29
+ }
30
+ const page = await acquireSessionPage();
31
+ try {
32
+ page.on('console', async (msg) => {
33
+ console.log(`[browser ${msg.type()}] ${msg.text()}`);
34
+ });
35
+ page.on('requestfailed', request => {
36
+ console.log('Request failed:', request.url());
37
+ });
38
+ await page.goto(endpoint, { waitUntil: 'networkidle2' });
39
+ // URL 구성 - queryParams가 있으면 추가
40
+ let requestUrl = new url_1.URL(path, endpoint);
41
+ if (queryParams && typeof queryParams === 'object') {
42
+ Object.keys(queryParams).forEach(key => {
43
+ if (queryParams[key] !== null && queryParams[key] !== undefined) {
44
+ requestUrl.searchParams.append(key, String(queryParams[key]));
45
+ }
46
+ });
47
+ }
48
+ const response = await page.evaluate(async (urlString, options) => {
49
+ const response = await fetch(urlString, options);
50
+ if (!response.ok) {
51
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
52
+ }
53
+ const contentType = response.headers.get('content-type') || '';
54
+ if (contentType.includes('application/json')) {
55
+ return await response.json();
56
+ }
57
+ else if (contentType.includes('text/')) {
58
+ return await response.text();
59
+ }
60
+ else {
61
+ // Binary data나 기타 타입의 경우
62
+ const arrayBuffer = await response.arrayBuffer();
63
+ return Array.from(new Uint8Array(arrayBuffer));
64
+ }
65
+ }, requestUrl.toString(), options);
66
+ return {
67
+ data: response
68
+ };
69
+ }
70
+ catch (error) {
71
+ logger.error('Error in HeadlessGet:', error);
72
+ throw error;
73
+ }
74
+ finally {
75
+ await releasePage(page);
76
+ }
77
+ }
78
+ HeadlessGet.parameterSpec = [
79
+ {
80
+ type: 'string',
81
+ name: 'path',
82
+ label: 'path'
83
+ },
84
+ {
85
+ type: 'http-headers',
86
+ name: 'headers',
87
+ label: 'headers'
88
+ },
89
+ {
90
+ type: 'options',
91
+ name: 'queryParams',
92
+ label: 'query-parameters'
93
+ }
94
+ ];
95
+ task_registry_1.TaskRegistry.registerTaskHandler('headless-get', HeadlessGet);
96
+ //# sourceMappingURL=headless-get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headless-get.js","sour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AAI,EAAE,CAAA;YAE9D,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBAC7C,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAC9B,CAAC;iBAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,yBAAyB;gBACzB,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAA;gBAChD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAA;YAChD,CAAC;QACH,CAAC,EACD,UAAU,CAAC,QAAQ,EAAE,EACrB,OAAO,CACR,CAAA;QAED,OAAO;YACL,IAAI,EAAE,QAAQ;SACf,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;QAC5C,MAAM,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;AACH,CAAC;AAED,WAAW,CAAC,aAAa,GAAG;IAC1B;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;KACjB;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,kBAAkB;KAC1B;CACF,CAAA;AAED,4BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import https from 'https'\nimport { URL } from 'url'\n\nimport { TaskRegistry } from '../task-registry'\nimport { ConnectionManager } from '../connection-manager'\n\nasync function HeadlessGet(step, { logger, data, domain }) {\n const { connection: connectionName, params: stepOptions } = step\n const { headers: requestHeaders, path, queryParams } = stepOptions || {}\n\n const connection = await ConnectionManager.getConnectionInstanceByName(domain, connectionName)\n\n if (!connection) {\n throw new Error(`Connection '${connectionName}' is not established.`)\n }\n\n const { endpoint, params: connectionParams, acquireSessionPage, releasePage } = connection\n\n const headers = {\n ...requestHeaders\n }\n\n const options = {\n method: 'GET',\n headers\n } as any\n\n const { rejectUnauthorized } = connectionParams\n\n if (!rejectUnauthorized) {\n const httpsAgent = new https.Agent({\n rejectUnauthorized\n })\n options.agent = httpsAgent\n }\n\n const page = await acquireSessionPage()\n\n try {\n page.on('console', async msg => {\n console.log(`[browser ${msg.type()}] ${msg.text()}`)\n })\n\n page.on('requestfailed', request => {\n console.log('Request failed:', request.url())\n })\n\n await page.goto(endpoint, { waitUntil: 'networkidle2' })\n\n // URL 구성 - queryParams가 있으면 추가\n let requestUrl = new URL(path, endpoint)\n if (queryParams && typeof queryParams === 'object') {\n Object.keys(queryParams).forEach(key => {\n if (queryParams[key] !== null && queryParams[key] !== undefined) {\n requestUrl.searchParams.append(key, String(queryParams[key]))\n }\n })\n }\n\n const response = await page.evaluate(\n async (urlString, options) => {\n const response = await fetch(urlString, options)\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const contentType = response.headers.get('content-type') || ''\n \n if (contentType.includes('application/json')) {\n return await response.json()\n } else if (contentType.includes('text/')) {\n return await response.text()\n } else {\n // Binary data나 기타 타입의 경우\n const arrayBuffer = await response.arrayBuffer()\n return Array.from(new Uint8Array(arrayBuffer))\n }\n },\n requestUrl.toString(),\n options\n )\n\n return {\n data: response\n }\n } catch (error) {\n logger.error('Error in HeadlessGet:', error)\n throw error\n } finally {\n await releasePage(page)\n }\n}\n\nHeadlessGet.parameterSpec = [\n {\n type: 'string',\n name: 'path',\n label: 'path'\n },\n {\n type: 'http-headers',\n name: 'headers',\n label: 'headers'\n },\n {\n type: 'options',\n name: 'queryParams',\n label: 'query-parameters'\n }\n]\n\nTaskRegistry.registerTaskHandler('headless-get', HeadlessGet)"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const https_1 = tslib_1.__importDefault(require("https"));
5
+ const url_1 = require("url");
6
+ const utils_1 = require("@things-factory/utils");
7
+ const task_registry_1 = require("../task-registry");
8
+ const connection_manager_1 = require("../connection-manager");
9
+ async function HeadlessPatch(step, { logger, data, domain }) {
10
+ const { connection: connectionName, params: stepOptions } = step;
11
+ const { headers: requestHeaders, contentType, path, accessor, queryParams } = stepOptions || {};
12
+ const connection = await connection_manager_1.ConnectionManager.getConnectionInstanceByName(domain, connectionName);
13
+ if (!connection) {
14
+ throw new Error(`Connection '${connectionName}' is not established.`);
15
+ }
16
+ const { endpoint, params: connectionParams, acquireSessionPage, releasePage } = connection;
17
+ const headers = {
18
+ ...requestHeaders
19
+ };
20
+ let body = (0, utils_1.access)(accessor, data);
21
+ if (contentType && body) {
22
+ headers['content-type'] = contentType;
23
+ switch (contentType) {
24
+ case 'text/plain':
25
+ body = JSON.stringify(body);
26
+ break;
27
+ case 'application/json':
28
+ body = JSON.stringify(body);
29
+ break;
30
+ case 'application/x-www-form-urlencoded':
31
+ const searchParams = new URLSearchParams();
32
+ for (const prop in body) {
33
+ searchParams.set(prop, body[prop]);
34
+ }
35
+ body = searchParams.toString();
36
+ break;
37
+ }
38
+ }
39
+ const options = {
40
+ method: 'PATCH',
41
+ headers,
42
+ body
43
+ };
44
+ const { rejectUnauthorized } = connectionParams;
45
+ if (!rejectUnauthorized) {
46
+ const httpsAgent = new https_1.default.Agent({
47
+ rejectUnauthorized
48
+ });
49
+ options.agent = httpsAgent;
50
+ }
51
+ const page = await acquireSessionPage();
52
+ try {
53
+ page.on('console', async (msg) => {
54
+ console.log(`[browser ${msg.type()}] ${msg.text()}`);
55
+ });
56
+ page.on('requestfailed', request => {
57
+ console.log('Request failed:', request.url());
58
+ });
59
+ await page.goto(endpoint, { waitUntil: 'networkidle2' });
60
+ // URL 구성 - queryParams가 있으면 추가
61
+ let requestUrl = new url_1.URL(path, endpoint);
62
+ if (queryParams && typeof queryParams === 'object') {
63
+ Object.keys(queryParams).forEach(key => {
64
+ if (queryParams[key] !== null && queryParams[key] !== undefined) {
65
+ requestUrl.searchParams.append(key, String(queryParams[key]));
66
+ }
67
+ });
68
+ }
69
+ const response = await page.evaluate(async (urlString, options) => {
70
+ const response = await fetch(urlString, options);
71
+ if (!response.ok) {
72
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
73
+ }
74
+ const contentType = response.headers.get('content-type') || '';
75
+ if (contentType.includes('application/json')) {
76
+ return await response.json();
77
+ }
78
+ else if (contentType.includes('text/')) {
79
+ return await response.text();
80
+ }
81
+ else {
82
+ // Binary data나 기타 타입의 경우
83
+ const arrayBuffer = await response.arrayBuffer();
84
+ return Array.from(new Uint8Array(arrayBuffer));
85
+ }
86
+ }, requestUrl.toString(), options);
87
+ return {
88
+ data: response
89
+ };
90
+ }
91
+ catch (error) {
92
+ logger.error('Error in HeadlessPatch:', error);
93
+ throw error;
94
+ }
95
+ finally {
96
+ await releasePage(page);
97
+ }
98
+ }
99
+ HeadlessPatch.parameterSpec = [
100
+ {
101
+ type: 'string',
102
+ name: 'path',
103
+ label: 'path'
104
+ },
105
+ {
106
+ type: 'http-headers',
107
+ name: 'headers',
108
+ label: 'headers'
109
+ },
110
+ {
111
+ type: 'options',
112
+ name: 'queryParams',
113
+ label: 'query-parameters'
114
+ },
115
+ {
116
+ type: 'select',
117
+ name: 'contentType',
118
+ label: 'content-type',
119
+ property: {
120
+ options: [
121
+ { display: '', value: '' },
122
+ { display: 'application/json', value: 'application/json' },
123
+ { display: 'text/plain', value: 'text/plain' },
124
+ { display: 'application/x-www-form-urlencoded', value: 'application/x-www-form-urlencoded' }
125
+ ]
126
+ }
127
+ },
128
+ {
129
+ type: 'scenario-step-input',
130
+ name: 'accessor',
131
+ label: 'accessor'
132
+ }
133
+ ];
134
+ task_registry_1.TaskRegistry.registerTaskHandler('headless-patch', HeadlessPatch);
135
+ //# sourceMappingURL=headless-patch.js.map