@things-factory/edge 7.0.1-beta.1 → 7.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/pages/edge-status-page.d.ts +1 -1
- package/dist-client/pages/edge-status-page.js.map +1 -1
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/connect-connections.d.ts +1 -0
- package/dist-server/controllers/connect-connections.js.map +1 -1
- package/dist-server/controllers/disconnect-connections.d.ts +1 -0
- package/dist-server/controllers/disconnect-connections.js.map +1 -1
- package/dist-server/controllers/log-aggregator.d.ts +6 -0
- package/dist-server/controllers/operato-client.d.ts +2 -0
- package/dist-server/controllers/operato-client.js +1 -1
- package/dist-server/controllers/operato-client.js.map +1 -1
- package/dist-server/controllers/run-task.d.ts +1 -0
- package/dist-server/controllers/run-task.js +1 -1
- package/dist-server/controllers/run-task.js.map +1 -1
- package/dist-server/controllers/sync-connections.d.ts +1 -0
- package/dist-server/controllers/sync-connections.js.map +1 -1
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/connection/connection-query.d.ts +4 -0
- package/dist-server/service/connection/connection-query.js +2 -2
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/index.d.ts +2 -0
- package/dist-server/service/index.d.ts +5 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/server/controllers/run-task.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-connections.js","sourceRoot":"","sources":["../../server/controllers/connect-connections.ts"],"names":[],"mappings":";;;;AAAA,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,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,kBAAkB,KAAI,EAAE,CAAA;YAC/D,MAAM,kBAAkB,CACtB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI;
|
|
1
|
+
{"version":3,"file":"connect-connections.js","sourceRoot":"","sources":["../../server/controllers/connect-connections.ts"],"names":[],"mappings":";;;;AAAA,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,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,kBAAkB,KAAI,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,uCACK,UAAU,KACb,MAAM,IACP;gBACH,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,uCACK,UAAU,KACb,MAAM,EAAE,IAAI,IACb;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;AArDD,gFAqDC;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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initDisconnectConnectionsSubscription(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disconnect-connections.js","sourceRoot":"","sources":["../../server/controllers/disconnect-connections.ts"],"names":[],"mappings":";;;;AAAA,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,EAAC,YAAY,EAAC,EAAE;;YACzB,MAAM,WAAW,GAAG,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,qBAAqB,KAAI,EAAE,CAAA;YAClE,MAAM,qBAAqB,CACzB,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBAC3B,IAAI;
|
|
1
|
+
{"version":3,"file":"disconnect-connections.js","sourceRoot":"","sources":["../../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,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, 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operato-client.js","sourceRoot":"","sources":["../../server/controllers/operato-client.ts"],"names":[],"mappings":";;;;AAAA,gCAA6B;AAE7B,8CAAwF;AACxF,yDAA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L,OAAO,kCACF,OAAO,KACV,yBAAyB,EAAE,SAAS,EACpC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAClD;aACF,CAAA;QACH,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CACpB,CAAA;QAED,MAAM,KAAK,GAAG,IAAI,oBAAa,CAAC;YAC9B,WAAW,EAAE,KAAK;SACnB,CAAC,CAAA;QAEF,MAAM,GAAG,IAAI,mBAAY,CAAC;YACxB,cAAc;YACd,KAAK;YACL,IAAI,EAAE,SAAS;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AA1ED,4CA0EC","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 addTypename: false\n })\n\n client = new ApolloClient({\n defaultOptions,\n cache,\n link: splitLink\n })\n }\n\n return client\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initRunTaskSubscription(): Promise<void>;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
6
6
|
const winston_1 = require("winston");
|
|
7
7
|
const env_1 = require("@things-factory/env");
|
|
8
|
-
const integration_base_1 = require("@things-factory/integration-base");
|
|
8
|
+
const integration_base_1 = require("@things-factory/integration-base/");
|
|
9
9
|
const operato_client_1 = require("./operato-client");
|
|
10
10
|
const log_aggregator_1 = require("./log-aggregator");
|
|
11
11
|
async function initRunTaskSubscription() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../server/controllers/run-task.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,qCAA8C;AAE9C,6CAA4C;AAC5C,
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AK,CAAC,6BAA6B,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IACxE,CAAC;IAED,IAAI,KAAK,CAAA;IAET,MAAM,aAAa,GAAG,IAAI,8BAAa,CAAC,EAAE,CAAC,CAAA;IAE3C,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC;QAC1B,MAAM,EAAE,gBAAM,CAAC,OAAO,CACpB,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAC1E;QACD,UAAU,EAAE,CAAC,aAAa,CAAC;KAC5B,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,IAAI,GAAG,GAAQ,MAAM,OAAO,iCAErB,IAAI,KACP,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,qCAG5B,OAAO,KACV,MAAM,IAET,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,KAAK,GAAG,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,KAAI,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(info => `${info.timestamp} ${info.level}: ${info.message}`)\n ),\n transports: [logAggregator]\n })\n\n try {\n var out: any = await handler(\n {\n ...step,\n params: JSON.parse(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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initSyncConnectionsSubscription(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-connections.js","sourceRoot":"","sources":["../../server/controllers/sync-connections.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,6CAA4C;AAC5C,uEAAkG;AAElG,qDAAmD;AAG5C,KAAK,UAAU,+BAA+B;IACnD,MAAM,MAAM,GAAG,MAAM,IAAA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C;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;AAvDD,0EAuDC;AAED,KAAK,UAAU,eAAe,CAAC,WAAyB;;IACtD,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAA;IAE/C,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAM;IACR,CAAC;IAED,MAAM,MAAM,GAAG,MAAA,WAAW,CAAC,CAAC,CAAC,0CAAE,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,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service';
|
package/dist-server/index.js.map
CHANGED
|
@@ -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;
|
|
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"]}
|
|
@@ -15,6 +15,7 @@ let ConnectionQuery = class ConnectionQuery {
|
|
|
15
15
|
return connections;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
exports.ConnectionQuery = ConnectionQuery;
|
|
18
19
|
tslib_1.__decorate([
|
|
19
20
|
(0, type_graphql_1.Query)(returns => [integration_base_1.Connection], { description: 'To fetch multiple connections' }),
|
|
20
21
|
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
@@ -22,8 +23,7 @@ tslib_1.__decorate([
|
|
|
22
23
|
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
23
24
|
tslib_1.__metadata("design:returntype", Promise)
|
|
24
25
|
], ConnectionQuery.prototype, "connectionsOnEdge", null);
|
|
25
|
-
ConnectionQuery = tslib_1.__decorate([
|
|
26
|
+
exports.ConnectionQuery = ConnectionQuery = tslib_1.__decorate([
|
|
26
27
|
(0, type_graphql_1.Resolver)(integration_base_1.Connection)
|
|
27
28
|
], ConnectionQuery);
|
|
28
|
-
exports.ConnectionQuery = ConnectionQuery;
|
|
29
29
|
//# sourceMappingURL=connection-query.js.map
|
|
@@ -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;
|
|
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"]}
|