@things-factory/integration-base 7.0.1-beta.7 → 7.0.1-beta.9

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,7 +15,7 @@ class MssqlConnector {
15
15
  connection_manager_1.ConnectionManager.logger.info('mssql-connector connections are ready');
16
16
  }
17
17
  async connect(connection) {
18
- const { endpoint, params: { user, password, database, encrypt = 'Y' } } = connection;
18
+ const { endpoint, params: { user, password, database, encrypt = 'Y', trustServerCertificate } } = connection;
19
19
  const [host, port = 1433] = endpoint.split(':');
20
20
  if (!Client) {
21
21
  throw new Error('mssql module loading failed');
@@ -24,9 +24,17 @@ class MssqlConnector {
24
24
  // client is pool
25
25
  user,
26
26
  password,
27
- server: `${host}`,
28
- database: `${database}`,
29
- encrypt: `${encrypt === 'Y'}`
27
+ server: host,
28
+ database,
29
+ pool: {
30
+ max: 10,
31
+ min: 0,
32
+ idleTimeoutMillis: 30000
33
+ },
34
+ options: {
35
+ encrypt: encrypt === 'Y',
36
+ trustServerCertificate: trustServerCertificate === 'Y'
37
+ }
30
38
  });
31
39
  connection_manager_1.ConnectionManager.addConnectionInstance(connection, {
32
40
  query: async (query, params) => {
@@ -74,6 +82,14 @@ class MssqlConnector {
74
82
  property: {
75
83
  options: ['Y', 'N']
76
84
  }
85
+ },
86
+ {
87
+ type: 'select',
88
+ name: 'trustServerCertificate',
89
+ label: 'trust-server-certificate',
90
+ property: {
91
+ options: ['Y', 'N']
92
+ }
77
93
  }
78
94
  ];
79
95
  }
@@ -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;IACF,IAAI,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC9B;AAAC,OAAO,GAAG,EAAE;IACZ,YAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;CAC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I,IAAI,QAAQ,QAAQ,QAAQ,aAAa,CAAC,CAAA;IAC3G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAA2B;QAC1C,IAAI,MAAM,GAAG,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;QAChE,IAAI;YACF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;YACpB,sCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,UAAU,CAAC,IAAI,WAAW,CAAC,CAAA;SAC5E;QAAC,OAAO,CAAC,EAAE;YACV,sCAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;SAClC;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;aACd;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,UAAU;aAClB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;iBACpB;aACF;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,UAAU,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AAzFD,wCAyFC;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 Client = require('mssql')\n} catch (err) {\n logger.error('mssql module loading failed')\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, encrypt = 'Y' }\n } = connection\n\n const [host, port = 1433] = endpoint.split(':')\n\n if (!Client) {\n throw new Error('mssql module loading failed')\n }\n\n const client = await Client.connect({\n // client is pool\n user,\n password,\n server: `${host}`,\n database: `${database}`,\n encrypt: `${encrypt === 'Y'}`\n })\n\n ConnectionManager.addConnectionInstance(connection, {\n query: async (query, params) => {\n var result = await client.query(query)\n return result.recordset\n\n // return (await client.query(query))\n },\n close: client.close.bind(client)\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 },\n {\n type: 'password',\n name: 'password',\n label: 'password'\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'select',\n name: 'encrypt',\n label: 'encrypt',\n property: {\n options: ['Y', 'N']\n }\n }\n ]\n }\n\n get taskPrefixes() {\n return ['database']\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;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ACF;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,CAAC,CAAA;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,uCAAuC,CAAA;IAChD,CAAC;CACF;AAzGD,wCAyGC;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 Client = require('mssql')\n} catch (err) {\n logger.error('mssql module loading failed')\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, encrypt = 'Y', trustServerCertificate }\n } = connection\n\n const [host, port = 1433] = endpoint.split(':')\n\n if (!Client) {\n throw new Error('mssql module loading failed')\n }\n\n const client = await Client.connect({\n // client is pool\n user,\n password,\n server: host,\n database,\n pool: {\n max: 10,\n min: 0,\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 client.query(query)\n return result.recordset\n\n // return (await client.query(query))\n },\n close: client.close.bind(client)\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 },\n {\n type: 'password',\n name: 'password',\n label: 'password'\n },\n {\n type: 'string',\n name: 'database',\n placeholder: 'SID',\n label: 'database'\n },\n {\n type: 'select',\n name: 'encrypt',\n label: 'encrypt',\n property: {\n options: ['Y', 'N']\n }\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']\n }\n\n get help() {\n return 'integration/connector/mssql-connector'\n }\n}\n\nConnectionManager.registerConnector('mssql-connector', new MssqlConnector())\n"]}