@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
@@ -51,129 +51,131 @@ var ScenarioInstanceStatus;
|
|
51
51
|
})(ScenarioInstanceStatus || (exports.ScenarioInstanceStatus = ScenarioInstanceStatus = {}));
|
52
52
|
(0, type_graphql_1.registerEnumType)(ScenarioInstanceStatus, {
|
53
53
|
name: 'ScenarioInstanceStatus',
|
54
|
-
description: '
|
54
|
+
description: 'Enumeration of possible states for a scenario instance.'
|
55
55
|
});
|
56
56
|
let ScenarioInstanceProgress = class ScenarioInstanceProgress {
|
57
57
|
};
|
58
58
|
exports.ScenarioInstanceProgress = ScenarioInstanceProgress;
|
59
59
|
tslib_1.__decorate([
|
60
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
60
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The number of rounds the scenario has completed.' }),
|
61
61
|
tslib_1.__metadata("design:type", Number)
|
62
62
|
], ScenarioInstanceProgress.prototype, "rounds", void 0);
|
63
63
|
tslib_1.__decorate([
|
64
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
64
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The completion rate of the scenario as a percentage.' }),
|
65
65
|
tslib_1.__metadata("design:type", Number)
|
66
66
|
], ScenarioInstanceProgress.prototype, "rate", void 0);
|
67
67
|
tslib_1.__decorate([
|
68
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
68
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of steps in the scenario.' }),
|
69
69
|
tslib_1.__metadata("design:type", Number)
|
70
70
|
], ScenarioInstanceProgress.prototype, "steps", void 0);
|
71
71
|
tslib_1.__decorate([
|
72
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
72
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The current step number being executed.' }),
|
73
73
|
tslib_1.__metadata("design:type", Number)
|
74
74
|
], ScenarioInstanceProgress.prototype, "step", void 0);
|
75
75
|
exports.ScenarioInstanceProgress = ScenarioInstanceProgress = tslib_1.__decorate([
|
76
|
-
(0, type_graphql_1.ObjectType)()
|
76
|
+
(0, type_graphql_1.ObjectType)({ description: 'Provides progress information for a running scenario instance.' })
|
77
77
|
], ScenarioInstanceProgress);
|
78
78
|
let ScenarioInstanceState = class ScenarioInstanceState {
|
79
79
|
};
|
80
80
|
exports.ScenarioInstanceState = ScenarioInstanceState;
|
81
81
|
tslib_1.__decorate([
|
82
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
82
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The domain in which the instance is running.' }),
|
83
83
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
84
84
|
], ScenarioInstanceState.prototype, "domain", void 0);
|
85
85
|
tslib_1.__decorate([
|
86
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
86
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique name of this specific instance.' }),
|
87
87
|
tslib_1.__metadata("design:type", String)
|
88
88
|
], ScenarioInstanceState.prototype, "instanceName", void 0);
|
89
89
|
tslib_1.__decorate([
|
90
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
90
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The name of the scenario being executed.' }),
|
91
91
|
tslib_1.__metadata("design:type", String)
|
92
92
|
], ScenarioInstanceState.prototype, "scenarioName", void 0);
|
93
93
|
tslib_1.__decorate([
|
94
|
-
(0, type_graphql_1.Field)(type => ScenarioInstanceStatus, {
|
94
|
+
(0, type_graphql_1.Field)(type => ScenarioInstanceStatus, {
|
95
|
+
nullable: true,
|
96
|
+
description: 'The current execution state of the instance.'
|
97
|
+
}),
|
95
98
|
tslib_1.__metadata("design:type", String)
|
96
99
|
], ScenarioInstanceState.prototype, "state", void 0);
|
97
100
|
tslib_1.__decorate([
|
98
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
101
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'A key-value map of variables used in the instance.' }),
|
99
102
|
tslib_1.__metadata("design:type", Object)
|
100
103
|
], ScenarioInstanceState.prototype, "variables", void 0);
|
101
104
|
tslib_1.__decorate([
|
102
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
105
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
106
|
+
nullable: true,
|
107
|
+
description: 'A key-value map of data generated and used by the instance.'
|
108
|
+
}),
|
103
109
|
tslib_1.__metadata("design:type", Object)
|
104
110
|
], ScenarioInstanceState.prototype, "data", void 0);
|
105
111
|
tslib_1.__decorate([
|
106
|
-
(0, type_graphql_1.Field)(type => ScenarioInstanceProgress, { nullable: true }),
|
112
|
+
(0, type_graphql_1.Field)(type => ScenarioInstanceProgress, { nullable: true, description: 'The progress of the running instance.' }),
|
107
113
|
tslib_1.__metadata("design:type", ScenarioInstanceProgress)
|
108
114
|
], ScenarioInstanceState.prototype, "progress", void 0);
|
109
115
|
tslib_1.__decorate([
|
110
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
116
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A message associated with the current state (e.g., an error message).' }),
|
111
117
|
tslib_1.__metadata("design:type", String)
|
112
118
|
], ScenarioInstanceState.prototype, "message", void 0);
|
113
119
|
tslib_1.__decorate([
|
114
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
120
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when this state was recorded.' }),
|
115
121
|
tslib_1.__metadata("design:type", Date)
|
116
122
|
], ScenarioInstanceState.prototype, "timestamp", void 0);
|
117
123
|
exports.ScenarioInstanceState = ScenarioInstanceState = tslib_1.__decorate([
|
118
|
-
(0, type_graphql_1.ObjectType)()
|
124
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents the complete state of a scenario instance at a point in time.' })
|
119
125
|
], ScenarioInstanceState);
|
120
126
|
let ScenarioInstanceRunResult = class ScenarioInstanceRunResult {
|
121
127
|
};
|
122
128
|
exports.ScenarioInstanceRunResult = ScenarioInstanceRunResult;
|
123
129
|
tslib_1.__decorate([
|
124
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
130
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The name of the scenario that was executed.' }),
|
125
131
|
tslib_1.__metadata("design:type", String)
|
126
132
|
], ScenarioInstanceRunResult.prototype, "scenarioName", void 0);
|
127
133
|
tslib_1.__decorate([
|
128
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
134
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique name of the instance that was run.' }),
|
129
135
|
tslib_1.__metadata("design:type", String)
|
130
136
|
], ScenarioInstanceRunResult.prototype, "instanceName", void 0);
|
131
137
|
tslib_1.__decorate([
|
132
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
138
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'The final set of variables after the run.' }),
|
133
139
|
tslib_1.__metadata("design:type", Object)
|
134
140
|
], ScenarioInstanceRunResult.prototype, "variables", void 0);
|
135
141
|
tslib_1.__decorate([
|
136
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
142
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'The final set of data after the run.' }),
|
137
143
|
tslib_1.__metadata("design:type", Object)
|
138
144
|
], ScenarioInstanceRunResult.prototype, "data", void 0);
|
139
145
|
tslib_1.__decorate([
|
140
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
146
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'The final result returned by the scenario.' }),
|
141
147
|
tslib_1.__metadata("design:type", Object)
|
142
148
|
], ScenarioInstanceRunResult.prototype, "result", void 0);
|
143
149
|
tslib_1.__decorate([
|
144
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
150
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the run completed.' }),
|
145
151
|
tslib_1.__metadata("design:type", Date)
|
146
152
|
], ScenarioInstanceRunResult.prototype, "timestamp", void 0);
|
147
153
|
tslib_1.__decorate([
|
148
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
154
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A final message from the run (e.g., success or failure reason).' }),
|
149
155
|
tslib_1.__metadata("design:type", String)
|
150
156
|
], ScenarioInstanceRunResult.prototype, "message", void 0);
|
151
157
|
tslib_1.__decorate([
|
152
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
158
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The final state of the instance after the run.' }),
|
153
159
|
tslib_1.__metadata("design:type", String)
|
154
160
|
], ScenarioInstanceRunResult.prototype, "state", void 0);
|
155
161
|
exports.ScenarioInstanceRunResult = ScenarioInstanceRunResult = tslib_1.__decorate([
|
156
|
-
(0, type_graphql_1.ObjectType)()
|
162
|
+
(0, type_graphql_1.ObjectType)({ description: 'Contains the final result of a completed scenario instance run.' })
|
157
163
|
], ScenarioInstanceRunResult);
|
158
164
|
let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
159
165
|
get root() {
|
160
|
-
|
161
|
-
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.root;
|
166
|
+
return this.context?.root;
|
162
167
|
}
|
163
168
|
get state() {
|
164
|
-
|
165
|
-
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.state;
|
169
|
+
return this.context?.state;
|
166
170
|
}
|
167
171
|
get progress() {
|
168
172
|
return this.calcProgress();
|
169
173
|
}
|
170
174
|
get variables() {
|
171
|
-
|
172
|
-
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.variables;
|
175
|
+
return this.context?.variables;
|
173
176
|
}
|
174
177
|
get data() {
|
175
|
-
|
176
|
-
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.data;
|
178
|
+
return this.context?.data;
|
177
179
|
}
|
178
180
|
get timestamp() {
|
179
181
|
return new Date();
|
@@ -199,7 +201,7 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
199
201
|
this.lastStep = -1;
|
200
202
|
this.nextStep = -1;
|
201
203
|
var { domain, user, lng, unsafeIP, prohibitedPrivileges } = context || {};
|
202
|
-
domain
|
204
|
+
domain ||= scenarioDomain;
|
203
205
|
this.scenarioId = scenarioId;
|
204
206
|
this.scenarioTtl = scenarioTtl;
|
205
207
|
this.instanceName = instanceName;
|
@@ -207,14 +209,14 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
207
209
|
this.steps = (0, orderBy_1.default)(steps || [], step => step.sequence);
|
208
210
|
this.domain = domain;
|
209
211
|
this.user = user;
|
210
|
-
this.disposer = context
|
212
|
+
this.disposer = context?.disposer;
|
211
213
|
this.context = {
|
212
214
|
domain,
|
213
215
|
user,
|
214
216
|
lng,
|
215
217
|
unsafeIP,
|
216
218
|
prohibitedPrivileges,
|
217
|
-
logger:
|
219
|
+
logger: context?.logger ||
|
218
220
|
(0, winston_1.createLogger)({
|
219
221
|
format: combine(errors({ stack: true }), systemTimestamp({ tz: SYSTEM_TZ }), splat(), LOGFORMAT),
|
220
222
|
transports: [
|
@@ -232,13 +234,13 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
232
234
|
})
|
233
235
|
]
|
234
236
|
}),
|
235
|
-
publish:
|
236
|
-
load:
|
237
|
-
data:
|
238
|
-
variables:
|
239
|
-
client: context
|
237
|
+
publish: context?.publish || this.publishData.bind(this),
|
238
|
+
load: context?.load || this.loadSubscenario.bind(this),
|
239
|
+
data: context?.data || {},
|
240
|
+
variables: context?.variables || {},
|
241
|
+
client: context?.client,
|
240
242
|
state: ScenarioInstanceStatus.STOPPED,
|
241
|
-
root:
|
243
|
+
root: context?.root || this,
|
242
244
|
closures: [],
|
243
245
|
checkState(state = ScenarioInstanceStatus.STARTED) {
|
244
246
|
return this.state == state;
|
@@ -332,7 +334,12 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
332
334
|
var { preventErrorPropagation } = params || {};
|
333
335
|
debug('load-subscenario', this.instanceName, stepName, scenarioConfig.name);
|
334
336
|
context.data[stepName] = {};
|
335
|
-
let subContext =
|
337
|
+
let subContext = {
|
338
|
+
...context,
|
339
|
+
data: context.data[stepName],
|
340
|
+
closures: [],
|
341
|
+
state: ScenarioInstanceStatus.READY
|
342
|
+
};
|
336
343
|
if (!scenarioConfig.domain) {
|
337
344
|
scenarioConfig.domain = context.domain;
|
338
345
|
}
|
@@ -409,19 +416,18 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
409
416
|
this.setState(ScenarioInstanceStatus.UNLOADED);
|
410
417
|
}
|
411
418
|
async dispose() {
|
412
|
-
var _a, _b, _c, _d, _e;
|
413
419
|
await this.stopSubScenarios();
|
414
420
|
this.unload();
|
415
|
-
var closure =
|
421
|
+
var closure = this.context?.closures?.pop();
|
416
422
|
while (closure) {
|
417
423
|
closure.call(this);
|
418
|
-
closure =
|
424
|
+
closure = this.context?.closures?.pop();
|
419
425
|
}
|
420
426
|
if (this.disposer) {
|
421
427
|
await this.disposer.call(this);
|
422
428
|
}
|
423
429
|
// {{ CHECKPOINT 본 인스턴스를 위해서 생성된 logger를 닫는다. 사용을 완료하고 닫기위해서 지연해서 수행한다.
|
424
|
-
if (
|
430
|
+
if (this.context?.logger) {
|
425
431
|
setTimeout(() => {
|
426
432
|
this.context.logger.close();
|
427
433
|
}, 300);
|
@@ -430,14 +436,10 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
430
436
|
}
|
431
437
|
async process(step, context) {
|
432
438
|
this.context.logger.info(`Step '${step.name}'(${step.id}) started.`);
|
433
|
-
step =
|
434
|
-
|
435
|
-
step.params
|
436
|
-
}
|
437
|
-
catch (ex) {
|
438
|
-
this.context.logger.error(`params(${step.params}) parsing error. params must be a JSON.`, ex);
|
439
|
-
}
|
440
|
-
step.params = step.params || {};
|
439
|
+
step = {
|
440
|
+
...step,
|
441
|
+
params: step.params || {}
|
442
|
+
};
|
441
443
|
const connection = step.connection && connection_manager_1.ConnectionManager.getConnectionInstanceEntityByName(this.domain, step.connection);
|
442
444
|
if (!connection || !connection.edgeId) {
|
443
445
|
var handler = engine_1.TaskRegistry.getTaskHandler(step.task);
|
@@ -459,75 +461,78 @@ let ScenarioInstance = ScenarioInstance_1 = class ScenarioInstance {
|
|
459
461
|
};
|
460
462
|
exports.ScenarioInstance = ScenarioInstance;
|
461
463
|
tslib_1.__decorate([
|
462
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
464
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The domain in which the instance is running.' }),
|
463
465
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
464
466
|
], ScenarioInstance.prototype, "domain", void 0);
|
465
467
|
tslib_1.__decorate([
|
466
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
468
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The user who initiated the instance.' }),
|
467
469
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
468
470
|
], ScenarioInstance.prototype, "user", void 0);
|
469
471
|
tslib_1.__decorate([
|
470
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
472
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The name of the scenario being executed.' }),
|
471
473
|
tslib_1.__metadata("design:type", String)
|
472
474
|
], ScenarioInstance.prototype, "scenarioName", void 0);
|
473
475
|
tslib_1.__decorate([
|
474
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
476
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The unique name for this specific instance of the scenario.' }),
|
475
477
|
tslib_1.__metadata("design:type", String)
|
476
478
|
], ScenarioInstance.prototype, "instanceName", void 0);
|
477
479
|
tslib_1.__decorate([
|
478
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
480
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The root scenario instance if this is a sub-scenario.' }),
|
479
481
|
tslib_1.__metadata("design:type", ScenarioInstance),
|
480
482
|
tslib_1.__metadata("design:paramtypes", [])
|
481
483
|
], ScenarioInstance.prototype, "root", null);
|
482
484
|
tslib_1.__decorate([
|
483
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
485
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The current execution state of the instance.' }),
|
484
486
|
tslib_1.__metadata("design:type", String),
|
485
487
|
tslib_1.__metadata("design:paramtypes", [])
|
486
488
|
], ScenarioInstance.prototype, "state", null);
|
487
489
|
tslib_1.__decorate([
|
488
|
-
(0, type_graphql_1.Field)(type => ScenarioInstanceProgress, { nullable: true }),
|
490
|
+
(0, type_graphql_1.Field)(type => ScenarioInstanceProgress, { nullable: true, description: 'The current progress of the instance.' }),
|
489
491
|
tslib_1.__metadata("design:type", ScenarioInstanceProgress),
|
490
492
|
tslib_1.__metadata("design:paramtypes", [])
|
491
493
|
], ScenarioInstance.prototype, "progress", null);
|
492
494
|
tslib_1.__decorate([
|
493
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
495
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'A key-value map of variables used in the instance.' }),
|
494
496
|
tslib_1.__metadata("design:type", Object),
|
495
497
|
tslib_1.__metadata("design:paramtypes", [])
|
496
498
|
], ScenarioInstance.prototype, "variables", null);
|
497
499
|
tslib_1.__decorate([
|
498
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
500
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, {
|
501
|
+
nullable: true,
|
502
|
+
description: 'A key-value map of data generated and used by the instance.'
|
503
|
+
}),
|
499
504
|
tslib_1.__metadata("design:type", Object),
|
500
505
|
tslib_1.__metadata("design:paramtypes", [])
|
501
506
|
], ScenarioInstance.prototype, "data", null);
|
502
507
|
tslib_1.__decorate([
|
503
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
508
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'The final result of the scenario run.' }),
|
504
509
|
tslib_1.__metadata("design:type", Object)
|
505
510
|
], ScenarioInstance.prototype, "result", void 0);
|
506
511
|
tslib_1.__decorate([
|
507
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
512
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp of the last update.' }),
|
508
513
|
tslib_1.__metadata("design:type", Date),
|
509
514
|
tslib_1.__metadata("design:paramtypes", [])
|
510
515
|
], ScenarioInstance.prototype, "timestamp", null);
|
511
516
|
tslib_1.__decorate([
|
512
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
517
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A message associated with the current state (e.g., an error message).' }),
|
513
518
|
tslib_1.__metadata("design:type", String)
|
514
519
|
], ScenarioInstance.prototype, "message", void 0);
|
515
520
|
exports.ScenarioInstance = ScenarioInstance = ScenarioInstance_1 = tslib_1.__decorate([
|
516
|
-
(0, type_graphql_1.ObjectType)(),
|
521
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a running or completed instance of a scenario.' }),
|
517
522
|
tslib_1.__metadata("design:paramtypes", [Object, Object, Object])
|
518
523
|
], ScenarioInstance);
|
519
524
|
let ScenarioInstanceList = class ScenarioInstanceList {
|
520
525
|
};
|
521
526
|
exports.ScenarioInstanceList = ScenarioInstanceList;
|
522
527
|
tslib_1.__decorate([
|
523
|
-
(0, type_graphql_1.Field)(type => [ScenarioInstance]),
|
528
|
+
(0, type_graphql_1.Field)(type => [ScenarioInstance], { description: 'The list of scenario instance items.' }),
|
524
529
|
tslib_1.__metadata("design:type", Array)
|
525
530
|
], ScenarioInstanceList.prototype, "items", void 0);
|
526
531
|
tslib_1.__decorate([
|
527
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
532
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of scenario instances.' }),
|
528
533
|
tslib_1.__metadata("design:type", Number)
|
529
534
|
], ScenarioInstanceList.prototype, "total", void 0);
|
530
535
|
exports.ScenarioInstanceList = ScenarioInstanceList = tslib_1.__decorate([
|
531
|
-
(0, type_graphql_1.ObjectType)()
|
536
|
+
(0, type_graphql_1.ObjectType)({ description: 'A paginated list of scenario instances.' })
|
532
537
|
], ScenarioInstanceList);
|
533
538
|
//# sourceMappingURL=scenario-instance-type.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-instance-type.js","sourceRoot":"","sources":["../../../server/service/scenario-instance/scenario-instance-type.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkC;AAElC,qEAAoC;AACpC,8EAAoC;AACpC,+CAAuE;AACvE,wDAAuB;AACvB,qCAA0D;AAE1D,iDAAwF;AACxF,iEAA4D;AAC5D,yDAAgD;AAChD,iDAA6C;AAE7C,iEAA4D;AAC5D,wEAAmE;AACnE,yCAA2C;AAG3C,0DAAiE;AAEjE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mDAAmD,CAAC,CAAA;AACnF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AAEjD,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE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EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;;iDAG/C;AAED;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;;4CAG/C;AAGD;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACrC;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACT,IAAI;;iDAEpB;AAGM;IADN,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACJ;2BAnDX,gBAAgB;IAD5B,IAAA,yBAAU,GAAE;;GACA,gBAAgB,CAqa5B;AAGM,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAMhC,CAAA;AANY,oDAAoB;AAE/B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC;;mDACT;AAGzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;mDACN;+BALF,oBAAoB;IADhC,IAAA,yBAAU,GAAE;GACA,oBAAoB,CAMhC","sourcesContent":["import 'winston-daily-rotate-file'\n\nimport orderBy from 'lodash/orderBy'\nimport moment from 'moment-timezone'\nimport { Field, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport util from 'util'\nimport { createLogger, format, transports } from 'winston'\n\nimport { Domain, pubsub, PubSubLogTransport, ScalarObject } from '@things-factory/shell'\nimport { cacheService } from '@things-factory/cache-service'\nimport { User } from '@things-factory/auth-base'\nimport { sleep } from '@things-factory/utils'\n\nimport { publishData } from '../../controllers/publish-data'\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { TaskRegistry } from '../../engine'\nimport { Context } from '../../engine/types'\nimport { Step } from '../step/step-type'\nimport { handler as edgeHandler } from '../../engine/edge-client'\n\nconst debug = require('debug')('things-factory:integration-base:scenario-instance')\nconst { combine, errors, splat, printf } = format\n\nconst LOGFORMAT = printf(({ level, message, timestamp, stack }) => {\n return `${timestamp} ${level}: ${stack || message}`\n})\n\nfunction getSystemTimeZone() {\n try {\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone\n if (!timeZone) {\n throw new Error('Unable to resolve timeZone')\n }\n return timeZone\n } catch (e) {\n console.warn('Failed to get system timeZone, falling back to UTC.', e)\n return 'UTC'\n }\n}\n\nconst SYSTEM_TZ = getSystemTimeZone()\nconst systemTimestamp = format((info, opts: { tz?: string }) => {\n if (opts.tz) info.timestamp = moment().tz(opts.tz).format()\n return info\n})\n\nexport enum ScenarioInstanceStatus {\n READY = 'READY',\n STARTED = 'STARTED',\n STOPPED = 'STOPPED',\n HALTED = 'HALTED',\n UNLOADED = 'UNLOADED'\n}\n\nregisterEnumType(ScenarioInstanceStatus, {\n name: 'ScenarioInstanceStatus',\n description: 'state enumeration of a scenario-instance'\n})\n\n@ObjectType()\nexport class ScenarioInstanceProgress {\n @Field(type => Int)\n rounds: number\n\n @Field(type => Int)\n rate: number\n\n @Field(type => Int)\n steps: number\n\n @Field(type => Int)\n step: number\n}\n\n@ObjectType()\nexport class ScenarioInstanceState {\n @Field({ nullable: true })\n public domain: Domain\n\n @Field({ nullable: true })\n public instanceName: string\n\n @Field({ nullable: true })\n public scenarioName: string\n\n @Field(type => ScenarioInstanceStatus, { nullable: true })\n public state: ScenarioInstanceStatus\n\n @Field(type => ScalarObject, { nullable: true })\n public variables: any\n\n @Field(type => ScalarObject, { nullable: true })\n public data: any\n\n @Field(type => ScenarioInstanceProgress, { nullable: true })\n public progress: ScenarioInstanceProgress\n\n @Field({ nullable: true })\n public message: string\n\n @Field({ nullable: true })\n public timestamp: Date\n}\n\n@ObjectType()\nexport class ScenarioInstanceRunResult {\n @Field({ nullable: true })\n public scenarioName: string\n\n @Field({ nullable: true })\n public instanceName: string\n\n @Field(type => ScalarObject, { nullable: true })\n public variables: any\n\n @Field(type => ScalarObject, { nullable: true })\n public data: any\n\n @Field(type => ScalarObject, { nullable: true })\n public result: any\n\n @Field({ nullable: true })\n public timestamp: Date\n\n @Field({ nullable: true })\n public message: string\n\n @Field({ nullable: true })\n public state: ScenarioInstanceStatus\n}\n\n@ObjectType()\nexport class ScenarioInstance {\n private subScenarioInstances: ScenarioInstance[] = [] // TODO Imple by WeakSet\n\n public context: Context\n\n @Field({ nullable: true })\n public domain: Domain\n\n @Field({ nullable: true })\n public user: User\n\n @Field({ nullable: true })\n public scenarioName: string\n\n @Field({ nullable: true })\n public instanceName: string\n\n @Field({ nullable: true })\n get root(): ScenarioInstance {\n return this.context?.root\n }\n\n @Field({ nullable: true })\n get state(): ScenarioInstanceStatus {\n return this.context?.state\n }\n\n @Field(type => ScenarioInstanceProgress, { nullable: true })\n get progress(): ScenarioInstanceProgress {\n return this.calcProgress()\n }\n\n @Field(type => ScalarObject, { nullable: true })\n get variables(): any {\n return this.context?.variables\n }\n\n @Field(type => ScalarObject, { nullable: true })\n get data(): any {\n return this.context?.data\n }\n\n @Field(type => ScalarObject, { nullable: true })\n result: any\n\n @Field({ nullable: true })\n get timestamp(): Date {\n return new Date()\n }\n\n @Field({ nullable: true })\n public message: string\n\n private scenarioId: string\n private scenarioTtl: number\n private steps: Step[]\n private rounds: number = 0\n\n private lastStep: number = -1\n private nextStep: number = -1\n private disposer: any\n public addSubScenarioInstance(instance: ScenarioInstance): ScenarioInstance[] {\n this.subScenarioInstances.push(instance)\n return this.subScenarioInstances\n }\n\n public getSubScenarioInstances(): ScenarioInstance[] {\n return this.subScenarioInstances\n }\n\n public async stopSubScenarios() {\n var subScenarioInstances = this.getSubScenarioInstances()\n\n var subInstance = subScenarioInstances.pop()\n while (subInstance) {\n await subInstance.dispose()\n subInstance = subScenarioInstances.pop()\n }\n }\n\n constructor(\n instanceName,\n {\n id: scenarioId,\n ttl: scenarioTtl,\n name: scenarioName,\n steps,\n domain: scenarioDomain\n }: { id: string; ttl?: number; name: string; steps: Step[]; domain: Domain },\n context?\n ) {\n var { domain, user, lng, unsafeIP, prohibitedPrivileges } = context || {}\n domain ||= scenarioDomain\n\n this.scenarioId = scenarioId\n this.scenarioTtl = scenarioTtl\n this.instanceName = instanceName\n this.scenarioName = scenarioName\n this.steps = orderBy(steps || [], step => step.sequence)\n this.domain = domain\n this.user = user\n this.disposer = context?.disposer\n\n this.context = {\n domain,\n user,\n lng,\n unsafeIP,\n prohibitedPrivileges,\n logger:\n context?.logger ||\n createLogger({\n format: combine(errors({ stack: true }), systemTimestamp({ tz: SYSTEM_TZ }), splat(), LOGFORMAT),\n transports: [\n new (transports as any).DailyRotateFile({\n filename: `logs/${domain.subdomain}/scenario-${scenarioName}-%DATE%.log`,\n datePattern: 'YYYY-MM-DD-HH',\n zippedArchive: false,\n maxSize: '5m',\n maxFiles: '14d',\n level: 'info'\n }),\n new PubSubLogTransport({\n topic: 'scenario-instance-log',\n source: { domain, scenarioName, instanceName }\n })\n ]\n }),\n publish: context?.publish || this.publishData.bind(this),\n load: context?.load || this.loadSubscenario.bind(this),\n data: context?.data || {},\n variables: context?.variables || {},\n client: context?.client,\n state: ScenarioInstanceStatus.STOPPED,\n root: context?.root || this,\n closures: [],\n checkState(state = ScenarioInstanceStatus.STARTED) {\n return this.state == state\n }\n }\n\n this.setState(ScenarioInstanceStatus.READY)\n }\n\n async run() {\n var state = this.getState()\n if (state == ScenarioInstanceStatus.STARTED || this.steps.length == 0) {\n return\n }\n\n this.setState(ScenarioInstanceStatus.STARTED)\n var context = this.context\n\n try {\n while (this.getState() == ScenarioInstanceStatus.STARTED) {\n if (this.nextStep == -1) {\n this.setNextStep(0)\n }\n\n if (this.nextStep == 0) {\n this.rounds++\n this.context.logger.info(`Start ${this.rounds} Rounds #######`)\n }\n\n var step = this.steps[this.nextStep]\n var next, data\n\n if (!step.skip) {\n // @ts-ignore: Initializer provides no value for this binding element and the binding element has no default value.\n var { next, state: stepState, data } = (await this.process(step, context)) || {}\n context.data[step.name] = data\n } else {\n next = ''\n stepState = undefined\n }\n\n this.publishState()\n\n await sleep(1)\n\n if (next) {\n this.setNextStep(\n this.steps.findIndex(step => {\n return step.name == next\n })\n )\n if (this.nextStep == -1) {\n throw 'Not Found Next Step'\n }\n } else if (this.nextStep == this.steps.length - 1) {\n this.setState(ScenarioInstanceStatus.STOPPED)\n } else {\n this.setNextStep(this.nextStep + 1)\n }\n\n /* last step 에 의해서 시나리오 state를 변경할 수 있도록 함. */\n if (stepState !== undefined) {\n this.setState(stepState)\n }\n }\n } catch (ex) {\n const message = ex.stack ? ex.stack : ex\n const { scenarioName, domain } = this\n\n this.context.logger.error(ex)\n\n debug('failed to run ', `[ Domain: ${domain.name}, Scenario: ${scenarioName} ]\\n`, ex)\n this.setState(\n ScenarioInstanceStatus.HALTED,\n typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n )\n\n throw ex\n }\n\n this.result = this.steps\n .filter(step => !!step.result)\n .reduce((sum, step) => {\n sum[step.name] = this.context.data[step.name]\n return sum\n }, {})\n\n const { scenarioId, scenarioTtl, variables, message, scenarioName, instanceName, result, domain } = this\n const obj = {\n scenarioName,\n instanceName,\n variables,\n data: this.data,\n result,\n timestamp: new Date(),\n message,\n state: ScenarioInstanceStatus.STOPPED /* redundent, no meaning */\n }\n\n if (this.scenarioTtl && this.scenarioId) {\n setTimeout(() => {\n cacheService.setInCache(scenarioId, { domain: domain.id, variables: variables || {} }, obj, scenarioTtl)\n })\n }\n\n return obj\n }\n\n async loadSubscenario(step, scenarioConfig, context) {\n var { name: stepName, params } = step\n var { preventErrorPropagation } = params || {}\n\n debug('load-subscenario', this.instanceName, stepName, scenarioConfig.name)\n\n context.data[stepName] = {}\n\n let subContext = {\n ...context,\n data: context.data[stepName],\n closures: [],\n state: ScenarioInstanceStatus.READY\n }\n\n if (!scenarioConfig.domain) {\n scenarioConfig.domain = context.domain\n }\n\n var subScenarioInstance = new ScenarioInstance(`${this.instanceName}$${stepName}`, scenarioConfig, subContext)\n this.addSubScenarioInstance(subScenarioInstance)\n await subScenarioInstance.run()\n\n if (!preventErrorPropagation && subScenarioInstance.getState() == ScenarioInstanceStatus.HALTED) {\n throw new Error(`Sub-scenario[${this.instanceName}$${stepName}] is halted.`)\n }\n\n return subContext\n }\n\n publishData(tag, data) {\n publishData(tag, data, this.context)\n }\n\n publishState() {\n const {\n instanceName,\n scenarioName,\n steps,\n domain,\n message,\n context: { data, variables, state }\n } = this\n\n pubsub.publish('scenario-instance-state', {\n scenarioInstanceState: {\n domain,\n instanceName,\n scenarioName,\n state,\n variables,\n progress: this.calcProgress(),\n data,\n message,\n timestamp: new Date()\n }\n })\n\n this.context.logger.info(this.message)\n }\n\n calcProgress(): ScenarioInstanceProgress {\n var steps = this.steps.length\n var step = Math.max(this.lastStep, 0)\n\n return {\n rounds: this.rounds,\n rate: steps ? Math.round(100 * (step / steps)) : 0,\n steps,\n step\n }\n }\n\n setNextStep(step) {\n this.lastStep = this.nextStep + 1\n this.nextStep = step\n }\n\n getState(): ScenarioInstanceStatus {\n return this.context.state\n }\n\n setState(state, message?) {\n if (this.context.state == state) {\n return\n }\n\n this.message = `${this.instanceName}:[state changed] ${ScenarioInstanceStatus[this.getState()]} => ${ScenarioInstanceStatus[state]}${\n message ? ' caused by ' + util.inspect(message, false, 2, true) : ''\n }`\n\n this.context.state = state\n\n if (state == ScenarioInstanceStatus.STOPPED || state == ScenarioInstanceStatus.HALTED) {\n this.setNextStep(-1)\n this.setState(ScenarioInstanceStatus.UNLOADED)\n } else if (state == ScenarioInstanceStatus.UNLOADED) {\n this.setNextStep(-1)\n this.dispose()\n }\n\n this.publishState()\n }\n\n async start() {\n await this.run()\n }\n\n stop() {\n if (this.getState() !== ScenarioInstanceStatus.HALTED) {\n this.setState(ScenarioInstanceStatus.STOPPED)\n }\n }\n\n unload() {\n this.setState(ScenarioInstanceStatus.UNLOADED)\n }\n\n async dispose() {\n await this.stopSubScenarios()\n\n this.unload()\n\n var closure = this.context?.closures?.pop()\n while (closure) {\n closure.call(this)\n closure = this.context?.closures?.pop()\n }\n\n if (this.disposer) {\n await this.disposer.call(this)\n }\n\n // {{ CHECKPOINT 본 인스턴스를 위해서 생성된 logger를 닫는다. 사용을 완료하고 닫기위해서 지연해서 수행한다.\n if (this.context?.logger) {\n setTimeout(() => {\n this.context.logger.close()\n }, 300)\n }\n // }}\n }\n\n async process(step, context): Promise<{ next: string; state: ScenarioInstanceStatus; data: object }> {\n this.context.logger.info(`Step '${step.name}'(${step.id}) started.`)\n\n step = {\n ...step\n } // copy step\n\n try {\n step.params = JSON.parse(step.params)\n } catch (ex) {\n this.context.logger.error(`params(${step.params}) parsing error. params must be a JSON.`, ex)\n }\n step.params = step.params || {}\n\n const connection =\n step.connection && ConnectionManager.getConnectionInstanceEntityByName(this.domain, step.connection)\n\n if (!connection || !connection.edgeId) {\n var handler = TaskRegistry.getTaskHandler(step.task)\n if (!handler) {\n throw new Error(`no task handler for step '${step.name}'(${step.id})`)\n }\n\n var retval: any = await handler(step, context)\n } else {\n var retval: any = await edgeHandler(step, context)\n }\n\n if (step.log) {\n var { data } = retval || {}\n this.context.logger.info(`returns ${typeof data == 'string' ? data : JSON.stringify(data, null, 2)}`)\n }\n\n this.context.logger.info(`Step done.`)\n return retval\n }\n}\n\n@ObjectType()\nexport class ScenarioInstanceList {\n @Field(type => [ScenarioInstance])\n items: ScenarioInstance[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
1
|
+
{"version":3,"file":"scenario-instance-type.js","sourceRoot":"","sources":["../../../server/service/scenario-instance/scenario-instance-type.ts"],"names":[],"mappings":";;;;;AAAA,qCAAkC;AAElC,qEAAoC;AACpC,8EAAoC;AACpC,+CAAuE;AACvE,wDAAuB;AACvB,qCAA0D;AAE1D,iDAAwF;AACxF,iEAA4D;AAC5D,yDAAgD;AAChD,iDAA6C;AAE7C,iEAA4D;AAC5D,wEAAmE;AACnE,yCAA2C;AAG3C,0D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IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;;GAC5E,gBAAgB,CAka5B;AAGM,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAMhC,CAAA;AANY,oDAAoB;AAE/B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;mDAClE;AAGzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;mDAClE;+BALF,oBAAoB;IADhC,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;GAC1D,oBAAoB,CAMhC","sourcesContent":["import 'winston-daily-rotate-file'\n\nimport orderBy from 'lodash/orderBy'\nimport moment from 'moment-timezone'\nimport { Field, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport util from 'util'\nimport { createLogger, format, transports } from 'winston'\n\nimport { Domain, pubsub, PubSubLogTransport, ScalarObject } from '@things-factory/shell'\nimport { cacheService } from '@things-factory/cache-service'\nimport { User } from '@things-factory/auth-base'\nimport { sleep } from '@things-factory/utils'\n\nimport { publishData } from '../../controllers/publish-data'\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { TaskRegistry } from '../../engine'\nimport { Context } from '../../engine/types'\nimport { Step } from '../step/step-type'\nimport { handler as edgeHandler } from '../../engine/edge-client'\n\nconst debug = require('debug')('things-factory:integration-base:scenario-instance')\nconst { combine, errors, splat, printf } = format\n\nconst LOGFORMAT = printf(({ level, message, timestamp, stack }) => {\n return `${timestamp} ${level}: ${stack || message}`\n})\n\nfunction getSystemTimeZone() {\n try {\n const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone\n if (!timeZone) {\n throw new Error('Unable to resolve timeZone')\n }\n return timeZone\n } catch (e) {\n console.warn('Failed to get system timeZone, falling back to UTC.', e)\n return 'UTC'\n }\n}\n\nconst SYSTEM_TZ = getSystemTimeZone()\nconst systemTimestamp = format((info, opts: { tz?: string }) => {\n if (opts.tz) info.timestamp = moment().tz(opts.tz).format()\n return info\n})\n\nexport enum ScenarioInstanceStatus {\n READY = 'READY',\n STARTED = 'STARTED',\n STOPPED = 'STOPPED',\n HALTED = 'HALTED',\n UNLOADED = 'UNLOADED'\n}\n\nregisterEnumType(ScenarioInstanceStatus, {\n name: 'ScenarioInstanceStatus',\n description: 'Enumeration of possible states for a scenario instance.'\n})\n\n@ObjectType({ description: 'Provides progress information for a running scenario instance.' })\nexport class ScenarioInstanceProgress {\n @Field(type => Int, { description: 'The number of rounds the scenario has completed.' })\n rounds: number\n\n @Field(type => Int, { description: 'The completion rate of the scenario as a percentage.' })\n rate: number\n\n @Field(type => Int, { description: 'The total number of steps in the scenario.' })\n steps: number\n\n @Field(type => Int, { description: 'The current step number being executed.' })\n step: number\n}\n\n@ObjectType({ description: 'Represents the complete state of a scenario instance at a point in time.' })\nexport class ScenarioInstanceState {\n @Field({ nullable: true, description: 'The domain in which the instance is running.' })\n public domain: Domain\n\n @Field({ nullable: true, description: 'The unique name of this specific instance.' })\n public instanceName: string\n\n @Field({ nullable: true, description: 'The name of the scenario being executed.' })\n public scenarioName: string\n\n @Field(type => ScenarioInstanceStatus, {\n nullable: true,\n description: 'The current execution state of the instance.'\n })\n public state: ScenarioInstanceStatus\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of variables used in the instance.' })\n public variables: any\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'A key-value map of data generated and used by the instance.'\n })\n public data: any\n\n @Field(type => ScenarioInstanceProgress, { nullable: true, description: 'The progress of the running instance.' })\n public progress: ScenarioInstanceProgress\n\n @Field({ nullable: true, description: 'A message associated with the current state (e.g., an error message).' })\n public message: string\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n public timestamp: Date\n}\n\n@ObjectType({ description: 'Contains the final result of a completed scenario instance run.' })\nexport class ScenarioInstanceRunResult {\n @Field({ nullable: true, description: 'The name of the scenario that was executed.' })\n public scenarioName: string\n\n @Field({ nullable: true, description: 'The unique name of the instance that was run.' })\n public instanceName: string\n\n @Field(type => ScalarObject, { nullable: true, description: 'The final set of variables after the run.' })\n public variables: any\n\n @Field(type => ScalarObject, { nullable: true, description: 'The final set of data after the run.' })\n public data: any\n\n @Field(type => ScalarObject, { nullable: true, description: 'The final result returned by the scenario.' })\n public result: any\n\n @Field({ nullable: true, description: 'The timestamp when the run completed.' })\n public timestamp: Date\n\n @Field({ nullable: true, description: 'A final message from the run (e.g., success or failure reason).' })\n public message: string\n\n @Field({ nullable: true, description: 'The final state of the instance after the run.' })\n public state: ScenarioInstanceStatus\n}\n\n@ObjectType({ description: 'Represents a running or completed instance of a scenario.' })\nexport class ScenarioInstance {\n private subScenarioInstances: ScenarioInstance[] = [] // TODO Imple by WeakSet\n\n public context: Context\n\n @Field({ nullable: true, description: 'The domain in which the instance is running.' })\n public domain: Domain\n\n @Field({ nullable: true, description: 'The user who initiated the instance.' })\n public user: User\n\n @Field({ nullable: true, description: 'The name of the scenario being executed.' })\n public scenarioName: string\n\n @Field({ nullable: true, description: 'The unique name for this specific instance of the scenario.' })\n public instanceName: string\n\n @Field({ nullable: true, description: 'The root scenario instance if this is a sub-scenario.' })\n get root(): ScenarioInstance {\n return this.context?.root\n }\n\n @Field({ nullable: true, description: 'The current execution state of the instance.' })\n get state(): ScenarioInstanceStatus {\n return this.context?.state\n }\n\n @Field(type => ScenarioInstanceProgress, { nullable: true, description: 'The current progress of the instance.' })\n get progress(): ScenarioInstanceProgress {\n return this.calcProgress()\n }\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of variables used in the instance.' })\n get variables(): any {\n return this.context?.variables\n }\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'A key-value map of data generated and used by the instance.'\n })\n get data(): any {\n return this.context?.data\n }\n\n @Field(type => ScalarObject, { nullable: true, description: 'The final result of the scenario run.' })\n result: any\n\n @Field({ nullable: true, description: 'The timestamp of the last update.' })\n get timestamp(): Date {\n return new Date()\n }\n\n @Field({ nullable: true, description: 'A message associated with the current state (e.g., an error message).' })\n public message: string\n\n private scenarioId: string\n private scenarioTtl: number\n private steps: Step[]\n private rounds: number = 0\n\n private lastStep: number = -1\n private nextStep: number = -1\n private disposer: any\n public addSubScenarioInstance(instance: ScenarioInstance): ScenarioInstance[] {\n this.subScenarioInstances.push(instance)\n return this.subScenarioInstances\n }\n\n public getSubScenarioInstances(): ScenarioInstance[] {\n return this.subScenarioInstances\n }\n\n public async stopSubScenarios() {\n var subScenarioInstances = this.getSubScenarioInstances()\n\n var subInstance = subScenarioInstances.pop()\n while (subInstance) {\n await subInstance.dispose()\n subInstance = subScenarioInstances.pop()\n }\n }\n\n constructor(\n instanceName,\n {\n id: scenarioId,\n ttl: scenarioTtl,\n name: scenarioName,\n steps,\n domain: scenarioDomain\n }: { id: string; ttl?: number; name: string; steps: Step[]; domain: Domain },\n context?\n ) {\n var { domain, user, lng, unsafeIP, prohibitedPrivileges } = context || {}\n domain ||= scenarioDomain\n\n this.scenarioId = scenarioId\n this.scenarioTtl = scenarioTtl\n this.instanceName = instanceName\n this.scenarioName = scenarioName\n this.steps = orderBy(steps || [], step => step.sequence)\n this.domain = domain\n this.user = user\n this.disposer = context?.disposer\n\n this.context = {\n domain,\n user,\n lng,\n unsafeIP,\n prohibitedPrivileges,\n logger:\n context?.logger ||\n createLogger({\n format: combine(errors({ stack: true }), systemTimestamp({ tz: SYSTEM_TZ }), splat(), LOGFORMAT),\n transports: [\n new (transports as any).DailyRotateFile({\n filename: `logs/${domain.subdomain}/scenario-${scenarioName}-%DATE%.log`,\n datePattern: 'YYYY-MM-DD-HH',\n zippedArchive: false,\n maxSize: '5m',\n maxFiles: '14d',\n level: 'info'\n }),\n new PubSubLogTransport({\n topic: 'scenario-instance-log',\n source: { domain, scenarioName, instanceName }\n })\n ]\n }),\n publish: context?.publish || this.publishData.bind(this),\n load: context?.load || this.loadSubscenario.bind(this),\n data: context?.data || {},\n variables: context?.variables || {},\n client: context?.client,\n state: ScenarioInstanceStatus.STOPPED,\n root: context?.root || this,\n closures: [],\n checkState(state = ScenarioInstanceStatus.STARTED) {\n return this.state == state\n }\n }\n\n this.setState(ScenarioInstanceStatus.READY)\n }\n\n async run() {\n var state = this.getState()\n if (state == ScenarioInstanceStatus.STARTED || this.steps.length == 0) {\n return\n }\n\n this.setState(ScenarioInstanceStatus.STARTED)\n var context = this.context\n\n try {\n while (this.getState() == ScenarioInstanceStatus.STARTED) {\n if (this.nextStep == -1) {\n this.setNextStep(0)\n }\n\n if (this.nextStep == 0) {\n this.rounds++\n this.context.logger.info(`Start ${this.rounds} Rounds #######`)\n }\n\n var step = this.steps[this.nextStep]\n var next, data\n\n if (!step.skip) {\n // @ts-ignore: Initializer provides no value for this binding element and the binding element has no default value.\n var { next, state: stepState, data } = (await this.process(step, context)) || {}\n context.data[step.name] = data\n } else {\n next = ''\n stepState = undefined\n }\n\n this.publishState()\n\n await sleep(1)\n\n if (next) {\n this.setNextStep(\n this.steps.findIndex(step => {\n return step.name == next\n })\n )\n if (this.nextStep == -1) {\n throw 'Not Found Next Step'\n }\n } else if (this.nextStep == this.steps.length - 1) {\n this.setState(ScenarioInstanceStatus.STOPPED)\n } else {\n this.setNextStep(this.nextStep + 1)\n }\n\n /* last step 에 의해서 시나리오 state를 변경할 수 있도록 함. */\n if (stepState !== undefined) {\n this.setState(stepState)\n }\n }\n } catch (ex) {\n const message = ex.stack ? ex.stack : ex\n const { scenarioName, domain } = this\n\n this.context.logger.error(ex)\n\n debug('failed to run ', `[ Domain: ${domain.name}, Scenario: ${scenarioName} ]\\n`, ex)\n this.setState(\n ScenarioInstanceStatus.HALTED,\n typeof message == 'object' ? JSON.stringify(message, null, 2) : message\n )\n\n throw ex\n }\n\n this.result = this.steps\n .filter(step => !!step.result)\n .reduce((sum, step) => {\n sum[step.name] = this.context.data[step.name]\n return sum\n }, {})\n\n const { scenarioId, scenarioTtl, variables, message, scenarioName, instanceName, result, domain } = this\n const obj = {\n scenarioName,\n instanceName,\n variables,\n data: this.data,\n result,\n timestamp: new Date(),\n message,\n state: ScenarioInstanceStatus.STOPPED /* redundent, no meaning */\n }\n\n if (this.scenarioTtl && this.scenarioId) {\n setTimeout(() => {\n cacheService.setInCache(scenarioId, { domain: domain.id, variables: variables || {} }, obj, scenarioTtl)\n })\n }\n\n return obj\n }\n\n async loadSubscenario(step, scenarioConfig, context) {\n var { name: stepName, params } = step\n var { preventErrorPropagation } = params || {}\n\n debug('load-subscenario', this.instanceName, stepName, scenarioConfig.name)\n\n context.data[stepName] = {}\n\n let subContext = {\n ...context,\n data: context.data[stepName],\n closures: [],\n state: ScenarioInstanceStatus.READY\n }\n\n if (!scenarioConfig.domain) {\n scenarioConfig.domain = context.domain\n }\n\n var subScenarioInstance = new ScenarioInstance(`${this.instanceName}$${stepName}`, scenarioConfig, subContext)\n this.addSubScenarioInstance(subScenarioInstance)\n await subScenarioInstance.run()\n\n if (!preventErrorPropagation && subScenarioInstance.getState() == ScenarioInstanceStatus.HALTED) {\n throw new Error(`Sub-scenario[${this.instanceName}$${stepName}] is halted.`)\n }\n\n return subContext\n }\n\n publishData(tag, data) {\n publishData(tag, data, this.context)\n }\n\n publishState() {\n const {\n instanceName,\n scenarioName,\n steps,\n domain,\n message,\n context: { data, variables, state }\n } = this\n\n pubsub.publish('scenario-instance-state', {\n scenarioInstanceState: {\n domain,\n instanceName,\n scenarioName,\n state,\n variables,\n progress: this.calcProgress(),\n data,\n message,\n timestamp: new Date()\n }\n })\n\n this.context.logger.info(this.message)\n }\n\n calcProgress(): ScenarioInstanceProgress {\n var steps = this.steps.length\n var step = Math.max(this.lastStep, 0)\n\n return {\n rounds: this.rounds,\n rate: steps ? Math.round(100 * (step / steps)) : 0,\n steps,\n step\n }\n }\n\n setNextStep(step) {\n this.lastStep = this.nextStep + 1\n this.nextStep = step\n }\n\n getState(): ScenarioInstanceStatus {\n return this.context.state\n }\n\n setState(state, message?) {\n if (this.context.state == state) {\n return\n }\n\n this.message = `${this.instanceName}:[state changed] ${ScenarioInstanceStatus[this.getState()]} => ${ScenarioInstanceStatus[state]}${\n message ? ' caused by ' + util.inspect(message, false, 2, true) : ''\n }`\n\n this.context.state = state\n\n if (state == ScenarioInstanceStatus.STOPPED || state == ScenarioInstanceStatus.HALTED) {\n this.setNextStep(-1)\n this.setState(ScenarioInstanceStatus.UNLOADED)\n } else if (state == ScenarioInstanceStatus.UNLOADED) {\n this.setNextStep(-1)\n this.dispose()\n }\n\n this.publishState()\n }\n\n async start() {\n await this.run()\n }\n\n stop() {\n if (this.getState() !== ScenarioInstanceStatus.HALTED) {\n this.setState(ScenarioInstanceStatus.STOPPED)\n }\n }\n\n unload() {\n this.setState(ScenarioInstanceStatus.UNLOADED)\n }\n\n async dispose() {\n await this.stopSubScenarios()\n\n this.unload()\n\n var closure = this.context?.closures?.pop()\n while (closure) {\n closure.call(this)\n closure = this.context?.closures?.pop()\n }\n\n if (this.disposer) {\n await this.disposer.call(this)\n }\n\n // {{ CHECKPOINT 본 인스턴스를 위해서 생성된 logger를 닫는다. 사용을 완료하고 닫기위해서 지연해서 수행한다.\n if (this.context?.logger) {\n setTimeout(() => {\n this.context.logger.close()\n }, 300)\n }\n // }}\n }\n\n async process(step, context): Promise<{ next: string; state: ScenarioInstanceStatus; data: object }> {\n this.context.logger.info(`Step '${step.name}'(${step.id}) started.`)\n\n step = {\n ...step,\n params: step.params || {}\n }\n\n const connection =\n step.connection && ConnectionManager.getConnectionInstanceEntityByName(this.domain, step.connection)\n\n if (!connection || !connection.edgeId) {\n var handler = TaskRegistry.getTaskHandler(step.task)\n if (!handler) {\n throw new Error(`no task handler for step '${step.name}'(${step.id})`)\n }\n\n var retval: any = await handler(step, context)\n } else {\n var retval: any = await edgeHandler(step, context)\n }\n\n if (step.log) {\n var { data } = retval || {}\n this.context.logger.info(`returns ${typeof data == 'string' ? data : JSON.stringify(data, null, 2)}`)\n }\n\n this.context.logger.info(`Step done.`)\n return retval\n }\n}\n\n@ObjectType({ description: 'A paginated list of scenario instances.' })\nexport class ScenarioInstanceList {\n @Field(type => [ScenarioInstance], { description: 'The list of scenario instance items.' })\n items: ScenarioInstance[]\n\n @Field(type => Int, { description: 'The total number of scenario instances.' })\n total: number\n}\n"]}
|
@@ -16,15 +16,15 @@ let ScenarioQueueSubscription = class ScenarioQueueSubscription {
|
|
16
16
|
exports.ScenarioQueueSubscription = ScenarioQueueSubscription;
|
17
17
|
tslib_1.__decorate([
|
18
18
|
(0, type_graphql_1.Subscription)({
|
19
|
+
description: 'Subscribes to changes in the scenario queue.',
|
19
20
|
subscribe: ({ args, context, info }) => {
|
20
|
-
var _a;
|
21
21
|
const { domain, user } = context.state;
|
22
|
-
const subdomain = domain
|
22
|
+
const subdomain = domain?.subdomain;
|
23
23
|
debug('subscribe', subdomain);
|
24
24
|
if (!domain) {
|
25
25
|
throw new Error('domain required.');
|
26
26
|
}
|
27
|
-
if (!
|
27
|
+
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
28
28
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
29
29
|
}
|
30
30
|
process.nextTick(async () => {
|
@@ -40,7 +40,7 @@ tslib_1.__decorate([
|
|
40
40
|
});
|
41
41
|
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('scenario-queue-state'), (0, graphql_yoga_1.filter)((payload) => {
|
42
42
|
const { domain: pdomain } = payload.scenarioQueueState;
|
43
|
-
if (
|
43
|
+
if (pdomain?.subdomain !== subdomain) {
|
44
44
|
return false;
|
45
45
|
}
|
46
46
|
return true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-queue-subscription.js","sourceRoot":"","sources":["../../../server/service/scenario-queue/scenario-queue-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,+DAA0D;AAC1D,iDAA8C;AAC9C,+CAA2C;AAC3C,yCAA6C;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;
|
1
|
+
{"version":3,"file":"scenario-queue-subscription.js","sourceRoot":"","sources":["../../../server/service/scenario-queue/scenario-queue-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,+DAA0D;AAC1D,iDAA8C;AAC9C,+CAA2C;AAC3C,yCAA6C;AAE7C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IA2CpC,kBAAkB,CAAS,OAAmD;QAC5E,OAAO,OAAO,CAAC,kBAAkB,CAAA;IACnC,CAAC;CACF,CAAA;AA9CY,8DAAyB;AA2CpC;IA1CC,IAAA,2BAAY,EAAC;QACZ,WAAW,EAAE,8CAA8C;QAC3D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YACrC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAE7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;gBACnG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;YACjF,CAAC;YAED,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;gBAC1B,IAAI,KAAK,GAAG,uBAAc,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;gBAClD,IAAI,KAAK,EAAE,CAAC;oBACV,cAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE;wBACrC,kBAAkB,EAAE;4BAClB,MAAM;4BACN,KAAK,EAAE,KAAK,CAAC,KAAK;yBACnB;qBACF,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC,CAAC,CAAA;YAEF,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,EACxC,IAAA,qBAAM,EAAC,CAAC,OAAmD,EAAE,EAAE;gBAC7D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAA;gBAEtD,IAAI,OAAO,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;oBACrC,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACkB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;;4CAAuD,wCAAkB;mEAElG;oCA7CU,yBAAyB;IADrC,IAAA,uBAAQ,GAAE;GACE,yBAAyB,CA8CrC","sourcesContent":["import { Resolver, Subscription, Root, Arg } from 'type-graphql'\nimport { ScenarioQueueState } from './scenario-queue-type'\nimport { pubsub } from '@things-factory/shell'\nimport { filter, pipe } from 'graphql-yoga'\nimport { ScenarioEngine } from '../../engine'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver()\nexport class ScenarioQueueSubscription {\n @Subscription({\n description: 'Subscribes to changes in the scenario queue.',\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var queue = ScenarioEngine.getPendingQueue(domain)\n if (queue) {\n pubsub.publish('scenario-queue-state', {\n scenarioQueueState: {\n domain,\n queue: queue.queue\n }\n })\n }\n })\n\n return pipe(\n pubsub.subscribe('scenario-queue-state'),\n filter((payload: { scenarioQueueState: ScenarioQueueState }) => {\n const { domain: pdomain } = payload.scenarioQueueState\n\n if (pdomain?.subdomain !== subdomain) {\n return false\n }\n\n return true\n })\n )\n }\n })\n scenarioQueueState(@Root() payload: { scenarioQueueState: ScenarioQueueState }): ScenarioQueueState {\n return payload.scenarioQueueState\n }\n}\n"]}
|
@@ -8,36 +8,36 @@ let PendingObject = class PendingObject {
|
|
8
8
|
};
|
9
9
|
exports.PendingObject = PendingObject;
|
10
10
|
tslib_1.__decorate([
|
11
|
-
(0, type_graphql_1.Field)(type => shell_1.ScalarObject),
|
11
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { description: 'The actual data or task object in the queue.' }),
|
12
12
|
tslib_1.__metadata("design:type", Object)
|
13
13
|
], PendingObject.prototype, "stuff", void 0);
|
14
14
|
tslib_1.__decorate([
|
15
|
-
(0, type_graphql_1.Field)(),
|
15
|
+
(0, type_graphql_1.Field)({ description: 'The timestamp indicating when the item is due for processing.' }),
|
16
16
|
tslib_1.__metadata("design:type", String)
|
17
17
|
], PendingObject.prototype, "due", void 0);
|
18
18
|
tslib_1.__decorate([
|
19
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
19
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The priority level of the item in the queue.' }),
|
20
20
|
tslib_1.__metadata("design:type", Number)
|
21
21
|
], PendingObject.prototype, "priority", void 0);
|
22
22
|
tslib_1.__decorate([
|
23
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
23
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A tag for categorizing or filtering queue items.' }),
|
24
24
|
tslib_1.__metadata("design:type", String)
|
25
25
|
], PendingObject.prototype, "tag", void 0);
|
26
26
|
exports.PendingObject = PendingObject = tslib_1.__decorate([
|
27
|
-
(0, type_graphql_1.ObjectType)()
|
27
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents an item pending in a scenario queue.' })
|
28
28
|
], PendingObject);
|
29
29
|
let ScenarioQueueState = class ScenarioQueueState {
|
30
30
|
};
|
31
31
|
exports.ScenarioQueueState = ScenarioQueueState;
|
32
32
|
tslib_1.__decorate([
|
33
|
-
(0, type_graphql_1.Field)(),
|
33
|
+
(0, type_graphql_1.Field)({ description: 'The domain to which this queue state belongs.' }),
|
34
34
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
35
35
|
], ScenarioQueueState.prototype, "domain", void 0);
|
36
36
|
tslib_1.__decorate([
|
37
|
-
(0, type_graphql_1.Field)(type => [PendingObject]),
|
37
|
+
(0, type_graphql_1.Field)(type => [PendingObject], { description: 'The list of pending items in the queue.' }),
|
38
38
|
tslib_1.__metadata("design:type", Array)
|
39
39
|
], ScenarioQueueState.prototype, "queue", void 0);
|
40
40
|
exports.ScenarioQueueState = ScenarioQueueState = tslib_1.__decorate([
|
41
|
-
(0, type_graphql_1.ObjectType)()
|
41
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents the state of a scenario queue for a specific domain.' })
|
42
42
|
], ScenarioQueueState);
|
43
43
|
//# sourceMappingURL=scenario-queue-type.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scenario-queue-type.js","sourceRoot":"","sources":["../../../server/service/scenario-queue/scenario-queue-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAqD;AAErD,iDAA4D;AAGrD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAYzB,CAAA;AAZY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,CAAC;;
|
1
|
+
{"version":3,"file":"scenario-queue-type.js","sourceRoot":"","sources":["../../../server/service/scenario-queue/scenario-queue-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAqD;AAErD,iDAA4D;AAGrD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAYzB,CAAA;AAZY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;;4CACnF;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;;0CAC7E;AAGX;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;;+CACpE;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;sCACtF,MAAM;0CAAA;wBAXA,aAAa;IADzB,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;GAClE,aAAa,CAYzB;AAGM,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAM9B,CAAA;AANY,gDAAkB;AAE7B;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;sCAChE,cAAM;kDAAA;AAGd;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;iDACrE;6BALX,kBAAkB;IAD9B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;GAClF,kBAAkB,CAM9B","sourcesContent":["import { Field, Int, ObjectType } from 'type-graphql'\n\nimport { Domain, ScalarObject } from '@things-factory/shell'\n\n@ObjectType({ description: 'Represents an item pending in a scenario queue.' })\nexport class PendingObject {\n @Field(type => ScalarObject, { description: 'The actual data or task object in the queue.' })\n stuff: any\n\n @Field({ description: 'The timestamp indicating when the item is due for processing.' })\n due: string\n\n @Field(type => Int, { description: 'The priority level of the item in the queue.' })\n priority: number\n\n @Field({ nullable: true, description: 'A tag for categorizing or filtering queue items.' })\n tag: String\n}\n\n@ObjectType({ description: 'Represents the state of a scenario queue for a specific domain.' })\nexport class ScenarioQueueState {\n @Field({ description: 'The domain to which this queue state belongs.' })\n domain: Domain\n\n @Field(type => [PendingObject], { description: 'The list of pending items in the queue.' })\n queue: PendingObject[]\n}\n"]}
|