@things-factory/edge 10.0.0-beta.21 → 10.0.0-beta.23

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.
@@ -57,7 +57,7 @@ async function initConnectConnectionsSubscription() {
57
57
  });
58
58
  }
59
59
  async function connectConnections(connections) {
60
- console.log('connectConnections ...', connections);
60
+ env_1.logger.info('connectConnections ...', connections);
61
61
  connections.forEach(connection => connectConnection(connection));
62
62
  }
63
63
  async function connectConnection(connection) {
@@ -1 +1 @@
1
- {"version":3,"file":"connect-connections.js","sourceRoot":"","sources":["../../server/controllers/connect-connections.ts"],"names":[],"mappings":";;AAQA,gFAqDC;;AA7DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAkG;AAElG,qDAAmD;AAG5C,KAAK,UAAU,kCAAkC;IACtD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,EAAC,YAAY,EAAC,EAAE;YACzB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,kBAAkB,IAAI,EAAE,CAAA;YAC/D,MAAM,kBAAkB,CACtB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;oBAE5C,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM;qBACP,CAAA;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CACH,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE;YACb,YAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,YAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,WAAyB;IACzD,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAA;IAElD,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;AAClE,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,UAAsB;IACrD,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IAE3B,MAAM,GAAG,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;IAC/D,IAAI,GAAG,EAAE,CAAC;QACR,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,SAAS,GAAG,oCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { logger } from '@things-factory/env'\nimport { Connection, ConnectionManager, ConnectionStatus } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\nimport { LogAggregator } from './log-aggregator'\n\nexport async function initConnectConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n connectConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.connectConnections || []\n await connectConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n ...connection,\n params\n }\n } catch (e) {\n return {\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function connectConnections(connections: Connection[]) {\n console.log('connectConnections ...', connections)\n\n connections.forEach(connection => connectConnection(connection))\n}\n\nasync function connectConnection(connection: Connection) {\n const { type } = connection\n\n const old = ConnectionManager.getConnectionInstance(connection)\n if (old) {\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n const connector = ConnectionManager.getConnector(type)\n if (!connector) {\n return\n }\n\n await connector.connect(connection)\n}\n"]}
1
+ {"version":3,"file":"connect-connections.js","sourceRoot":"","sources":["../../server/controllers/connect-connections.ts"],"names":[],"mappings":";;AAOA,gFAqDC;;AA5DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAgF;AAEhF,qDAAmD;AAE5C,KAAK,UAAU,kCAAkC;IACtD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,EAAC,YAAY,EAAC,EAAE;YACzB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,kBAAkB,IAAI,EAAE,CAAA;YAC/D,MAAM,kBAAkB,CACtB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;oBAE5C,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM;qBACP,CAAA;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CACH,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE;YACb,YAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,YAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,WAAyB;IACzD,YAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAA;IAElD,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;AAClE,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,UAAsB;IACrD,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IAE3B,MAAM,GAAG,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;IAC/D,IAAI,GAAG,EAAE,CAAC;QACR,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,SAAS,GAAG,oCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { logger } from '@things-factory/env'\nimport { Connection, ConnectionManager } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\n\nexport async function initConnectConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n connectConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.connectConnections || []\n await connectConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n ...connection,\n params\n }\n } catch (e) {\n return {\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function connectConnections(connections: Connection[]) {\n logger.info('connectConnections ...', connections)\n\n connections.forEach(connection => connectConnection(connection))\n}\n\nasync function connectConnection(connection: Connection) {\n const { type } = connection\n\n const old = ConnectionManager.getConnectionInstance(connection)\n if (old) {\n ConnectionManager.removeConnectionInstance(connection)\n }\n\n const connector = ConnectionManager.getConnector(type)\n if (!connector) {\n return\n }\n\n await connector.connect(connection)\n}\n"]}
@@ -57,7 +57,7 @@ async function initDisconnectConnectionsSubscription() {
57
57
  });
58
58
  }
59
59
  async function disconnectConnections(connections) {
60
- console.log('disconnectConnections ...', connections);
60
+ env_1.logger.info('disconnectConnections ...', connections);
61
61
  connections.forEach(connection => disconnectConnection(connection));
62
62
  }
