@things-factory/integration-base 5.0.0 → 5.0.11
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/db.test.sqlite +0 -0
- package/dist-server/engine/connection-manager.js +2 -4
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/echo-back-connector.js +3 -5
- package/dist-server/engine/connector/echo-back-connector.js.map +1 -1
- package/dist-server/engine/connector/echo-back-server.js +3 -5
- package/dist-server/engine/connector/echo-back-server.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/index.js.map +1 -1
- package/dist-server/engine/connector/mqtt-connector.js +2 -4
- package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
- package/dist-server/engine/connector/mssql-connector.js.map +1 -1
- package/dist-server/engine/connector/mysql-connector.js +2 -4
- package/dist-server/engine/connector/mysql-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
- package/dist-server/engine/connector/socket-server.js +2 -4
- package/dist-server/engine/connector/socket-server.js.map +1 -1
- package/dist-server/engine/connector/sqlite-connector.js.map +1 -1
- package/dist-server/engine/index.js +4 -17
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/pending-queue.js.map +1 -1
- package/dist-server/engine/scenario-engine.js.map +1 -1
- package/dist-server/engine/task/book-up-scenario.js.map +1 -1
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/echo-receive.js.map +1 -1
- package/dist-server/engine/task/echo-send.js.map +1 -1
- package/dist-server/engine/task/empty-check.js.map +1 -1
- package/dist-server/engine/task/end.js.map +1 -1
- package/dist-server/engine/task/floating-point.js +2 -4
- package/dist-server/engine/task/floating-point.js.map +1 -1
- package/dist-server/engine/task/goto.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.js +2 -4
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.js +2 -4
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/http-get.js +3 -5
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +3 -5
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/engine/task/local-graphql-mutate.js +2 -4
- package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/local-graphql-query.js +2 -4
- package/dist-server/engine/task/local-graphql-query.js.map +1 -1
- package/dist-server/engine/task/log.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +2 -4
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/publish.js.map +1 -1
- package/dist-server/engine/task/reset-pending-queue.js.map +1 -1
- package/dist-server/engine/task/script.js.map +1 -1
- package/dist-server/engine/task/sleep.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-goto.js.map +1 -1
- package/dist-server/engine/task/switch-range-goto.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-set.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-set.js.map +1 -1
- package/dist-server/engine/task/throw.js.map +1 -1
- package/dist-server/engine/task/utils/substitute.js.map +1 -1
- package/dist-server/engine/task/variables.js.map +1 -1
- package/dist-server/engine/task-registry.js.map +1 -1
- package/dist-server/engine/types.js.map +1 -1
- package/dist-server/index.js +4 -17
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/restful/index.js.map +1 -1
- package/dist-server/restful/unstable/index.js.map +1 -1
- package/dist-server/restful/unstable/run-scenario.js +2 -4
- package/dist-server/restful/unstable/run-scenario.js.map +1 -1
- package/dist-server/restful/unstable/scenario-instance.js +2 -4
- package/dist-server/restful/unstable/scenario-instance.js.map +1 -1
- package/dist-server/restful/unstable/scenario-instances.js +2 -4
- package/dist-server/restful/unstable/scenario-instances.js.map +1 -1
- package/dist-server/restful/unstable/scenario.js +2 -4
- package/dist-server/restful/unstable/scenario.js.map +1 -1
- package/dist-server/restful/unstable/scenarios.js +2 -4
- package/dist-server/restful/unstable/scenarios.js.map +1 -1
- package/dist-server/restful/unstable/start-scenario.js +2 -4
- package/dist-server/restful/unstable/start-scenario.js.map +1 -1
- package/dist-server/restful/unstable/stop-scenario.js +2 -4
- package/dist-server/restful/unstable/stop-scenario.js.map +1 -1
- package/dist-server/routers/scenario-view-router.js +2 -4
- package/dist-server/routers/scenario-view-router.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +45 -56
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +35 -46
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +14 -25
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.js +82 -90
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connection/index.js.map +1 -1
- package/dist-server/service/connector/connector-query.js +18 -29
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/connector/connector-type.js +17 -25
- package/dist-server/service/connector/connector-type.js.map +1 -1
- package/dist-server/service/connector/index.js.map +1 -1
- package/dist-server/service/index.js +11 -24
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/payload-log/index.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js +33 -44
- package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-query.js +29 -40
- package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-type.js +20 -28
- package/dist-server/service/payload-log/payload-log-type.js.map +1 -1
- package/dist-server/service/payload-log/payload-log.js +30 -38
- package/dist-server/service/payload-log/payload-log.js.map +1 -1
- package/dist-server/service/property-spec.js +12 -21
- package/dist-server/service/property-spec.js.map +1 -1
- package/dist-server/service/scenario/index.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +45 -56
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +47 -58
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +71 -79
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario-flow/scenario-flow.js +8 -16
- package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
- package/dist-server/service/scenario-instance/index.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +24 -36
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-query.js +44 -55
- package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +17 -28
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +60 -71
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/scenario-queue/index.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js +7 -18
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-type.js +16 -24
- package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
- package/dist-server/service/step/index.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +15 -26
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.js +34 -45
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/service/step/step-type.js +66 -74
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/service/task-type/index.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +19 -30
- package/dist-server/service/task-type/task-type-query.js.map +1 -1
- package/dist-server/service/task-type/task-type-type.js +17 -25
- package/dist-server/service/task-type/task-type-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -6
- package/server/engine/types.ts +1 -2
- package/server/service/property-spec.ts +3 -2
- package/server/service/scenario-instance/scenario-instance-mutation.ts +2 -2
- package/server/service/scenario-instance/scenario-instance-type.ts +4 -4
- package/server/service/scenario-queue/scenario-queue-type.ts +3 -2
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
7
5
|
const api_1 = require("@things-factory/api");
|
|
8
6
|
const debug = require('debug')('things-factory:integration-base:restful:unstable:scenarios');
|
|
9
7
|
function FPSparams(query) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../../server/restful/unstable/scenarios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../../server/restful/unstable/scenarios.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,6CAAgE;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4DAA4D,CAAC,CAAA;AAE5F,SAAS,SAAS,CAAC,KAAK;IACtB,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IAE3B,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,QAAQ,GAAG,EAAE,CAAA;IAEjB,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IACrB,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEvB,IAAI,UAAU,GAAG;QACf,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK;KAClC,CAAA;IAED,OAAO;QACL,OAAO;QACP,QAAQ;QACR,UAAU;KACX,CAAA;AACH,CAAC;AAED,sBAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEhC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAEhE,KAAK,CAAC,yBAAyB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAEhD,OAAO,CAAC,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BT;QACD,SAAS,EAAE;YACT,OAAO;YACP,UAAU;YACV,QAAQ;SACT;QACD,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nconst debug = require('debug')('things-factory:integration-base:restful:unstable:scenarios')\n\nfunction FPSparams(query) {\n var { page, limit } = query\n\n var filters = []\n var sortings = []\n\n page = parseInt(page)\n limit = parseInt(limit)\n\n var pagination = {\n page: isNaN(page) ? 0 : page,\n limit: isNaN(limit) ? 100 : limit\n }\n\n return {\n filters,\n sortings,\n pagination\n }\n}\n\nrouter.get('/unstable/scenarios', async (context, next) => {\n const { client } = context.state\n\n var { filters, sortings, pagination } = FPSparams(context.query)\n\n debug('get:/unstable/scenarios', context.params)\n\n context.body = await client.query({\n query: gql`\n query($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {\n scenarios(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\n state\n schedule\n timezone\n steps {\n id\n name\n description\n sequence\n task\n skip\n log\n connection\n params\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination,\n sortings\n },\n context\n })\n})\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
7
5
|
const api_1 = require("@things-factory/api");
|
|
8
6
|
const debug = require('debug')('things-factory:integration-base:restful:unstable:start-scenario');
|
|
9
7
|
api_1.restfulApiRouter.post('/unstable/start-scenario/:scenarioName', async (context, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/start-scenario.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/start-scenario.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,6CAAgE;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iEAAiE,CAAC,CAAA;AAEjG,sBAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC5E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IACvC,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA;IAExE,KAAK,CAAC,6CAA6C,EAAE,YAAY,CAAC,CAAA;IAElE,OAAO,CAAC,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;KAWZ;QACD,SAAS,EAAE;YACT,YAAY;YACZ,YAAY;YACZ,SAAS;SACV;QACD,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nconst debug = require('debug')('things-factory:integration-base:restful:unstable:start-scenario')\n\nrouter.post('/unstable/start-scenario/:scenarioName', async (context, next) => {\n const { client } = context.state\n const { scenarioName } = context.params\n const { instanceName = '', variables = {} } = context.request.body || {}\n\n debug('post:/unstable/start-scenario/:scenarioName', scenarioName)\n\n context.body = await client.mutate({\n mutation: gql`\n mutation($instanceName: String, $scenarioName: String!, $variables: Object) {\n startScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {\n instanceName\n scenarioName\n state\n data\n message\n timestamp\n }\n }\n `,\n variables: {\n instanceName,\n scenarioName,\n variables\n },\n context\n })\n})\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
|
|
7
5
|
const api_1 = require("@things-factory/api");
|
|
8
6
|
const debug = require('debug')('things-factory:integration-base:restful:unstable:stop-scenario');
|
|
9
7
|
api_1.restfulApiRouter.post('/unstable/stop-scenario/:instanceName', async (context, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stop-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/stop-scenario.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stop-scenario.js","sourceRoot":"","sources":["../../../server/restful/unstable/stop-scenario.ts"],"names":[],"mappings":";;;AAAA,sEAA6B;AAC7B,6CAAgE;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,gEAAgE,CAAC,CAAA;AAEhG,sBAAM,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAEvC,KAAK,CAAC,4CAA4C,EAAE,YAAY,CAAC,CAAA;IAEjE,OAAO,CAAC,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,QAAQ,EAAE,IAAA,qBAAG,EAAA;;;;;;;;;;;KAWZ;QACD,SAAS,EAAE;YACT,YAAY;SACb;QACD,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\nimport { restfulApiRouter as router } from '@things-factory/api'\n\nconst debug = require('debug')('things-factory:integration-base:restful:unstable:stop-scenario')\n\nrouter.post('/unstable/stop-scenario/:instanceName', async (context, next) => {\n const { client } = context.state\n const { instanceName } = context.params\n\n debug('post:/unstable/stop-scenario/:scenarioName', instanceName)\n\n context.body = await client.mutate({\n mutation: gql`\n mutation($instanceName: String!) {\n stopScenario(instanceName: $instanceName) {\n instanceName\n scenarioName\n state\n data\n message\n timestamp\n }\n }\n `,\n variables: {\n instanceName\n },\n context\n })\n})\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.scenarioViewRouter = void 0;
|
|
7
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const koa_router_1 = tslib_1.__importDefault(require("koa-router"));
|
|
8
6
|
const typeorm_1 = require("typeorm");
|
|
9
7
|
const service_1 = require("../service");
|
|
10
8
|
exports.scenarioViewRouter = new koa_router_1.default();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-view-router.js","sourceRoot":"","sources":["../../server/routers/scenario-view-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scenario-view-router.js","sourceRoot":"","sources":["../../server/routers/scenario-view-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAC/B,qCAAuC;AACvC,wCAA2C;AAE9B,QAAA,kBAAkB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE9C,0BAAkB,CAAC,GAAG,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAChC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;IAE/B,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAa,EAAC,kBAAQ,CAAC,CAAC,OAAO,CACpD;QACE,MAAM;QACN,IAAI;KACL,EACD;QACE,SAAS,EAAE,CAAC,OAAO,CAAC;KACrB,CACF,CAAA;IAED,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAK,CAAA;IACpC,MAAM,KAAK,GAAG,EAAE,CAAA;IAChB,MAAM,KAAK,GAAG,EAAE,CAAA;IAEhB,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7B,KAAK,CAAC,EAAE,CAAC,GAAG;YACV,EAAE;YACF,IAAI;SACL,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACzC,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;YACnB,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;SACxB,CAAC,CAAA;KACH;IAED,MAAM,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;QACpC,KAAK,EAAE;YACL,KAAK;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\nimport { getRepository } from 'typeorm'\nimport { Scenario, Step } from '../service'\n\nexport const scenarioViewRouter = new Router()\n\nscenarioViewRouter.get('/scenario-view/:name', async (context, next) => {\n const { domain } = context.state\n const { name } = context.params\n\n const scenario = await getRepository(Scenario).findOne(\n {\n domain,\n name\n },\n {\n relations: ['steps']\n }\n )\n\n const steps: Step[] = scenario.steps\n const nodes = {}\n const edges = []\n\n steps.forEach(({ id, name }) => {\n nodes[id] = {\n id,\n name\n }\n })\n\n for (let i = 0; i < steps.length - 1; i++) {\n edges.push({\n source: steps[i].id,\n target: steps[i + 1].id\n })\n }\n\n await context.render('scenario-view', {\n model: {\n nodes,\n edges\n }\n })\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAE5C,yEAAmE;AAEnE,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE;QACpB,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC7G;SAAM;QACL,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC9F;AACH,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAE5C,yEAAmE;AAEnE,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE;QACpB,mBAAmB,CAAC,GAAG,CAAC,iBAAiB,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC7G;SAAM;QACL,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;KAC9F;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\n\nimport { scenarioViewRouter } from './routers/scenario-view-router'\n\nconst isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use('/domain/:domain', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n } else {\n domainPrivateRouter.use('', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n }\n})\n"]}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.ConnectionMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const type_graphql_1 = require("type-graphql");
|
|
17
6
|
const typeorm_1 = require("typeorm");
|
|
18
7
|
const connection_manager_1 = require("../../engine/connection-manager");
|
|
@@ -93,69 +82,69 @@ let ConnectionMutation = class ConnectionMutation {
|
|
|
93
82
|
: connection_type_1.ConnectionStatus.DISCONNECTED });
|
|
94
83
|
}
|
|
95
84
|
};
|
|
96
|
-
__decorate([
|
|
85
|
+
tslib_1.__decorate([
|
|
97
86
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
98
87
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To create new connection' }),
|
|
99
|
-
__param(0, (0, type_graphql_1.Arg)('connection')),
|
|
100
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
101
|
-
__metadata("design:type", Function),
|
|
102
|
-
__metadata("design:paramtypes", [connection_type_1.NewConnection, Object]),
|
|
103
|
-
__metadata("design:returntype", Promise)
|
|
88
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('connection')),
|
|
89
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
90
|
+
tslib_1.__metadata("design:type", Function),
|
|
91
|
+
tslib_1.__metadata("design:paramtypes", [connection_type_1.NewConnection, Object]),
|
|
92
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
104
93
|
], ConnectionMutation.prototype, "createConnection", null);
|
|
105
|
-
__decorate([
|
|
94
|
+
tslib_1.__decorate([
|
|
106
95
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
107
96
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To modify connection information' }),
|
|
108
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
109
|
-
__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
110
|
-
__param(2, (0, type_graphql_1.Ctx)()),
|
|
111
|
-
__metadata("design:type", Function),
|
|
112
|
-
__metadata("design:paramtypes", [String, connection_type_1.ConnectionPatch, Object]),
|
|
113
|
-
__metadata("design:returntype", Promise)
|
|
97
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
98
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
99
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
100
|
+
tslib_1.__metadata("design:type", Function),
|
|
101
|
+
tslib_1.__metadata("design:paramtypes", [String, connection_type_1.ConnectionPatch, Object]),
|
|
102
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
114
103
|
], ConnectionMutation.prototype, "updateConnection", null);
|
|
115
|
-
__decorate([
|
|
104
|
+
tslib_1.__decorate([
|
|
116
105
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
117
106
|
(0, type_graphql_1.Mutation)(returns => [connection_type_1.Connection], { description: "To modify multiple connections' information" }),
|
|
118
|
-
__param(0, (0, type_graphql_1.Arg)('patches', type => [connection_type_1.ConnectionPatch])),
|
|
119
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
120
|
-
__metadata("design:type", Function),
|
|
121
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
122
|
-
__metadata("design:returntype", Promise)
|
|
107
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [connection_type_1.ConnectionPatch])),
|
|
108
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
109
|
+
tslib_1.__metadata("design:type", Function),
|
|
110
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
111
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
123
112
|
], ConnectionMutation.prototype, "updateMultipleConnection", null);
|
|
124
|
-
__decorate([
|
|
113
|
+
tslib_1.__decorate([
|
|
125
114
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
126
115
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete connection' }),
|
|
127
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
128
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
129
|
-
__metadata("design:type", Function),
|
|
130
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
131
|
-
__metadata("design:returntype", Promise)
|
|
116
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
117
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
118
|
+
tslib_1.__metadata("design:type", Function),
|
|
119
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
120
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
132
121
|
], ConnectionMutation.prototype, "deleteConnection", null);
|
|
133
|
-
__decorate([
|
|
122
|
+
tslib_1.__decorate([
|
|
134
123
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
135
124
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple connections' }),
|
|
136
|
-
__param(0, (0, type_graphql_1.Arg)('names', type => [String])),
|
|
137
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
138
|
-
__metadata("design:type", Function),
|
|
139
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
140
|
-
__metadata("design:returntype", Promise)
|
|
125
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('names', type => [String])),
|
|
126
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
127
|
+
tslib_1.__metadata("design:type", Function),
|
|
128
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
129
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
141
130
|
], ConnectionMutation.prototype, "deleteConnections", null);
|
|
142
|
-
__decorate([
|
|
131
|
+
tslib_1.__decorate([
|
|
143
132
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To connect a connection' }),
|
|
144
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
145
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
146
|
-
__metadata("design:type", Function),
|
|
147
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
148
|
-
__metadata("design:returntype", Promise)
|
|
133
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
134
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
|
136
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
137
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
149
138
|
], ConnectionMutation.prototype, "connectConnection", null);
|
|
150
|
-
__decorate([
|
|
139
|
+
tslib_1.__decorate([
|
|
151
140
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To disconnect a connection' }),
|
|
152
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
153
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
154
|
-
__metadata("design:type", Function),
|
|
155
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
156
|
-
__metadata("design:returntype", Promise)
|
|
141
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
142
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
143
|
+
tslib_1.__metadata("design:type", Function),
|
|
144
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
145
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
157
146
|
], ConnectionMutation.prototype, "disconnectConnection", null);
|
|
158
|
-
ConnectionMutation = __decorate([
|
|
147
|
+
ConnectionMutation = tslib_1.__decorate([
|
|
159
148
|
(0, type_graphql_1.Resolver)(connection_type_1.Connection)
|
|
160
149
|
], ConnectionMutation);
|
|
161
150
|
exports.ConnectionMutation = ConnectionMutation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAA2C;AAE3C,wEAAmE;AACnE,uDAAgG;AAGhG,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAG7B,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAY;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAA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C;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,WAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,WAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiBxD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,WAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAkB3D;AA9IU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CA+I9B;AA/IY,gDAAkB"}
|
|
1
|
+
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA2C;AAE3C,wEAAmE;AACnE,uDAAgG;AAGhG,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAG7B,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAY;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IA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EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiBxD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAkB3D;AA9IU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CA+I9B;AA/IY,gDAAkB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { getRepository, In } from 'typeorm'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(@Arg('connection') connection: NewConnection, @Ctx() context: any): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: any\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: any\n ): Promise<Connection[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const connectionRepo = tx.getRepository(Connection)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await connectionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOne(newRecord.id)\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(@Arg('names', type => [String]) names: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain,\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: any): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: domain, name },\n relations: ['domain']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: any) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain, name },\n relations: ['domain']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n}\n"]}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
var _a;
|
|
15
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
4
|
exports.ConnectionQuery = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
17
6
|
const type_graphql_1 = require("type-graphql");
|
|
18
7
|
const typeorm_1 = require("typeorm");
|
|
19
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
@@ -66,52 +55,52 @@ let ConnectionQuery = class ConnectionQuery {
|
|
|
66
55
|
return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(connection.creatorId);
|
|
67
56
|
}
|
|
68
57
|
};
|
|
69
|
-
__decorate([
|
|
58
|
+
tslib_1.__decorate([
|
|
70
59
|
(0, type_graphql_1.Query)(returns => connection_type_1.Connection, { description: 'To fetch a connection' }),
|
|
71
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
72
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
73
|
-
__metadata("design:type", Function),
|
|
74
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
75
|
-
__metadata("design:returntype", Promise)
|
|
60
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
61
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
62
|
+
tslib_1.__metadata("design:type", Function),
|
|
63
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
64
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
76
65
|
], ConnectionQuery.prototype, "connection", null);
|
|
77
|
-
__decorate([
|
|
66
|
+
tslib_1.__decorate([
|
|
78
67
|
(0, type_graphql_1.Query)(returns => connection_type_1.ConnectionList, { description: 'To fetch multiple connections' }),
|
|
79
|
-
__param(0, (0, type_graphql_1.Args)()),
|
|
80
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
81
|
-
__metadata("design:type", Function),
|
|
82
|
-
__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
|
|
83
|
-
__metadata("design:returntype", Promise)
|
|
68
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
69
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
70
|
+
tslib_1.__metadata("design:type", Function),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
|
|
72
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
84
73
|
], ConnectionQuery.prototype, "connections", null);
|
|
85
|
-
__decorate([
|
|
74
|
+
tslib_1.__decorate([
|
|
86
75
|
(0, type_graphql_1.Query)(returns => connection_type_1.ConnectionState, { description: 'To fetch the state of a connection' }),
|
|
87
|
-
__param(0, (0, type_graphql_1.Arg)('name')),
|
|
88
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
89
|
-
__metadata("design:type", Function),
|
|
90
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
91
|
-
__metadata("design:returntype", connection_type_1.ConnectionState)
|
|
76
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
|
77
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
78
|
+
tslib_1.__metadata("design:type", Function),
|
|
79
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
80
|
+
tslib_1.__metadata("design:returntype", connection_type_1.ConnectionState)
|
|
92
81
|
], ConnectionQuery.prototype, "fetchConnectionState", null);
|
|
93
|
-
__decorate([
|
|
82
|
+
tslib_1.__decorate([
|
|
94
83
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
95
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
96
|
-
__metadata("design:type", Function),
|
|
97
|
-
__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
98
|
-
__metadata("design:returntype", Promise)
|
|
84
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
85
|
+
tslib_1.__metadata("design:type", Function),
|
|
86
|
+
tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
87
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
99
88
|
], ConnectionQuery.prototype, "domain", null);
|
|
100
|
-
__decorate([
|
|
89
|
+
tslib_1.__decorate([
|
|
101
90
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
102
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
103
|
-
__metadata("design:type", Function),
|
|
104
|
-
__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
105
|
-
__metadata("design:returntype", Promise)
|
|
91
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
92
|
+
tslib_1.__metadata("design:type", Function),
|
|
93
|
+
tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
94
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
106
95
|
], ConnectionQuery.prototype, "updater", null);
|
|
107
|
-
__decorate([
|
|
96
|
+
tslib_1.__decorate([
|
|
108
97
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
109
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
110
|
-
__metadata("design:type", Function),
|
|
111
|
-
__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
112
|
-
__metadata("design:returntype", Promise)
|
|
98
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
99
|
+
tslib_1.__metadata("design:type", Function),
|
|
100
|
+
tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
|
|
101
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
113
102
|
], ConnectionQuery.prototype, "creator", null);
|
|
114
|
-
ConnectionQuery = __decorate([
|
|
103
|
+
ConnectionQuery = tslib_1.__decorate([
|
|
115
104
|
(0, type_graphql_1.Resolver)(connection_type_1.Connection)
|
|
116
105
|
], ConnectionQuery);
|
|
117
106
|
exports.ConnectionQuery = ConnectionQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"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AAA;;;;iDAcjD;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;iEAAjB,iBAAS,oBAAT,iBAAS;;kDAoB1C;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IACnE,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAAgB,iCAAe;2DASpF;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAE1C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAlEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAmE3B;AAnEY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { getRepository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: any): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(@Args() params: ListParam, @Ctx() context: any): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: any): ConnectionState {\n const { domain } = context.state\n\n var connection = ConnectionManager.getConnectionInstanceByName(domain, name)\n\n return {\n name,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (await getRepository(Domain).findOne(connection.domainId))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOne(connection.updaterId)\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOne(connection.creatorId)\n }\n}\n"]}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
var _a;
|
|
15
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
4
|
exports.ConnectionSubscription = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
17
6
|
const type_graphql_1 = require("type-graphql");
|
|
18
7
|
const typeorm_1 = require("typeorm");
|
|
19
8
|
const connection_type_1 = require("./connection-type");
|
|
@@ -29,7 +18,7 @@ let ConnectionSubscription = class ConnectionSubscription {
|
|
|
29
18
|
return payload.log;
|
|
30
19
|
}
|
|
31
20
|
};
|
|
32
|
-
__decorate([
|
|
21
|
+
tslib_1.__decorate([
|
|
33
22
|
(0, type_graphql_1.Subscription)({
|
|
34
23
|
subscribe: (_, args, context, info) => {
|
|
35
24
|
var _a;
|
|
@@ -67,13 +56,13 @@ __decorate([
|
|
|
67
56
|
})(_, args, context, info);
|
|
68
57
|
}
|
|
69
58
|
}),
|
|
70
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
71
|
-
__param(1, (0, type_graphql_1.Arg)('name', { nullable: true })),
|
|
72
|
-
__metadata("design:type", Function),
|
|
73
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
74
|
-
__metadata("design:returntype", connection_type_1.ConnectionState)
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('name', { nullable: true })),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [Object, String]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", connection_type_1.ConnectionState)
|
|
75
64
|
], ConnectionSubscription.prototype, "connectionState", null);
|
|
76
|
-
__decorate([
|
|
65
|
+
tslib_1.__decorate([
|
|
77
66
|
(0, type_graphql_1.Subscription)({
|
|
78
67
|
subscribe: (_, args, context, info) => {
|
|
79
68
|
var _a;
|
|
@@ -101,13 +90,13 @@ __decorate([
|
|
|
101
90
|
})(_, args, context, info);
|
|
102
91
|
}
|
|
103
92
|
}),
|
|
104
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
105
|
-
__param(1, (0, type_graphql_1.Arg)('level', { nullable: true })),
|
|
106
|
-
__metadata("design:type", Function),
|
|
107
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
108
|
-
__metadata("design:returntype", typeof (_a = typeof shell_1.Log !== "undefined" && shell_1.Log) === "function" ? _a : Object)
|
|
93
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
94
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('level', { nullable: true })),
|
|
95
|
+
tslib_1.__metadata("design:type", Function),
|
|
96
|
+
tslib_1.__metadata("design:paramtypes", [Object, String]),
|
|
97
|
+
tslib_1.__metadata("design:returntype", typeof (_a = typeof shell_1.Log !== "undefined" && shell_1.Log) === "function" ? _a : Object)
|
|
109
98
|
], ConnectionSubscription.prototype, "connectionLog", null);
|
|
110
|
-
ConnectionSubscription = __decorate([
|
|
99
|
+
ConnectionSubscription = tslib_1.__decorate([
|
|
111
100
|
(0, type_graphql_1.Resolver)(connection_type_1.Connection)
|
|
112
101
|
], ConnectionSubscription);
|
|
113
102
|
exports.ConnectionSubscription = ConnectionSubscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;;AAAA,+CAAgE;AAChE,qCAAuC;AACvC,uDAAiF;AACjF,iDAAmD;AACnD,iEAAkD;AAClD,wEAAmE;AAEnE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAGpF,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAmDjC,eAAe,CACL,OAA6C,EACpB,IAAY;QAE7C,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAuCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AA/CC;IAlDC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;YACpC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YACrB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;aACpC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,EAAE;gBACvD,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,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OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC;KACF,CAAC;IACa,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAyB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;gEAAiB,WAAG,oBAAH,WAAG;2DAEjG;AAjGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CAkGlC;AAlGY,wDAAsB","sourcesContent":["import { Resolver, Subscription, Root, Arg } from 'type-graphql'\nimport { getRepository } from 'typeorm'\nimport { Connection, ConnectionState, ConnectionStatus } from './connection-type'\nimport { pubsub, Log } from '@things-factory/shell'\nimport { withFilter } from 'graphql-subscriptions'\nimport { ConnectionManager } from '../../engine/connection-manager'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return withFilter(\n () => pubsub.asyncIterator('connection-state'),\n (payload, variables, context, info) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const { name } = variables\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n }\n )(_, args, context, info)\n }\n })\n connectionState(\n @Root() payload: { connectionState: ConnectionState },\n @Arg('name', { nullable: true }) name: string\n ): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return withFilter(\n () => pubsub.asyncIterator('connection-log'),\n (payload, variables, context, info) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.connectionLog\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n }\n )(_, args, context, info)\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
|