@things-factory/edge-client 9.0.0-beta.25 → 9.0.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +3 -3
  2. package/dist-server/controllers/connect-connections.d.ts +0 -2
  3. package/dist-server/controllers/connect-connections.js +0 -8
  4. package/dist-server/controllers/connect-connections.js.map +0 -1
  5. package/dist-server/controllers/disconnect-connections.d.ts +0 -2
  6. package/dist-server/controllers/disconnect-connections.js +0 -8
  7. package/dist-server/controllers/disconnect-connections.js.map +0 -1
  8. package/dist-server/controllers/index.d.ts +0 -2
  9. package/dist-server/controllers/index.js +0 -6
  10. package/dist-server/controllers/index.js.map +0 -1
  11. package/dist-server/controllers/run-task.d.ts +0 -2
  12. package/dist-server/controllers/run-task.js +0 -32
  13. package/dist-server/controllers/run-task.js.map +0 -1
  14. package/dist-server/controllers/sync-connections.d.ts +0 -2
  15. package/dist-server/controllers/sync-connections.js +0 -8
  16. package/dist-server/controllers/sync-connections.js.map +0 -1
  17. package/dist-server/engine/connector/edge-connector.d.ts +0 -14
  18. package/dist-server/engine/connector/edge-connector.js +0 -38
  19. package/dist-server/engine/connector/edge-connector.js.map +0 -1
  20. package/dist-server/engine/index.d.ts +0 -1
  21. package/dist-server/engine/index.js +0 -4
  22. package/dist-server/engine/index.js.map +0 -1
  23. package/dist-server/index.d.ts +0 -2
  24. package/dist-server/index.js +0 -19
  25. package/dist-server/index.js.map +0 -1
  26. package/dist-server/service/appliance/edge-client-mutation.d.ts +0 -4
  27. package/dist-server/service/appliance/edge-client-mutation.js +0 -28
  28. package/dist-server/service/appliance/edge-client-mutation.js.map +0 -1
  29. package/dist-server/service/appliance/edge-client-subscription.d.ts +0 -8
  30. package/dist-server/service/appliance/edge-client-subscription.js +0 -209
  31. package/dist-server/service/appliance/edge-client-subscription.js.map +0 -1
  32. package/dist-server/service/appliance/edge-client-type.d.ts +0 -18
  33. package/dist-server/service/appliance/edge-client-type.js +0 -70
  34. package/dist-server/service/appliance/edge-client-type.js.map +0 -1
  35. package/dist-server/service/appliance/index.d.ts +0 -5
  36. package/dist-server/service/appliance/index.js +0 -9
  37. package/dist-server/service/appliance/index.js.map +0 -1
  38. package/dist-server/service/index.d.ts +0 -5
  39. package/dist-server/service/index.js +0 -21
  40. package/dist-server/service/index.js.map +0 -1
  41. package/dist-server/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/edge-client",
3
- "version": "9.0.0-beta.25",
3
+ "version": "9.0.0-beta.27",
4
4
  "main": "dist-server/index.js",
5
5
  "things-factory": true,
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@things-factory/auth-base": "^9.0.0-beta.25",
26
- "@things-factory/integration-base": "^9.0.0-beta.25",
26
+ "@things-factory/integration-base": "^9.0.0-beta.27",
27
27
  "@things-factory/lock-client": "^9.0.0-beta.25",
28
28
  "@things-factory/shell": "^9.0.0-beta.25"
29
29
  },
30
- "gitHead": "7b11df06e4b7586cc316da7dd5ab905592d85dcc"
30
+ "gitHead": "3038f56087036b06717f8e4910383c6b1320218d"
31
31
  }