63
63
  async function disconnectConnection(connection) {
@@ -1 +1 @@
1
- {"version":3,"file":"disconnect-connections.js","sourceRoot":"","sources":["../../server/controllers/disconnect-connections.ts"],"names":[],"mappings":";;AAQA,sFAqDC;;AA7DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAkG;AAElG,qDAAmD;AAG5C,KAAK,UAAU,qCAAqC;IACzD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,E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\nimport { Connection, ConnectionManager, ConnectionStatus } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\nimport { LogAggregator } from './log-aggregator'\n\nexport async function initDisconnectConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n disconnectConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.disconnectConnections || []\n await disconnectConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n ...connection,\n params\n }\n } catch (e) {\n return {\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function disconnectConnections(connections: Connection[]) {\n console.log('disconnectConnections ...', connections)\n\n connections.forEach(connection => disconnectConnection(connection))\n}\n\nasync function disconnectConnection(connection: Connection) {\n const { type } = connection\n\n const old = ConnectionManager.getConnectionInstance(connection)\n if (old) {\n ConnectionManager.removeConnectionInstance(connection)\n }\n}\n"]}
1
+ {"version":3,"file":"disconnect-connections.js","sourceRoot":"","sources":["../../server/controllers/disconnect-connections.ts"],"names":[],"mappings":";;AAOA,sFAqDC;;AA5DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAgF;AAEhF,qDAAmD;AAE5C,KAAK,UAAU,qCAAqC;IACzD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,EAAC,YAAY,EAAC,EAAE;YACzB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,qBAAqB,IAAI,EAAE,CAAA;YAClE,MAAM,qBAAqB,CACzB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;oBAE5C,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM;qBACP,CAAA;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO;wBACL,GAAG,UAAU;wBACb,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CACH,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE;YACb,YAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,YAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,WAAyB;IAC5D,YAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA;IAErD,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;AACrE,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,UAAsB;IACxD,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAA;IAE3B,MAAM,GAAG,GAAG,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;IAC/D,IAAI,GAAG,EAAE,CAAC;QACR,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;AACH,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { logger } from '@things-factory/env'\nimport { Connection, ConnectionManager } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\n\nexport async function initDisconnectConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n disconnectConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.disconnectConnections || []\n await disconnectConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n ...connection,\n params\n }\n } catch (e) {\n return {\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function disconnectConnections(connections: Connection[]) {\n logger.info('disconnectConnections ...', connections)\n\n connections.forEach(connection => disconnectConnection(connection))\n}\n\nasync function disconnectConnection(connection: Connection) {\n const { type } = connection\n\n const old = ConnectionManager.getConnectionInstance(connection)\n if (old) {\n ConnectionManager.removeConnectionInstance(connection)\n }\n}\n"]}
@@ -10,7 +10,6 @@ const graphql_ws_1 = require("graphql-ws");
10
10
  const subscriptions_1 = require("@apollo/client/link/subscriptions");
11
11
  const utilities_1 = require("@apollo/client/utilities");
12
12
  const shell_1 = require("@things-factory/shell");
13
- const auth_base_1 = require("@things-factory/auth-base");
14
13
  const env_1 = require("@things-factory/env");
15
14
  const OperatoConfig = env_1.config.get('operato', {});
16
15
  const { endpoint: uri, domain: subdomain, authKey } = OperatoConfig;
@@ -27,7 +26,7 @@ const defaultOptions = {
27
26
  errorPolicy: 'all'
28
27
  }
29
28
  };
