@things-factory/edge 7.0.0-alpha.18
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/CHANGELOG.md +8 -0
- package/assets/images/hatiolab-logo.png +0 -0
- package/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/pages/edge-status-page.ts +180 -0
- package/client/route.ts +7 -0
- package/client/tsconfig.json +11 -0
- package/config/config.development.js +7 -0
- package/config/config.production.js +7 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/edge-status-page.d.ts +39 -0
- package/dist-client/pages/edge-status-page.js +187 -0
- package/dist-client/pages/edge-status-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/connect-connections.js +71 -0
- package/dist-server/controllers/connect-connections.js.map +1 -0
- package/dist-server/controllers/disconnect-connections.js +66 -0
- package/dist-server/controllers/disconnect-connections.js.map +1 -0
- package/dist-server/controllers/log-aggregator.js +20 -0
- package/dist-server/controllers/log-aggregator.js.map +1 -0
- package/dist-server/controllers/operato-client.js +89 -0
- package/dist-server/controllers/operato-client.js.map +1 -0
- package/dist-server/controllers/run-task.js +87 -0
- package/dist-server/controllers/run-task.js.map +1 -0
- package/dist-server/controllers/sync-connections.js +74 -0
- package/dist-server/controllers/sync-connections.js.map +1 -0
- package/dist-server/index.js +20 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/service/connection/connection-query.js +29 -0
- package/dist-server/service/connection/connection-query.js.map +1 -0
- package/dist-server/service/connection/index.js +6 -0
- package/dist-server/service/connection/index.js.map +1 -0
- package/dist-server/service/index.js +19 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +39 -0
- package/server/controllers/connect-connections.ts +84 -0
- package/server/controllers/disconnect-connections.ts +77 -0
- package/server/controllers/log-aggregator.ts +14 -0
- package/server/controllers/operato-client.ts +108 -0
- package/server/controllers/run-task.ts +104 -0
- package/server/controllers/sync-connections.ts +89 -0
- package/server/index.ts +17 -0
- package/server/service/connection/connection-query.ts +21 -0
- package/server/service/connection/index.ts +3 -0
- package/server/service/index.ts +19 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +8 -0
- package/translations/en.json +4 -0
- package/translations/ja.json +4 -0
- package/translations/ko.json +4 -0
- package/translations/ms.json +4 -0
- package/translations/zh.json +4 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRunTaskSubscription = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
6
|
+
const winston_1 = require("winston");
|
|
7
|
+
const env_1 = require("@things-factory/env");
|
|
8
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
9
|
+
const operato_client_1 = require("./operato-client");
|
|
10
|
+
const log_aggregator_1 = require("./log-aggregator");
|
|
11
|
+
async function initRunTaskSubscription() {
|
|
12
|
+
const client = await (0, operato_client_1.getOperatoClient)();
|
|
13
|
+
const subscription = client.subscribe({
|
|
14
|
+
query: (0, graphql_tag_1.default) `
|
|
15
|
+
subscription {
|
|
16
|
+
runTask {
|
|
17
|
+
id
|
|
18
|
+
step {
|
|
19
|
+
task
|
|
20
|
+
connection
|
|
21
|
+
params
|
|
22
|
+
}
|
|
23
|
+
context {
|
|
24
|
+
domain {
|
|
25
|
+
id
|
|
26
|
+
name
|
|
27
|
+
subdomain
|
|
28
|
+
}
|
|
29
|
+
data
|
|
30
|
+
variables
|
|
31
|
+
lng
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
});
|
|
37
|
+
subscription.subscribe({
|
|
38
|
+
next: async (subscription) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const { id, step, context } = ((_a = subscription === null || subscription === void 0 ? void 0 : subscription.data) === null || _a === void 0 ? void 0 : _a.runTask) || {};
|
|
41
|
+
env_1.logger.info(`received run-task request: %s, %s, %s`, id, step, context);
|
|
42
|
+
await runTask(id, step, context);
|
|
43
|
+
},
|
|
44
|
+
error: error => {
|
|
45
|
+
env_1.logger.error(`operato subscription for runTask error: ${error}`);
|
|
46
|
+
},
|
|
47
|
+
complete: () => {
|
|
48
|
+
env_1.logger.info(`operato subscription for runTask complete`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.initRunTaskSubscription = initRunTaskSubscription;
|
|
53
|
+
async function runTask(id, step, context) {
|
|
54
|
+
var handler = integration_base_1.TaskRegistry.getTaskHandler(step.task);
|
|
55
|
+
if (!handler) {
|
|
56
|
+
throw new Error(`no task handler for step '${step.name}'(${step.id})`);
|
|
57
|
+
}
|
|
58
|
+
var error;
|
|
59
|
+
const logAggregator = new log_aggregator_1.LogAggregator({});
|
|
60
|
+
const logger = (0, winston_1.createLogger)({
|
|
61
|
+
format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)),
|
|
62
|
+
transports: [logAggregator]
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
var out = await handler(Object.assign(Object.assign({}, step), { params: JSON.parse(step.params) }), Object.assign(Object.assign({}, context), { logger }));
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
error = (e === null || e === void 0 ? void 0 : e.stack) || e;
|
|
69
|
+
}
|
|
70
|
+
const client = await (0, operato_client_1.getOperatoClient)();
|
|
71
|
+
await client.mutate({
|
|
72
|
+
mutation: (0, graphql_tag_1.default) `
|
|
73
|
+
mutation RunTaskCallback($result: RunTaskCallbackInput!) {
|
|
74
|
+
runTaskCallback(result: $result)
|
|
75
|
+
}
|
|
76
|
+
`,
|
|
77
|
+
variables: {
|
|
78
|
+
result: {
|
|
79
|
+
id,
|
|
80
|
+
out,
|
|
81
|
+
logs: logAggregator.formatResults(),
|
|
82
|
+
error
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=run-task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../server/controllers/run-task.ts"],"names":[],"mappings":";;;;AAAA,sEAA6B;AAE7B,qCAA8C;AAE9C,6CAA4C;AAC5C,uEAAsF;AAEtF,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,GAAyD,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,0CAAE,OAAO,KAAI,EAAE,CAAA;YACrH,YAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;YACvE,MAAM,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QAClC,CAAC;QACD,KAAK,EAAE,KAAK,CAAC,EAAE;YACb,YAAM,CAAC,KAAK,CAAC,2CAA2C,KAAK,EAAE,CAAC,CAAA;QAClE,CAAC;QACD,QAAQ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,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, ScenarioContext, 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: ScenarioContext } = 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: ScenarioContext) {\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,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initSyncConnectionsSubscription = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
6
|
+
const env_1 = require("@things-factory/env");
|
|
7
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
8
|
+
const operato_client_1 = require("./operato-client");
|
|
9
|
+
async function initSyncConnectionsSubscription() {
|
|
10
|
+
const client = await (0, operato_client_1.getOperatoClient)();
|
|
11
|
+
const subscription = client.subscribe({
|
|
12
|
+
query: (0, graphql_tag_1.default) `
|
|
13
|
+
subscription {
|
|
14
|
+
syncConnections {
|
|
15
|
+
domain {
|
|
16
|
+
id
|
|
17
|
+
name
|
|
18
|
+
subdomain
|
|
19
|
+
}
|
|
20
|
+
id
|
|
21
|
+
type
|
|
22
|
+
name
|
|
23
|
+
description
|
|
24
|
+
endpoint
|
|
25
|
+
active
|
|
26
|
+
state
|
|
27
|
+
params
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`
|
|
31
|
+
});
|
|
32
|
+
subscription.subscribe({
|
|
33
|
+
next: async (subscription) => {
|
|
34
|
+
var _a;
|
|
35
|
+
const connections = ((_a = subscription.data) === null || _a === void 0 ? void 0 : _a.syncConnections) || [];
|
|
36
|
+
await syncConnections(connections.map(connection => {
|
|
37
|
+
try {
|
|
38
|
+
const params = JSON.parse(connection.params);
|
|
39
|
+
return Object.assign(Object.assign({}, connection), { params });
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return Object.assign(Object.assign({}, connection), { params: null });
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
},
|
|
46
|
+
error: error => {
|
|
47
|
+
env_1.logger.error(`operato subscription error: ${error}`);
|
|
48
|
+
},
|
|
49
|
+
complete: () => {
|
|
50
|
+
env_1.logger.info(`operato subscription complete`);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.initSyncConnectionsSubscription = initSyncConnectionsSubscription;
|
|
55
|
+
async function syncConnections(connections) {
|
|
56
|
+
var _a;
|
|
57
|
+
console.log('syncConnections ...', connections);
|
|
58
|
+
if (connections.length == 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const domain = (_a = connections[0]) === null || _a === void 0 ? void 0 : _a.domain;
|
|
62
|
+
const oldConnections = integration_base_1.ConnectionManager.getConnectionInstances(domain);
|
|
63
|
+
Object.values(oldConnections).forEach(old => integration_base_1.ConnectionManager.removeConnectionInstance(old));
|
|
64
|
+
connections.forEach(connection => syncConnection(connection));
|
|
65
|
+
}
|
|
66
|
+
async function syncConnection(connection) {
|
|
67
|
+
const { type, state } = connection;
|
|
68
|
+
var connector = integration_base_1.ConnectionManager.getConnector(type);
|
|
69
|
+
if (!connector) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await connector.connect(connection);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=sync-connections.js.map
|
|
@@ -0,0 +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,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,eAAe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;IAElC,IAAI,SAAS,GAAG,oCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACpD,IAAI,CAAC,SAAS,EAAE;QACd,OAAM;KACP;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,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./service"), exports);
|
|
5
|
+
const sync_connections_1 = require("./controllers/sync-connections");
|
|
6
|
+
const connect_connections_1 = require("./controllers/connect-connections");
|
|
7
|
+
const disconnect_connections_1 = require("./controllers/disconnect-connections");
|
|
8
|
+
const run_task_1 = require("./controllers/run-task");
|
|
9
|
+
process.on('bootstrap-module-start', async ({ app, config, client }) => {
|
|
10
|
+
try {
|
|
11
|
+
await (0, sync_connections_1.initSyncConnectionsSubscription)();
|
|
12
|
+
await (0, disconnect_connections_1.initDisconnectConnectionsSubscription)();
|
|
13
|
+
await (0, connect_connections_1.initConnectConnectionsSubscription)();
|
|
14
|
+
await (0, run_task_1.initRunTaskSubscription)();
|
|
15
|
+
}
|
|
16
|
+
catch (ex) {
|
|
17
|
+
console.error('Just has failed to initialize Edge Server.', ex);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;QACF,MAAM,IAAA,kDAA+B,GAAE,CAAA;QACvC,MAAM,IAAA,8DAAqC,GAAE,CAAA;QAC7C,MAAM,IAAA,wDAAkC,GAAE,CAAA;QAC1C,MAAM,IAAA,kCAAuB,GAAE,CAAA;KAChC;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,CAAC,CAAA;KAChE;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"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const integration_base_1 = require("@things-factory/integration-base");
|
|
7
|
+
let ConnectionQuery = class ConnectionQuery {
|
|
8
|
+
async connectionsOnEdge(context) {
|
|
9
|
+
const entities = integration_base_1.ConnectionManager.getEntities();
|
|
10
|
+
const connections = Object.values(entities).reduce((sum, keyval) => {
|
|
11
|
+
const items = Object.values(keyval);
|
|
12
|
+
sum.push(...items);
|
|
13
|
+
return sum;
|
|
14
|
+
}, []);
|
|
15
|
+
return connections;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Query)(returns => [integration_base_1.Connection], { description: 'To fetch multiple connections' }),
|
|
20
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
21
|
+
tslib_1.__metadata("design:type", Function),
|
|
22
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
23
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
24
|
+
], ConnectionQuery.prototype, "connectionsOnEdge", null);
|
|
25
|
+
ConnectionQuery = tslib_1.__decorate([
|
|
26
|
+
(0, type_graphql_1.Resolver)(integration_base_1.Connection)
|
|
27
|
+
], ConnectionQuery);
|
|
28
|
+
exports.ConnectionQuery = ConnectionQuery;
|
|
29
|
+
//# sourceMappingURL=connection-query.js.map
|
|
@@ -0,0 +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;AAVO;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;AAXU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,6BAAU,CAAC;GACR,eAAe,CAY3B;AAZY,0CAAe","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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/connection/index.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEvC,QAAA,SAAS,GAAG,CAAC,kCAAe,CAAC,CAAA","sourcesContent":["import { ConnectionQuery } from './connection-query'\n\nexport const resolvers = [ConnectionQuery]\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* EXPORT ENTITY TYPES */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.schema = exports.subscribers = exports.entities = void 0;
|
|
5
|
+
/* IMPORT ENTITIES AND RESOLVERS */
|
|
6
|
+
const connection_1 = require("./connection");
|
|
7
|
+
exports.entities = [
|
|
8
|
+
/* ENTITIES */
|
|
9
|
+
];
|
|
10
|
+
exports.subscribers = [
|
|
11
|
+
/* SUBSCRIBERS */
|
|
12
|
+
];
|
|
13
|
+
exports.schema = {
|
|
14
|
+
resolverClasses: [
|
|
15
|
+
/* RESOLVER CLASSES */
|
|
16
|
+
...connection_1.resolvers
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";AAAA,yBAAyB;;;AAEzB,mCAAmC;AACnC,6CAA+D;AAElD,QAAA,QAAQ,GAAG;AACtB,cAAc;CACf,CAAA;AAEY,QAAA,WAAW,GAAG;AACzB,iBAAiB;CAClB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,sBAAmB;KACvB;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { resolvers as ConnectionResolvers } from './connection'\n\nexport const entities = [\n /* ENTITIES */\n]\n\nexport const subscribers = [\n /* SUBSCRIBERS */\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...ConnectionResolvers\n ]\n}\n"]}
|