@things-factory/integration-base 9.0.0-beta.4 → 9.0.0-beta.47

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.
@@ -84,7 +84,6 @@ async function startScenario(instanceName, scenarioName, variables, context) {
84
84
  async function stopScenario(instanceName, context) {
85
85
  const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
86
86
  debug('stopScenario', instanceName);
87
- runScenario;
88
87
  var scenarioInstance = scenario_engine_1.ScenarioEngine.getScenarioInstance(domain, instanceName);
89
88
  if (!scenarioInstance) {
90
89
  debug('stopScenario', `ScenarioInstance(${instanceName}) Not Found.`);
@@ -1 +1 @@
1
- {"version":3,"file":"scenario-controller.js","sourceRoot":"","sources":["../../server/controllers/scenario-controller.ts"],"names":[],"mappings":";;AAsCA,oCASC;AAED,kCAkDC;AAED,sCAwBC;AAED,oCA4BC;AA3JD,iDAAiF;AACjF,yDAA4D;AAC5D,iEAA4D;AAE5D,+DAA0D;AAC1D,2DAAuD;AACvD,gGAAiH;AAGjH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,yDAAyD,CAAC,CAAA;AAEzF,KAAK,UAAU,YAAY,CACzB,YAAoB,EACpB,MAAc;IAQd,IAAI,UAAU,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAA;IAExC,IAAI,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QACtC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;QACxD,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;KAC7D,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACjC,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAClC,KAAK,EAA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AA0B,EAAE;YACpC,QAAQ,EAAE,YAAY;SACvB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAErC,YAAY,GAAG,YAAY,IAAI,YAAY,CAAA;IAC3C,OAAO,MAAM,gCAAc,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;AAC5F,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,YAAoB,EACpB,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAEtE,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAEnC,WAAW,CAAA;IAEX,IAAI,gBAAgB,GAAG,gCAAc,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAE/E,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,KAAK,CAAC,cAAc,EAAE,oBAAoB,YAAY,cAAc,CAAC,CAAA;QACrE,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,QAAQ,EAAE,YAAY;SACvB,CAAC,CACH,CAAA;IACH,CAAC;IAED,IAAI,QAAQ,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAExE,MAAM,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAErC,MAAM,gCAAc,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAEjD,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import { getRepository, Domain, GraphqlLocalClient } from '@things-factory/shell'\nimport { checkUserHasRole } from '@things-factory/auth-base'\nimport { cacheService } from '@things-factory/cache-service'\n\nimport { ScenarioEngine } from '../engine/scenario-engine'\nimport { Scenario } from '../service/scenario/scenario'\nimport { ScenarioInstance, ScenarioInstanceRunResult } from '../service/scenario-instance/scenario-instance-type'\nimport { Step } from '../service/step/step-type'\n\nconst debug = require('debug')('things-factory:integration-base:controller:run-scenario')\n\nasync function findScenario(\n scenarioName: string,\n domain: Domain\n): Promise<{\n id: string\n ttl: number\n name: string\n steps: Step[]\n domain: Domain\n}> {\n var repository = getRepository(Scenario)\n\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, name: scenarioName },\n relations: ['domain', 'steps', 'role', 'creator', 'updater']\n })\n\n if (!scenario && domain.parentId) {\n scenario = await repository.findOne({\n where: { domain: { id: domain.parentId }, name: scenarioName },\n relations: ['domain', 'steps', 'role', 'creator', 'updater']\n })\n }\n\n return scenario as any\n}\n\nexport async function checkHasRole(scenario: Partial<Scenario>, context: ResolverContext): Promise<void> {\n const { domain, user } = context.state\n if (!(await checkUserHasRole(scenario.roleId, domain, user))) {\n throw new Error(\n context.t('error.scenario run unauthorized', {\n scenario: scenario.name\n })\n )\n }\n}\n\nexport async function runScenario(\n instanceName: string,\n scenarioName: string,\n variables: any,\n context: ResolverContext\n): Promise<ScenarioInstanceRunResult> {\n const { domain, user, lng } = context.state\n\n debug('runScenario', scenarioName, instanceName, variables)\n\n var scenario = await findScenario(scenarioName, domain)\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioName\n })\n )\n }\n\n await checkHasRole(scenario, context)\n\n if (scenario.ttl > 0) {\n const cachedValue = await cacheService.getFromCache(scenario.id, { domain: domain.id, variables: variables || {} })\n if (cachedValue) {\n return cachedValue.value\n }\n }\n\n /* 시나리오 인스턴스를 생성한다. */\n instanceName = instanceName || scenarioName + '-' + String(Date.now())\n var instance = new ScenarioInstance(instanceName, scenario, {\n domain,\n user,\n lng,\n variables,\n client: GraphqlLocalClient.client\n })\n\n try {\n return await instance.run()\n } catch (err) {\n console.error(err)\n\n throw new Error(\n context.t('error.scenario run error', {\n scenario: scenarioName\n })\n )\n }\n}\n\nexport async function startScenario(\n instanceName: string,\n scenarioName: string,\n variables: any,\n context: ResolverContext\n): Promise<ScenarioInstance> {\n const { domain, user, lng } = context.state\n\n debug('startScenario', instanceName, scenarioName, variables)\n\n var scenario = await findScenario(scenarioName, domain)\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioName\n })\n )\n }\n\n await checkHasRole(scenario, context)\n\n instanceName = instanceName || scenarioName\n return await ScenarioEngine.load(instanceName, scenario, { domain, user, lng, variables })\n}\n\nexport async function stopScenario(\n instanceName: string,\n context: ResolverContext\n): Promise<ScenarioInstance | undefined> {\n const { domain, user, unsafeIP, prohibitedPrivileges } = context.state\n\n debug('stopScenario', instanceName)\n\n runScenario\n\n var scenarioInstance = ScenarioEngine.getScenarioInstance(domain, instanceName)\n\n if (!scenarioInstance) {\n debug('stopScenario', `ScenarioInstance(${instanceName}) Not Found.`)\n throw new Error(\n context.t('error.scenario instance not found', {\n instance: instanceName\n })\n )\n }\n\n var scenario = await findScenario(scenarioInstance.scenarioName, domain)\n\n await checkHasRole(scenario, context)\n\n await ScenarioEngine.unload(domain, instanceName)\n\n return scenarioInstance\n}\n"]}
1
+ {"version":3,"file":"scenario-controller.js","sourceRoot":"","sources":["../../server/controllers/scenario-controller.ts"],"names":[],"mappings":";;AAsCA,oCASC;AAED,kCAkDC;AAED,sCAwBC;AAED,oCA0BC;AAzJD,iDAAiF;AACjF,yDAA4D;AAC5D,iEAA4D;AAE5D,+DAA0D;AAC1D,2DAAuD;AACvD,gGAAiH;AAGjH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,yDAAyD,CAAC,CAAA;AAEzF,KAAK,UAAU,YAAY,CACzB,YAAoB,EACpB,MAAc;IAQd,IAAI,UAAU,GAAG,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAA;IAExC,IAAI,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QACtC,KAA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AAM,CAAC,CAAA;IAExE,MAAM,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAErC,MAAM,gCAAc,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IAEjD,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import { getRepository, Domain, GraphqlLocalClient } from '@things-factory/shell'\nimport { checkUserHasRole } from '@things-factory/auth-base'\nimport { cacheService } from '@things-factory/cache-service'\n\nimport { ScenarioEngine } from '../engine/scenario-engine'\nimport { Scenario } from '../service/scenario/scenario'\nimport { ScenarioInstance, ScenarioInstanceRunResult } from '../service/scenario-instance/scenario-instance-type'\nimport { Step } from '../service/step/step-type'\n\nconst debug = require('debug')('things-factory:integration-base:controller:run-scenario')\n\nasync function findScenario(\n scenarioName: string,\n domain: Domain\n): Promise<{\n id: string\n ttl: number\n name: string\n steps: Step[]\n domain: Domain\n}> {\n var repository = getRepository(Scenario)\n\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, name: scenarioName },\n relations: ['domain', 'steps', 'role', 'creator', 'updater']\n })\n\n if (!scenario && domain.parentId) {\n scenario = await repository.findOne({\n where: { domain: { id: domain.parentId }, name: scenarioName },\n relations: ['domain', 'steps', 'role', 'creator', 'updater']\n })\n }\n\n return scenario as any\n}\n\nexport async function checkHasRole(scenario: Partial<Scenario>, context: ResolverContext): Promise<void> {\n const { domain, user } = context.state\n if (!(await checkUserHasRole(scenario.roleId, domain, user))) {\n throw new Error(\n context.t('error.scenario run unauthorized', {\n scenario: scenario.name\n })\n )\n }\n}\n\nexport async function runScenario(\n instanceName: string,\n scenarioName: string,\n variables: any,\n context: ResolverContext\n): Promise<ScenarioInstanceRunResult> {\n const { domain, user, lng } = context.state\n\n debug('runScenario', scenarioName, instanceName, variables)\n\n var scenario = await findScenario(scenarioName, domain)\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioName\n })\n )\n }\n\n await checkHasRole(scenario, context)\n\n if (scenario.ttl > 0) {\n const cachedValue = await cacheService.getFromCache(scenario.id, { domain: domain.id, variables: variables || {} })\n if (cachedValue) {\n return cachedValue.value\n }\n }\n\n /* 시나리오 인스턴스를 생성한다. */\n instanceName = instanceName || scenarioName + '-' + String(Date.now())\n var instance = new ScenarioInstance(instanceName, scenario, {\n domain,\n user,\n lng,\n variables,\n client: GraphqlLocalClient.client\n })\n\n try {\n return await instance.run()\n } catch (err) {\n console.error(err)\n\n throw new Error(\n context.t('error.scenario run error', {\n scenario: scenarioName\n })\n )\n }\n}\n\nexport async function startScenario(\n instanceName: string,\n scenarioName: string,\n variables: any,\n context: ResolverContext\n): Promise<ScenarioInstance> {\n const { domain, user, lng } = context.state\n\n debug('startScenario', instanceName, scenarioName, variables)\n\n var scenario = await findScenario(scenarioName, domain)\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioName\n })\n )\n }\n\n await checkHasRole(scenario, context)\n\n instanceName = instanceName || scenarioName\n return await ScenarioEngine.load(instanceName, scenario, { domain, user, lng, variables })\n}\n\nexport async function stopScenario(\n instanceName: string,\n context: ResolverContext\n): Promise<ScenarioInstance | undefined> {\n const { domain, user, unsafeIP, prohibitedPrivileges } = context.state\n\n debug('stopScenario', instanceName)\n\n var scenarioInstance = ScenarioEngine.getScenarioInstance(domain, instanceName)\n\n if (!scenarioInstance) {\n debug('stopScenario', `ScenarioInstance(${instanceName}) Not Found.`)\n throw new Error(\n context.t('error.scenario instance not found', {\n instance: instanceName\n })\n )\n }\n\n var scenario = await findScenario(scenarioInstance.scenarioName, domain)\n\n await checkHasRole(scenario, context)\n\n await ScenarioEngine.unload(domain, instanceName)\n\n return scenarioInstance\n}\n"]}
@@ -1,5 +1,5 @@
1
- import './connector';
2
- import './task';
1
+ import './connector/index.js';
2
+ import './task/index.js';
3
3
  export * from './connection-manager';
4
4
  export * from './scenario-engine';
5
5
  export * from './task-registry';
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- require("./connector");
5
- require("./task");
4
+ require("./connector/index.js");
5
+ require("./task/index.js");
6
6
  tslib_1.__exportStar(require("./connection-manager"), exports);
7
7
  tslib_1.__exportStar(require("./scenario-engine"), exports);
8
8
  tslib_1.__exportStar(require("./task-registry"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;;AAAA,uBAAoB;AACpB,kBAAe;AAEf,+DAAoC;AACpC,4DAAiC;AACjC,0DAA+B;AAC/B,yEAA8C;AAC9C,wDAA6B;AAC7B,0DAA+B","sourcesContent":["import './connector'\nimport './task'\n\nexport * from './connection-manager'\nexport * from './scenario-engine'\nexport * from './task-registry'\nexport * from './analyzer/analyze-integration'\nexport * from './edge-client'\nexport * from './resource-pool'\n\nexport { Connector, Context, TaskHandler } from './types'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAC7B,2BAAwB;AAExB,+DAAoC;AACpC,4DAAiC;AACjC,0DAA+B;AAC/B,yEAA8C;AAC9C,wDAA6B;AAC7B,0DAA+B","sourcesContent":["import './connector/index.js'\nimport './task/index.js'\n\nexport * from './connection-manager'\nexport * from './scenario-engine'\nexport * from './task-registry'\nexport * from './analyzer/analyze-integration'\nexport * from './edge-client'\nexport * from './resource-pool'\n\nexport { Connector, Context, TaskHandler } from './types'\n"]}
@@ -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';
@@ -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 engine_1 = require("./engine");
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 engine_1.ConnectionManager.ready();
14
- await engine_1.ScenarioEngine.loadAll();
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
- engine_1.ConnectionManager.logger.error('Just has failed to start Scenario Engine.', ex);
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,mDAAwB;AACxB,wDAA6B;AAC7B,oDAAyB;AAEzB,oBAAiB;AACjB,qBAAkB,CAAC,UAAU;AAE7B,qCAA4D;AAE5D,OAAO,CAAC,EAAE,CAAC,wBAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAO,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,0BAAiB,CAAC,KAAK,EAAE,CAAA;QAC/B,MAAM,uBAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,0BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,EAAE,CAAC,CAAA;IACjF,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["export * from './migrations'\nexport * from './engine'\nexport * from './controllers'\nexport * from './service'\n\nimport './routes'\nimport './restful' /* APIs */\n\nimport { ConnectionManager, ScenarioEngine } from './engine'\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"]}
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"]}
@@ -1,23 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const env_1 = require("@things-factory/env");
4
- const scenario_view_router_1 = require("./routers/scenario-view-router");
5
- const scenario_schedule_callback_router_1 = require("./routers/scenario-schedule-callback-router");
6
- const isPathBaseDomain = !env_1.config.get('subdomain') && !env_1.config.get('useVirtualHostBasedDomain');
4
+ const shell_1 = require("@things-factory/shell");
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
+ const isPathBaseDomain = !env_1.config.get('subdomain');
7
8
  process.on('bootstrap-module-domain-public-route', (app, domainPrivateRouter) => {
8
9
  if (isPathBaseDomain) {
9
- domainPrivateRouter.use('/domain/:domain', scenario_schedule_callback_router_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_1.scenarioScheduleCallbackRouter.allowedMethods());
10
+ domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`, scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.allowedMethods());
10
11
  }
11
12
  else {
12
- domainPrivateRouter.use('', scenario_schedule_callback_router_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_1.scenarioScheduleCallbackRouter.allowedMethods());
13
+ domainPrivateRouter.use('', scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.routes(), scenario_schedule_callback_router_js_1.scenarioScheduleCallbackRouter.allowedMethods());
13
14
  }
14
15
  });
15
16
  process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
16
17
  if (isPathBaseDomain) {
17
- domainPrivateRouter.use('/domain/:domain', scenario_view_router_1.scenarioViewRouter.routes(), scenario_view_router_1.scenarioViewRouter.allowedMethods());
18
+ domainPrivateRouter.use(`/${(0, shell_1.getRoutePrefixForDomainType)()}/:domain`, scenario_view_router_js_1.scenarioViewRouter.routes(), scenario_view_router_js_1.scenarioViewRouter.allowedMethods());
18
19
  }
19
20
  else {
20
- domainPrivateRouter.use('', scenario_view_router_1.scenarioViewRouter.routes(), scenario_view_router_1.scenarioViewRouter.allowedMethods());
21
+ domainPrivateRouter.use('', scenario_view_router_js_1.scenarioViewRouter.routes(), scenario_view_router_js_1.scenarioViewRouter.allowedMethods());
21
22
  }
22
23
  });
23
24
  //# sourceMappingURL=routes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAE5C,yEAAmE;AACnE,mGAA4F;AAE5F,MAAM,gBAAgB,GAAG,CAAC,YAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,YAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAE7F,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACrF,IAAI,gBAAgB,EAAE,CAAC;QACrB,mBAAmB,CAAC,GAAG,CACrB,iBAAiB,EACjB,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,CAAC,cAAc,EAAE,CAChD,CAAA;IACH,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CACrB,EAAE,EACF,kEAA8B,CAAC,MAAM,EAAE,EACvC,kEAA8B,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,CAAC,iBAAiB,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;IAC9G,CAAC;SAAM,CAAC;QACN,mBAAmB,CAAC,GAAG,CAAC,EAAE,EAAE,yCAAkB,CAAC,MAAM,EAAE,EAAE,yCAAkB,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/F,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { config } from '@things-factory/env'\n\nimport { scenarioViewRouter } from './routers/scenario-view-router'\nimport { scenarioScheduleCallbackRouter } from './routers/scenario-schedule-callback-router'\n\nconst isPathBaseDomain = !config.get('subdomain') && !config.get('useVirtualHostBasedDomain')\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPrivateRouter) => {\n if (isPathBaseDomain) {\n domainPrivateRouter.use(\n '/domain/: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('/domain/:domain', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n } else {\n domainPrivateRouter.use('', scenarioViewRouter.routes(), scenarioViewRouter.allowedMethods())\n }\n})\n"]}
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) ? connection_type_1.ConnectionStatus.CONNECTED : connection_type_1.ConnectionStatus.DISCONNECTED });
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) ? connection_type_1.ConnectionStatus.CONNECTED : connection_type_1.ConnectionStatus.DISCONNECTED });
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
- // @Directive('@privilege(category: "connection", privilege: "mutation", domainOwnerGranted: true)')
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;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGzF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAwB;QAClG,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,IAAI,IACb,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CAAc,IAAY,EAAgB,KAAsB,EAAS,OAAwB;QACrH,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SAC3C,CAAC,C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,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;AAGK;IADL,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;;;;2DAexD;AAGK;IADL,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,GAAxB,MAAM,kBAAkB;IAMvB,AAAN,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,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,IAAI,IACb,CAAA;IACJ,CAAC;IAOK,AAAN,KAAK,CAAC,gBAAgB,CACP,IAAY,EACX,KAAsB,EAC7B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,UAAU,GACV,KAAK,KACR,OAAO,EAAE,IAAI,IAC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;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,+CAAmF;AAEnF,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAG1F,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QA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U,CAAC;GACR,eAAe,CA6E3B","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } 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: 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 @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 @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"]}
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,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,kCAAgB,CAAC,YAAY,GACpB,CAAA;IACjB,CAAC;IAIK,AAAN,KAAK,CAAC,WAAW,CACU,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,I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G,CAAC;IACrH,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;;;4CAA4B,iCAAe;2DAShG;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAClB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;2CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAI1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;0BA/EU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAgF3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } 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"]}