30
- var client;
29
+ let client;
31
30
  async function getOperatoClient() {
32
31
  if (!client) {
33
32
  if (!authKey || !subdomain) {
@@ -38,11 +37,9 @@ async function getOperatoClient() {
38
37
  subdomain: 'system'
39
38
  }
40
39
  });
41
- const user = await (0, shell_1.getRepository)(auth_base_1.User).findOne({
42
- where: {
43
- id: domain.owner
44
- }
45
- });
40
+ if (!domain) {
41
+ throw new Error('system domain not found');
42
+ }
46
43
  const httpLink = (0, core_1.createHttpLink)({
47
44
  uri: uri
48
45
  });
@@ -1 +1 @@
1
- {"version":3,"file":"operato-client.js","sourceRoot":"","sources":["../../server/controllers/operato-client.ts"],"names":[],"mappings":";;AAiCA,4CAwEC;;AAzGD,gCAA6B;AAE7B,8CAAwF;AACxF,yDAAwD;AAExD,oDAA0B;AAC1B,2CAAyC;AACzC,qEAAiE;AACjE,wDAA4D;AAE5D,iDAA6D;AAC7D,yDAAgD;AAChD,6CAA4C;AAE5C,MAAM,aAAa,GAAG,YAAM,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AAC/C,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,aAAa,CAAA;AAEnE,MAAM,cAAc,GAAQ;IAC1B,UAAU,EAAE;QACV,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,UAAU,EAAE,gBAAgB;QACzC,WAAW,EAAE,KAAK;KACnB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,KAAK;KACnB;CACF,CAAA;AAED,IAAI,MAAM,CAAA;AAEH,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC;YACjD,KAAK,EAAE;gBACL,SAAS,EAAE,QAAQ;aACpB;SACF,CAAC,CAAA;QAEF,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE;gBACL,EAAE,EAAE,MAAM,CAAC,KAAK;aACjB;SACF,CAAC,CA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AS;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import 'cross-fetch/polyfill'\n\nimport { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client/core'\nimport { setContext } from '@apollo/client/link/context'\n\nimport WebSocket from 'ws'\nimport { createClient } from 'graphql-ws'\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions'\nimport { getMainDefinition } from '@apollo/client/utilities'\n\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\n\nconst OperatoConfig = config.get('operato', {})\nconst { endpoint: uri, domain: subdomain, authKey } = OperatoConfig\n\nconst defaultOptions: any = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache', //'network-only'\n errorPolicy: 'all'\n },\n mutate: {\n errorPolicy: 'all'\n }\n}\n\nvar client\n\nexport async function getOperatoClient() {\n if (!client) {\n if (!authKey || !subdomain) {\n throw new Error('some operato config missing.')\n }\n\n const domain = await getRepository(Domain).findOne({\n where: {\n subdomain: 'system'\n }\n })\n\n const user = await getRepository(User).findOne({\n where: {\n id: domain.owner\n }\n })\n\n const httpLink = createHttpLink({\n uri: uri\n })\n\n /* \n CHECKPOINT: \n 1. GraphqQLWsLink를 사용하면 setContext를 통한 추가 헤더 설정이 무시됩니다.\n 따라서, GraphQLWsLink를 사용하려면, connectionParams를 통해 헤더를 설정해야 합니다.\n \n 2. 서버에서 실행시, webSocketImpl을 명시적으로 지정해야 합니다.\n */\n const wsLink = new GraphQLWsLink(\n createClient({\n url: uri.replace(/^http/, 'ws'),\n keepAlive: 10_000,\n retryAttempts: 1_000_000,\n shouldRetry: e => true,\n webSocketImpl: WebSocket,\n connectionParams: {\n headers: {\n 'x-things-factory-domain': subdomain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n })\n )\n\n const splitLink = split(\n ({ query }) => {\n const def = getMainDefinition(query)\n return def.kind === 'OperationDefinition' && def.operation === 'subscription'\n },\n wsLink,\n setContext((_, { headers }) => {\n return {\n headers: {\n ...headers,\n 'x-things-factory-domain': subdomain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n }).concat(httpLink)\n )\n\n const cache = new InMemoryCache()\n\n client = new ApolloClient({\n defaultOptions,\n cache,\n link: splitLink\n })\n }\n\n return client\n}\n"]}
1
+ {"version":3,"file":"operato-client.js","sourceRoot":"","sources":["../../server/controllers/operato-client.ts"],"names":[],"mappings":";;AAgCA,4CAsEC;;AAtGD,gCAA6B;AAE7B,8CAAwF;AACxF,yDAAwD;AAExD,oDAA0B;AAC1B,2CAAyC;AACzC,qEAAiE;AACjE,wDAA4D;AAE5D,iDAA6D;AAC7D,6CAA4C;AAE5C,MAAM,aAAa,GAAG,YAAM,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AAC/C,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,aAAa,CAAA;AAEnE,MAAM,cAAc,GAAQ;IAC1B,UAAU,EAAE;QACV,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,QAAQ;KACtB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,UAAU,EAAE,gBAAgB;QACzC,WAAW,EAAE,KAAK;KACnB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,KAAK;KACnB;CACF,CAAA;AAED,IAAI,MAAM,CAAA;AAEH,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QACjD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,cAAM,CAAC,CAAC,OAAO,CAAC;YACjD,KAAK,EAAE;gBACL,SAAS,EAAE,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,MAAM,KAAK,GAAG,IAAI,oBAAa,EAAE,CAAA;QAEjC,MAAM,GAAG,IAAI,mBAAY,CAAC;YACxB,cAAc;YACd,KAAK;YACL,IAAI,EAAE,SAAS;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import 'cross-fetch/polyfill'\n\nimport { ApolloClient, InMemoryCache, createHttpLink, split } from '@apollo/client/core'\nimport { setContext } from '@apollo/client/link/context'\n\nimport WebSocket from 'ws'\nimport { createClient } from 'graphql-ws'\nimport { GraphQLWsLink } from '@apollo/client/link/subscriptions'\nimport { getMainDefinition } from '@apollo/client/utilities'\n\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { config } from '@things-factory/env'\n\nconst OperatoConfig = config.get('operato', {})\nconst { endpoint: uri, domain: subdomain, authKey } = OperatoConfig\n\nconst defaultOptions: any = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache', //'network-only'\n errorPolicy: 'all'\n },\n mutate: {\n errorPolicy: 'all'\n }\n}\n\nlet client\n\nexport async function getOperatoClient() {\n if (!client) {\n if (!authKey || !subdomain) {\n throw new Error('some operato config missing.')\n }\n\n const domain = await getRepository(Domain).findOne({\n where: {\n subdomain: 'system'\n }\n })\n\n if (!domain) {\n throw new Error('system domain not found')\n }\n\n const httpLink = createHttpLink({\n uri: uri\n })\n\n /* \n CHECKPOINT: \n 1. GraphqQLWsLink를 사용하면 setContext를 통한 추가 헤더 설정이 무시됩니다.\n 따라서, GraphQLWsLink를 사용하려면, connectionParams를 통해 헤더를 설정해야 합니다.\n \n 2. 서버에서 실행시, webSocketImpl을 명시적으로 지정해야 합니다.\n */\n const wsLink = new GraphQLWsLink(\n createClient({\n url: uri.replace(/^http/, 'ws'),\n keepAlive: 10_000,\n retryAttempts: 1_000_000,\n shouldRetry: e => true,\n webSocketImpl: WebSocket,\n connectionParams: {\n headers: {\n 'x-things-factory-domain': subdomain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n })\n )\n\n const splitLink = split(\n ({ query }) => {\n const def = getMainDefinition(query)\n return def.kind === 'OperationDefinition' && def.operation === 'subscription'\n },\n wsLink,\n setContext((_, { headers }) => {\n return {\n headers: {\n ...headers,\n 'x-things-factory-domain': subdomain,\n authorization: authKey ? `Bearer ${authKey}` : ''\n }\n }\n }).concat(httpLink)\n )\n\n const cache = new InMemoryCache()\n\n client = new ApolloClient({\n defaultOptions,\n cache,\n link: splitLink\n })\n }\n\n return client\n}\n"]}
@@ -49,23 +49,24 @@ async function initRunTaskSubscription() {
49
49
  });