@@ -1,2 +0,0 @@
1
- import { Connection } from '@things-factory/integration-base';
2
- export declare function connectConnections(connections: Connection[], context: ResolverContext): Promise<any>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectConnections = connectConnections;
4
- const shell_1 = require("@things-factory/shell");
5
- async function connectConnections(connections, context) {
6
- shell_1.pubsub.publish('connect-connections', connections);
7
- }
8
- //# sourceMappingURL=connect-connections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect-connections.js","sourceRoot":"","sources":["../../server/controllers/connect-connections.ts"],"names":[],"mappings":";;AAGA,gDAEC;AALD,iDAA8C;AAGvC,KAAK,UAAU,kBAAkB,CAAC,WAAyB,EAAE,OAAwB;IAC1F,cAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAA;AACpD,CAAC","sourcesContent":["import { pubsub } from '@things-factory/shell'\nimport { Connection } from '@things-factory/integration-base'\n\nexport async function connectConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n pubsub.publish('connect-connections', connections)\n}\n"]}
@@ -1,2 +0,0 @@
1
- import { Connection } from '@things-factory/integration-base';
2
- export declare function disconnectConnections(connections: Connection[], context: ResolverContext): Promise<any>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.disconnectConnections = disconnectConnections;
4
- const shell_1 = require("@things-factory/shell");
5
- async function disconnectConnections(connections, context) {
6
- shell_1.pubsub.publish('disconnect-connections', connections);
7
- }
8
- //# sourceMappingURL=disconnect-connections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"disconnect-connections.js","sourceRoot":"","sources":["../../server/controllers/disconnect-connections.ts"],"names":[],"mappings":";;AAGA,sDAEC;AALD,iDAA8C;AAGvC,KAAK,UAAU,qBAAqB,CAAC,WAAyB,EAAE,OAAwB;IAC7F,cAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,WAAW,CAAC,CAAA;AACvD,CAAC","sourcesContent":["import { pubsub } from '@things-factory/shell'\nimport { Connection } from '@things-factory/integration-base'\n\nexport async function disconnectConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n pubsub.publish('disconnect-connections', connections)\n}\n"]}
@@ -1,2 +0,0 @@
1
- export * from './run-task';
2
- export * from './sync-connections';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./run-task"), exports);
5
- tslib_1.__exportStar(require("./sync-connections"), exports);
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,6DAAkC","sourcesContent":["export * from './run-task'\nexport * from './sync-connections'\n"]}
@@ -1,2 +0,0 @@
1
- import { TaskHandler } from '@things-factory/integration-base';
2
- export declare const runTask: TaskHandler;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runTask = void 0;
4
- const shell_1 = require("@things-factory/shell");
5
- const lock_client_1 = require("@things-factory/lock-client");
6
- const runTask = async (step, scenarioContext) => {
7
- var _a;
8
- const { logger } = scenarioContext;
9
- try {
10
- const id = await (0, lock_client_1.requestLock)();
11
- shell_1.pubsub.publish('run-task', {
12
- id,
13
- step,
14
- context: scenarioContext
15
- });
16
- const result = await (0, lock_client_1.tryLock)({ id });
17
- const { out, logs, error } = result || {};
18
- if (((_a = logger.transports) === null || _a === void 0 ? void 0 : _a.length) > 0) {
19
- /* 강제로 시나리오 인스턴스가 종료된 경우에는 logger도 닫힌 상태가 된다. 이 경우에는 transports가 설정되지 않게된다. */
20
- logs && logs.map(log => logger.log(log));
21
- }
22
- if (error) {
23
- throw new Error(error);
24
- }
25
- return out;
26
- }
27
- catch (err) {
28
- throw new Error(err);
29
- }
30
- };
31
- exports.runTask = runTask;
32
- //# sourceMappingURL=run-task.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../server/controllers/run-task.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C,6DAAkE;AAE3D,MAAM,OAAO,GAAgB,KAAK,EAAE,IAAU,EAAE,eAAwB,EAAE,EAAE;;IACjF,MAAM,EAAE,MAAM,EAAE,GAAoB,eAAe,CAAA;IAEnD,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,IAAA,yBAAW,GAAE,CAAA;QAE9B,cAAM,CAAC,OAAO,CAAC,UAAU,EAAE;YACzB,EAAE;YACF,IAAI;YACJ,OAAO,EAAE,eAAe;SACzB,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAO,EAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QACpC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;QAEzC,IAAI,CAAA,MAAA,MAAM,CAAC,UAAU,0CAAE,MAAM,IAAG,CAAC,EAAE,CAAC;YAClC,8EAA8E;YAC9E,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAC1C,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IACtB,CAAC;AACH,CAAC,CAAA;AA5BY,QAAA,OAAO,WA4BnB","sourcesContent":["import { pubsub } from '@things-factory/shell'\nimport { Context, Step, TaskHandler } from '@things-factory/integration-base'\nimport { requestLock, tryLock } from '@things-factory/lock-client'\n\nexport const runTask: TaskHandler = async (step: Step, scenarioContext: Context) => {\n const { logger }: { logger: any } = scenarioContext\n\n try {\n const id = await requestLock()\n\n pubsub.publish('run-task', {\n id,\n step,\n context: scenarioContext\n })\n\n const result = await tryLock({ id })\n const { out, logs, error } = result || {}\n\n if (logger.transports?.length > 0) {\n /* 강제로 시나리오 인스턴스가 종료된 경우에는 logger도 닫힌 상태가 된다. 이 경우에는 transports가 설정되지 않게된다. */\n logs && logs.map(log => logger.log(log))\n }\n\n if (error) {\n throw new Error(error)\n }\n\n return out\n } catch (err) {\n throw new Error(err)\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- import { Connection } from '@things-factory/integration-base';
2
- export declare function syncConnections(connections: Connection[], context: ResolverContext): Promise<any>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.syncConnections = syncConnections;
4
- const shell_1 = require("@things-factory/shell");
5
- async function syncConnections(connections, context) {
6
- shell_1.pubsub.publish('sync-connections', connections);
7
- }
8
- //# sourceMappingURL=sync-connections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-connections.js","sourceRoot":"","sources":["../../server/controllers/sync-connections.ts"],"names":[],"mappings":";;AAGA,0CAEC;AALD,iDAA8C;AAGvC,KAAK,UAAU,eAAe,CAAC,WAAyB,EAAE,OAAwB;IACvF,cAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import { pubsub } from '@things-factory/shell'\nimport { Connection } from '@things-factory/integration-base'\n\nexport async function syncConnections(connections: Connection[], context: ResolverContext): Promise<any> {\n pubsub.publish('sync-connections', connections)\n}\n"]}
@@ -1,14 +0,0 @@
1
- import { Connector, InputConnection } from '@things-factory/integration-base';
2
- /**
3
- * This connector only serves the role of a tag specifying that a particular step of the task will be performed on the Edge Server,
4
- * and therefore, contains no special logic.
5
- */
6
- export declare class EdgeConnector implements Connector {
7
- ready(connectionConfigs: InputConnection[]): Promise<void>;
8
- connect(connection: InputConnection): Promise<void>;
9
- disconnect(connection: InputConnection): Promise<void>;
10
- get parameterSpec(): any[];
11
- get taskPrefixes(): any[];
12
- get help(): string;
13
- get description(): string;
14
- }
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EdgeConnector = void 0;
4
- const integration_base_1 = require("@things-factory/integration-base");
5
- /**
6
- * This connector only serves the role of a tag specifying that a particular step of the task will be performed on the Edge Server,
7
- * and therefore, contains no special logic.
8
- */
9
- class EdgeConnector {
10
- async ready(connectionConfigs) {
11
- await Promise.all(connectionConfigs.map(this.connect.bind(this)));
12
- integration_base_1.ConnectionManager.logger.info('edge-connector connections are ready');
13
- }
14
- async connect(connection) {
15
- const edge = {};
16
- integration_base_1.ConnectionManager.addConnectionInstance(connection, edge);
17
- integration_base_1.ConnectionManager.logger.info(`edge-connector connection(${connection.name}:${connection.endpoint}) is connected`);
18
- }
19
- async disconnect(connection) {
20
- integration_base_1.ConnectionManager.removeConnectionInstance(connection);
21
- integration_base_1.ConnectionManager.logger.info(`edge-connector connection(${connection.name}) is disconnected`);
22
- }
23
- get parameterSpec() {
24
- return [];
25
- }
26
- get taskPrefixes() {
27
- return []; // intentionally empty
28
- }
29
- get help() {
30
- return 'integration/connector/edge-connector';
31
- }
32
- get description() {
33
- return 'Operato Edge Connector';
34
- }
35
- }
36
- exports.EdgeConnector = EdgeConnector;
37
- integration_base_1.ConnectionManager.registerConnector('edge-connector', new EdgeConnector());
38
- //# sourceMappingURL=edge-connector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/edge-connector.ts"],"names":[],"mappings":";;;AAAA,uEAAgG;AAEhG;;;GAGG;AACH,MAAa,aAAa;IACxB,KAAK,CAAC,KAAK,CAAC,iBAAoC;QAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAEjE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAA;IACvE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAA2B;QACvC,MAAM,IAAI,GAAG,EAAE,CAAA;QAEf,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAEzD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CAAC,CAAA;IACpH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAA2B;QAC1C,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IAChG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,EAAE,CAAA,CAAC,sBAAsB;IAClC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,sCAAsC,CAAA;IAC/C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,wBAAwB,CAAA;IACjC,CAAC;CACF;AApCD,sCAoCC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,aAAa,EAAE,CAAC,CAAA","sourcesContent":["import { Connector, ConnectionManager, InputConnection } from '@things-factory/integration-base'\n\n/**\n * This connector only serves the role of a tag specifying that a particular step of the task will be performed on the Edge Server,\n * and therefore, contains no special logic.\n */\nexport class EdgeConnector implements Connector {\n async ready(connectionConfigs: InputConnection[]) {\n await Promise.all(connectionConfigs.map(this.connect.bind(this)))\n\n ConnectionManager.logger.info('edge-connector connections are ready')\n }\n\n async connect(connection: InputConnection) {\n const edge = {}\n\n ConnectionManager.addConnectionInstance(connection, edge)\n\n ConnectionManager.logger.info(`edge-connector connection(${connection.name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection: InputConnection) {\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`edge-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return [] // intentionally empty\n }\n\n get help() {\n return 'integration/connector/edge-connector'\n }\n\n get description() {\n return 'Operato Edge Connector'\n }\n}\n\nConnectionManager.registerConnector('edge-connector', new EdgeConnector())\n"]}
@@ -1 +0,0 @@
1
- import './connector/edge-connector';
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./connector/edge-connector");
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,sCAAmC","sourcesContent":["import './connector/edge-connector'\n"]}
@@ -1,2 +0,0 @@
1
- export * from './service';
2
- import './engine';
@@ -1,19 +0,0 @@
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 integration_base_1 = require("@things-factory/integration-base");
6
- const run_task_1 = require("./controllers/run-task");
7
- const sync_connections_1 = require("./controllers/sync-connections");
8
- const connect_connections_1 = require("./controllers/connect-connections");
9
- const disconnect_connections_1 = require("./controllers/disconnect-connections");
10
- require("./engine"); // for registering edge-connector
11
- process.on('bootstrap-module-start', async ({ app, config, client }) => {
12
- (0, integration_base_1.setEdgeClient)({
13
- handler: run_task_1.runTask,
14
- syncConnections: sync_connections_1.syncConnections,
15
- connectConnections: connect_connections_1.connectConnections,
16
- disconnectConnections: disconnect_connections_1.disconnectConnections
17
- });
18
- });
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AAEzB,uEAAgE;AAChE,qDAAgD;AAChD,qEAAgE;AAChE,2EAAsE;AACtE,iFAA4E;AAC5E,oBAAiB,CAAC,iCAAiC;AAEnD,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAA,gCAAa,EAAC;QACZ,OAAO,EAAE,kBAAO;QAChB,eAAe,EAAf,kCAAe;QACf,kBAAkB,EAAlB,wCAAkB;QAClB,qBAAqB,EAArB,8CAAqB;KACtB,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["export * from './service'\n\nimport { setEdgeClient } from '@things-factory/integration-base'\nimport { runTask } from './controllers/run-task'\nimport { syncConnections } from './controllers/sync-connections'\nimport { connectConnections } from './controllers/connect-connections'\nimport { disconnectConnections } from './controllers/disconnect-connections'\nimport './engine' // for registering edge-connector\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n setEdgeClient({\n handler: runTask,\n syncConnections,\n connectConnections,\n disconnectConnections\n })\n})\n"]}
@@ -1,4 +0,0 @@
1
- import { RunTaskCallbackInput } from './edge-client-type';
2
- export declare class EdgeClientMutation {
3
- runTaskCallback(result: RunTaskCallbackInput, context: ResolverContext): Promise<boolean>;
4
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EdgeClientMutation = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const auth_base_1 = require("@things-factory/auth-base");
7
- const lock_client_1 = require("@things-factory/lock-client");
8
- const edge_client_type_1 = require("./edge-client-type");
9
- let EdgeClientMutation = class EdgeClientMutation {
10
- async runTaskCallback(result, context) {
11
- const { id, out, logs, error } = result;
12
- await (0, lock_client_1.releaseLock)({ id, payload: { out, logs, error } });
13
- return true;
14
- }
15
- };
16
- exports.EdgeClientMutation = EdgeClientMutation;
17
- tslib_1.__decorate([
18
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To receive the result of runTask' }),
19
- tslib_1.__param(0, (0, type_graphql_1.Arg)('result', type => edge_client_type_1.RunTaskCallbackInput)),
20
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
21
- tslib_1.__metadata("design:type", Function),
22
- tslib_1.__metadata("design:paramtypes", [edge_client_type_1.RunTaskCallbackInput, Object]),
23
- tslib_1.__metadata("design:returntype", Promise)
24
- ], EdgeClientMutation.prototype, "runTaskCallback", null);
25
- exports.EdgeClientMutation = EdgeClientMutation = tslib_1.__decorate([
26
- (0, type_graphql_1.Resolver)(auth_base_1.Appliance)
27
- ], EdgeClientMutation);
28
- //# sourceMappingURL=edge-client-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge-client-mutation.js","sourceRoot":"","sources":["../../../server/service/appliance/edge-client-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,yDAAqD;AACrD,6DAAyD;AAEzD,yDAAyD;AAGlD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,eAAe,CAA8C,MAA4B,EAAS,OAAwB;QAC9H,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;QAEvC,MAAM,IAAA,yBAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QAExD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AATY,gDAAkB;AAEvB;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;IAC3D,mBAAA,IAAA,kBAAG,EAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,uCAAoB,CAAC,CAAA;IAAgC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAA5B,uCAAoB;;yDAM9F;6BARU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,kBAAkB,CAS9B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Appliance } from '@things-factory/auth-base'\nimport { releaseLock } from '@things-factory/lock-client'\n\nimport { RunTaskCallbackInput } from './edge-client-type'\n\n@Resolver(Appliance)\nexport class EdgeClientMutation {\n @Mutation(returns => Boolean, { description: 'To receive the result of runTask' })\n async runTaskCallback(@Arg('result', type => RunTaskCallbackInput) result: RunTaskCallbackInput, @Ctx() context: ResolverContext): Promise<boolean> {\n const { id, out, logs, error } = result\n\n await releaseLock({ id, payload: { out, logs, error } })\n\n return true\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { Connection } from '@things-factory/integration-base';
2
- import { RunTaskPayload } from './edge-client-type';
3
- export declare class EdgeClientSubscription {
4
- syncConnections(payload: Connection[]): Connection[];
5
- connectConnections(payload: Connection[]): Connection[];
6
- disconnectConnections(payload: Connection[]): Connection[];
7
- runTask(payload: RunTaskPayload): RunTaskPayload;
8
- }
@@ -1,209 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EdgeClientSubscription = void 0;
4
- const tslib_1 = require("tslib");
5
- const graphql_yoga_1 = require("graphql-yoga");
6
- const type_graphql_1 = require("type-graphql");
7
- const shell_1 = require("@things-factory/shell");
8
- const auth_base_1 = require("@things-factory/auth-base");
9
- const integration_base_1 = require("@things-factory/integration-base");
10
- const edge_client_type_1 = require("./edge-client-type");
11
- let EdgeClientSubscription = class EdgeClientSubscription {
12
- syncConnections(payload) {
13
- return payload.map(connection => {
14
- return Object.assign(Object.assign({}, connection), { params: JSON.stringify(connection.params) });
15
- });
16
- }
17
- connectConnections(payload) {
18
- return payload.map(connection => {
19
- return Object.assign(Object.assign({}, connection), { params: JSON.stringify(connection.params) });
20
- });
21
- }
22
- disconnectConnections(payload) {
23
- return payload.map(connection => {
24
- return Object.assign(Object.assign({}, connection), { params: JSON.stringify(connection.params) });
25
- });
26
- }
27
- runTask(payload) {
28
- const { id, step, context } = payload;
29
- const { name, task, description, connection, params } = step;
30
- return {
31
- id, // requestId
32
- step: {
33
- name,
34
- task,
35
- description,
36
- connection,
37
- params: JSON.stringify(params)
38
- },
39
- context
40
- };
41
- }
42
- };
43
- exports.EdgeClientSubscription = EdgeClientSubscription;
44
- tslib_1.__decorate([
45
- (0, type_graphql_1.Subscription)(type => [integration_base_1.Connection], {
46
- subscribe: async ({ args, context, info }) => {
47
- var _a;
48
- const { domain, user } = context.state;
49
- const subdomain = domain === null || domain === void 0 ? void 0 : domain.subdomain;
50
- if (!domain) {
51
- throw new Error('domain required');
52
- }
53
- if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
54
- throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
55
- }
56
- const appliance = user.reference &&
57
- (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOne({
58
- where: {
59
- id: user.reference
60
- }
61
- }));
62
- if (!appliance) {
63
- throw new Error('Appliance not found');
64
- }
65
- process.nextTick(async () => {
66
- const connections = Object.values(integration_base_1.ConnectionManager.getConnectionInstanceEntities(domain)).filter(({ edgeId }) => edgeId == appliance.id);
67
- if (connections.length > 0) {
68
- shell_1.pubsub.publish('sync-connections', connections);
69
- }
70
- });
71
- return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('sync-connections'), (0, graphql_yoga_1.filter)(async (payload) => {
72
- const connections = payload;
73
- const { edgeId } = connections[0];
74
- if (connections.find(connection => { var _a; return ((_a = connection.domain) === null || _a === void 0 ? void 0 : _a.subdomain) !== subdomain; })) {
75
- return false;
76
- }
77
- if (!edgeId || (appliance === null || appliance === void 0 ? void 0 : appliance.id) !== edgeId) {
78
- return false;
79
- }
80
- return true;
81
- }));
82
- }
83
- }),
84
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
85
- tslib_1.__metadata("design:type", Function),
86
- tslib_1.__metadata("design:paramtypes", [Array]),
87
- tslib_1.__metadata("design:returntype", Array)
88
- ], EdgeClientSubscription.prototype, "syncConnections", null);
89
- tslib_1.__decorate([
90
- (0, type_graphql_1.Subscription)(type => [integration_base_1.Connection], {
91
- subscribe: async ({ args, context, info }) => {
92
- var _a;
93
- const { domain, user } = context.state;
94
- const subdomain = domain === null || domain === void 0 ? void 0 : domain.subdomain;
95
- if (!domain) {
96
- throw new Error('domain required');
97
- }
98
- if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
99
- throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
100
- }
101
- const appliance = user.reference &&
102
- (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOne({
103
- where: {
104
- id: user.reference
105
- }
106
- }));
107
- if (!appliance) {
108
- throw new Error('Appliance not found');
109
- }
110
- return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('connect-connections'), (0, graphql_yoga_1.filter)(async (payload) => {
111
- const connections = payload;
112
- const { edgeId } = connections[0];
113
- if (connections.find(connection => { var _a; return ((_a = connection.domain) === null || _a === void 0 ? void 0 : _a.subdomain) !== subdomain; })) {
114
- return false;
115
- }
116
- if (!edgeId || (appliance === null || appliance === void 0 ? void 0 : appliance.id) !== edgeId) {
117
- return false;
118
- }
119
- return true;
120
- }));
121
- }
122
- }),
123
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
124
- tslib_1.__metadata("design:type", Function),
125
- tslib_1.__metadata("design:paramtypes", [Array]),
126
- tslib_1.__metadata("design:returntype", Array)
127
- ], EdgeClientSubscription.prototype, "connectConnections", null);
128
- tslib_1.__decorate([
129
- (0, type_graphql_1.Subscription)(type => [integration_base_1.Connection], {
130
- subscribe: async ({ args, context, info }) => {
131
- var _a;
132
- const { domain, user } = context.state;
133
- const subdomain = domain === null || domain === void 0 ? void 0 : domain.subdomain;
134
- if (!domain) {
135
- throw new Error('domain required');
136
- }
137
- if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
138
- throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
139
- }
140
- const appliance = user.reference &&
141
- (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOne({
142
- where: {
143
- id: user.reference
144
- }
145
- }));
146
- if (!appliance) {
147
- throw new Error('Appliance not found');
148
- }
149
- return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('disconnect-connections'), (0, graphql_yoga_1.filter)(async (payload) => {
150
- const connections = payload;
151
- const { edgeId } = connections[0];
152
- if (connections.find(connection => { var _a; return ((_a = connection.domain) === null || _a === void 0 ? void 0 : _a.subdomain) !== subdomain; })) {
153
- return false;
154
- }
155
- if (!edgeId || (appliance === null || appliance === void 0 ? void 0 : appliance.id) !== edgeId) {
156
- return false;
157
- }
158
- return true;
159
- }));
160
- }
161
- }),
162
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
163
- tslib_1.__metadata("design:type", Function),
164
- tslib_1.__metadata("design:paramtypes", [Array]),
165
- tslib_1.__metadata("design:returntype", Array)
166
- ], EdgeClientSubscription.prototype, "disconnectConnections", null);
167
- tslib_1.__decorate([
168
- (0, type_graphql_1.Subscription)({
169
- subscribe: async ({ args, context, info }) => {
170
- var _a;
171
- const { domain, user } = context.state;
172
- const subdomain = domain === null || domain === void 0 ? void 0 : domain.subdomain;
173
- if (!domain) {
174
- throw new Error('domain required');
175
- }
176
- if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
177
- throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
178
- }
179
- const appliance = user.reference &&
180
- (await (0, shell_1.getRepository)(auth_base_1.Appliance).findOne({
181
- where: {
182
- id: user.reference
183
- }
184
- }));
185
- if (!appliance) {
186
- throw new Error('Appliance not found');
187
- }
188
- return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('run-task'), (0, graphql_yoga_1.filter)(async (payload) => {
189
- const { domainId, connection } = payload.step;
190
- if (domainId !== domain.id) {
191
- return false;
192
- }
193
- const { edgeId } = connection && integration_base_1.ConnectionManager.getConnectionInstanceEntityByName(domain, connection);
194
- if (!edgeId || (appliance === null || appliance === void 0 ? void 0 : appliance.id) !== edgeId) {
195
- return false;
196
- }
197
- return true;
198
- }));
199
- }
200
- }),
201
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
202
- tslib_1.__metadata("design:type", Function),
203
- tslib_1.__metadata("design:paramtypes", [edge_client_type_1.RunTaskPayload]),
204
- tslib_1.__metadata("design:returntype", edge_client_type_1.RunTaskPayload)
205
- ], EdgeClientSubscription.prototype, "runTask", null);
206
- exports.EdgeClientSubscription = EdgeClientSubscription = tslib_1.__decorate([
207
- (0, type_graphql_1.Resolver)(auth_base_1.Appliance)
208
- ], EdgeClientSubscription);
209
- //# sourceMappingURL=edge-client-subscription.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge-client-subscription.js","sourceRoot":"","sources":["../../../server/service/appliance/edge-client-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAqE;AACrE,yDAA2D;AAC3D,uEAAsF;AAEtF,yDAAgE;AAGzD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAuDjC,eAAe,CAAS,OAAqB;QAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC9B,uCACK,UAAU,KACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,IAC1C;QACH,CAAC,CAAQ,CAAA;IACX,CAAC;IA8CD,kBAAkB,CAAS,OAAqB;QAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC9B,uCACK,UAAU,KACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,IAC1C;QACH,CAAC,CAAQ,CAAA;IACX,CAAC;IA8CD,qBAAqB,CAAS,OAAqB;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC9B,uCACK,UAAU,KACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,IAC1C;QACH,CAAC,CAAQ,CAAA;IACX,CAAC;IA8CD,OAAO,CAAS,OAAuB;QACrC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QACrC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IA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c;4CAAG,iCAAc;qDAevD;iCArOU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,sBAAsB,CAsOlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Resolver, Subscription, Root, Arg } from 'type-graphql'\n\nimport { pubsub, getRepository, Domain } from '@things-factory/shell'\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { ConnectionManager, Connection, Step } from '@things-factory/integration-base'\n\nimport { EdgeContext, RunTaskPayload } from './edge-client-type'\n\n@Resolver(Appliance)\nexport class EdgeClientSubscription {\n @Subscription(type => [Connection], {\n subscribe: async ({ args, context, info }) => {\n const { domain, user }: { domain: Domain; user: User } = context.state\n const subdomain = domain?.subdomain\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n const appliance =\n user.reference &&\n (await getRepository(Appliance).findOne({\n where: {\n id: user.reference\n }\n }))\n\n if (!appliance) {\n throw new Error('Appliance not found')\n }\n\n process.nextTick(async () => {\n const connections = Object.values(ConnectionManager.getConnectionInstanceEntities(domain)).filter(\n ({ edgeId }) => edgeId == appliance.id\n )\n\n if (connections.length > 0) {\n pubsub.publish('sync-connections', connections)\n }\n })\n\n return pipe(\n pubsub.subscribe('sync-connections'),\n filter(async (payload: Connection[]) => {\n const connections = payload\n const { edgeId } = connections[0]\n\n if (connections.find(connection => connection.domain?.subdomain !== subdomain)) {\n return false\n }\n\n if (!edgeId || appliance?.id !== edgeId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n syncConnections(@Root() payload: Connection[]): Connection[] {\n return payload.map(connection => {\n return {\n ...connection,\n params: JSON.stringify(connection.params)\n }\n }) as any\n }\n\n @Subscription(type => [Connection], {\n subscribe: async ({ args, context, info }) => {\n const { domain, user }: { domain: Domain; user: User } = context.state\n const subdomain = domain?.subdomain\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n const appliance =\n user.reference &&\n (await getRepository(Appliance).findOne({\n where: {\n id: user.reference\n }\n }))\n\n if (!appliance) {\n throw new Error('Appliance not found')\n }\n\n return pipe(\n pubsub.subscribe('connect-connections'),\n filter(async (payload: Connection[]) => {\n const connections = payload\n const { edgeId } = connections[0]\n\n if (connections.find(connection => connection.domain?.subdomain !== subdomain)) {\n return false\n }\n\n if (!edgeId || appliance?.id !== edgeId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n connectConnections(@Root() payload: Connection[]): Connection[] {\n return payload.map(connection => {\n return {\n ...connection,\n params: JSON.stringify(connection.params)\n }\n }) as any\n }\n\n @Subscription(type => [Connection], {\n subscribe: async ({ args, context, info }) => {\n const { domain, user }: { domain: Domain; user: User } = context.state\n const subdomain = domain?.subdomain\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n const appliance =\n user.reference &&\n (await getRepository(Appliance).findOne({\n where: {\n id: user.reference\n }\n }))\n\n if (!appliance) {\n throw new Error('Appliance not found')\n }\n\n return pipe(\n pubsub.subscribe('disconnect-connections'),\n filter(async (payload: Connection[]) => {\n const connections = payload\n const { edgeId } = connections[0]\n\n if (connections.find(connection => connection.domain?.subdomain !== subdomain)) {\n return false\n }\n\n if (!edgeId || appliance?.id !== edgeId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n disconnectConnections(@Root() payload: Connection[]): Connection[] {\n return payload.map(connection => {\n return {\n ...connection,\n params: JSON.stringify(connection.params)\n }\n }) as any\n }\n\n @Subscription({\n subscribe: async ({ args, context, info }) => {\n const { domain, user }: { domain: Domain; user: User } = context.state\n\n const subdomain = domain?.subdomain\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n const appliance =\n user.reference &&\n (await getRepository(Appliance).findOne({\n where: {\n id: user.reference\n }\n }))\n\n if (!appliance) {\n throw new Error('Appliance not found')\n }\n return pipe(\n pubsub.subscribe('run-task'),\n filter(async (payload: { id: string; step: Step; context: EdgeContext }) => {\n const { domainId, connection } = payload.step\n\n if (domainId !== domain.id) {\n return false\n }\n\n const { edgeId } = connection && ConnectionManager.getConnectionInstanceEntityByName(domain, connection)\n\n if (!edgeId || appliance?.id !== edgeId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n runTask(@Root() payload: RunTaskPayload): RunTaskPayload {\n const { id, step, context } = payload\n const { name, task, description, connection, params } = step\n\n return {\n id, // requestId\n step: {\n name,\n task,\n description,\n connection,\n params: JSON.stringify(params)\n },\n context\n }\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- import { Step } from '@things-factory/integration-base';
2
- export declare class EdgeContext {
3
- domain: any;
4
- data: any;
5
- variables: any;
6
- lng: string;
7
- }
8
- export declare class RunTaskPayload {
9
- id: string;
10
- step: Step;
11
- context: EdgeContext;
12
- }
13
- export declare class RunTaskCallbackInput {
14
- id: string;
15
- out: any;
16
- logs: any;
17
- error: any;
18
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RunTaskCallbackInput = exports.RunTaskPayload = exports.EdgeContext = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const shell_1 = require("@things-factory/shell");
7
- const integration_base_1 = require("@things-factory/integration-base");
8
- let EdgeContext = class EdgeContext {
9
- };
10
- exports.EdgeContext = EdgeContext;
11
- tslib_1.__decorate([
12
- (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
13
- tslib_1.__metadata("design:type", Object)
14
- ], EdgeContext.prototype, "domain", void 0);
15
- tslib_1.__decorate([
16
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
17
- tslib_1.__metadata("design:type", Object)
18
- ], EdgeContext.prototype, "data", void 0);
19
- tslib_1.__decorate([
20
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
21
- tslib_1.__metadata("design:type", Object)
22
- ], EdgeContext.prototype, "variables", void 0);
23
- tslib_1.__decorate([
24
- (0, type_graphql_1.Field)({ nullable: true }),
25
- tslib_1.__metadata("design:type", String)
26
- ], EdgeContext.prototype, "lng", void 0);
27
- exports.EdgeContext = EdgeContext = tslib_1.__decorate([
28
- (0, type_graphql_1.ObjectType)()
29
- ], EdgeContext);
30
- let RunTaskPayload = class RunTaskPayload {
31
- };
32
- exports.RunTaskPayload = RunTaskPayload;
33
- tslib_1.__decorate([
34
- (0, type_graphql_1.Field)(),
35
- tslib_1.__metadata("design:type", String)
36
- ], RunTaskPayload.prototype, "id", void 0);
37
- tslib_1.__decorate([
38
- (0, type_graphql_1.Field)(),
39
- tslib_1.__metadata("design:type", integration_base_1.Step)
40
- ], RunTaskPayload.prototype, "step", void 0);
41
- tslib_1.__decorate([
42
- (0, type_graphql_1.Field)(),
43
- tslib_1.__metadata("design:type", EdgeContext)
44
- ], RunTaskPayload.prototype, "context", void 0);
45
- exports.RunTaskPayload = RunTaskPayload = tslib_1.__decorate([
46
- (0, type_graphql_1.ObjectType)()
47
- ], RunTaskPayload);
48
- let RunTaskCallbackInput = class RunTaskCallbackInput {
49
- };
50
- exports.RunTaskCallbackInput = RunTaskCallbackInput;
51
- tslib_1.__decorate([
52
- (0, type_graphql_1.Field)({ nullable: true }),
53
- tslib_1.__metadata("design:type", String)
54
- ], RunTaskCallbackInput.prototype, "id", void 0);
55
- tslib_1.__decorate([
56
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
57
- tslib_1.__metadata("design:type", Object)
58
- ], RunTaskCallbackInput.prototype, "out", void 0);
59
- tslib_1.__decorate([
60
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
61
- tslib_1.__metadata("design:type", Object)
62
- ], RunTaskCallbackInput.prototype, "logs", void 0);
63
- tslib_1.__decorate([
64
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
65
- tslib_1.__metadata("design:type", Object)
66
- ], RunTaskCallbackInput.prototype, "error", void 0);
67
- exports.RunTaskCallbackInput = RunTaskCallbackInput = tslib_1.__decorate([
68
- (0, type_graphql_1.InputType)()
69
- ], RunTaskCallbackInput);
70
- //# sourceMappingURL=edge-client-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge-client-type.js","sourceRoot":"","sources":["../../../server/service/appliance/edge-client-type.ts"],"names":[],"mappings":";;;;AAAA,+CAA2D;AAE3D,iDAA4D;AAC5D,uEAAuD;AAGhD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAYvB,CAAA;AAZY,kCAAW;AAEtB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAC/B;AAGX;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACvC;AAGT;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAClC;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACf;sBAXA,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAYvB;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAS1B,CAAA;AATY,wCAAc;AAEzB;IADC,IAAA,oBAAK,GAAE;;0CACE;AAGV;IADC,IAAA,oBAAK,GAAE;sCACF,uBAAI;4CAAA;AAGV;IADC,IAAA,oBAAK,GAAE;sCACC,WAAW;+CAAA;yBART,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAS1B;AAGM,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAYhC,CAAA;AAZY,oDAAoB;AAE/B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAChB;AAGV;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACxC;AAGR;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACvC;AAGT;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACtC;+BAXC,oBAAoB;IADhC,IAAA,wBAAS,GAAE;GACC,oBAAoB,CAYhC","sourcesContent":["import { InputType, ObjectType, Field } from 'type-graphql'\n\nimport { Domain, ScalarObject } from '@things-factory/shell'\nimport { Step } from '@things-factory/integration-base'\n\n@ObjectType()\nexport class EdgeContext {\n @Field(type => Domain, { nullable: true })\n domain: any\n\n @Field(type => ScalarObject, { nullable: true })\n data: any\n\n @Field(type => ScalarObject, { nullable: true })\n variables: any\n\n @Field({ nullable: true })\n lng: string\n}\n\n@ObjectType()\nexport class RunTaskPayload {\n @Field()\n id: string\n\n @Field()\n step: Step\n\n @Field()\n context: EdgeContext\n}\n\n@InputType()\nexport class RunTaskCallbackInput {\n @Field({ nullable: true })\n id: string\n\n @Field(type => ScalarObject, { nullable: true })\n out: any\n\n @Field(type => ScalarObject, { nullable: true })\n logs: any\n\n @Field(type => ScalarObject, { nullable: true })\n error: any\n}\n"]}