@things-factory/integration-base 8.0.39 → 9.0.0-9.0.0-beta.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/engine/connector/headless-connector.d.ts +23 -0
- package/dist-server/engine/connector/headless-connector.js +357 -0
- package/dist-server/engine/connector/headless-connector.js.map +1 -0
- package/dist-server/engine/connector/http-connector.js +1 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/index.d.ts +1 -0
- package/dist-server/engine/connector/index.js +1 -0
- package/dist-server/engine/connector/index.js.map +1 -1
- package/dist-server/engine/index.d.ts +3 -2
- package/dist-server/engine/index.js +3 -2
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/resource-pool/headless-pool.d.ts +1 -0
- package/dist-server/engine/resource-pool/headless-pool.js +62 -0
- package/dist-server/engine/resource-pool/headless-pool.js.map +1 -0
- package/dist-server/engine/resource-pool/index.d.ts +1 -0
- package/dist-server/engine/resource-pool/index.js +5 -0
- package/dist-server/engine/resource-pool/index.js.map +1 -0
- package/dist-server/engine/task/headless-post.js +19 -33
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +20 -13
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +29 -6
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +178 -64
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/index.d.ts +6 -6
- package/dist-server/index.js +10 -10
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +6 -6
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.js +17 -5
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.js +3 -0
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/translations/en.json +12 -4
- package/translations/ja.json +12 -4
- package/translations/ko.json +12 -4
- package/translations/ms.json +12 -4
- package/translations/zh.json +12 -4
- package/server/controllers/index.ts +0 -2
- package/server/controllers/publish-data.ts +0 -29
- package/server/controllers/scenario-controller.ts +0 -154
- package/server/engine/analyzer/analyze-integration.ts +0 -115
- package/server/engine/connection-manager.ts +0 -232
- package/server/engine/connector/echo-back-connector.ts +0 -51
- package/server/engine/connector/echo-back-server.ts +0 -72
- package/server/engine/connector/graphql-connector.ts +0 -126
- package/server/engine/connector/http-connector.ts +0 -65
- package/server/engine/connector/index.ts +0 -12
- package/server/engine/connector/mqtt-connector.ts +0 -78
- package/server/engine/connector/mssql-connector.ts +0 -152
- package/server/engine/connector/mysql-connector.ts +0 -94
- package/server/engine/connector/operato-connector.ts +0 -264
- package/server/engine/connector/oracle-connector.ts +0 -218
- package/server/engine/connector/postgresql-connector.ts +0 -152
- package/server/engine/connector/proxy-connector.ts +0 -53
- package/server/engine/connector/socket-server.ts +0 -86
- package/server/engine/connector/sqlite-connector.ts +0 -69
- package/server/engine/edge-client.ts +0 -45
- package/server/engine/index.ts +0 -10
- package/server/engine/pending-queue.ts +0 -97
- package/server/engine/scenario-engine.ts +0 -106
- package/server/engine/task/book-up-scenario.ts +0 -73
- package/server/engine/task/csv-readline.ts +0 -127
- package/server/engine/task/data-accessor.ts +0 -36
- package/server/engine/task/data-mapper.ts +0 -47
- package/server/engine/task/database-query.ts +0 -56
- package/server/engine/task/echo-receive.ts +0 -21
- package/server/engine/task/echo-send.ts +0 -32
- package/server/engine/task/empty-check.ts +0 -38
- package/server/engine/task/end.ts +0 -18
- package/server/engine/task/floating-point.ts +0 -71
- package/server/engine/task/goto.ts +0 -27
- package/server/engine/task/graphql-mutate.ts +0 -79
- package/server/engine/task/graphql-query.ts +0 -78
- package/server/engine/task/headless-post.ts +0 -147
- package/server/engine/task/headless-scrap.ts +0 -80
- package/server/engine/task/http-get.ts +0 -117
- package/server/engine/task/http-post.ts +0 -148
- package/server/engine/task/index.ts +0 -45
- package/server/engine/task/jsonata.ts +0 -45
- package/server/engine/task/local-graphql-mutate.ts +0 -100
- package/server/engine/task/local-graphql-query.ts +0 -100
- package/server/engine/task/log.ts +0 -78
- package/server/engine/task/mqtt-publish.ts +0 -45
- package/server/engine/task/mqtt-subscribe.ts +0 -139
- package/server/engine/task/mssql-procedure.ts +0 -128
- package/server/engine/task/oracle-procedure.ts +0 -124
- package/server/engine/task/pick-pending-scenario.ts +0 -80
- package/server/engine/task/publish.ts +0 -40
- package/server/engine/task/random.ts +0 -53
- package/server/engine/task/reset-pending-queue.ts +0 -17
- package/server/engine/task/script.ts +0 -63
- package/server/engine/task/set-domain.ts +0 -37
- package/server/engine/task/sleep.ts +0 -34
- package/server/engine/task/socket-listener.ts +0 -96
- package/server/engine/task/state-group-read.ts +0 -69
- package/server/engine/task/state-read.ts +0 -56
- package/server/engine/task/state-write.ts +0 -65
- package/server/engine/task/stop-scenario.ts +0 -44
- package/server/engine/task/sub-scenario.ts +0 -57
- package/server/engine/task/switch-goto.ts +0 -43
- package/server/engine/task/switch-range-goto.ts +0 -53
- package/server/engine/task/switch-range-scenario.ts +0 -79
- package/server/engine/task/switch-range-set.ts +0 -48
- package/server/engine/task/switch-scenario.ts +0 -67
- package/server/engine/task/switch-set.ts +0 -37
- package/server/engine/task/throw.ts +0 -27
- package/server/engine/task/utils/headless-pool-for-scenario.ts +0 -71
- package/server/engine/task/utils/substitute.ts +0 -44
- package/server/engine/task/variables.ts +0 -17
- package/server/engine/task-registry.ts +0 -23
- package/server/engine/types.ts +0 -114
- package/server/index.ts +0 -20
- package/server/migrations/index.ts +0 -9
- package/server/restful/index.ts +0 -1
- package/server/restful/unstable/index.ts +0 -7
- package/server/restful/unstable/run-scenario.ts +0 -51
- package/server/restful/unstable/scenario-instance.ts +0 -52
- package/server/restful/unstable/scenario-instances.ts +0 -80
- package/server/restful/unstable/scenario.ts +0 -41
- package/server/restful/unstable/scenarios.ts +0 -69
- package/server/restful/unstable/start-scenario.ts +0 -33
- package/server/restful/unstable/stop-scenario.ts +0 -30
- package/server/routers/scenario-schedule-callback-router.ts +0 -69
- package/server/routers/scenario-view-router.ts +0 -46
- package/server/routes.ts +0 -35
- package/server/service/analysis/analysis-query.ts +0 -13
- package/server/service/analysis/index.ts +0 -3
- package/server/service/connection/connection-mutation.ts +0 -190
- package/server/service/connection/connection-query.ts +0 -87
- package/server/service/connection/connection-subscription.ts +0 -104
- package/server/service/connection/connection-type.ts +0 -305
- package/server/service/connection/index.ts +0 -7
- package/server/service/connector/connector-query.ts +0 -62
- package/server/service/connector/connector-type.ts +0 -29
- package/server/service/connector/index.ts +0 -4
- package/server/service/index.ts +0 -52
- package/server/service/payload-log/index.ts +0 -7
- package/server/service/payload-log/payload-log-mutation.ts +0 -151
- package/server/service/payload-log/payload-log-query.ts +0 -49
- package/server/service/payload-log/payload-log-type.ts +0 -36
- package/server/service/payload-log/payload-log.ts +0 -100
- package/server/service/property-spec.ts +0 -24
- package/server/service/scenario/index.ts +0 -6
- package/server/service/scenario/scenario-mutation.ts +0 -396
- package/server/service/scenario/scenario-query.ts +0 -109
- package/server/service/scenario/scenario-type.ts +0 -78
- package/server/service/scenario/scenario.ts +0 -124
- package/server/service/scenario-flow/scenario-flow.ts +0 -17
- package/server/service/scenario-instance/index.ts +0 -6
- package/server/service/scenario-instance/scenario-instance-mutation.ts +0 -44
- package/server/service/scenario-instance/scenario-instance-query.ts +0 -42
- package/server/service/scenario-instance/scenario-instance-subscription.ts +0 -118
- package/server/service/scenario-instance/scenario-instance-type.ts +0 -557
- package/server/service/scenario-queue/index.ts +0 -4
- package/server/service/scenario-queue/scenario-queue-subscription.ts +0 -55
- package/server/service/scenario-queue/scenario-queue-type.ts +0 -27
- package/server/service/state-register/data-resolver.ts +0 -56
- package/server/service/state-register/index.ts +0 -8
- package/server/service/state-register/state-register-mutation.ts +0 -166
- package/server/service/state-register/state-register-query.ts +0 -80
- package/server/service/state-register/state-register-type.ts +0 -80
- package/server/service/state-register/state-register.ts +0 -113
- package/server/service/step/index.ts +0 -6
- package/server/service/step/step-mutation.ts +0 -52
- package/server/service/step/step-query.ts +0 -55
- package/server/service/step/step-type.ts +0 -238
- package/server/service/task-type/index.ts +0 -4
- package/server/service/task-type/task-type-query.ts +0 -95
- package/server/service/task-type/task-type-type.ts +0 -29
package/dist-server/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from './migrations';
|
2
|
-
export * from './engine';
|
3
|
-
export * from './controllers';
|
4
|
-
export * from './service';
|
5
|
-
import './routes';
|
6
|
-
import './restful';
|
1
|
+
export * from './migrations/index.js';
|
2
|
+
export * from './engine/index.js';
|
3
|
+
export * from './controllers/index.js';
|
4
|
+
export * from './service/index.js';
|
5
|
+
import './routes.js';
|
6
|
+
import './restful/index.js';
|
package/dist-server/index.js
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
-
tslib_1.__exportStar(require("./migrations"), exports);
|
5
|
-
tslib_1.__exportStar(require("./engine"), exports);
|
6
|
-
tslib_1.__exportStar(require("./controllers"), exports);
|
7
|
-
tslib_1.__exportStar(require("./service"), exports);
|
8
|
-
require("./routes");
|
9
|
-
require("./restful"); /* APIs */
|
10
|
-
const
|
4
|
+
tslib_1.__exportStar(require("./migrations/index.js"), exports);
|
5
|
+
tslib_1.__exportStar(require("./engine/index.js"), exports);
|
6
|
+
tslib_1.__exportStar(require("./controllers/index.js"), exports);
|
7
|
+
tslib_1.__exportStar(require("./service/index.js"), exports);
|
8
|
+
require("./routes.js");
|
9
|
+
require("./restful/index.js"); /* APIs */
|
10
|
+
const index_js_1 = require("./engine/index.js");
|
11
11
|
process.on('bootstrap-module-start', async ({ app, config, client }) => {
|
12
12
|
try {
|
13
|
-
await
|
14
|
-
await
|
13
|
+
await index_js_1.ConnectionManager.ready();
|
14
|
+
await index_js_1.ScenarioEngine.loadAll();
|
15
15
|
console.log('Scenario Engine has just started.');
|
16
16
|
}
|
17
17
|
catch (ex) {
|
18
|
-
|
18
|
+
index_js_1.ConnectionManager.logger.error('Just has failed to start Scenario Engine.', ex);
|
19
19
|
}
|
20
20
|
});
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AACrC,4DAAiC;AACjC,iEAAsC;AACtC,6DAAkC;AAElC,uBAAoB;AACpB,8BAA2B,CAAC,UAAU;AAEtC,gDAAqE;AAErE,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,4BAAiB,CAAC,KAAK,EAAE,CAAA;QAC/B,MAAM,yBAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,4BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,EAAE,CAAC,CAAA;IACjF,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './migrations/index.js'\nexport * from './engine/index.js'\nexport * from './controllers/index.js'\nexport * from './service/index.js'\n\nimport './routes.js'\nimport './restful/index.js' /* APIs */\n\nimport { ConnectionManager, ScenarioEngine } from './engine/index.js'\n\nprocess.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {\n try {\n await ConnectionManager.ready()\n await ScenarioEngine.loadAll()\n\n console.log('Scenario Engine has just started.')\n } catch (ex) {\n ConnectionManager.logger.error('Just has failed to start Scenario Engine.', ex)\n }\n})\n"]}
|
package/dist-server/routes.js
CHANGED
@@ -2,23 +2,23 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const env_1 = require("@things-factory/env");
|
4
4
|
const shell_1 = require("@things-factory/shell");
|
5
|
-
const
|
6
|
-
const
|
5
|
+
const scenario_view_router_js_1 = require("./routers/scenario-view-router.js");
|
6
|
+
const scenario_schedule_callback_router_js_1 = require("./routers/scenario-schedule-callback-router.js");
|
7
7
|
const isPathBaseDomain = !env_1.config.get('subdomain');
|
8
8
|
process.on('bootstrap-module-domain-public-route', (app, domainPrivateRouter) => {
|
9
9
|
if (isPathBaseDomain) {
|
10
|
-
domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`,
|
10
|
+
domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`, scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.allowedMethods());
|
11
11
|
}
|
12
12
|
else {
|
13
|
-
domainPrivateRouter.use('',
|
13
|
+
domainPrivateRouter.use('', scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.allowedMethods());
|
14
14
|
}
|
15
15
|
});
|
16
16
|
process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
|
17
17
|
if (isPathBaseDomain) {
|
18
|
-
domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`,
|
18
|
+
domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`, scenario_view_router_js_1.scenarioViewRouter.routes(), scenario_view_router_js_1.scenarioViewRouter.allowedMethods());
|
19
19
|
}
|
20
20
|
else {
|
21
|
-
domainPrivateRouter.use('',
|
21
|
+
domainPrivateRouter.use('', scenario_view_router_js_1.scenarioViewRouter.routes(), scenario_view_router_js_1.scenarioViewRouter.allowedMethods());
|
22
22
|
}
|
23
23
|
});
|
24
24
|
//# sourceMappingURL=routes.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,iDAAmE;AAEnE
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,iDAAmE;AAEnE,+EAAsE;AACtE,yGAA+F;AAE/F,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AAEjD,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACrF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CACrB,IAAI,IAAA,mCAA2B,GAAE,UAAU,EAC3C,qEAA8B,CAAC,MAAM,EAAE,EACvC,qEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;IACH,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CACrB,EAAE,EACF,qEAA8B,CAAC,MAAM,EAAE,EACvC,qEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;IACH,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CACrB,IAAI,IAAA,mCAA2B,GAAE,UAAU,EAC3C,4CAAkB,CAAC,MAAM,EAAE,EAC3B,4CAAkB,CAAC,cAAc,EAAE,CACpC,CAAA;IACH,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,4CAAkB,CAAC,MAAM,EAAE,EAAE,4CAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/F,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\nimport { getRoutePrefixForDomainType } from '@things-factory/shell'\n\nimport { scenarioViewRouter } from './routers/scenario-view-router.js'\nimport { scenarioScheduleCallbackRouter } from './routers/scenario-schedule-callback-router.js'\n\nconst isPathBaseDomain = !config.get('subdomain')\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(\n `/${getRoutePrefixForDomainType()}/:domain`,\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n } else {\n domainPrivateRouter.use(\n '',\n scenarioScheduleCallbackRouter.routes(),\n scenarioScheduleCallbackRouter.allowedMethods()\n )\n }\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(\n `/${getRoutePrefixForDomainType()}/:domain`,\n scenarioViewRouter.routes(),\n scenarioViewRouter.allowedMethods()\n )\n } else {\n domainPrivateRouter.use('', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n }\n})\n"]}
|
@@ -65,7 +65,9 @@ let ConnectionMutation = class ConnectionMutation {
|
|
65
65
|
});
|
66
66
|
await connection.connect();
|
67
67
|
await repository.save(connection);
|
68
|
-
return Object.assign(Object.assign({}, connection), { state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
68
|
+
return Object.assign(Object.assign({}, connection), { state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
69
|
+
? connection_type_1.ConnectionStatus.CONNECTED
|
70
|
+
: connection_type_1.ConnectionStatus.DISCONNECTED });
|
69
71
|
}
|
70
72
|
async disconnectConnection(name, context) {
|
71
73
|
const { domain } = context.state;
|
@@ -76,7 +78,9 @@ let ConnectionMutation = class ConnectionMutation {
|
|
76
78
|
});
|
77
79
|
await connection.disconnect();
|
78
80
|
await repository.save(connection);
|
79
|
-
return Object.assign(Object.assign({}, connection), { state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
81
|
+
return Object.assign(Object.assign({}, connection), { state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
|
82
|
+
? connection_type_1.ConnectionStatus.CONNECTED
|
83
|
+
: connection_type_1.ConnectionStatus.DISCONNECTED });
|
80
84
|
}
|
81
85
|
async importConnections(connections, context) {
|
82
86
|
const { tx, domain, user } = context.state;
|
@@ -105,6 +109,7 @@ let ConnectionMutation = class ConnectionMutation {
|
|
105
109
|
exports.ConnectionMutation = ConnectionMutation;
|
106
110
|
tslib_1.__decorate([
|
107
111
|
(0, type_graphql_1.Directive)('@transaction'),
|
112
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
108
113
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To create new connection' }),
|
109
114
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('connection')),
|
110
115
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -114,6 +119,7 @@ tslib_1.__decorate([
|
|
114
119
|
], ConnectionMutation.prototype, "createConnection", null);
|
115
120
|
tslib_1.__decorate([
|
116
121
|
(0, type_graphql_1.Directive)('@transaction'),
|
122
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
117
123
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To modify connection information' }),
|
118
124
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
119
125
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
@@ -124,6 +130,7 @@ tslib_1.__decorate([
|
|
124
130
|
], ConnectionMutation.prototype, "updateConnection", null);
|
125
131
|
tslib_1.__decorate([
|
126
132
|
(0, type_graphql_1.Directive)('@transaction'),
|
133
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
127
134
|
(0, type_graphql_1.Mutation)(returns => [connection_type_1.Connection], { description: "To modify multiple connections' information" }),
|
128
135
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [connection_type_1.ConnectionPatch])),
|
129
136
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -133,6 +140,7 @@ tslib_1.__decorate([
|
|
133
140
|
], ConnectionMutation.prototype, "updateMultipleConnection", null);
|
134
141
|
tslib_1.__decorate([
|
135
142
|
(0, type_graphql_1.Directive)('@transaction'),
|
143
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
136
144
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete connection' }),
|
137
145
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
138
146
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -142,6 +150,7 @@ tslib_1.__decorate([
|
|
142
150
|
], ConnectionMutation.prototype, "deleteConnection", null);
|
143
151
|
tslib_1.__decorate([
|
144
152
|
(0, type_graphql_1.Directive)('@transaction'),
|
153
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
145
154
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple connections' }),
|
146
155
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('names', type => [String])),
|
147
156
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -150,6 +159,8 @@ tslib_1.__decorate([
|
|
150
159
|
tslib_1.__metadata("design:returntype", Promise)
|
151
160
|
], ConnectionMutation.prototype, "deleteConnections", null);
|
152
161
|
tslib_1.__decorate([
|
162
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
163
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
153
164
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To connect a connection' }),
|
154
165
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
155
166
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -158,6 +169,8 @@ tslib_1.__decorate([
|
|
158
169
|
tslib_1.__metadata("design:returntype", Promise)
|
159
170
|
], ConnectionMutation.prototype, "connectConnection", null);
|
160
171
|
tslib_1.__decorate([
|
172
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
173
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
161
174
|
(0, type_graphql_1.Mutation)(returns => connection_type_1.Connection, { description: 'To disconnect a connection' }),
|
162
175
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
163
176
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -166,9 +179,8 @@ tslib_1.__decorate([
|
|
166
179
|
tslib_1.__metadata("design:returntype", Promise)
|
167
180
|
], ConnectionMutation.prototype, "disconnectConnection", null);
|
168
181
|
tslib_1.__decorate([
|
169
|
-
(0, type_graphql_1.Directive)('@transaction')
|
170
|
-
|
171
|
-
,
|
182
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
183
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
172
184
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple connections' }),
|
173
185
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('connections', type => [connection_type_1.ConnectionPatch])),
|
174
186
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;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L,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;;;;8DAgB3D;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IAC1B,oGAAoG;;IACnG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAA6B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA2CvG;6BAnLU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAoL9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\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: ResolverContext): 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(@Arg('name') name: string, @Arg('patch') patch: ConnectionPatch, @Ctx() context: ResolverContext): 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: { id: domain.id }, 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(@Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[], @Ctx() context: ResolverContext): 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.findOneBy({ id: 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: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, 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: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\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: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : 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: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection) ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @Directive('@transaction')\n // @Directive('@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(@Arg('connections', type => [ConnectionPatch]) connections: Connection[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGzF,IAAM,kBAAkB,GA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C,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;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EACR,6GAA6G,CAC9G;IACA,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;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EACR,6GAA6G,CAC9G;IACA,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IAE7E,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,iCAAe,CAAC,CAAC,CAAA;IAC7C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DA4CP;6BAhOU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAiO9B","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\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 @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(\n @Arg('connection') connection: NewConnection,\n @Ctx() context: ResolverContext\n ): 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 @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\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: ResolverContext\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: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: ResolverContext\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.findOneBy({ id: 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 @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'To delete connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain: { id: domain.id }, name })\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\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 @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain', 'edge']\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 @Directive('@transaction')\n @Directive(\n '@privilege(category: \"connection\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => Boolean, { description: 'To import multiple connections' })\n async importConnections(\n @Arg('connections', type => [ConnectionPatch]) connections: Connection[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Connection)\n\n await Promise.all(\n connections.map(async (connection: Connection) => {\n const { id, name } = connection\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Connection with id '${id}:${name}' is already taken by another domain`\n }\n\n const sameName = await repository.findOneBy({ domain: { id: domain.id }, name })\n if (sameName && sameName.id != id) {\n throw `Connection with name '${name}' is already taken by another connection`\n }\n\n await repository.save({\n ...sameId,\n ...connection,\n domain,\n updater: user\n })\n\n return\n }\n }\n\n await repository.save({\n ...connection,\n domain,\n updater: user,\n creator: user\n })\n })\n )\n\n return true\n }\n}\n"]}
|
@@ -55,6 +55,7 @@ let ConnectionQuery = class ConnectionQuery {
|
|
55
55
|
};
|
56
56
|
exports.ConnectionQuery = ConnectionQuery;
|
57
57
|
tslib_1.__decorate([
|
58
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
58
59
|
(0, type_graphql_1.Query)(returns => connection_type_1.Connection, { description: 'To fetch a connection' }),
|
59
60
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
60
61
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -63,6 +64,7 @@ tslib_1.__decorate([
|
|
63
64
|
tslib_1.__metadata("design:returntype", Promise)
|
64
65
|
], ConnectionQuery.prototype, "connection", null);
|
65
66
|
tslib_1.__decorate([
|
67
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
66
68
|
(0, type_graphql_1.Query)(returns => connection_type_1.ConnectionList, { description: 'To fetch multiple connections' }),
|
67
69
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
68
70
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -71,6 +73,7 @@ tslib_1.__decorate([
|
|
71
73
|
tslib_1.__metadata("design:returntype", Promise)
|
72
74
|
], ConnectionQuery.prototype, "connections", null);
|
73
75
|
tslib_1.__decorate([
|
76
|
+
(0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
74
77
|
(0, type_graphql_1.Query)(returns => connection_type_1.ConnectionState, { description: 'To fetch the state of a connection' }),
|
75
78
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
76
79
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+
|
1
|
+
{"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAG1F,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAA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'@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, 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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, 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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): 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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
|
@@ -11,7 +11,7 @@ export * from './payload-log/payload-log';
|
|
11
11
|
export * from './state-register/state-register';
|
12
12
|
export declare const entities: any[];
|
13
13
|
export declare const schema: {
|
14
|
-
resolverClasses: (typeof import("./
|
14
|
+
resolverClasses: (typeof import("./connection/connection-query").ConnectionQuery | typeof import("./connection/connection-mutation").ConnectionMutation | typeof import("./connection/connection-subscription").ConnectionSubscription | typeof import("./connector/connector-query").ConnectorQuery | typeof import("./scenario/scenario-query").ScenarioQuery | typeof import("./scenario/scenario-mutation").ScenarioMutation | typeof import("./scenario-instance/scenario-instance-query").ScenarioInstanceQuery | typeof import("./scenario-instance/scenario-instance-mutation").ScenarioInstanceMutation | typeof import("./scenario-instance/scenario-instance-subscription").ScenarioInstanceSubscription | typeof import("./scenario-queue/scenario-queue-subscription").ScenarioQueueSubscription | typeof import("./step/step-query").StepQuery | typeof import("./step/step-mutation").StepMutation | typeof import("./task-type/task-type-query").TaskTypeQuery | typeof import("./payload-log/payload-log-query").PayloadLogQuery | typeof import("./payload-log/payload-log-mutation").PayloadLogMutation | typeof import("./state-register/state-register-query").StateRegisterQuery | typeof import("./state-register/state-register-mutation").StateRegisterMutation | typeof import("./state-register/data-resolver").DataResolver | typeof import("./analysis/analysis-query").IntegrationAnalysisQuery)[];
|
15
15
|
};
|
16
16
|
export { PayloadType } from './payload-log/payload-log';
|
17
17
|
export { createPayloadLog } from './payload-log/payload-log-mutation';
|