50
50
  }
51
51
  async function runTask(id, step, context) {
52
- var handler = integration_base_1.TaskRegistry.getTaskHandler(step.task);
52
+ const handler = step.task ? integration_base_1.TaskRegistry.getTaskHandler(step.task) : null;
53
53
  if (!handler) {
54
54
  throw new Error(`no task handler for step '${step.name}'(${step.id})`);
55
55
  }
56
- var error;
56
+ let error;
57
+ let out;
57
58
  const logAggregator = new log_aggregator_1.LogAggregator({});
58
- const logger = (0, winston_1.createLogger)({
59
+ const taskLogger = (0, winston_1.createLogger)({
59
60
  format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.printf(({ timestamp, level, message, stack }) => `${timestamp} ${level}: ${stack || message}`)),
60
61
  transports: [logAggregator]
61
62
  });
62
63
  try {
63
- var out = await handler({
64
+ out = await handler({
64
65
  ...step,
65
66
  params: step.params || {}
66
67
  }, {
67
68
  ...context,
68
- logger
69
+ logger: taskLogger
69
70
  });
70
71
  }
71
72
  catch (e) {
@@ -1 +1 @@
1
- {"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../server/controllers/run-task.ts"],"names":[],"mappings":";;AAUA,0DAyCC;;AAnDD,sEAA6B;AAE7B,qCAA8C;AAE9C,6CAA4C;AAC5C,wEAA+E;AAE/E,qDAAmD;AACnD,qDAAgD;AAEzC,KAAK,UAAU,uBAAuB;IAC3C,MAAM,MAAM,GAAG,MAAM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ClB,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,KAAK,KAAK,IAAI,OAAO,EAAE,CAAC,CACtG;QACD,UAAU,EAAE,CAAC,aAAa,CAAC;KAC5B,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,IAAI,GAAG,GAAQ,MAAM,OAAO,CAC1B;YACE,GAAG,IAAI;YACP,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;SAC1B,EACD;YACE,GAAG,OAAO;YACV,MAAM;SACP,CACF,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,MAAM,CAAC,MAAM,CAAC;QAClB,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;KAIZ;QACD,SAAS,EAAE;YACT,MAAM,EAAE;gBACN,EAAE;gBACF,GAAG;gBACH,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE;gBACnC,KAAK;aACN;SACF;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { createLogger, format } from 'winston'\n\nimport { logger } from '@things-factory/env'\nimport { Step, Context, TaskRegistry } from '@things-factory/integration-base/'\n\nimport { getOperatoClient } from './operato-client'\nimport { LogAggregator } from './log-aggregator'\n\nexport async function initRunTaskSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n runTask {\n id\n step {\n task\n connection\n params\n }\n context {\n domain {\n id\n name\n subdomain\n }\n data\n variables\n lng\n }\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const { id, step, context }: { id: string; step: Step; context: Context } = subscription?.data?.runTask || {}\n logger.info(`received run-task request: %s, %s, %s`, id, step, context)\n await runTask(id, step, context)\n },\n error: error => {\n logger.error(`operato subscription for runTask error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription for runTask complete`)\n }\n })\n}\n\nasync function runTask(id: string, step: Step, context: Context) {\n var handler = TaskRegistry.getTaskHandler(step.task)\n if (!handler) {\n throw new Error(`no task handler for step '${step.name}'(${step.id})`)\n }\n\n var error\n\n const logAggregator = new LogAggregator({})\n\n const logger = createLogger({\n format: format.combine(\n format.timestamp(),\n format.printf(({ timestamp, level, message, stack }) => `${timestamp} ${level}: ${stack || message}`)\n ),\n transports: [logAggregator]\n })\n\n try {\n var out: any = await handler(\n {\n ...step,\n params: step.params || {}\n },\n {\n ...context,\n logger\n }\n )\n } catch (e) {\n error = e?.stack || e\n }\n\n const client = await getOperatoClient()\n\n await client.mutate({\n mutation: gql`\n mutation RunTaskCallback($result: RunTaskCallbackInput!) {\n runTaskCallback(result: $result)\n }\n `,\n variables: {\n result: {\n id,\n out,\n logs: logAggregator.formatResults(),\n error\n }\n }\n })\n}\n"]}
1
+ {"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../server/controllers/run-task.ts"],"names":[],"mappings":";;AAUA,0DAyCC;;AAnDD,sEAA6B;AAE7B,qCAA8C;AAE9C,6CAA4C;AAC5C,wEAA+E;AAE/E,qDAAmD;AACnD,qDAAgD;AAEzC,KAAK,UAAU,uBAAuB;IAC3C,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;KAqBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,EAAC,YAAY,EAAC,EAAE;YACzB,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAiD,YAAY,EAAE,IAAI,EAAE,OAAO,IA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H,GAAG,GAAG,MAAM,OAAO,CACjB;YACE,GAAG,IAAI;YACP,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;SAC1B,EACD;YACE,GAAG,OAAO;YACV,MAAM,EAAE,UAAU;SACnB,CACF,CAAA;IACH,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,MAAM,CAAC,MAAM,CAAC;QAClB,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;KAIZ;QACD,SAAS,EAAE;YACT,MAAM,EAAE;gBACN,EAAE;gBACF,GAAG;gBACH,IAAI,EAAE,aAAa,CAAC,aAAa,EAAE;gBACnC,KAAK;aACN;SACF;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { createLogger, format } from 'winston'\n\nimport { logger } from '@things-factory/env'\nimport { Step, Context, TaskRegistry } from '@things-factory/integration-base/'\n\nimport { getOperatoClient } from './operato-client'\nimport { LogAggregator } from './log-aggregator'\n\nexport async function initRunTaskSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n runTask {\n id\n step {\n task\n connection\n params\n }\n context {\n domain {\n id\n name\n subdomain\n }\n data\n variables\n lng\n }\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const { id, step, context }: { id: string; step: Step; context: Context } = subscription?.data?.runTask || {}\n logger.info(`received run-task request: %s, %s, %s`, id, step, context)\n await runTask(id, step, context)\n },\n error: error => {\n logger.error(`operato subscription for runTask error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription for runTask complete`)\n }\n })\n}\n\nasync function runTask(id: string, step: Step, context: Context) {\n const handler = step.task ? TaskRegistry.getTaskHandler(step.task) : null\n if (!handler) {\n throw new Error(`no task handler for step '${step.name}'(${step.id})`)\n }\n\n let error\n let out: any\n\n const logAggregator = new LogAggregator({})\n\n const taskLogger = createLogger({\n format: format.combine(\n format.timestamp(),\n format.printf(({ timestamp, level, message, stack }) => `${timestamp} ${level}: ${stack || message}`)\n ),\n transports: [logAggregator]\n })\n\n try {\n out = await handler(\n {\n ...step,\n params: step.params || {}\n },\n {\n ...context,\n logger: taskLogger\n }\n )\n } catch (e: any) {\n error = e?.stack || e\n }\n\n const client = await getOperatoClient()\n\n await client.mutate({\n mutation: gql`\n mutation RunTaskCallback($result: RunTaskCallbackInput!) {\n runTaskCallback(result: $result)\n }\n `,\n variables: {\n result: {\n id,\n out,\n logs: logAggregator.formatResults(),\n error\n }\n }\n })\n}\n"]}
@@ -59,8 +59,8 @@ async function initSyncConnectionsSubscription() {
59
59
  });
