@things-factory/integration-base 6.2.70 → 6.2.75
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/analyzer/analyze-integration.js +2 -2
- package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js +4 -3
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/scenario-engine.js +4 -3
- package/dist-server/engine/scenario-engine.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js +2 -2
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/stop-scenario.js +2 -2
- package/dist-server/engine/task/stop-scenario.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js +2 -2
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js +2 -2
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js +2 -2
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/routers/scenario-schedule-callback-router.js +2 -2
- package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
- package/dist-server/routers/scenario-view-router.js +2 -2
- package/dist-server/routers/scenario-view-router.js.map +1 -1
- package/dist-server/service/index.js +1 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/scenario/index.js +2 -2
- package/dist-server/service/scenario/index.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +18 -18
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +13 -12
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +3 -118
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario/scenario.js +124 -0
- package/dist-server/service/scenario/scenario.js.map +1 -0
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +2 -2
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +2 -2
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.js +3 -3
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/service/step/step-type.js +4 -4
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/engine/analyzer/analyze-integration.ts +1 -1
- package/server/engine/connector/operato-connector.ts +4 -3
- package/server/engine/scenario-engine.ts +3 -1
- package/server/engine/task/pick-pending-scenario.ts +1 -1
- package/server/engine/task/stop-scenario.ts +1 -1
- package/server/engine/task/sub-scenario.ts +1 -1
- package/server/engine/task/switch-range-scenario.ts +1 -1
- package/server/engine/task/switch-scenario.ts +1 -1
- package/server/routers/scenario-schedule-callback-router.ts +1 -1
- package/server/routers/scenario-view-router.ts +2 -1
- package/server/service/index.ts +1 -1
- package/server/service/scenario/index.ts +1 -1
- package/server/service/scenario/scenario-mutation.ts +3 -5
- package/server/service/scenario/scenario-query.ts +2 -1
- package/server/service/scenario/scenario-type.ts +3 -106
- package/server/service/scenario/scenario.ts +109 -0
- package/server/service/scenario-instance/scenario-instance-mutation.ts +1 -1
- package/server/service/step/step-mutation.ts +1 -1
- package/server/service/step/step-query.ts +1 -1
- package/server/service/step/step-type.ts +1 -1
@@ -6,17 +6,17 @@ const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
7
7
|
const scheduler_client_1 = require("@things-factory/scheduler-client");
|
8
8
|
const step_type_1 = require("../step/step-type");
|
9
|
+
const scenario_1 = require("./scenario");
|
9
10
|
const scenario_type_1 = require("./scenario-type");
|
10
11
|
const crypto = require('crypto');
|
11
|
-
const debug = require('debug')('things-factory:integration-base:scenario-mutation');
|
12
12
|
let ScenarioMutation = class ScenarioMutation {
|
13
13
|
async createScenario(scenario, context) {
|
14
14
|
const { domain, user, tx } = context.state;
|
15
|
-
return await tx.getRepository(
|
15
|
+
return await tx.getRepository(scenario_1.Scenario).save(Object.assign(Object.assign({}, scenario), { domain, creator: user, updater: user }));
|
16
16
|
}
|
17
17
|
async updateScenario(name, patch, context) {
|
18
18
|
const { domain, user, tx } = context.state;
|
19
|
-
const repository = tx.getRepository(
|
19
|
+
const repository = tx.getRepository(scenario_1.Scenario);
|
20
20
|
const scenario = await repository.findOne({
|
21
21
|
where: { domain: { id: domain.id }, name }
|
22
22
|
});
|
@@ -32,7 +32,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
32
32
|
let results = [];
|
33
33
|
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
34
34
|
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
35
|
-
const scenarioRepo = tx.getRepository(
|
35
|
+
const scenarioRepo = tx.getRepository(scenario_1.Scenario);
|
36
36
|
if (_createRecords.length > 0) {
|
37
37
|
for (let i = 0; i < _createRecords.length; i++) {
|
38
38
|
const newRecord = _createRecords[i];
|
@@ -52,12 +52,12 @@ let ScenarioMutation = class ScenarioMutation {
|
|
52
52
|
}
|
53
53
|
async deleteScenario(name, context) {
|
54
54
|
const { domain, tx } = context.state;
|
55
|
-
await tx.getRepository(
|
55
|
+
await tx.getRepository(scenario_1.Scenario).delete({ domain: { id: domain.id }, name });
|
56
56
|
return true;
|
57
57
|
}
|
58
58
|
async deleteScenarios(ids, context) {
|
59
59
|
const { domain, tx } = context.state;
|
60
|
-
await tx.getRepository(
|
60
|
+
await tx.getRepository(scenario_1.Scenario).delete({
|
61
61
|
domain: { id: domain.id },
|
62
62
|
id: (0, typeorm_1.In)(ids)
|
63
63
|
});
|
@@ -65,7 +65,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
65
65
|
}
|
66
66
|
async importScenarios(scenarios, context) {
|
67
67
|
const { tx, domain, user } = context.state;
|
68
|
-
const repository = tx.getRepository(
|
68
|
+
const repository = tx.getRepository(scenario_1.Scenario);
|
69
69
|
await Promise.all(scenarios.map(async (scenario) => {
|
70
70
|
const { id, name } = scenario;
|
71
71
|
var savedScenario;
|
@@ -97,7 +97,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
97
97
|
}
|
98
98
|
async copyScenarios(ids, context) {
|
99
99
|
const { domain, user, tx } = context.state;
|
100
|
-
const originals = await tx.getRepository(
|
100
|
+
const originals = await tx.getRepository(scenario_1.Scenario).find({
|
101
101
|
where: {
|
102
102
|
id: (0, typeorm_1.In)(ids),
|
103
103
|
domain: { id: domain.id }
|
@@ -137,7 +137,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
137
137
|
updater: user
|
138
138
|
};
|
139
139
|
});
|
140
|
-
var copiedScenarios = await tx.getRepository(
|
140
|
+
var copiedScenarios = await tx.getRepository(scenario_1.Scenario).save(newCopys);
|
141
141
|
var copiedSteps = await tx.getRepository(step_type_1.Step).save(newSteps);
|
142
142
|
return copiedScenarios.map(scenario => {
|
143
143
|
scenario.steps = copiedSteps.filter(step => step.scenario == scenario.id);
|
@@ -146,7 +146,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
146
146
|
}
|
147
147
|
async startScenarioSchedule(scenarioId, context) {
|
148
148
|
const { domain, user, tx } = context.state;
|
149
|
-
var repository = tx.getRepository(
|
149
|
+
var repository = tx.getRepository(scenario_1.Scenario);
|
150
150
|
var scenario = await repository.findOne({
|
151
151
|
where: { domain: { id: domain.id }, id: scenarioId }
|
152
152
|
});
|
@@ -206,7 +206,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
206
206
|
}
|
207
207
|
async stopScenarioSchedule(scenarioId, context) {
|
208
208
|
const { domain, tx } = context.state;
|
209
|
-
var repository = tx.getRepository(
|
209
|
+
var repository = tx.getRepository(scenario_1.Scenario);
|
210
210
|
var scenario = await repository.findOne({
|
211
211
|
where: { domain: { id: domain.id }, id: scenarioId }
|
212
212
|
});
|
@@ -227,7 +227,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
227
227
|
tslib_1.__decorate([
|
228
228
|
(0, type_graphql_1.Directive)('@transaction'),
|
229
229
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
230
|
-
(0, type_graphql_1.Mutation)(returns =>
|
230
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'To create new scenario' }),
|
231
231
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenario', type => scenario_type_1.NewScenario)),
|
232
232
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
233
233
|
tslib_1.__metadata("design:type", Function),
|
@@ -237,7 +237,7 @@ tslib_1.__decorate([
|
|
237
237
|
tslib_1.__decorate([
|
238
238
|
(0, type_graphql_1.Directive)('@transaction'),
|
239
239
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
240
|
-
(0, type_graphql_1.Mutation)(returns =>
|
240
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'To modify scenario information' }),
|
241
241
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
242
242
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', type => scenario_type_1.ScenarioPatch)),
|
243
243
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
@@ -248,7 +248,7 @@ tslib_1.__decorate([
|
|
248
248
|
tslib_1.__decorate([
|
249
249
|
(0, type_graphql_1.Directive)('@transaction'),
|
250
250
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
251
|
-
(0, type_graphql_1.Mutation)(returns => [
|
251
|
+
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], { description: "To modify multiple scenarios' information" }),
|
252
252
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [scenario_type_1.ScenarioPatch])),
|
253
253
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
254
254
|
tslib_1.__metadata("design:type", Function),
|
@@ -288,7 +288,7 @@ tslib_1.__decorate([
|
|
288
288
|
tslib_1.__decorate([
|
289
289
|
(0, type_graphql_1.Directive)('@transaction'),
|
290
290
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
291
|
-
(0, type_graphql_1.Mutation)(returns => [
|
291
|
+
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], { description: 'To import multiple scenarios' }),
|
292
292
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
293
293
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
294
294
|
tslib_1.__metadata("design:type", Function),
|
@@ -298,7 +298,7 @@ tslib_1.__decorate([
|
|
298
298
|
tslib_1.__decorate([
|
299
299
|
(0, type_graphql_1.Directive)('@transaction'),
|
300
300
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
301
|
-
(0, type_graphql_1.Mutation)(returns =>
|
301
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, {
|
302
302
|
description: 'To start posting scenario based on the schedule of the given scenario'
|
303
303
|
}),
|
304
304
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenarioId')),
|
@@ -310,7 +310,7 @@ tslib_1.__decorate([
|
|
310
310
|
tslib_1.__decorate([
|
311
311
|
(0, type_graphql_1.Directive)('@transaction'),
|
312
312
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
313
|
-
(0, type_graphql_1.Mutation)(returns =>
|
313
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, {
|
314
314
|
nullable: true,
|
315
315
|
description: 'To stop posting scenario based on the schedule of the given scenario'
|
316
316
|
}),
|
@@ -321,7 +321,7 @@ tslib_1.__decorate([
|
|
321
321
|
tslib_1.__metadata("design:returntype", Promise)
|
322
322
|
], ScenarioMutation.prototype, "stopScenarioSchedule", null);
|
323
323
|
ScenarioMutation = tslib_1.__decorate([
|
324
|
-
(0, type_graphql_1.Resolver)(
|
324
|
+
(0, type_graphql_1.Resolver)(scenario_1.Scenario)
|
325
325
|
], ScenarioMutation);
|
326
326
|
exports.ScenarioMutation = ScenarioMutation;
|
327
327
|
//# sourceMappingURL=scenario-mutation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-mutation.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA2C;AAG3C,uEAKyC;AAEzC,iDAAwC;AACxC,mDAAsE;AAEtE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AAG5E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAIrB,AAAN,KAAK,CAAC,cAAc,CACoB,QAAqB,EACpD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAQ,CAAC,CAAC,IAAI,iCACvC,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAKK,AAAN,KAAK,CAAC,cAAc,CACL,IAAY,EACY,KAAoB,EAClD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,wBAAQ,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACxC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAA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IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,wBAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE9E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDA4DP;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wBAAQ,EAAE;QAC7B,WAAW,EAAE,uEAAuE;KACrF,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DA0EP;AAQK;IANL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wBAAQ,EAAE;QAC7B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,sEAAsE;KACpF,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DA2BP;AAzXU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,wBAAQ,CAAC;GACN,gBAAgB,CA0X5B;AA1XY,4CAAgB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, In } from 'typeorm'\n\nimport { Domain } from '@things-factory/shell'\nimport {\n Application,\n getCallbackBaseWithDomainContext,\n registerSchedule,\n unregisterSchedule\n} from '@things-factory/scheduler-client'\n\nimport { Step } from '../step/step-type'\nimport { NewScenario, Scenario, ScenarioPatch } from './scenario-type'\n\nconst crypto = require('crypto')\n\nconst debug = require('debug')('things-factory:integration-base:scenario-mutation')\n\n@Resolver(Scenario)\nexport class ScenarioMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, { description: 'To create new scenario' })\n async createScenario(\n @Arg('scenario', type => NewScenario) scenario: NewScenario,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Scenario).save({\n ...scenario,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, { description: 'To modify scenario information' })\n async updateScenario(\n @Arg('name') name: string,\n @Arg('patch', type => ScenarioPatch) patch: ScenarioPatch,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Scenario)\n const scenario = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: name\n })\n )\n }\n\n return await repository.save({\n ...scenario,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Scenario], { description: \"To modify multiple scenarios' information\" })\n async updateMultipleScenario(\n @Arg('patches', type => [ScenarioPatch]) patches: ScenarioPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Scenario[]> {\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 scenarioRepo = tx.getRepository(Scenario)\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 scenarioRepo.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 scenario = await scenarioRepo.findOneBy({ id: newRecord.id })\n\n const result = await scenarioRepo.save({\n ...scenario,\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('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete scenario' })\n async deleteScenario(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Scenario).delete({ domain: { id: domain.id }, name })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple scenarios' })\n async deleteScenarios(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Scenario).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple scenarios' })\n async importScenarios(\n @Arg('scenarios', type => [ScenarioPatch]) scenarios: Scenario[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Scenario)\n\n await Promise.all(\n scenarios.map(async (scenario: Scenario) => {\n const { id, name } = scenario\n var savedScenario\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Scenario 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 `Scenario Name '${name}' is already taken by another scenario`\n }\n\n savedScenario = await repository.save({\n ...sameId,\n ...scenario,\n domain,\n updater: user\n })\n } else {\n savedScenario = await repository.save({\n ...scenario,\n domain,\n updater: user,\n creator: user\n })\n }\n } else {\n savedScenario = await repository.save({\n ...scenario,\n domain,\n updater: user,\n creator: user\n })\n }\n\n await tx.getRepository(Step).delete({ domain: { id: domain.id }, scenario: { id: savedScenario.id } })\n await tx.getRepository(Step).save(\n scenario.steps.map((step: Step) => {\n return {\n ...step,\n domain,\n scenario: savedScenario,\n updater: user\n }\n })\n )\n })\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Scenario], { description: 'To import multiple scenarios' })\n async copyScenarios(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Scenario[]> {\n const { domain, user, tx } = context.state\n\n const originals = await tx.getRepository(Scenario).find({\n where: {\n id: In(ids),\n domain: { id: domain.id }\n },\n relations: ['domain', 'steps']\n })\n\n if (originals.length == 0) {\n return []\n }\n\n var newSteps = []\n\n var newCopys = originals.map(scenario => {\n let scenarioId = crypto.randomUUID()\n newSteps.push(\n ...scenario.steps.map(step => {\n return {\n scenario: scenarioId,\n name: step.name,\n description: step.description,\n sequence: step.sequence,\n task: step.task,\n connection: step.connection,\n params: step.params,\n\n domain,\n creator: user,\n updater: user\n }\n })\n )\n\n return {\n id: scenarioId,\n name: scenario.name + ' (' + scenarioId + ')',\n type: scenario.type,\n description: scenario.description,\n active: false, // deprecated\n schedule: scenario.schedule,\n timezone: scenario.timezone,\n\n domain,\n creator: user,\n updater: user\n }\n })\n\n var copiedScenarios = await tx.getRepository(Scenario).save(newCopys)\n var copiedSteps = await tx.getRepository(Step).save(newSteps)\n\n return copiedScenarios.map(scenario => {\n scenario.steps = copiedSteps.filter(step => step.scenario == scenario.id)\n return scenario\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, {\n description: 'To start posting scenario based on the schedule of the given scenario'\n })\n async startScenarioSchedule(\n @Arg('scenarioId') scenarioId: string,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(Scenario)\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, id: scenarioId }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioId\n })\n )\n }\n\n if (!scenario.schedule) {\n throw new Error(\n context.t('error.schedule is not set', {\n scenario: scenario.name\n })\n )\n }\n\n if (!scenario.timezone) {\n throw new Error(\n context.t('error.timezone is not set', {\n scenario: scenario.name\n })\n )\n }\n\n try {\n var handle = await registerSchedule({\n name: scenario.name,\n client: {\n application: Application,\n group: `${domain.id}`,\n type: 'scenario',\n key: scenario.id,\n operation: 'start'\n },\n type: 'cron',\n schedule: scenario.schedule,\n timezone: scenario.timezone,\n task: {\n type: 'rest',\n connection: {\n host: `${getCallbackBaseWithDomainContext(domain)}/callback-schedule-for-scenario`,\n headers: {\n 'Content-Type': 'application/json',\n accept: '*/*'\n }\n },\n data: {\n domainId: domain.id,\n userId: user.id,\n scenarioId\n },\n history_check: true,\n failed_policy: 'retry_dlq',\n max_retry_count: -1,\n retry_period: 60\n }\n })\n\n return await repository.save({\n ...scenario,\n scheduleId: handle\n })\n } catch (err) {\n console.error('startScenarioSchedule', err)\n }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, {\n nullable: true,\n description: 'To stop posting scenario based on the schedule of the given scenario'\n })\n async stopScenarioSchedule(\n @Arg('scenarioId') scenarioId: string,\n @Ctx() context: ResolverContext\n ): Promise<Scenario | undefined> {\n const { domain, tx } = context.state\n\n var repository = tx.getRepository(Scenario)\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, id: scenarioId }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioId\n })\n )\n }\n\n try {\n await unregisterSchedule(scenario.scheduleId)\n\n return await repository.save({\n ...scenario,\n scheduleId: null\n })\n } catch (err) {\n console.error('stopScenarioSchedule', err)\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"scenario-mutation.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,uEAKyC;AAEzC,iDAAwC;AACxC,yCAAqC;AACrC,mDAA4D;AAE5D,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAGzB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAIrB,AAAN,KAAK,CAAC,cAAc,CACoB,QAAqB,EACpD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,IAAI,iCACvC,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAKK,AAAN,KAAK,CAAC,cAAc,CACL,IAAY,EACY,KAAoB,EAClD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACxC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,E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A,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE9E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDA4DP;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,WAAW,EAAE,uEAAuE;KACrF,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DA0EP;AAQK;IANL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,sEAAsE;KACpF,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DA2BP;AAzXU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA0X5B;AA1XY,4CAAgB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport {\n Application,\n getCallbackBaseWithDomainContext,\n registerSchedule,\n unregisterSchedule\n} from '@things-factory/scheduler-client'\n\nimport { Step } from '../step/step-type'\nimport { Scenario } from './scenario'\nimport { NewScenario, ScenarioPatch } from './scenario-type'\n\nconst crypto = require('crypto')\n\n@Resolver(Scenario)\nexport class ScenarioMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, { description: 'To create new scenario' })\n async createScenario(\n @Arg('scenario', type => NewScenario) scenario: NewScenario,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Scenario).save({\n ...scenario,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, { description: 'To modify scenario information' })\n async updateScenario(\n @Arg('name') name: string,\n @Arg('patch', type => ScenarioPatch) patch: ScenarioPatch,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Scenario)\n const scenario = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: name\n })\n )\n }\n\n return await repository.save({\n ...scenario,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Scenario], { description: \"To modify multiple scenarios' information\" })\n async updateMultipleScenario(\n @Arg('patches', type => [ScenarioPatch]) patches: ScenarioPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Scenario[]> {\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 scenarioRepo = tx.getRepository(Scenario)\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 scenarioRepo.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 scenario = await scenarioRepo.findOneBy({ id: newRecord.id })\n\n const result = await scenarioRepo.save({\n ...scenario,\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('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete scenario' })\n async deleteScenario(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Scenario).delete({ domain: { id: domain.id }, name })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple scenarios' })\n async deleteScenarios(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Scenario).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple scenarios' })\n async importScenarios(\n @Arg('scenarios', type => [ScenarioPatch]) scenarios: Scenario[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx, domain, user } = context.state\n\n const repository = tx.getRepository(Scenario)\n\n await Promise.all(\n scenarios.map(async (scenario: Scenario) => {\n const { id, name } = scenario\n var savedScenario\n\n if (id) {\n const sameId = await repository.findOneBy({ id })\n\n if (sameId) {\n if (sameId.domainId != domain.id) {\n throw `Scenario 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 `Scenario Name '${name}' is already taken by another scenario`\n }\n\n savedScenario = await repository.save({\n ...sameId,\n ...scenario,\n domain,\n updater: user\n })\n } else {\n savedScenario = await repository.save({\n ...scenario,\n domain,\n updater: user,\n creator: user\n })\n }\n } else {\n savedScenario = await repository.save({\n ...scenario,\n domain,\n updater: user,\n creator: user\n })\n }\n\n await tx.getRepository(Step).delete({ domain: { id: domain.id }, scenario: { id: savedScenario.id } })\n await tx.getRepository(Step).save(\n scenario.steps.map((step: Step) => {\n return {\n ...step,\n domain,\n scenario: savedScenario,\n updater: user\n }\n })\n )\n })\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Scenario], { description: 'To import multiple scenarios' })\n async copyScenarios(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Scenario[]> {\n const { domain, user, tx } = context.state\n\n const originals = await tx.getRepository(Scenario).find({\n where: {\n id: In(ids),\n domain: { id: domain.id }\n },\n relations: ['domain', 'steps']\n })\n\n if (originals.length == 0) {\n return []\n }\n\n var newSteps = []\n\n var newCopys = originals.map(scenario => {\n let scenarioId = crypto.randomUUID()\n newSteps.push(\n ...scenario.steps.map(step => {\n return {\n scenario: scenarioId,\n name: step.name,\n description: step.description,\n sequence: step.sequence,\n task: step.task,\n connection: step.connection,\n params: step.params,\n\n domain,\n creator: user,\n updater: user\n }\n })\n )\n\n return {\n id: scenarioId,\n name: scenario.name + ' (' + scenarioId + ')',\n type: scenario.type,\n description: scenario.description,\n active: false, // deprecated\n schedule: scenario.schedule,\n timezone: scenario.timezone,\n\n domain,\n creator: user,\n updater: user\n }\n })\n\n var copiedScenarios = await tx.getRepository(Scenario).save(newCopys)\n var copiedSteps = await tx.getRepository(Step).save(newSteps)\n\n return copiedScenarios.map(scenario => {\n scenario.steps = copiedSteps.filter(step => step.scenario == scenario.id)\n return scenario\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, {\n description: 'To start posting scenario based on the schedule of the given scenario'\n })\n async startScenarioSchedule(\n @Arg('scenarioId') scenarioId: string,\n @Ctx() context: ResolverContext\n ): Promise<Scenario> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(Scenario)\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, id: scenarioId }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioId\n })\n )\n }\n\n if (!scenario.schedule) {\n throw new Error(\n context.t('error.schedule is not set', {\n scenario: scenario.name\n })\n )\n }\n\n if (!scenario.timezone) {\n throw new Error(\n context.t('error.timezone is not set', {\n scenario: scenario.name\n })\n )\n }\n\n try {\n var handle = await registerSchedule({\n name: scenario.name,\n client: {\n application: Application,\n group: `${domain.id}`,\n type: 'scenario',\n key: scenario.id,\n operation: 'start'\n },\n type: 'cron',\n schedule: scenario.schedule,\n timezone: scenario.timezone,\n task: {\n type: 'rest',\n connection: {\n host: `${getCallbackBaseWithDomainContext(domain)}/callback-schedule-for-scenario`,\n headers: {\n 'Content-Type': 'application/json',\n accept: '*/*'\n }\n },\n data: {\n domainId: domain.id,\n userId: user.id,\n scenarioId\n },\n history_check: true,\n failed_policy: 'retry_dlq',\n max_retry_count: -1,\n retry_period: 60\n }\n })\n\n return await repository.save({\n ...scenario,\n scheduleId: handle\n })\n } catch (err) {\n console.error('startScenarioSchedule', err)\n }\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"scenario\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Scenario, {\n nullable: true,\n description: 'To stop posting scenario based on the schedule of the given scenario'\n })\n async stopScenarioSchedule(\n @Arg('scenarioId') scenarioId: string,\n @Ctx() context: ResolverContext\n ): Promise<Scenario | undefined> {\n const { domain, tx } = context.state\n\n var repository = tx.getRepository(Scenario)\n var scenario = await repository.findOne({\n where: { domain: { id: domain.id }, id: scenarioId }\n })\n\n if (!scenario) {\n throw new Error(\n context.t('error.scenario not found', {\n scenario: scenarioId\n })\n )\n }\n\n try {\n await unregisterSchedule(scenario.scheduleId)\n\n return await repository.save({\n ...scenario,\n scheduleId: null\n })\n } catch (err) {\n console.error('stopScenarioSchedule', err)\n }\n }\n}\n"]}
|
@@ -9,12 +9,13 @@ const shell_1 = require("@things-factory/shell");
|
|
9
9
|
const engine_1 = require("../../engine");
|
10
10
|
const scenario_instance_type_1 = require("../scenario-instance/scenario-instance-type");
|
11
11
|
const step_type_1 = require("../step/step-type");
|
12
|
+
const scenario_1 = require("./scenario");
|
12
13
|
const scenario_type_1 = require("./scenario-type");
|
13
14
|
const connection_type_1 = require("../connection/connection-type");
|
14
15
|
let ScenarioQuery = class ScenarioQuery {
|
15
16
|
async scenario(id, context) {
|
16
17
|
const { domain } = context.state;
|
17
|
-
const scenario = await (0, shell_1.getRepository)(
|
18
|
+
const scenario = await (0, shell_1.getRepository)(scenario_1.Scenario).findOne({ where: { id } });
|
18
19
|
if (domain.id == scenario.domainId || domain.parentId == scenario.domainId) {
|
19
20
|
return scenario;
|
20
21
|
}
|
@@ -22,7 +23,7 @@ let ScenarioQuery = class ScenarioQuery {
|
|
22
23
|
async scenarios(params, context) {
|
23
24
|
const { domain } = context.state;
|
24
25
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
25
|
-
repository: (0, shell_1.getRepository)(
|
26
|
+
repository: (0, shell_1.getRepository)(scenario_1.Scenario),
|
26
27
|
params,
|
27
28
|
domain,
|
28
29
|
searchables: ['name', 'description', 'type']
|
@@ -72,7 +73,7 @@ let ScenarioQuery = class ScenarioQuery {
|
|
72
73
|
};
|
73
74
|
tslib_1.__decorate([
|
74
75
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "query", domainOwnerGranted: true)'),
|
75
|
-
(0, type_graphql_1.Query)(returns =>
|
76
|
+
(0, type_graphql_1.Query)(returns => scenario_1.Scenario, { description: 'To fetch a scenario' }),
|
76
77
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
77
78
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
78
79
|
tslib_1.__metadata("design:type", Function),
|
@@ -92,21 +93,21 @@ tslib_1.__decorate([
|
|
92
93
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
93
94
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
94
95
|
tslib_1.__metadata("design:type", Function),
|
95
|
-
tslib_1.__metadata("design:paramtypes", [
|
96
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario]),
|
96
97
|
tslib_1.__metadata("design:returntype", Promise)
|
97
98
|
], ScenarioQuery.prototype, "domain", null);
|
98
99
|
tslib_1.__decorate([
|
99
100
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
100
101
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
101
102
|
tslib_1.__metadata("design:type", Function),
|
102
|
-
tslib_1.__metadata("design:paramtypes", [
|
103
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario]),
|
103
104
|
tslib_1.__metadata("design:returntype", Promise)
|
104
105
|
], ScenarioQuery.prototype, "updater", null);
|
105
106
|
tslib_1.__decorate([
|
106
107
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
107
108
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
108
109
|
tslib_1.__metadata("design:type", Function),
|
109
|
-
tslib_1.__metadata("design:paramtypes", [
|
110
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario]),
|
110
111
|
tslib_1.__metadata("design:returntype", Promise)
|
111
112
|
], ScenarioQuery.prototype, "creator", null);
|
112
113
|
tslib_1.__decorate([
|
@@ -114,7 +115,7 @@ tslib_1.__decorate([
|
|
114
115
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
115
116
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
116
117
|
tslib_1.__metadata("design:type", Function),
|
117
|
-
tslib_1.__metadata("design:paramtypes", [
|
118
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario, Object]),
|
118
119
|
tslib_1.__metadata("design:returntype", Promise)
|
119
120
|
], ScenarioQuery.prototype, "steps", null);
|
120
121
|
tslib_1.__decorate([
|
@@ -122,7 +123,7 @@ tslib_1.__decorate([
|
|
122
123
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
123
124
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
124
125
|
tslib_1.__metadata("design:type", Function),
|
125
|
-
tslib_1.__metadata("design:paramtypes", [
|
126
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario, Object]),
|
126
127
|
tslib_1.__metadata("design:returntype", Promise)
|
127
128
|
], ScenarioQuery.prototype, "connectionNames", null);
|
128
129
|
tslib_1.__decorate([
|
@@ -130,7 +131,7 @@ tslib_1.__decorate([
|
|
130
131
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
131
132
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
132
133
|
tslib_1.__metadata("design:type", Function),
|
133
|
-
tslib_1.__metadata("design:paramtypes", [
|
134
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario, Object]),
|
134
135
|
tslib_1.__metadata("design:returntype", Promise)
|
135
136
|
], ScenarioQuery.prototype, "publishTags", null);
|
136
137
|
tslib_1.__decorate([
|
@@ -138,7 +139,7 @@ tslib_1.__decorate([
|
|
138
139
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
139
140
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
140
141
|
tslib_1.__metadata("design:type", Function),
|
141
|
-
tslib_1.__metadata("design:paramtypes", [
|
142
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario, Object]),
|
142
143
|
tslib_1.__metadata("design:returntype", Promise)
|
143
144
|
], ScenarioQuery.prototype, "state", null);
|
144
145
|
tslib_1.__decorate([
|
@@ -146,11 +147,11 @@ tslib_1.__decorate([
|
|
146
147
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
147
148
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
148
149
|
tslib_1.__metadata("design:type", Function),
|
149
|
-
tslib_1.__metadata("design:paramtypes", [
|
150
|
+
tslib_1.__metadata("design:paramtypes", [scenario_1.Scenario, Object]),
|
150
151
|
tslib_1.__metadata("design:returntype", Promise)
|
151
152
|
], ScenarioQuery.prototype, "instances", null);
|
152
153
|
ScenarioQuery = tslib_1.__decorate([
|
153
|
-
(0, type_graphql_1.Resolver)(
|
154
|
+
(0, type_graphql_1.Resolver)(scenario_1.Scenario)
|
154
155
|
], ScenarioQuery);
|
155
156
|
exports.ScenarioQuery = ScenarioQuery;
|
156
157
|
//# sourceMappingURL=scenario-query.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-query.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAqC;AAErC,yDAAgD;AAChD,iDAAuG;AAEvG,yCAA6C;AAC7C,wFAAsG;AACtG,iDAAwC;AACxC,
|
1
|
+
{"version":3,"file":"scenario-query.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAqC;AAErC,yDAAgD;AAChD,iDAAuG;AAEvG,yCAA6C;AAC7C,wFAAsG;AACtG,iDAAwC;AACxC,yCAAqC;AACrC,mDAA8C;AAC9C,mEAA0D;AAGnD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGlB,AAAN,KAAK,CAAC,QAAQ,CAAY,EAAU,EAAS,OAAwB;QACnE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAA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AKrC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,yCAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC7C,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAsB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAhB,mBAAQ;;8CAIzC;AAxFU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CAyFzB;AAzFY,sCAAa","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Not, IsNull } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ScenarioEngine } from '../../engine'\nimport { ScenarioInstance, ScenarioInstanceStatus } from '../scenario-instance/scenario-instance-type'\nimport { Step } from '../step/step-type'\nimport { Scenario } from './scenario'\nimport { ScenarioList } from './scenario-type'\nimport { Connection } from '../connection/connection-type'\n\n@Resolver(Scenario)\nexport class ScenarioQuery {\n @Directive('@privilege(category: \"scenario\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Scenario, { description: 'To fetch a scenario' })\n async scenario(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Scenario> {\n const { domain } = context.state\n\n const scenario = await getRepository(Scenario).findOne({ where: { id } })\n if (domain.id == scenario.domainId || domain.parentId == scenario.domainId) {\n return scenario\n }\n }\n\n @Directive('@privilege(category: \"scenario\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => ScenarioList, { description: 'To fetch multiple scenarios' })\n async scenarios(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ScenarioList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Scenario),\n params,\n domain,\n searchables: ['name', 'description', 'type']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() scenario: Scenario) {\n return await getRepository(Domain).findOneBy({ id: scenario.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() scenario: Scenario): Promise<User> {\n return await getRepository(User).findOneBy({ id: scenario.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() scenario: Scenario): Promise<User> {\n return await getRepository(User).findOneBy({ id: scenario.creatorId })\n }\n\n @FieldResolver(type => [Step])\n async steps(@Root() scenario: Scenario, @Ctx() context: ResolverContext): Promise<Step[]> {\n const { domain } = context.state\n\n return await getRepository(Step).find({\n where: { domain: { id: domain.id }, scenario: { id: scenario.id } }\n })\n }\n\n @FieldResolver(type => [Connection])\n async connectionNames(@Root() scenario: Scenario, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n const steps = await getRepository(Step).find({\n where: { domain: { id: domain.id }, scenario: { id: scenario.id }, connection: Not(IsNull()) }\n })\n\n return steps.map(step => step.connection).filter(Boolean)\n }\n\n @FieldResolver(type => [Connection])\n async publishTags(@Root() scenario: Scenario, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n const steps = await getRepository(Step).find({\n where: { domain: { id: domain.id }, scenario: { id: scenario.id }, task: 'publish' }\n })\n\n return steps.map(step => JSON.parse(step.params)?.tag).filter(Boolean)\n }\n\n @FieldResolver(type => String, { nullable: true })\n async state(@Root() scenario: Scenario, @Ctx() context: ResolverContext): Promise<string> {\n const { domain } = context.state\n\n var instance = ScenarioEngine.getScenarioInstance(domain, scenario.name)\n return instance && ScenarioInstanceStatus[instance.context?.state]\n }\n\n @FieldResolver(type => [ScenarioInstance], { nullable: true })\n async instances(@Root() scenario: Scenario, @Ctx() context: ResolverContext): Promise<ScenarioInstance[]> {\n const { domain } = context.state\n\n return ScenarioEngine.getScenarioInstances(domain, scenario.name)\n }\n}\n"]}
|
@@ -1,126 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ScenarioList = exports.ScenarioPatch = exports.NewScenario =
|
3
|
+
exports.ScenarioList = exports.ScenarioPatch = exports.NewScenario = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
|
-
const typeorm_1 = require("typeorm");
|
7
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
8
|
-
const
|
9
|
-
const engine_1 = require("../../engine");
|
7
|
+
const scenario_1 = require("./scenario");
|
10
8
|
const step_type_1 = require("../step/step-type");
|
11
|
-
let Scenario = class Scenario {
|
12
|
-
async start(instanceName, variables) {
|
13
|
-
try {
|
14
|
-
await engine_1.ScenarioEngine.load(instanceName || this.name, this, { domain: this.domain, user: this.updater, variables });
|
15
|
-
}
|
16
|
-
catch (ex) { }
|
17
|
-
}
|
18
|
-
async stop(instanceName) {
|
19
|
-
try {
|
20
|
-
await engine_1.ScenarioEngine.unload(this.domain, instanceName || this.name);
|
21
|
-
}
|
22
|
-
finally {
|
23
|
-
}
|
24
|
-
}
|
25
|
-
};
|
26
|
-
tslib_1.__decorate([
|
27
|
-
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
28
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
29
|
-
tslib_1.__metadata("design:type", String)
|
30
|
-
], Scenario.prototype, "id", void 0);
|
31
|
-
tslib_1.__decorate([
|
32
|
-
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
33
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
34
|
-
tslib_1.__metadata("design:type", shell_1.Domain)
|
35
|
-
], Scenario.prototype, "domain", void 0);
|
36
|
-
tslib_1.__decorate([
|
37
|
-
(0, typeorm_1.RelationId)((scenario) => scenario.domain),
|
38
|
-
tslib_1.__metadata("design:type", String)
|
39
|
-
], Scenario.prototype, "domainId", void 0);
|
40
|
-
tslib_1.__decorate([
|
41
|
-
(0, typeorm_1.Column)(),
|
42
|
-
(0, type_graphql_1.Field)(),
|
43
|
-
tslib_1.__metadata("design:type", String)
|
44
|
-
], Scenario.prototype, "name", void 0);
|
45
|
-
tslib_1.__decorate([
|
46
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
47
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
48
|
-
tslib_1.__metadata("design:type", String)
|
49
|
-
], Scenario.prototype, "description", void 0);
|
50
|
-
tslib_1.__decorate([
|
51
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
52
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
53
|
-
tslib_1.__metadata("design:type", String)
|
54
|
-
], Scenario.prototype, "type", void 0);
|
55
|
-
tslib_1.__decorate([
|
56
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
57
|
-
(0, type_graphql_1.Field)({ nullable: true, description: 'accessible and executable system-wide' }),
|
58
|
-
tslib_1.__metadata("design:type", Boolean)
|
59
|
-
], Scenario.prototype, "public", void 0);
|
60
|
-
tslib_1.__decorate([
|
61
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
62
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '[will be deprecated] automatically be started when this server start' }),
|
63
|
-
tslib_1.__metadata("design:type", Boolean)
|
64
|
-
], Scenario.prototype, "active", void 0);
|
65
|
-
tslib_1.__decorate([
|
66
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
67
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
68
|
-
tslib_1.__metadata("design:type", String)
|
69
|
-
], Scenario.prototype, "schedule", void 0);
|
70
|
-
tslib_1.__decorate([
|
71
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
72
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
73
|
-
tslib_1.__metadata("design:type", String)
|
74
|
-
], Scenario.prototype, "scheduleId", void 0);
|
75
|
-
tslib_1.__decorate([
|
76
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
77
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
78
|
-
tslib_1.__metadata("design:type", String)
|
79
|
-
], Scenario.prototype, "timezone", void 0);
|
80
|
-
tslib_1.__decorate([
|
81
|
-
(0, typeorm_1.OneToMany)(type => step_type_1.Step, step => step.scenario),
|
82
|
-
(0, type_graphql_1.Field)(type => [step_type_1.Step], { nullable: true }),
|
83
|
-
tslib_1.__metadata("design:type", Array)
|
84
|
-
], Scenario.prototype, "steps", void 0);
|
85
|
-
tslib_1.__decorate([
|
86
|
-
(0, typeorm_1.Column)({ type: 'simple-json', nullable: true }),
|
87
|
-
(0, type_graphql_1.Field)(type => auth_base_1.PrivilegeObject, { nullable: true }),
|
88
|
-
tslib_1.__metadata("design:type", auth_base_1.PrivilegeObject)
|
89
|
-
], Scenario.prototype, "privilege", void 0);
|
90
|
-
tslib_1.__decorate([
|
91
|
-
(0, typeorm_1.CreateDateColumn)(),
|
92
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
93
|
-
tslib_1.__metadata("design:type", Date)
|
94
|
-
], Scenario.prototype, "createdAt", void 0);
|
95
|
-
tslib_1.__decorate([
|
96
|
-
(0, typeorm_1.UpdateDateColumn)(),
|
97
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
98
|
-
tslib_1.__metadata("design:type", Date)
|
99
|
-
], Scenario.prototype, "updatedAt", void 0);
|
100
|
-
tslib_1.__decorate([
|
101
|
-
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
102
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
103
|
-
tslib_1.__metadata("design:type", auth_base_1.User)
|
104
|
-
], Scenario.prototype, "creator", void 0);
|
105
|
-
tslib_1.__decorate([
|
106
|
-
(0, typeorm_1.RelationId)((scenario) => scenario.creator),
|
107
|
-
tslib_1.__metadata("design:type", String)
|
108
|
-
], Scenario.prototype, "creatorId", void 0);
|
109
|
-
tslib_1.__decorate([
|
110
|
-
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
111
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
112
|
-
tslib_1.__metadata("design:type", auth_base_1.User)
|
113
|
-
], Scenario.prototype, "updater", void 0);
|
114
|
-
tslib_1.__decorate([
|
115
|
-
(0, typeorm_1.RelationId)((scenario) => scenario.updater),
|
116
|
-
tslib_1.__metadata("design:type", String)
|
117
|
-
], Scenario.prototype, "updaterId", void 0);
|
118
|
-
Scenario = tslib_1.__decorate([
|
119
|
-
(0, typeorm_1.Entity)(),
|
120
|
-
(0, typeorm_1.Index)('ix_scenario_0', (scenario) => [scenario.domain, scenario.name], { unique: true }),
|
121
|
-
(0, type_graphql_1.ObjectType)()
|
122
|
-
], Scenario);
|
123
|
-
exports.Scenario = Scenario;
|
124
9
|
let NewScenario = class NewScenario {
|
125
10
|
};
|
126
11
|
tslib_1.__decorate([
|
@@ -204,7 +89,7 @@ exports.ScenarioPatch = ScenarioPatch;
|
|
204
89
|
let ScenarioList = class ScenarioList {
|
205
90
|
};
|
206
91
|
tslib_1.__decorate([
|
207
|
-
(0, type_graphql_1.Field)(type => [Scenario]),
|
92
|
+
(0, type_graphql_1.Field)(type => [scenario_1.Scenario]),
|
208
93
|
tslib_1.__metadata("design:type", Array)
|
209
94
|
], ScenarioList.prototype, "items", void 0);
|
210
95
|
tslib_1.__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-type.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;
|
1
|
+
{"version":3,"file":"scenario-type.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAA0D;AAE1D,yCAAqC;AACrC,iDAA6C;AAGtC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAqBvB,CAAA;AApBC;IAAC,IAAA,oBAAK,GAAE;;yCACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,E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AI,EAAE,CAAC;sCACd,0BAAc;gDAAA;AAE1B;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AA7BJ,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CA8BzB;AA9BY,sCAAa;AAiCnB,IAAM,YAAY,GAAlB,MAAM,YAAY;CAMxB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,CAAC;;2CACT;AAEjB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;2CACN;AALF,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CAMxB;AANY,oCAAY","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { PrivilegeInput } from '@things-factory/auth-base'\n\nimport { Scenario } from './scenario'\nimport { StepPatch } from '../step/step-type'\n\n@InputType()\nexport class NewScenario {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n schedule?: string\n\n @Field({ nullable: true })\n timezone?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n privilege?: PrivilegeInput\n}\n\n@InputType()\nexport class ScenarioPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n schedule?: string\n\n @Field({ nullable: true })\n timezone?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => [StepPatch], { nullable: true })\n steps?: StepPatch[]\n\n @Field({ nullable: true })\n privilege?: PrivilegeInput\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ScenarioList {\n @Field(type => [Scenario])\n items: Scenario[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|