@things-factory/integration-base 9.0.0-beta.8 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/publish-data.js +7 -2
- package/dist-server/controllers/publish-data.js.map +1 -1
- package/dist-server/engine/analyzer/analyze-integration.js +1 -1
- package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/engine/connection-manager.js +41 -40
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/graphql-connector.js +4 -1
- package/dist-server/engine/connector/graphql-connector.js.map +1 -1
- package/dist-server/engine/connector/headless-connector.js +1 -2
- package/dist-server/engine/connector/headless-connector.js.map +1 -1
- package/dist-server/engine/connector/http-connector.js +5 -1
- package/dist-server/engine/connector/http-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.js +10 -8
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.js +2 -2
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/postgresql-connector.js +3 -3
- package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
- package/dist-server/engine/connector/proxy-connector.js +1 -1
- package/dist-server/engine/connector/proxy-connector.js.map +1 -1
- package/dist-server/engine/index.d.ts +2 -2
- package/dist-server/engine/index.js +2 -2
- package/dist-server/engine/index.js.map +1 -1
- package/dist-server/engine/scenario-engine.js +10 -7
- package/dist-server/engine/scenario-engine.js.map +1 -1
- package/dist-server/engine/task/headless-post.js +3 -1
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +36 -4
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/http-get.js +4 -1
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +4 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +29 -6
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.d.ts +84 -0
- package/dist-server/engine/task/mqtt-subscribe.js +197 -79
- package/dist-server/engine/task/mqtt-subscribe.js.map +1 -1
- package/dist-server/engine/task/mssql-procedure.js +1 -1
- package/dist-server/engine/task/mssql-procedure.js.map +1 -1
- package/dist-server/engine/task/oracle-procedure.js +10 -10
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/pick-pending-scenario.js +5 -1
- package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
- package/dist-server/engine/task/state-group-read.js +1 -2
- package/dist-server/engine/task/state-group-read.js.map +1 -1
- package/dist-server/engine/task/state-read.js +1 -2
- package/dist-server/engine/task/state-read.js.map +1 -1
- package/dist-server/engine/task/state-write.js +1 -2
- package/dist-server/engine/task/state-write.js.map +1 -1
- package/dist-server/engine/task/stop-scenario.js +3 -3
- package/dist-server/engine/task/stop-scenario.js.map +1 -1
- package/dist-server/engine/task/sub-scenario.js +5 -2
- package/dist-server/engine/task/sub-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-range-scenario.js +5 -2
- package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
- package/dist-server/engine/task/switch-scenario.js +5 -2
- package/dist-server/engine/task/switch-scenario.js.map +1 -1
- package/dist-server/engine/task/variables.js +1 -1
- package/dist-server/engine/task/variables.js.map +1 -1
- package/dist-server/engine/task-registry.js +4 -2
- package/dist-server/engine/task-registry.js.map +1 -1
- package/dist-server/index.d.ts +6 -6
- package/dist-server/index.js +10 -10
- package/dist-server/index.js.map +1 -1
- package/dist-server/routers/scenario-schedule-callback-router.js +2 -2
- package/dist-server/routers/scenario-schedule-callback-router.js.map +1 -1
- package/dist-server/routes.js +8 -7
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/analysis/analysis-query.d.ts +3 -0
- package/dist-server/service/analysis/analysis-query.js +6 -1
- package/dist-server/service/analysis/analysis-query.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +3 -1
- package/dist-server/service/connection/connection-mutation.js +69 -21
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.d.ts +3 -0
- package/dist-server/service/connection/connection-query.js +22 -6
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +14 -8
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +15 -4
- package/dist-server/service/connection/connection-type.js +78 -58
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connector/connector-query.d.ts +4 -1
- package/dist-server/service/connector/connector-query.js +8 -5
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/connector/connector-type.js +12 -9
- package/dist-server/service/connector/connector-type.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-mutation.js +30 -12
- package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-query.d.ts +3 -0
- package/dist-server/service/payload-log/payload-log-query.js +5 -2
- package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
- package/dist-server/service/payload-log/payload-log-type.js +11 -11
- package/dist-server/service/payload-log/payload-log-type.js.map +1 -1
- package/dist-server/service/payload-log/payload-log.d.ts +1 -1
- package/dist-server/service/payload-log/payload-log.js +18 -14
- package/dist-server/service/payload-log/payload-log.js.map +1 -1
- package/dist-server/service/property-spec.js +12 -7
- package/dist-server/service/property-spec.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +71 -26
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.d.ts +3 -0
- package/dist-server/service/scenario/scenario-query.js +7 -5
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +27 -24
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario/scenario.js +27 -24
- package/dist-server/service/scenario/scenario.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js +8 -3
- package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-query.d.ts +3 -0
- package/dist-server/service/scenario-instance/scenario-instance-query.js +5 -2
- package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js +10 -9
- package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
- package/dist-server/service/scenario-instance/scenario-instance-type.js +76 -71
- package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js +4 -4
- package/dist-server/service/scenario-queue/scenario-queue-subscription.js.map +1 -1
- package/dist-server/service/scenario-queue/scenario-queue-type.js +8 -8
- package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
- package/dist-server/service/state-register/data-resolver.js +3 -4
- package/dist-server/service/state-register/data-resolver.js.map +1 -1
- package/dist-server/service/state-register/state-register-mutation.js +41 -16
- package/dist-server/service/state-register/state-register-mutation.js.map +1 -1
- package/dist-server/service/state-register/state-register-query.d.ts +3 -0
- package/dist-server/service/state-register/state-register-query.js +7 -4
- package/dist-server/service/state-register/state-register-query.js.map +1 -1
- package/dist-server/service/state-register/state-register-type.js +3 -3
- package/dist-server/service/state-register/state-register-type.js.map +1 -1
- package/dist-server/service/state-register/state-register.js +4 -2
- package/dist-server/service/state-register/state-register.js.map +1 -1
- package/dist-server/service/step/step-mutation.js +13 -5
- package/dist-server/service/step/step-mutation.js.map +1 -1
- package/dist-server/service/step/step-query.d.ts +3 -0
- package/dist-server/service/step/step-query.js +5 -2
- package/dist-server/service/step/step-query.js.map +1 -1
- package/dist-server/service/step/step-type.d.ts +11 -3
- package/dist-server/service/step/step-type.js +54 -35
- package/dist-server/service/step/step-type.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +5 -3
- package/dist-server/service/task-type/task-type-query.js.map +1 -1
- package/dist-server/service/task-type/task-type-type.js +12 -9
- package/dist-server/service/task-type/task-type-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/task/headless-scrap.ja.md +11 -4
- package/helps/integration/task/headless-scrap.ko.md +12 -5
- package/helps/integration/task/headless-scrap.md +10 -3
- package/helps/integration/task/headless-scrap.ms.md +9 -2
- package/helps/integration/task/headless-scrap.zh.md +9 -2
- package/package.json +12 -12
- package/translations/en.json +6 -1
- package/translations/ja.json +6 -1
- package/translations/ko.json +6 -1
- package/translations/ms.json +6 -1
- package/translations/zh.json +6 -1
@@ -12,7 +12,12 @@ const crypto = require('crypto');
|
|
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(scenario_1.Scenario).save(
|
15
|
+
return await tx.getRepository(scenario_1.Scenario).save({
|
16
|
+
...scenario,
|
17
|
+
domain,
|
18
|
+
creator: user,
|
19
|
+
updater: user
|
20
|
+
});
|
16
21
|
}
|
17
22
|
async updateScenario(name, patch, context) {
|
18
23
|
const { domain, user, tx } = context.state;
|
@@ -25,7 +30,11 @@ let ScenarioMutation = class ScenarioMutation {
|
|
25
30
|
scenario: name
|
26
31
|
}));
|
27
32
|
}
|
28
|
-
return await repository.save(
|
33
|
+
return await repository.save({
|
34
|
+
...scenario,
|
35
|
+
...patch,
|
36
|
+
updater: user
|
37
|
+
});
|
29
38
|
}
|
30
39
|
async updateMultipleScenario(patches, context) {
|
31
40
|
const { domain, user, tx } = context.state;
|
@@ -36,16 +45,25 @@ let ScenarioMutation = class ScenarioMutation {
|
|
36
45
|
if (_createRecords.length > 0) {
|
37
46
|
for (let i = 0; i < _createRecords.length; i++) {
|
38
47
|
const newRecord = _createRecords[i];
|
39
|
-
const result = await scenarioRepo.save(
|
40
|
-
|
48
|
+
const result = await scenarioRepo.save({
|
49
|
+
...newRecord,
|
50
|
+
domain,
|
51
|
+
creator: user,
|
52
|
+
updater: user
|
53
|
+
});
|
54
|
+
results.push({ ...result, cuFlag: '+' });
|
41
55
|
}
|
42
56
|
}
|
43
57
|
if (_updateRecords.length > 0) {
|
44
58
|
for (let i = 0; i < _updateRecords.length; i++) {
|
45
59
|
const newRecord = _updateRecords[i];
|
46
60
|
const scenario = await scenarioRepo.findOneBy({ id: newRecord.id });
|
47
|
-
const result = await scenarioRepo.save(
|
48
|
-
|
61
|
+
const result = await scenarioRepo.save({
|
62
|
+
...scenario,
|
63
|
+
...newRecord,
|
64
|
+
updater: user
|
65
|
+
});
|
66
|
+
results.push({ ...result, cuFlag: 'M' });
|
49
67
|
}
|
50
68
|
}
|
51
69
|
return results;
|
@@ -79,18 +97,38 @@ let ScenarioMutation = class ScenarioMutation {
|
|
79
97
|
if (sameName && sameName.id != id) {
|
80
98
|
throw `Scenario Name '${name}' is already taken by another scenario`;
|
81
99
|
}
|
82
|
-
savedScenario = await repository.save(
|
100
|
+
savedScenario = await repository.save({
|
101
|
+
...sameId,
|
102
|
+
...scenario,
|
103
|
+
domain,
|
104
|
+
updater: user
|
105
|
+
});
|
83
106
|
}
|
84
107
|
else {
|
85
|
-
savedScenario = await repository.save(
|
108
|
+
savedScenario = await repository.save({
|
109
|
+
...scenario,
|
110
|
+
domain,
|
111
|
+
updater: user,
|
112
|
+
creator: user
|
113
|
+
});
|
86
114
|
}
|
87
115
|
}
|
88
116
|
else {
|
89
|
-
savedScenario = await repository.save(
|
117
|
+
savedScenario = await repository.save({
|
118
|
+
...scenario,
|
119
|
+
domain,
|
120
|
+
updater: user,
|
121
|
+
creator: user
|
122
|
+
});
|
90
123
|
}
|
91
124
|
await tx.getRepository(step_type_1.Step).delete({ domain: { id: domain.id }, scenario: { id: savedScenario.id } });
|
92
125
|
await tx.getRepository(step_type_1.Step).save(scenario.steps.map((step) => {
|
93
|
-
return
|
126
|
+
return {
|
127
|
+
...step,
|
128
|
+
domain,
|
129
|
+
scenario: savedScenario,
|
130
|
+
updater: user
|
131
|
+
};
|
94
132
|
}));
|
95
133
|
}));
|
96
134
|
return true;
|
@@ -198,7 +236,10 @@ let ScenarioMutation = class ScenarioMutation {
|
|
198
236
|
retry_period: 60
|
199
237
|
}
|
200
238
|
});
|
201
|
-
return await repository.save(
|
239
|
+
return await repository.save({
|
240
|
+
...scenario,
|
241
|
+
scheduleId: handle
|
242
|
+
});
|
202
243
|
}
|
203
244
|
catch (err) {
|
204
245
|
console.error('startScenarioSchedule', err);
|
@@ -217,7 +258,10 @@ let ScenarioMutation = class ScenarioMutation {
|
|
217
258
|
}
|
218
259
|
try {
|
219
260
|
await (0, scheduler_client_1.unregisterSchedule)(scenario.scheduleId);
|
220
|
-
return await repository.save(
|
261
|
+
return await repository.save({
|
262
|
+
...scenario,
|
263
|
+
scheduleId: null
|
264
|
+
});
|
221
265
|
}
|
222
266
|
catch (err) {
|
223
267
|
console.error('stopScenarioSchedule', err);
|
@@ -228,7 +272,7 @@ exports.ScenarioMutation = ScenarioMutation;
|
|
228
272
|
tslib_1.__decorate([
|
229
273
|
(0, type_graphql_1.Directive)('@transaction'),
|
230
274
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
231
|
-
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: '
|
275
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'Creates a new scenario.' }),
|
232
276
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenario', type => scenario_type_1.NewScenario)),
|
233
277
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
234
278
|
tslib_1.__metadata("design:type", Function),
|
@@ -238,7 +282,7 @@ tslib_1.__decorate([
|
|
238
282
|
tslib_1.__decorate([
|
239
283
|
(0, type_graphql_1.Directive)('@transaction'),
|
240
284
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
241
|
-
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: '
|
285
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'Updates an existing scenario.' }),
|
242
286
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
243
287
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', type => scenario_type_1.ScenarioPatch)),
|
244
288
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
@@ -249,7 +293,9 @@ tslib_1.__decorate([
|
|
249
293
|
tslib_1.__decorate([
|
250
294
|
(0, type_graphql_1.Directive)('@transaction'),
|
251
295
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
252
|
-
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], {
|
296
|
+
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], {
|
297
|
+
description: 'Updates multiple scenarios at once. Can be used to create or update records.'
|
298
|
+
}),
|
253
299
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [scenario_type_1.ScenarioPatch])),
|
254
300
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
255
301
|
tslib_1.__metadata("design:type", Function),
|
@@ -259,7 +305,7 @@ tslib_1.__decorate([
|
|
259
305
|
tslib_1.__decorate([
|
260
306
|
(0, type_graphql_1.Directive)('@transaction'),
|
261
307
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
262
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: '
|
308
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Deletes a single scenario by its name.' }),
|
263
309
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
|
264
310
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
265
311
|
tslib_1.__metadata("design:type", Function),
|
@@ -269,7 +315,7 @@ tslib_1.__decorate([
|
|
269
315
|
tslib_1.__decorate([
|
270
316
|
(0, type_graphql_1.Directive)('@transaction'),
|
271
317
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
272
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: '
|
318
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Deletes multiple scenarios by their IDs.' }),
|
273
319
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
274
320
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
275
321
|
tslib_1.__metadata("design:type", Function),
|
@@ -279,7 +325,9 @@ tslib_1.__decorate([
|
|
279
325
|
tslib_1.__decorate([
|
280
326
|
(0, type_graphql_1.Directive)('@transaction'),
|
281
327
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
282
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, {
|
328
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, {
|
329
|
+
description: 'Imports multiple scenarios, including their steps. This can overwrite existing scenarios if IDs match.'
|
330
|
+
}),
|
283
331
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenarios', type => [scenario_type_1.ScenarioPatch])),
|
284
332
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
285
333
|
tslib_1.__metadata("design:type", Function),
|
@@ -289,7 +337,9 @@ tslib_1.__decorate([
|
|
289
337
|
tslib_1.__decorate([
|
290
338
|
(0, type_graphql_1.Directive)('@transaction'),
|
291
339
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
292
|
-
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], {
|
340
|
+
(0, type_graphql_1.Mutation)(returns => [scenario_1.Scenario], {
|
341
|
+
description: 'Copies multiple existing scenarios within the same domain, creating new scenarios with new IDs.'
|
342
|
+
}),
|
293
343
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
294
344
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
295
345
|
tslib_1.__metadata("design:type", Function),
|
@@ -299,9 +349,7 @@ tslib_1.__decorate([
|
|
299
349
|
tslib_1.__decorate([
|
300
350
|
(0, type_graphql_1.Directive)('@transaction'),
|
301
351
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
302
|
-
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, {
|
303
|
-
description: 'To start posting scenario based on the schedule of the given scenario'
|
304
|
-
}),
|
352
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'Starts the schedule for a specific scenario, if one is defined.' }),
|
305
353
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenarioId')),
|
306
354
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
307
355
|
tslib_1.__metadata("design:type", Function),
|
@@ -311,10 +359,7 @@ tslib_1.__decorate([
|
|
311
359
|
tslib_1.__decorate([
|
312
360
|
(0, type_graphql_1.Directive)('@transaction'),
|
313
361
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "mutation", domainOwnerGranted: true)'),
|
314
|
-
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, {
|
315
|
-
nullable: true,
|
316
|
-
description: 'To stop posting scenario based on the schedule of the given scenario'
|
317
|
-
}),
|
362
|
+
(0, type_graphql_1.Mutation)(returns => scenario_1.Scenario, { description: 'Stops the schedule for a specific scenario.' }),
|
318
363
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('scenarioId')),
|
319
364
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
320
365
|
tslib_1.__metadata("design:type", Function),
|
@@ -1 +1 @@
|
|
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;AACr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AAC;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;2BAzXU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA0X5B","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"]}
|
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,CAAC;YAC3C,GAAG,QAAQ;YACX,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,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,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,0BAA0B,EAAE;gBACpC,QAAQ,EAAE,IAAI;aACf,CAAC,CACH,CAAA;QACH,CAAC;QAED,OAAO,MAAM,UAAU,CAAC,IAAI,CAA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BAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA4X5B","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: 'Creates a 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: 'Updates an existing scenario.' })\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], {\n description: 'Updates multiple scenarios at once. Can be used to create or update records.'\n })\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: 'Deletes a single scenario by its name.' })\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: 'Deletes multiple scenarios by their IDs.' })\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, {\n description:\n 'Imports multiple scenarios, including their steps. This can overwrite existing scenarios if IDs match.'\n })\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], {\n description: 'Copies multiple existing scenarios within the same domain, creating new scenarios with new IDs.'\n })\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, { description: 'Starts the schedule for a specific scenario, if one is defined.' })\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, { description: 'Stops the schedule for a specific scenario.' })\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"]}
|
@@ -4,6 +4,9 @@ import { ScenarioInstance } from '../scenario-instance/scenario-instance-type';
|
|
4
4
|
import { Step } from '../step/step-type';
|
5
5
|
import { Scenario } from './scenario';
|
6
6
|
import { ScenarioList } from './scenario-type';
|
7
|
+
/**
|
8
|
+
* @description Provides GraphQL resolvers for the Scenario entity.
|
9
|
+
*/
|
7
10
|
export declare class ScenarioQuery {
|
8
11
|
scenario(id: string, context: ResolverContext): Promise<Scenario>;
|
9
12
|
scenarios(params: ListParam, context: ResolverContext): Promise<ScenarioList>;
|
@@ -12,6 +12,9 @@ const step_type_1 = require("../step/step-type");
|
|
12
12
|
const scenario_1 = require("./scenario");
|
13
13
|
const scenario_type_1 = require("./scenario-type");
|
14
14
|
const connection_type_1 = require("../connection/connection-type");
|
15
|
+
/**
|
16
|
+
* @description Provides GraphQL resolvers for the Scenario entity.
|
17
|
+
*/
|
15
18
|
let ScenarioQuery = class ScenarioQuery {
|
16
19
|
async scenario(id, context) {
|
17
20
|
const { domain } = context.state;
|
@@ -58,13 +61,12 @@ let ScenarioQuery = class ScenarioQuery {
|
|
58
61
|
const steps = await (0, shell_1.getRepository)(step_type_1.Step).find({
|
59
62
|
where: { domain: { id: domain.id }, scenario: { id: scenario.id }, task: 'publish' }
|
60
63
|
});
|
61
|
-
return steps.map(step =>
|
64
|
+
return steps.map(step => step.params?.tag).filter(Boolean);
|
62
65
|
}
|
63
66
|
async state(scenario, context) {
|
64
|
-
var _a;
|
65
67
|
const { domain } = context.state;
|
66
68
|
var instance = engine_1.ScenarioEngine.getScenarioInstance(domain, scenario.name);
|
67
|
-
return instance && scenario_instance_type_1.ScenarioInstanceStatus[
|
69
|
+
return instance && scenario_instance_type_1.ScenarioInstanceStatus[instance.context?.state];
|
68
70
|
}
|
69
71
|
async instances(scenario, context) {
|
70
72
|
const { domain } = context.state;
|
@@ -77,7 +79,7 @@ let ScenarioQuery = class ScenarioQuery {
|
|
77
79
|
exports.ScenarioQuery = ScenarioQuery;
|
78
80
|
tslib_1.__decorate([
|
79
81
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "query", domainOwnerGranted: true)'),
|
80
|
-
(0, type_graphql_1.Query)(returns => scenario_1.Scenario, { description: '
|
82
|
+
(0, type_graphql_1.Query)(returns => scenario_1.Scenario, { description: 'Fetches a single scenario by its ID.' }),
|
81
83
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
82
84
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
83
85
|
tslib_1.__metadata("design:type", Function),
|
@@ -86,7 +88,7 @@ tslib_1.__decorate([
|
|
86
88
|
], ScenarioQuery.prototype, "scenario", null);
|
87
89
|
tslib_1.__decorate([
|
88
90
|
(0, type_graphql_1.Directive)('@privilege(category: "scenario", privilege: "query", domainOwnerGranted: true)'),
|
89
|
-
(0, type_graphql_1.Query)(returns => scenario_type_1.ScenarioList, { description: '
|
91
|
+
(0, type_graphql_1.Query)(returns => scenario_type_1.ScenarioList, { description: 'Fetches a paginated list of scenarios.' }),
|
90
92
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
91
93
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
92
94
|
tslib_1.__metadata("design:type", Function),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-query.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAqC;AAErC,yDAAsD;AACtD,iDAAuG;AAEvG,yCAA6C;AAC7C,wFAAsG;AACtG,iDAAwC;AACxC,yCAAqC;AACrC,mDAA8C;AAC9C,mEAA0D;
|
1
|
+
{"version":3,"file":"scenario-query.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qCAAqC;AAErC,yDAAsD;AACtD,iDAAuG;AAEvG,yCAA6C;AAC7C,wFAAsG;AACtG,iDAAwC;AACxC,yCAAqC;AACrC,mDAA8C;AAC9C,mEAA0D;AAE1D;;GAEG;AAEI,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,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;QACzE,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC3E,OAAO,QAAQ,CAAA;QACjB,CAAC;IACH,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS,CAA0B,MAAiB,EAAS,OAAwB;QACzF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;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BAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAhB,mBAAQ;;8CAIzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;yCAEpC;wBA7FU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CA8FzB","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Not, IsNull } from 'typeorm'\n\nimport { User, Role } 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/**\n * @description Provides GraphQL resolvers for the Scenario entity.\n */\n@Resolver(Scenario)\nexport class ScenarioQuery {\n @Directive('@privilege(category: \"scenario\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Scenario, { description: 'Fetches a single scenario by its ID.' })\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: 'Fetches a paginated list of scenarios.' })\n async scenarios(@Args(type => ListParam) 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 => 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 @FieldResolver(type => Role)\n async role(@Root() scenario: Scenario) {\n return scenario.roleId && (await getRepository(Role).findOneBy({ id: scenario.roleId }))\n }\n}\n"]}
|
@@ -10,102 +10,105 @@ let NewScenario = class NewScenario {
|
|
10
10
|
};
|
11
11
|
exports.NewScenario = NewScenario;
|
12
12
|
tslib_1.__decorate([
|
13
|
-
(0, type_graphql_1.Field)(),
|
13
|
+
(0, type_graphql_1.Field)({ description: 'The name of the new scenario.' }),
|
14
14
|
tslib_1.__metadata("design:type", String)
|
15
15
|
], NewScenario.prototype, "name", void 0);
|
16
16
|
tslib_1.__decorate([
|
17
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
17
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A detailed description for the new scenario.' }),
|
18
18
|
tslib_1.__metadata("design:type", String)
|
19
19
|
], NewScenario.prototype, "description", void 0);
|
20
20
|
tslib_1.__decorate([
|
21
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
21
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The type of the new scenario, for categorization.' }),
|
22
22
|
tslib_1.__metadata("design:type", String)
|
23
23
|
], NewScenario.prototype, "type", void 0);
|
24
24
|
tslib_1.__decorate([
|
25
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
25
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A cron-style schedule for the new scenario.' }),
|
26
26
|
tslib_1.__metadata("design:type", String)
|
27
27
|
], NewScenario.prototype, "schedule", void 0);
|
28
28
|
tslib_1.__decorate([
|
29
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
29
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timezone for the schedule.' }),
|
30
30
|
tslib_1.__metadata("design:type", String)
|
31
31
|
], NewScenario.prototype, "timezone", void 0);
|
32
32
|
tslib_1.__decorate([
|
33
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
33
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Time-to-live in seconds for new scenario instances.' }),
|
34
34
|
tslib_1.__metadata("design:type", Number)
|
35
35
|
], NewScenario.prototype, "ttl", void 0);
|
36
36
|
tslib_1.__decorate([
|
37
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
37
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Indicates if the new scenario should be active upon creation.' }),
|
38
38
|
tslib_1.__metadata("design:type", Boolean)
|
39
39
|
], NewScenario.prototype, "active", void 0);
|
40
40
|
tslib_1.__decorate([
|
41
|
-
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
|
41
|
+
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The role required to execute the new scenario.' }),
|
42
42
|
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
43
43
|
], NewScenario.prototype, "role", void 0);
|
44
44
|
exports.NewScenario = NewScenario = tslib_1.__decorate([
|
45
|
-
(0, type_graphql_1.InputType)()
|
45
|
+
(0, type_graphql_1.InputType)({ description: 'Input for creating a new scenario.' })
|
46
46
|
], NewScenario);
|
47
47
|
let ScenarioPatch = class ScenarioPatch {
|
48
48
|
};
|
49
49
|
exports.ScenarioPatch = ScenarioPatch;
|
50
50
|
tslib_1.__decorate([
|
51
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
51
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'The unique identifier of the scenario to update.' }),
|
52
52
|
tslib_1.__metadata("design:type", String)
|
53
53
|
], ScenarioPatch.prototype, "id", void 0);
|
54
54
|
tslib_1.__decorate([
|
55
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new name for the scenario.' }),
|
56
56
|
tslib_1.__metadata("design:type", String)
|
57
57
|
], ScenarioPatch.prototype, "name", void 0);
|
58
58
|
tslib_1.__decorate([
|
59
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
59
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new description for the scenario.' }),
|
60
60
|
tslib_1.__metadata("design:type", String)
|
61
61
|
], ScenarioPatch.prototype, "description", void 0);
|
62
62
|
tslib_1.__decorate([
|
63
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
63
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new type for the scenario.' }),
|
64
64
|
tslib_1.__metadata("design:type", String)
|
65
65
|
], ScenarioPatch.prototype, "type", void 0);
|
66
66
|
tslib_1.__decorate([
|
67
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
67
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new schedule for the scenario.' }),
|
68
68
|
tslib_1.__metadata("design:type", String)
|
69
69
|
], ScenarioPatch.prototype, "schedule", void 0);
|
70
70
|
tslib_1.__decorate([
|
71
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
71
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new timezone for the scenario.' }),
|
72
72
|
tslib_1.__metadata("design:type", String)
|
73
73
|
], ScenarioPatch.prototype, "timezone", void 0);
|
74
74
|
tslib_1.__decorate([
|
75
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new time-to-live for scenario instances.' }),
|
76
76
|
tslib_1.__metadata("design:type", Number)
|
77
77
|
], ScenarioPatch.prototype, "ttl", void 0);
|
78
78
|
tslib_1.__decorate([
|
79
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
79
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The new active status for the scenario.' }),
|
80
80
|
tslib_1.__metadata("design:type", Boolean)
|
81
81
|
], ScenarioPatch.prototype, "active", void 0);
|
82
82
|
tslib_1.__decorate([
|
83
|
-
(0, type_graphql_1.Field)(type => [step_type_1.StepPatch], { nullable: true }),
|
83
|
+
(0, type_graphql_1.Field)(type => [step_type_1.StepPatch], { nullable: true, description: 'A list of steps to be updated within the scenario.' }),
|
84
84
|
tslib_1.__metadata("design:type", Array)
|
85
85
|
], ScenarioPatch.prototype, "steps", void 0);
|
86
86
|
tslib_1.__decorate([
|
87
|
-
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true }),
|
87
|
+
(0, type_graphql_1.Field)(type => shell_1.ObjectRef, { nullable: true, description: 'The new role for the scenario.' }),
|
88
88
|
tslib_1.__metadata("design:type", shell_1.ObjectRef)
|
89
89
|
], ScenarioPatch.prototype, "role", void 0);
|
90
90
|
tslib_1.__decorate([
|
91
|
-
(0, type_graphql_1.Field)({
|
91
|
+
(0, type_graphql_1.Field)({
|
92
|
+
nullable: true,
|
93
|
+
description: 'A flag indicating whether the scenario is being created, updated, or deleted.'
|
94
|
+
}),
|
92
95
|
tslib_1.__metadata("design:type", String)
|
93
96
|
], ScenarioPatch.prototype, "cuFlag", void 0);
|
94
97
|
exports.ScenarioPatch = ScenarioPatch = tslib_1.__decorate([
|
95
|
-
(0, type_graphql_1.InputType)()
|
98
|
+
(0, type_graphql_1.InputType)({ description: 'Input for updating (patching) an existing scenario.' })
|
96
99
|
], ScenarioPatch);
|
97
100
|
let ScenarioList = class ScenarioList {
|
98
101
|
};
|
99
102
|
exports.ScenarioList = ScenarioList;
|
100
103
|
tslib_1.__decorate([
|
101
|
-
(0, type_graphql_1.Field)(type => [scenario_1.Scenario]),
|
104
|
+
(0, type_graphql_1.Field)(type => [scenario_1.Scenario], { description: 'The list of scenario items.' }),
|
102
105
|
tslib_1.__metadata("design:type", Array)
|
103
106
|
], ScenarioList.prototype, "items", void 0);
|
104
107
|
tslib_1.__decorate([
|
105
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
108
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of scenarios.' }),
|
106
109
|
tslib_1.__metadata("design:type", Number)
|
107
110
|
], ScenarioList.prototype, "total", void 0);
|
108
111
|
exports.ScenarioList = ScenarioList = tslib_1.__decorate([
|
109
|
-
(0, type_graphql_1.ObjectType)()
|
112
|
+
(0, type_graphql_1.ObjectType)({ description: 'A paginated list of scenarios.' })
|
110
113
|
], ScenarioList);
|
111
114
|
//# sourceMappingURL=scenario-type.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-type.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,yCAAqC;AACrC,iDAA6C;AAGtC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAwBvB,CAAA;AAxBY,kCAAW;AAEtB;IADC,IAAA,oBAAK,
|
1
|
+
{"version":3,"file":"scenario-type.js","sourceRoot":"","sources":["../../../server/service/scenario/scenario-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,yCAAqC;AACrC,iDAA6C;AAGtC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAwBvB,CAAA;AAxBY,kCAAW;AAEtB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;yCAC5C;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;;gDACnE;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;yCAC/E;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;6CACrE;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;6CACxD;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;;wCAClF;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;;2CACxF;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAA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,EAAE,IAAI,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;;4CAC/F;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;sCACrF,iBAAS;2CAAA;AAMhB;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,+EAA+E;KAC7F,CAAC;;6CACa;wBAnCJ,aAAa;IADzB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;GACrE,aAAa,CAoCzB;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAY;CAMxB,CAAA;AANY,oCAAY;AAEvB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;2CACzD;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;;2CACzD;uBALF,YAAY;IADxB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;GACjD,YAAY,CAMxB","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { Scenario } from './scenario'\nimport { StepPatch } from '../step/step-type'\n\n@InputType({ description: 'Input for creating a new scenario.' })\nexport class NewScenario {\n @Field({ description: 'The name of the new scenario.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new scenario.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new scenario, for categorization.' })\n type?: string\n\n @Field({ nullable: true, description: 'A cron-style schedule for the new scenario.' })\n schedule?: string\n\n @Field({ nullable: true, description: 'The timezone for the schedule.' })\n timezone?: string\n\n @Field({ nullable: true, description: 'Time-to-live in seconds for new scenario instances.' })\n ttl?: number\n\n @Field({ nullable: true, description: 'Indicates if the new scenario should be active upon creation.' })\n active?: boolean\n\n @Field(type => ObjectRef, { nullable: true, description: 'The role required to execute the new scenario.' })\n role?: ObjectRef\n}\n\n@InputType({ description: 'Input for updating (patching) an existing scenario.' })\nexport class ScenarioPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the scenario to update.' })\n id?: string\n\n @Field({ nullable: true, description: 'The new name for the scenario.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the scenario.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the scenario.' })\n type?: string\n\n @Field({ nullable: true, description: 'The new schedule for the scenario.' })\n schedule?: string\n\n @Field({ nullable: true, description: 'The new timezone for the scenario.' })\n timezone?: string\n\n @Field({ nullable: true, description: 'The new time-to-live for scenario instances.' })\n ttl?: number\n\n @Field({ nullable: true, description: 'The new active status for the scenario.' })\n active?: boolean\n\n @Field(type => [StepPatch], { nullable: true, description: 'A list of steps to be updated within the scenario.' })\n steps?: StepPatch[]\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new role for the scenario.' })\n role?: ObjectRef\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the scenario is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of scenarios.' })\nexport class ScenarioList {\n @Field(type => [Scenario], { description: 'The list of scenario items.' })\n items: Scenario[]\n\n @Field(type => Int, { description: 'The total number of scenarios.' })\n total: number\n}\n"]}
|