60
60
  }
61
61
  async function syncConnections(connections) {
62
- console.log('syncConnections ...', connections);
63
- if (connections.length == 0) {
62
+ env_1.logger.info('syncConnections ...', connections);
63
+ if (connections.length === 0) {
64
64
  return;
65
65
  }
66
66
  const domain = connections[0]?.domain;
@@ -70,7 +70,7 @@ async function syncConnections(connections) {
70
70
  }
71
71
  async function syncConnection(connection) {
72
72
  const { type, state } = connection;
73
- var connector = integration_base_1.ConnectionManager.getConnector(type);
73
+ const connector = integration_base_1.ConnectionManager.getConnector(type);
74
74
  if (!connector) {
75
75
  return;
76
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sync-connections.js","sourceRoot":"","sources":["../../server/controllers/sync-connections.ts"],"names":[],"mappings":";;AAQA,0EAuDC;;AA/DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAkG;AAElG,qDAAmD;AAG5C,KAAK,UAAU,+BAA+B;IACnD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAE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A;IAE7F,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,UAAsB;IAClD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAElC,IAAI,SAAS,GAAG,oCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACpD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { logger } from '@things-factory/env'\nimport { Connection, ConnectionManager, ConnectionStatus } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\nimport { LogAggregator } from './log-aggregator'\n\nexport async function initSyncConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n syncConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.syncConnections || []\n await syncConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n // domain,\n ...connection,\n params\n }\n } catch (e) {\n return {\n // domain,\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function syncConnections(connections: Connection[]) {\n console.log('syncConnections ...', connections)\n\n if (connections.length == 0) {\n return\n }\n\n const domain = connections[0]?.domain\n const oldConnections = ConnectionManager.getConnectionInstances(domain)\n Object.values(oldConnections).forEach(old => ConnectionManager.removeConnectionInstance(old))\n\n connections.forEach(connection => syncConnection(connection))\n}\n\nasync function syncConnection(connection: Connection) {\n const { type, state } = connection\n\n var connector = ConnectionManager.getConnector(type)\n if (!connector) {\n return\n }\n\n await connector.connect(connection)\n}\n"]}
1
+ {"version":3,"file":"sync-connections.js","sourceRoot":"","sources":["../../server/controllers/sync-connections.ts"],"names":[],"mappings":";;AAOA,0EAuDC;;AA9DD,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAgF;AAEhF,qDAAmD;AAE5C,KAAK,UAAU,+BAA+B;IACnD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAgB,GAAE,CAAA;IAEvC,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACpC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;KAkBT;KACF,CAAC,CAAA;IAEF,YAAY,CAAC,SAAS,CAAC;QACrB,IAAI,EAAE,KAAK,EAAC,YAAY,EAAC,EAAE;YACzB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,eAAe,IAAI,EAAE,CAAA;YAC5D,MAAM,eAAe,CACnB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;oBAE5C,OAAO;wBACL,UAAU;wBACV,GAAG,UAAU;wBACb,MAAM;qBACP,CAAA;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO;wBACL,UAAU;wBACV,GAAG,UAAU;wBACb,MAAM,EAAE,IAAI;qBACb,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CACH,CAAA;QACH,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE;YACb,YAAM,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,YAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,WAAyB;IACtD,YAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAA;IAE/C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAA;IACrC,MAAM,cAAc,GAAG,oCAAiB,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;IACvE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,oCAAiB,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAA;IAE7F,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED,KAAK,UAAU,cAAc,CAAC,UAAsB;IAClD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAA;IAElC,MAAM,SAAS,GAAG,oCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IAED,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import gql from 'graphql-tag'\n\nimport { logger } from '@things-factory/env'\nimport { Connection, ConnectionManager } from '@things-factory/integration-base'\n\nimport { getOperatoClient } from './operato-client'\n\nexport async function initSyncConnectionsSubscription() {\n const client = await getOperatoClient()\n\n const subscription = client.subscribe({\n query: gql`\n subscription {\n syncConnections {\n domain {\n id\n name\n subdomain\n }\n id\n type\n name\n description\n endpoint\n active\n state\n params\n }\n }\n `\n })\n\n subscription.subscribe({\n next: async subscription => {\n const connections = subscription.data?.syncConnections || []\n await syncConnections(\n connections.map(connection => {\n try {\n const params = JSON.parse(connection.params)\n\n return {\n // domain,\n ...connection,\n params\n }\n } catch (e) {\n return {\n // domain,\n ...connection,\n params: null\n }\n }\n })\n )\n },\n error: error => {\n logger.error(`operato subscription error: ${error}`)\n },\n complete: () => {\n logger.info(`operato subscription complete`)\n }\n })\n}\n\nasync function syncConnections(connections: Connection[]) {\n logger.info('syncConnections ...', connections)\n\n if (connections.length === 0) {\n return\n }\n\n const domain = connections[0]?.domain\n const oldConnections = ConnectionManager.getConnectionInstances(domain)\n Object.values(oldConnections).forEach(old => ConnectionManager.removeConnectionInstance(old))\n\n connections.forEach(connection => syncConnection(connection))\n}\n\nasync function syncConnection(connection: Connection) {\n const { type, state } = connection\n\n const connector = ConnectionManager.getConnector(type)\n if (!connector) {\n return\n }\n\n await connector.connect(connection)\n}\n"]}
@@ -14,7 +14,7 @@ process.on('bootstrap-module-start', async ({ app, config, client }) => {
14
14
  await (0, run_task_1.initRunTaskSubscription)();
15
15
  }
16
16
  catch (ex) {
17
- console.error('Just has failed to initialize Edge Server.', ex);
17
+ console.error('Failed to initialize Edge Server.', ex);
18
18
  }
19
19
  });
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AAEzB,qEAAgF;AAChF,2EAAsF;AACtF,iFAA4F;AAC5F,qDAAgE;AAEhE,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,IAAA,kDAA+B,GAAE,CAAA;QACvC,MAAM,IAAA,8DAAqC,GAAE,CAAA;QAC7C,MAAM,IAAA,wDAAkC,GAAE,CAAA;QAC1C,MAAM,IAAA,kCAAuB,GAAE,CAAA;IACjC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,CAAC,CAAA;IACjE,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './service'\n\nimport { initSyncConnectionsSubscription } from './controllers/sync-connections'\nimport { initConnectConnectionsSubscription } from './controllers/connect-connections'\nimport { initDisconnectConnectionsSubscription } from './controllers/disconnect-connections'\nimport { initRunTaskSubscription } from './controllers/run-task'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await initSyncConnectionsSubscription()\n await initDisconnectConnectionsSubscription()\n await initConnectConnectionsSubscription()\n await initRunTaskSubscription()\n } catch (ex) {\n console.error('Just has failed to initialize Edge Server.', ex)\n }\n})\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AAEzB,qEAAgF;AAChF,2EAAsF;AACtF,iFAA4F;AAC5F,qDAAgE;AAEhE,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,IAAA,kDAA+B,GAAE,CAAA;QACvC,MAAM,IAAA,8DAAqC,GAAE,CAAA;QAC7C,MAAM,IAAA,wDAAkC,GAAE,CAAA;QAC1C,MAAM,IAAA,kCAAuB,GAAE,CAAA;IACjC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAA;IACxD,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './service'\n\nimport { initSyncConnectionsSubscription } from './controllers/sync-connections'\nimport { initConnectConnectionsSubscription } from './controllers/connect-connections'\nimport { initDisconnectConnectionsSubscription } from './controllers/disconnect-connections'\nimport { initRunTaskSubscription } from './controllers/run-task'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await initSyncConnectionsSubscription()\n await initDisconnectConnectionsSubscription()\n await initConnectConnectionsSubscription()\n await initRunTaskSubscription()\n } catch (ex) {\n console.error('Failed to initialize Edge Server.', ex)\n }\n})\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAKnF,uEAAgF;AAGzE,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,iBAAiB,CAAQ,OAAwB;QACrD,MAAM,QAAQ,GAA2D,oCAAiB,CAAC,WAAW,EAAE,CAAA;QACxG,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACjE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACnC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;YAClB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAS,CAAC,CAAA;QAEb,OAAO,WAAW,CAAA;IACpB,CAAC;CACF,CAAA;AAZY,0CAAe;AAEpB;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,6BAAU,CAAC,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACxD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAS7B;0BAXU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,6BAAU,CAAC;GACR,eAAe,CAY3B","sourcesContent":["import { Arg, Args, Ctx, 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, Connection } from '@things-factory/integration-base'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => [Connection], { description: 'To fetch multiple connections' })\n async connectionsOnEdge(@Ctx() context: ResolverContext): Promise<Connection[]> {\n const entities: { [domainId: string]: { [name: string]: Connection } } = ConnectionManager.getEntities()\n const connections = Object.values(entities).reduce((sum, keyval) => {\n const items = Object.values(keyval)\n sum.push(...items)\n return sum\n }, [] as any)\n\n return connections\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmD;AAEnD,uEAAgF;AAGzE,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,iBAAiB,CAAQ,OAAwB;QACrD,MAAM,QAAQ,GAA2D,oCAAiB,CAAC,WAAW,EAAE,CAAA;QACxG,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACjE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACnC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;YAClB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAS,CAAC,CAAA;QAEb,OAAO,WAAW,CAAA;IACpB,CAAC;CACF,CAAA;AAZY,0CAAe;AAEpB;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,6BAAU,CAAC,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACxD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAS7B;0BAXU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,6BAAU,CAAC;GACR,eAAe,CAY3B","sourcesContent":["import { Ctx, Query, Resolver } from 'type-graphql'\n\nimport { ConnectionManager, Connection } from '@things-factory/integration-base'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => [Connection], { description: 'To fetch multiple connections' })\n async connectionsOnEdge(@Ctx() context: ResolverContext): Promise<Connection[]> {\n const entities: { [domainId: string]: { [name: string]: Connection } } = ConnectionManager.getEntities()\n const connections = Object.values(entities).reduce((sum, keyval) => {\n const items = Object.values(keyval)\n sum.push(...items)\n return sum\n }, [] as any)\n\n return connections\n }\n}\n"]}