@things-factory/integration-base 9.0.20 → 9.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/engine/analyzer/analyze-integration.js +2 -2
- package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/engine/connection-manager.d.ts +13 -1
- package/dist-server/engine/connection-manager.js +105 -7
- package/dist-server/engine/connection-manager.js.map +1 -1
- package/dist-server/engine/connector/headless-connector.d.ts +8 -0
- package/dist-server/engine/connector/headless-connector.js +4 -2
- package/dist-server/engine/connector/headless-connector.js.map +1 -1
- package/dist-server/engine/connector/mqtt-connector.d.ts +1 -0
- package/dist-server/engine/connector/mqtt-connector.js +4 -2
- package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
- package/dist-server/engine/connector/mssql-connector.d.ts +4 -0
- package/dist-server/engine/connector/mssql-connector.js +4 -2
- package/dist-server/engine/connector/mssql-connector.js.map +1 -1
- package/dist-server/engine/connector/mysql-connector.d.ts +10 -2
- package/dist-server/engine/connector/mysql-connector.js +23 -18
- package/dist-server/engine/connector/mysql-connector.js.map +1 -1
- package/dist-server/engine/connector/operato-connector.d.ts +8 -2
- package/dist-server/engine/connector/operato-connector.js +2 -1
- package/dist-server/engine/connector/operato-connector.js.map +1 -1
- package/dist-server/engine/connector/oracle-connector.d.ts +3 -0
- package/dist-server/engine/connector/oracle-connector.js +4 -2
- package/dist-server/engine/connector/oracle-connector.js.map +1 -1
- package/dist-server/engine/connector/postgresql-connector.d.ts +13 -2
- package/dist-server/engine/connector/postgresql-connector.js +14 -6
- package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
- package/dist-server/engine/connector/pyrun-connector.d.ts +1 -0
- package/dist-server/engine/connector/pyrun-connector.js +3 -3
- package/dist-server/engine/connector/pyrun-connector.js.map +1 -1
- package/dist-server/engine/edge-client.d.ts +1 -1
- package/dist-server/engine/edge-client.js.map +1 -1
- package/dist-server/engine/task/database-query.js +1 -1
- package/dist-server/engine/task/database-query.js.map +1 -1
- package/dist-server/engine/task/echo-receive.js +1 -1
- package/dist-server/engine/task/echo-receive.js.map +1 -1
- package/dist-server/engine/task/echo-send.js +1 -1
- package/dist-server/engine/task/echo-send.js.map +1 -1
- package/dist-server/engine/task/graphql-mutate.js +1 -1
- package/dist-server/engine/task/graphql-mutate.js.map +1 -1
- package/dist-server/engine/task/graphql-query.js +1 -1
- package/dist-server/engine/task/graphql-query.js.map +1 -1
- package/dist-server/engine/task/headless-post.js +1 -1
- package/dist-server/engine/task/headless-post.js.map +1 -1
- package/dist-server/engine/task/headless-scrap.js +1 -1
- package/dist-server/engine/task/headless-scrap.js.map +1 -1
- package/dist-server/engine/task/http-get.js +1 -1
- package/dist-server/engine/task/http-get.js.map +1 -1
- package/dist-server/engine/task/http-post.js +1 -1
- package/dist-server/engine/task/http-post.js.map +1 -1
- package/dist-server/engine/task/mqtt-publish.js +1 -1
- package/dist-server/engine/task/mqtt-publish.js.map +1 -1
- package/dist-server/engine/task/mqtt-subscribe.js +1 -1
- 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 +1 -1
- package/dist-server/engine/task/oracle-procedure.js.map +1 -1
- package/dist-server/engine/task/pyrun-execute.js +1 -1
- package/dist-server/engine/task/pyrun-execute.js.map +1 -1
- package/dist-server/engine/task/socket-listener.js +1 -1
- package/dist-server/engine/task/socket-listener.js.map +1 -1
- package/dist-server/service/connection/connection-mutation.d.ts +3 -1
- package/dist-server/service/connection/connection-mutation.js +62 -22
- package/dist-server/service/connection/connection-mutation.js.map +1 -1
- package/dist-server/service/connection/connection-query.d.ts +2 -1
- package/dist-server/service/connection/connection-query.js +14 -13
- package/dist-server/service/connection/connection-query.js.map +1 -1
- package/dist-server/service/connection/connection-subscription.js +6 -4
- package/dist-server/service/connection/connection-subscription.js.map +1 -1
- package/dist-server/service/connection/connection-type.d.ts +10 -99
- package/dist-server/service/connection/connection-type.js +36 -182
- package/dist-server/service/connection/connection-type.js.map +1 -1
- package/dist-server/service/connection/connection.d.ts +119 -0
- package/dist-server/service/connection/connection.js +239 -0
- package/dist-server/service/connection/connection.js.map +1 -0
- package/dist-server/service/connection/index.d.ts +1 -1
- package/dist-server/service/connection/index.js +2 -2
- package/dist-server/service/connection/index.js.map +1 -1
- package/dist-server/service/connector/connector-query.js +2 -2
- package/dist-server/service/connector/connector-query.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/property-spec.d.ts +1 -0
- package/dist-server/service/property-spec.js +8 -1
- package/dist-server/service/property-spec.js.map +1 -1
- package/dist-server/service/scenario/scenario-mutation.js +1 -1
- package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
- package/dist-server/service/scenario/scenario-query.js +3 -3
- package/dist-server/service/scenario/scenario-query.js.map +1 -1
- package/dist-server/service/scenario/scenario-type.js +4 -1
- package/dist-server/service/scenario/scenario-type.js.map +1 -1
- package/dist-server/service/scenario/scenario.js +1 -1
- package/dist-server/service/scenario/scenario.js.map +1 -1
- package/dist-server/service/task-type/task-type-query.js +2 -2
- package/dist-server/service/task-type/task-type-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
@@ -0,0 +1,239 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Connection = exports.ConnectionStatus = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
6
|
+
const typeorm_1 = require("typeorm");
|
7
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
8
|
+
const env_1 = require("@things-factory/env");
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
10
|
+
const engine_1 = require("../../engine");
|
11
|
+
const proxy_connector_1 = require("../../engine/connector/proxy-connector");
|
12
|
+
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
13
|
+
const DATABASE_TYPE = ORMCONFIG.type;
|
14
|
+
var ConnectionStatus;
|
15
|
+
(function (ConnectionStatus) {
|
16
|
+
ConnectionStatus["CONNECTED"] = "CONNECTED";
|
17
|
+
ConnectionStatus["DISCONNECTED"] = "DISCONNECTED"; // Represents a terminated or inactive connection.
|
18
|
+
})(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {}));
|
19
|
+
(0, type_graphql_1.registerEnumType)(ConnectionStatus, {
|
20
|
+
name: 'ConnectionStatus',
|
21
|
+
description: 'Enumeration of possible states for a connection.'
|
22
|
+
});
|
23
|
+
let Connection = class Connection {
|
24
|
+
/**
|
25
|
+
* Asynchronous method to establish the connection.
|
26
|
+
*
|
27
|
+
*/
|
28
|
+
async connect() {
|
29
|
+
const { type, edge } = this;
|
30
|
+
const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
|
31
|
+
await connector.connect({
|
32
|
+
...this,
|
33
|
+
params: await this.getResolvedParameters() // 🔐 해결된 파라미터 사용
|
34
|
+
});
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* @brief Asynchronous method to disconnect the connection.
|
38
|
+
*
|
39
|
+
*/
|
40
|
+
async disconnect() {
|
41
|
+
try {
|
42
|
+
const { type, edge } = this;
|
43
|
+
const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
|
44
|
+
await connector.disconnect(this);
|
45
|
+
}
|
46
|
+
finally {
|
47
|
+
}
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
* Gets a parameter value with fallback to EnvVar.
|
51
|
+
* Priority: params → EnvVar (only for useDomainAttribute=true)
|
52
|
+
*
|
53
|
+
* @param key - The parameter key
|
54
|
+
* @param defaultValue - Optional default value
|
55
|
+
* @returns The parameter value or default value
|
56
|
+
*/
|
57
|
+
async getParameter(key, defaultValue) {
|
58
|
+
// 1. params에서 직접 값 확인 (null/undefined가 아닌 경우)
|
59
|
+
if (this.params?.[key] !== null && this.params?.[key] !== undefined && this.params?.[key] !== '') {
|
60
|
+
return this.params[key];
|
61
|
+
}
|
62
|
+
// 2. useDomainAttribute가 true인 경우에만 EnvVar에서 조회
|
63
|
+
const connector = engine_1.ConnectionManager.getConnector(this.type);
|
64
|
+
const paramSpec = connector?.parameterSpec?.find(spec => spec.name === key);
|
65
|
+
if (paramSpec?.useDomainAttribute) {
|
66
|
+
const envVarKey = `Connection::${this.name}::${key}`;
|
67
|
+
const envVarRepository = (0, shell_1.getRepository)(shell_1.EnvVar);
|
68
|
+
const envVar = await envVarRepository.findOne({
|
69
|
+
where: { domain: { id: this.domainId }, name: envVarKey, active: true }
|
70
|
+
});
|
71
|
+
if (envVar) {
|
72
|
+
return envVar.value;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
// 3. useDomainAttribute가 false인 경우 기본값 반환
|
76
|
+
return defaultValue;
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* Gets all parameters with resolved values (params + Domain attributes).
|
80
|
+
*
|
81
|
+
* @returns Object with all resolved parameter values
|
82
|
+
*/
|
83
|
+
async getResolvedParameters() {
|
84
|
+
const resolved = {};
|
85
|
+
const connector = engine_1.ConnectionManager.getConnector(this.type);
|
86
|
+
const paramSpecs = connector?.parameterSpec || [];
|
87
|
+
for (const spec of paramSpecs) {
|
88
|
+
const key = spec.name;
|
89
|
+
resolved[key] = await this.getParameter(key);
|
90
|
+
}
|
91
|
+
return resolved;
|
92
|
+
}
|
93
|
+
};
|
94
|
+
exports.Connection = Connection;
|
95
|
+
tslib_1.__decorate([
|
96
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
97
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the connection.' }),
|
98
|
+
tslib_1.__metadata("design:type", String)
|
99
|
+
], Connection.prototype, "id", void 0);
|
100
|
+
tslib_1.__decorate([
|
101
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
102
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain to which this connection belongs.' }),
|
103
|
+
tslib_1.__metadata("design:type", shell_1.Domain
|
104
|
+
/**
|
105
|
+
* Stores the ID of the associated Domain.
|
106
|
+
*/
|
107
|
+
)
|
108
|
+
], Connection.prototype, "domain", void 0);
|
109
|
+
tslib_1.__decorate([
|
110
|
+
(0, typeorm_1.RelationId)((connection) => connection.domain),
|
111
|
+
tslib_1.__metadata("design:type", String)
|
112
|
+
], Connection.prototype, "domainId", void 0);
|
113
|
+
tslib_1.__decorate([
|
114
|
+
(0, typeorm_1.Column)(),
|
115
|
+
(0, type_graphql_1.Field)({ description: 'The name of the connection.' }),
|
116
|
+
tslib_1.__metadata("design:type", String)
|
117
|
+
], Connection.prototype, "name", void 0);
|
118
|
+
tslib_1.__decorate([
|
119
|
+
(0, typeorm_1.Column)({
|
120
|
+
nullable: true
|
121
|
+
}),
|
122
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'A detailed description of the connection.' }),
|
123
|
+
tslib_1.__metadata("design:type", String)
|
124
|
+
], Connection.prototype, "description", void 0);
|
125
|
+
tslib_1.__decorate([
|
126
|
+
(0, typeorm_1.Column)(),
|
127
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The type of the connection (e.g., tcp, http, mqtt).' }),
|
128
|
+
tslib_1.__metadata("design:type", String)
|
129
|
+
], Connection.prototype, "type", void 0);
|
130
|
+
tslib_1.__decorate([
|
131
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.Appliance, { nullable: true }),
|
132
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The edge appliance that delegates this connection, if any.' }),
|
133
|
+
tslib_1.__metadata("design:type", auth_base_1.Appliance
|
134
|
+
/**
|
135
|
+
* Stores the ID of the Appliance who delegate the connection.
|
136
|
+
*/
|
137
|
+
)
|
138
|
+
], Connection.prototype, "edge", void 0);
|
139
|
+
tslib_1.__decorate([
|
140
|
+
(0, typeorm_1.RelationId)((connection) => connection.edge),
|
141
|
+
tslib_1.__metadata("design:type", String)
|
142
|
+
], Connection.prototype, "edgeId", void 0);
|
143
|
+
tslib_1.__decorate([
|
144
|
+
(0, typeorm_1.Column)(),
|
145
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The endpoint URL or address for the connection.' }),
|
146
|
+
tslib_1.__metadata("design:type", String)
|
147
|
+
], Connection.prototype, "endpoint", void 0);
|
148
|
+
tslib_1.__decorate([
|
149
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
150
|
+
(0, type_graphql_1.Field)({
|
151
|
+
nullable: true,
|
152
|
+
description: 'Whether to automatically connect when the application starts'
|
153
|
+
}),
|
154
|
+
tslib_1.__metadata("design:type", Boolean)
|
155
|
+
], Connection.prototype, "active", void 0);
|
156
|
+
tslib_1.__decorate([
|
157
|
+
(0, typeorm_1.Column)({ default: false }),
|
158
|
+
(0, type_graphql_1.Field)({
|
159
|
+
nullable: true,
|
160
|
+
description: 'When true, connection is created on-demand when needed and cleaned up after use.'
|
161
|
+
}),
|
162
|
+
tslib_1.__metadata("design:type", Boolean)
|
163
|
+
], Connection.prototype, "onDemand", void 0);
|
164
|
+
tslib_1.__decorate([
|
165
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The current status of the connection (e.g., CONNECTED, DISCONNECTED).' }),
|
166
|
+
tslib_1.__metadata("design:type", String)
|
167
|
+
], Connection.prototype, "state", void 0);
|
168
|
+
tslib_1.__decorate([
|
169
|
+
(0, typeorm_1.Column)({
|
170
|
+
type: DATABASE_TYPE == 'postgres' ? 'varchar' : 'simple-json',
|
171
|
+
nullable: true,
|
172
|
+
transformer: DATABASE_TYPE == 'postgres'
|
173
|
+
? {
|
174
|
+
to: (value) => JSON.stringify(value),
|
175
|
+
from: (value) => {
|
176
|
+
try {
|
177
|
+
return JSON.parse(value);
|
178
|
+
}
|
179
|
+
catch (error) {
|
180
|
+
return null;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
: undefined
|
185
|
+
}),
|
186
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'A key-value map of parameters for the connection.' }),
|
187
|
+
tslib_1.__metadata("design:type", Object)
|
188
|
+
], Connection.prototype, "params", void 0);
|
189
|
+
tslib_1.__decorate([
|
190
|
+
(0, typeorm_1.CreateDateColumn)(),
|
191
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the connection was created.' }),
|
192
|
+
tslib_1.__metadata("design:type", Date
|
193
|
+
/**
|
194
|
+
* The date and time when the connection was last updated.
|
195
|
+
*/
|
196
|
+
)
|
197
|
+
], Connection.prototype, "createdAt", void 0);
|
198
|
+
tslib_1.__decorate([
|
199
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
200
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the connection was last updated.' }),
|
201
|
+
tslib_1.__metadata("design:type", Date
|
202
|
+
/**
|
203
|
+
* Many-to-One relationship with the User entity who created the connection. Optional field.
|
204
|
+
*/
|
205
|
+
)
|
206
|
+
], Connection.prototype, "updatedAt", void 0);
|
207
|
+
tslib_1.__decorate([
|
208
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
209
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The user who created the connection.' }),
|
210
|
+
tslib_1.__metadata("design:type", auth_base_1.User
|
211
|
+
/**
|
212
|
+
* Stores the ID of the User who created the connection.
|
213
|
+
*/
|
214
|
+
)
|
215
|
+
], Connection.prototype, "creator", void 0);
|
216
|
+
tslib_1.__decorate([
|
217
|
+
(0, typeorm_1.RelationId)((connection) => connection.creator),
|
218
|
+
tslib_1.__metadata("design:type", String)
|
219
|
+
], Connection.prototype, "creatorId", void 0);
|
220
|
+
tslib_1.__decorate([
|
221
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
222
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The user who last updated the connection.' }),
|
223
|
+
tslib_1.__metadata("design:type", auth_base_1.User
|
224
|
+
/**
|
225
|
+
* Stores the ID of the User who last updated the connection.
|
226
|
+
*
|
227
|
+
*/
|
228
|
+
)
|
229
|
+
], Connection.prototype, "updater", void 0);
|
230
|
+
tslib_1.__decorate([
|
231
|
+
(0, typeorm_1.RelationId)((connection) => connection.updater),
|
232
|
+
tslib_1.__metadata("design:type", String)
|
233
|
+
], Connection.prototype, "updaterId", void 0);
|
234
|
+
exports.Connection = Connection = tslib_1.__decorate([
|
235
|
+
(0, typeorm_1.Entity)(),
|
236
|
+
(0, typeorm_1.Index)('ix_connection_0', (connection) => [connection.domain, connection.name], { unique: true }),
|
237
|
+
(0, type_graphql_1.ObjectType)({ description: 'Represents a configured connection to an external system or service.' })
|
238
|
+
], Connection);
|
239
|
+
//# sourceMappingURL=connection.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../server/service/connection/connection.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCASgB;AAEhB,yDAA2D;AAC3D,6CAA4C;AAC5C,iDAA2G;AAE3G,yCAAgD;AAChD,4EAAuE;AAEvE,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA,CAAC,kDAAkD;AAClF,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kDAAkD;CAChE,CAAC,CAAA;AAKK,IAAM,UAAU,GAAhB,MAAM,UAAU;IA4KrB;;;OAGG;IACH,KAAK,CAAC,OAAO;QAC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AAI,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;sCACnF,IAAI;IAEf;;OAEG;;6CAJY;AAOf;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;sCACtE,gBAAI;IAEb;;OAEG;;2CAJU;AAMb;IADC,IAAA,oBAAU,EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;6CAC1C;AAQjB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;sCAC3E,gBAAI;IAEb;;;OAGG;;2CALU;AAOb;IADC,IAAA,oBAAU,EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;6CAC1C;qBA1KN,UAAU;IAHtB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5G,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sEAAsE,EAAE,CAAC;GACvF,UAAU,CA2PtB","sourcesContent":["import { Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User, Appliance } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain, EnvVar, ScalarObject, encryptJsonTransformer, getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\nimport { ProxyConnector } from '../../engine/connector/proxy-connector'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED', // Represents an active, established connection.\n DISCONNECTED = 'DISCONNECTED' // Represents a terminated or inactive connection.\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'Enumeration of possible states for a connection.'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType({ description: 'Represents a configured connection to an external system or service.' })\nexport class Connection {\n /**\n * Unique identifier for the connection, generated in UUID format.\n */\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the connection.' })\n readonly id: string\n\n /**\n * Many-to-One relationship with the Domain entity.\n */\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain to which this connection belongs.' })\n domain: Domain\n\n /**\n * Stores the ID of the associated Domain.\n */\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n /**\n * The name of the connection.\n */\n @Column()\n @Field({ description: 'The name of the connection.' })\n name: string\n\n /**\n * Optional description for the connection.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true, description: 'A detailed description of the connection.' })\n description: string\n\n /**\n * The type of the connection.\n */\n @Column()\n @Field({ nullable: true, description: 'The type of the connection (e.g., tcp, http, mqtt).' })\n type: string\n\n /**\n * Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.\n */\n @ManyToOne(type => Appliance, { nullable: true })\n @Field({ nullable: true, description: 'The edge appliance that delegates this connection, if any.' })\n edge: Appliance\n\n /**\n * Stores the ID of the Appliance who delegate the connection.\n */\n @RelationId((connection: Connection) => connection.edge)\n edgeId: string\n\n /**\n * The endpoint for the connection.\n */\n @Column()\n @Field({ nullable: true, description: 'The endpoint URL or address for the connection.' })\n endpoint: string\n\n /**\n * Whether to automatically connect when the application starts\n */\n @Column({ nullable: true })\n @Field({\n nullable: true,\n description: 'Whether to automatically connect when the application starts'\n })\n active: boolean\n\n /**\n * Indicates whether the connection should be created on-demand when needed.\n */\n @Column({ default: false })\n @Field({\n nullable: true,\n description: 'When true, connection is created on-demand when needed and cleaned up after use.'\n })\n onDemand: boolean\n\n /**\n * The status of the connection, using the ConnectionStatus type.\n */\n @Field({ nullable: true, description: 'The current status of the connection (e.g., CONNECTED, DISCONNECTED).' })\n state: ConnectionStatus\n\n /**\n * Additional parameters for the connection, stored as a JSON string.\n *\n * [Caution]\n * 이 컬럼타입은 postgres 데이터베이스에서는 varchar 타입을 유지한다.\n * 이는 데이터베이스 타입을 변경하면 기존 데이터가 손실될 수 있기 때문이다.\n */\n // TODO: 암호화 처리가 필요하면, 이렇게 설정을 변경하라.\n // @Column({\n // type:\n // DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n // ? 'longtext'\n // : DATABASE_TYPE == 'oracle'\n // ? 'clob'\n // : DATABASE_TYPE == 'mssql'\n // ? 'nvarchar'\n // : 'varchar', // PostgreSQL, SQLite\n // length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined,\n // transformer: encryptJsonTransformer\n // })\n @Column({\n type: DATABASE_TYPE == 'postgres' ? 'varchar' : 'simple-json',\n nullable: true,\n transformer:\n DATABASE_TYPE == 'postgres'\n ? {\n to: (value: any) => JSON.stringify(value),\n from: (value: string) => {\n try {\n return JSON.parse(value)\n } catch (error) {\n return null\n }\n }\n }\n : undefined\n })\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the connection.' })\n params: { [key: string]: any }\n\n /**\n * The date and time when the connection was created.\n */\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the connection was created.' })\n createdAt: Date\n\n /**\n * The date and time when the connection was last updated.\n */\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the connection was last updated.' })\n updatedAt: Date\n\n /**\n * Many-to-One relationship with the User entity who created the connection. Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who created the connection.' })\n creator: User\n\n /**\n * Stores the ID of the User who created the connection.\n */\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n /**\n * Many-to-One relationship with the User entity who last updated the connection.\n * Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who last updated the connection.' })\n updater: User\n\n /**\n * Stores the ID of the User who last updated the connection.\n *\n */\n @RelationId((connection: Connection) => connection.updater)\n updaterId: string\n\n /**\n * Asynchronous method to establish the connection.\n *\n */\n async connect() {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n\n await connector.connect({\n ...this,\n params: await this.getResolvedParameters() // 🔐 해결된 파라미터 사용\n })\n }\n\n /**\n * @brief Asynchronous method to disconnect the connection.\n *\n */\n async disconnect() {\n try {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n await connector.disconnect(this)\n } finally {\n }\n }\n\n /**\n * Gets a parameter value with fallback to EnvVar.\n * Priority: params → EnvVar (only for useDomainAttribute=true)\n *\n * @param key - The parameter key\n * @param defaultValue - Optional default value\n * @returns The parameter value or default value\n */\n async getParameter(key: string, defaultValue?: any): Promise<any> {\n // 1. params에서 직접 값 확인 (null/undefined가 아닌 경우)\n if (this.params?.[key] !== null && this.params?.[key] !== undefined && this.params?.[key] !== '') {\n return this.params[key]\n }\n\n // 2. useDomainAttribute가 true인 경우에만 EnvVar에서 조회\n const connector = ConnectionManager.getConnector(this.type)\n const paramSpec = connector?.parameterSpec?.find(spec => spec.name === key)\n\n if (paramSpec?.useDomainAttribute) {\n const envVarKey = `Connection::${this.name}::${key}`\n const envVarRepository = getRepository<EnvVar>(EnvVar)\n const envVar = await envVarRepository.findOne({\n where: { domain: { id: this.domainId }, name: envVarKey, active: true }\n })\n\n if (envVar) {\n return envVar.value\n }\n }\n\n // 3. useDomainAttribute가 false인 경우 기본값 반환\n return defaultValue\n }\n\n /**\n * Gets all parameters with resolved values (params + Domain attributes).\n *\n * @returns Object with all resolved parameter values\n */\n async getResolvedParameters(): Promise<{ [key: string]: any }> {\n const resolved = {}\n\n const connector = ConnectionManager.getConnector(this.type)\n const paramSpecs = connector?.parameterSpec || []\n\n for (const spec of paramSpecs) {\n const key = spec.name\n resolved[key] = await this.getParameter(key)\n }\n\n return resolved\n }\n}\n"]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Connection } from './connection
|
1
|
+
import { Connection } from './connection';
|
2
2
|
import { ConnectionQuery } from './connection-query';
|
3
3
|
import { ConnectionMutation } from './connection-mutation';
|
4
4
|
import { ConnectionSubscription } from './connection-subscription';
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.resolvers = exports.entities = void 0;
|
4
|
-
const
|
4
|
+
const connection_1 = require("./connection");
|
5
5
|
const connection_query_1 = require("./connection-query");
|
6
6
|
const connection_mutation_1 = require("./connection-mutation");
|
7
7
|
const connection_subscription_1 = require("./connection-subscription");
|
8
|
-
exports.entities = [
|
8
|
+
exports.entities = [connection_1.Connection];
|
9
9
|
exports.resolvers = [connection_query_1.ConnectionQuery, connection_mutation_1.ConnectionMutation, connection_subscription_1.ConnectionSubscription];
|
10
10
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/connection/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/connection/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,yDAAoD;AACpD,+DAA0D;AAC1D,uEAAkE;AAErD,QAAA,QAAQ,GAAG,CAAC,uBAAU,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,CAAC,kCAAe,EAAE,wCAAkB,EAAE,gDAAsB,CAAC,CAAA","sourcesContent":["import { Connection } from './connection'\nimport { ConnectionQuery } from './connection-query'\nimport { ConnectionMutation } from './connection-mutation'\nimport { ConnectionSubscription } from './connection-subscription'\n\nexport const entities = [Connection]\nexport const resolvers = [ConnectionQuery, ConnectionMutation, ConnectionSubscription]\n"]}
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
7
7
|
const connection_manager_1 = require("../../engine/connection-manager");
|
8
|
-
const
|
8
|
+
const connection_1 = require("../connection/connection");
|
9
9
|
const connector_type_1 = require("./connector-type");
|
10
10
|
/**
|
11
11
|
* @description Provides GraphQL resolvers for connector types.
|
@@ -45,7 +45,7 @@ let ConnectorQuery = class ConnectorQuery {
|
|
45
45
|
}
|
46
46
|
async connectorByConnection(connectionName, context) {
|
47
47
|
const { domain } = context.state;
|
48
|
-
var connection = await (0, shell_1.getRepository)(
|
48
|
+
var connection = await (0, shell_1.getRepository)(connection_1.Connection).findOne({
|
49
49
|
where: { domain: { id: domain.id }, name: connectionName }
|
50
50
|
});
|
51
51
|
return connection && connection_manager_1.ConnectionManager.getConnector(connection.type);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connector-query.js","sourceRoot":"","sources":["../../../server/service/connector/connector-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwD;AAExD,iDAAqD;AAErD,wEAAmE;AACnE,
|
1
|
+
{"version":3,"file":"connector-query.js","sourceRoot":"","sources":["../../../server/service/connector/connector-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwD;AAExD,iDAAqD;AAErD,wEAAmE;AACnE,yDAAqD;AACrD,qDAA+D;AAE/D;;GAEG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAEnB,AAAN,KAAK,CAAC,SAAS,CAAc,IAAY,EAAS,OAAwB;QACxE,aAAa;Q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AAE,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;SAC3D,CAAC,CAAA;QAEF,OAAO,UAAU,IAAK,sCAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAS,CAAA;IAC/E,CAAC;CACF,CAAA;AApDY,wCAAc;AAEnB;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IAChF,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CAWhD;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;;;;gDAsBpG;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,mEAAmE,EAAE,CAAC;IAEnH,mBAAA,IAAA,kBAAG,EAAC,gBAAgB,CAAC,CAAA;IACrB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DASP;yBAnDU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,cAAc,CAoD1B","sourcesContent":["import { Arg, Ctx, Query, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection } from '../connection/connection'\nimport { ConnectorList, ConnectorType } from './connector-type'\n\n/**\n * @description Provides GraphQL resolvers for connector types.\n */\n@Resolver(ConnectorType)\nexport class ConnectorQuery {\n @Query(returns => ConnectorType, { description: 'Fetches a single connector type by its name.' })\n async connector(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<ConnectorType> {\n // @ts-ignore\n const { description, help, parameterSpec, taskPrefixes } = ConnectionManager.getConnector(name) || {}\n\n return {\n name,\n description,\n help,\n parameterSpec,\n taskPrefixes: taskPrefixes || []\n }\n }\n\n @Query(returns => ConnectorList, { description: 'Fetches a list of all available connector types.' })\n async connectors(): Promise<ConnectorList> {\n var connectors = ConnectionManager.getConnectors()\n var items = Object.keys(connectors)\n .map(name => {\n var connector = connectors[name]\n return {\n name,\n description: connector.description,\n help: connector.help,\n parameterSpec: connector.parameterSpec,\n taskPrefixes: connector.taskPrefixes || []\n }\n })\n .sort((x, y) => {\n return x.name < y.name ? -1 : 1\n })\n\n return {\n items,\n total: items.length\n }\n }\n\n @Query(returns => ConnectorType, { description: 'Fetches the connector type associated with a specific connection.' })\n async connectorByConnection(\n @Arg('connectionName') connectionName: string,\n @Ctx() context: ResolverContext\n ): Promise<ConnectorType> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name: connectionName }\n })\n\n return connection && (ConnectionManager.getConnector(connection.type) as any)\n }\n}\n"]}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export * from './property-spec';
|
2
2
|
export * from './task-type/task-type-type';
|
3
3
|
export * from './connector/connector-type';
|
4
|
+
export * from './connection/connection';
|
4
5
|
export * from './connection/connection-type';
|
5
6
|
export * from './scenario/scenario';
|
6
7
|
export * from './scenario-instance/scenario-instance-type';
|
@@ -15,6 +15,7 @@ const analysis_1 = require("./analysis");
|
|
15
15
|
tslib_1.__exportStar(require("./property-spec"), exports);
|
16
16
|
tslib_1.__exportStar(require("./task-type/task-type-type"), exports);
|
17
17
|
tslib_1.__exportStar(require("./connector/connector-type"), exports);
|
18
|
+
tslib_1.__exportStar(require("./connection/connection"), exports);
|
18
19
|
tslib_1.__exportStar(require("./connection/connection-type"), exports);
|
19
20
|
tslib_1.__exportStar(require("./scenario/scenario"), exports);
|
20
21
|
tslib_1.__exportStar(require("./scenario-instance/scenario-instance-type"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA+F;AAC/F,2CAA4F;AAC5F,yCAAyF;AACzF,2DAAkH;AAClH,qDAAyG;AACzG,iCAA6E;AAC7E,2CAA0F;AAC1F,+CAAgG;AAChG,qDAAyG;AACzG,yCAAkE;AAElE,0DAA+B;AAC/B,qEAA0C;AAC1C,qEAA0C;AAC1C,uEAA4C;AAC5C,8DAAmC;AACnC,qFAA0D;AAC1D,+EAAoD;AACpD,2DAAgC;AAChC,wEAA6C;AAC7C,oEAAyC;AACzC,0EAA+C;AAElC,QAAA,QAAQ,GAAG;IACtB,GAAG,oBAAgB;IACnB,GAAG,oBAAiB;IACpB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,4BAAwB;IAC3B,GAAG,yBAAqB;IACxB,GAAG,eAAY;IACf,GAAG,sBAAkB;IACrB,GAAG,yBAAqB;CACzB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,GAAG,qBAAiB;QACpB,GAAG,qBAAkB;QACrB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,6BAAyB;QAC5B,GAAG,0BAAsB;QACzB,GAAG,gBAAa;QAChB,GAAG,uBAAmB;QACtB,GAAG,oBAAwB;QAC3B,GAAG,0BAAsB;KAC1B;CACF,CAAA;AAED,yDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,2EAAqE;AAA5D,wHAAA,gBAAgB,OAAA","sourcesContent":["import { entities as ConnectionEntities, resolvers as ConnectionResolvers } from './connection'\nimport { entities as ConnectorEntities, resolvers as ConnectorResolvers } from './connector'\nimport { entities as ScenarioEntities, resolvers as ScenarioResolvers } from './scenario'\nimport { entities as ScenarioInstanceEntities, resolvers as ScenarioInstanceResolvers } from './scenario-instance'\nimport { entities as ScenarioQueueEntities, resolvers as ScenarioQueueResolvers } from './scenario-queue'\nimport { entities as StepEntities, resolvers as StepResolvers } from './step'\nimport { entities as TaskTypeEntities, resolvers as TaskTypeResolvers } from './task-type'\nimport { entities as PayloadLogEntities, resolvers as PayloadLogResolvers } from './payload-log'\nimport { entities as StateRegisterEntities, resolvers as StateRegisterResolvers } from './state-register'\nimport { resolvers as IntegrationAnalysisQuery } from './analysis'\n\nexport * from './property-spec'\nexport * from './task-type/task-type-type'\nexport * from './connector/connector-type'\nexport * from './connection/connection-type'\nexport * from './scenario/scenario'\nexport * from './scenario-instance/scenario-instance-type'\nexport * from './scenario-queue/scenario-queue-type'\nexport * from './step/step-type'\nexport * from './scenario-flow/scenario-flow'\nexport * from './payload-log/payload-log'\nexport * from './state-register/state-register'\n\nexport const entities = [\n ...TaskTypeEntities,\n ...ConnectorEntities,\n ...ConnectionEntities,\n ...ScenarioEntities,\n ...ScenarioInstanceEntities,\n ...ScenarioQueueEntities,\n ...StepEntities,\n ...PayloadLogEntities,\n ...StateRegisterEntities\n]\n\nexport const schema = {\n resolverClasses: [\n ...TaskTypeResolvers,\n ...ConnectorResolvers,\n ...ConnectionResolvers,\n ...ScenarioResolvers,\n ...ScenarioInstanceResolvers,\n ...ScenarioQueueResolvers,\n ...StepResolvers,\n ...PayloadLogResolvers,\n ...IntegrationAnalysisQuery,\n ...StateRegisterResolvers\n ]\n}\n\nexport { PayloadType } from './payload-log/payload-log'\nexport { createPayloadLog } from './payload-log/payload-log-mutation'\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA+F;AAC/F,2CAA4F;AAC5F,yCAAyF;AACzF,2DAAkH;AAClH,qDAAyG;AACzG,iCAA6E;AAC7E,2CAA0F;AAC1F,+CAAgG;AAChG,qDAAyG;AACzG,yCAAkE;AAElE,0DAA+B;AAC/B,qEAA0C;AAC1C,qEAA0C;AAC1C,kEAAuC;AACvC,uEAA4C;AAC5C,8DAAmC;AACnC,qFAA0D;AAC1D,+EAAoD;AACpD,2DAAgC;AAChC,wEAA6C;AAC7C,oEAAyC;AACzC,0EAA+C;AAElC,QAAA,QAAQ,GAAG;IACtB,GAAG,oBAAgB;IACnB,GAAG,oBAAiB;IACpB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,4BAAwB;IAC3B,GAAG,yBAAqB;IACxB,GAAG,eAAY;IACf,GAAG,sBAAkB;IACrB,GAAG,yBAAqB;CACzB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,GAAG,qBAAiB;QACpB,GAAG,qBAAkB;QACrB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,6BAAyB;QAC5B,GAAG,0BAAsB;QACzB,GAAG,gBAAa;QAChB,GAAG,uBAAmB;QACtB,GAAG,oBAAwB;QAC3B,GAAG,0BAAsB;KAC1B;CACF,CAAA;AAED,yDAAuD;AAA9C,0GAAA,WAAW,OAAA;AACpB,2EAAqE;AAA5D,wHAAA,gBAAgB,OAAA","sourcesContent":["import { entities as ConnectionEntities, resolvers as ConnectionResolvers } from './connection'\nimport { entities as ConnectorEntities, resolvers as ConnectorResolvers } from './connector'\nimport { entities as ScenarioEntities, resolvers as ScenarioResolvers } from './scenario'\nimport { entities as ScenarioInstanceEntities, resolvers as ScenarioInstanceResolvers } from './scenario-instance'\nimport { entities as ScenarioQueueEntities, resolvers as ScenarioQueueResolvers } from './scenario-queue'\nimport { entities as StepEntities, resolvers as StepResolvers } from './step'\nimport { entities as TaskTypeEntities, resolvers as TaskTypeResolvers } from './task-type'\nimport { entities as PayloadLogEntities, resolvers as PayloadLogResolvers } from './payload-log'\nimport { entities as StateRegisterEntities, resolvers as StateRegisterResolvers } from './state-register'\nimport { resolvers as IntegrationAnalysisQuery } from './analysis'\n\nexport * from './property-spec'\nexport * from './task-type/task-type-type'\nexport * from './connector/connector-type'\nexport * from './connection/connection'\nexport * from './connection/connection-type'\nexport * from './scenario/scenario'\nexport * from './scenario-instance/scenario-instance-type'\nexport * from './scenario-queue/scenario-queue-type'\nexport * from './step/step-type'\nexport * from './scenario-flow/scenario-flow'\nexport * from './payload-log/payload-log'\nexport * from './state-register/state-register'\n\nexport const entities = [\n ...TaskTypeEntities,\n ...ConnectorEntities,\n ...ConnectionEntities,\n ...ScenarioEntities,\n ...ScenarioInstanceEntities,\n ...ScenarioQueueEntities,\n ...StepEntities,\n ...PayloadLogEntities,\n ...StateRegisterEntities\n]\n\nexport const schema = {\n resolverClasses: [\n ...TaskTypeResolvers,\n ...ConnectorResolvers,\n ...ConnectionResolvers,\n ...ScenarioResolvers,\n ...ScenarioInstanceResolvers,\n ...ScenarioQueueResolvers,\n ...StepResolvers,\n ...PayloadLogResolvers,\n ...IntegrationAnalysisQuery,\n ...StateRegisterResolvers\n ]\n}\n\nexport { PayloadType } from './payload-log/payload-log'\nexport { createPayloadLog } from './payload-log/payload-log-mutation'\n"]}
|
@@ -8,7 +8,7 @@ let PropertySpec = class PropertySpec {
|
|
8
8
|
};
|
9
9
|
exports.PropertySpec = PropertySpec;
|
10
10
|
tslib_1.__decorate([
|
11
|
-
(0, type_graphql_1.Field)({ description: 'The data type of the property (e.g., text, number, boolean, select).' }),
|
11
|
+
(0, type_graphql_1.Field)({ description: 'The data type of the property (e.g., text, number, boolean, select, password).' }),
|
12
12
|
tslib_1.__metadata("design:type", String)
|
13
13
|
], PropertySpec.prototype, "type", void 0);
|
14
14
|
tslib_1.__decorate([
|
@@ -34,6 +34,13 @@ tslib_1.__decorate([
|
|
34
34
|
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'CSS styles to be applied to the input field.' }),
|
35
35
|
tslib_1.__metadata("design:type", Object)
|
36
36
|
], PropertySpec.prototype, "styles", void 0);
|
37
|
+
tslib_1.__decorate([
|
38
|
+
(0, type_graphql_1.Field)({
|
39
|
+
nullable: true,
|
40
|
+
description: 'Whether this property should use Domain attributes for secure storage instead of direct params.'
|
41
|
+
}),
|
42
|
+
tslib_1.__metadata("design:type", Boolean)
|
43
|
+
], PropertySpec.prototype, "useDomainAttribute", void 0);
|
37
44
|
exports.PropertySpec = PropertySpec = tslib_1.__decorate([
|
38
45
|
(0, type_graphql_1.ObjectType)({
|
39
46
|
description: 'Describes a single property for a component or a step, used for UI rendering and configuration.'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"property-spec.js","sourceRoot":"","sources":["../../server/service/property-spec.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAEhD,iDAAoD;AAK7C,IAAM,YAAY,GAAlB,MAAM,YAAY;
|
1
|
+
{"version":3,"file":"property-spec.js","sourceRoot":"","sources":["../../server/service/property-spec.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAEhD,iDAAoD;AAK7C,IAAM,YAAY,GAAlB,MAAM,YAAY;CA2BxB,CAAA;AA3BY,oCAAY;AAEvB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,gFAAgF,EAAE,CAAC;;0CAC7F;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,yDAAyD,EAAE,CAAC;;2CACrE;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,qEAAqE,EAAE,CAAC;;0CAClF;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;iDAC5D;AAMpB;IAJC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,0EAA0E;KACxF,CAAC;;8CAC+B;AAGjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;;4CAC9E;AAM/B;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,iGAAiG;KAC/G,CAAC;;wDAC0B;uBA1BjB,YAAY;IAHxB,IAAA,yBAAU,EAAC;QACV,WAAW,EAAE,iGAAiG;KAC/G,CAAC;GACW,YAAY,CA2BxB","sourcesContent":["import { Field, ObjectType } from 'type-graphql'\n\nimport { ScalarObject } from '@things-factory/shell'\n\n@ObjectType({\n description: 'Describes a single property for a component or a step, used for UI rendering and configuration.'\n})\nexport class PropertySpec {\n @Field({ description: 'The data type of the property (e.g., text, number, boolean, select, password).' })\n type: string\n\n @Field({ description: 'The human-readable label for the property, shown in UI.' })\n label: string\n\n @Field({ description: 'The name of the property, used as the key in configuration objects.' })\n name: string\n\n @Field({ nullable: true, description: 'Placeholder text for the input field.' })\n placeholder?: string\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'Additional properties specific to the type (e.g., options for a select).'\n })\n property?: { [key: string]: any }\n\n @Field(type => ScalarObject, { nullable: true, description: 'CSS styles to be applied to the input field.' })\n styles?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'Whether this property should use Domain attributes for secure storage instead of direct params.'\n })\n useDomainAttribute?: boolean\n}\n"]}
|
@@ -167,7 +167,7 @@ let ScenarioMutation = class ScenarioMutation {
|
|
167
167
|
name: scenario.name + ' (' + scenarioId + ')',
|
168
168
|
type: scenario.type,
|
169
169
|
description: scenario.description,
|
170
|
-
active: false,
|
170
|
+
active: false,
|
171
171
|
schedule: scenario.schedule,
|
172
172
|
timezone: scenario.timezone,
|
173
173
|
domain,
|
@@ -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;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,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GAAiG;KAC/G,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDA4DP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE,EAAE,WAAW,EAAE,iEAAiE,EAAE,CAAC;IAE/G,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6DA0EP;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;IAE3F,mBAAA,IAAA,kBAAG,EAAC,YAAY,CAAC,CAAA;IACjB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DA2BP;2BA3XU,gBAAgB;IAD5B,IAAA,uBAAQ,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"]}
|
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,EAA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A,kBAAG,GAAE,CAAA;;;;4DA2BP;2BA3XU,gBAAgB;IAD5B,IAAA,uBAAQ,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,\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"]}
|
@@ -11,7 +11,7 @@ const scenario_instance_type_1 = require("../scenario-instance/scenario-instance
|
|
11
11
|
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
|
-
const
|
14
|
+
const connection_1 = require("../connection/connection");
|
15
15
|
/**
|
16
16
|
* @description Provides GraphQL resolvers for the Scenario entity.
|
17
17
|
*/
|
@@ -125,7 +125,7 @@ tslib_1.__decorate([
|
|
125
125
|
tslib_1.__metadata("design:returntype", Promise)
|
126
126
|
], ScenarioQuery.prototype, "steps", null);
|
127
127
|
tslib_1.__decorate([
|
128
|
-
(0, type_graphql_1.FieldResolver)(type => [
|
128
|
+
(0, type_graphql_1.FieldResolver)(type => [connection_1.Connection]),
|
129
129
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
130
130
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
131
131
|
tslib_1.__metadata("design:type", Function),
|
@@ -133,7 +133,7 @@ tslib_1.__decorate([
|
|
133
133
|
tslib_1.__metadata("design:returntype", Promise)
|
134
134
|
], ScenarioQuery.prototype, "connectionNames", null);
|
135
135
|
tslib_1.__decorate([
|
136
|
-
(0, type_graphql_1.FieldResolver)(type => [
|
136
|
+
(0, type_graphql_1.FieldResolver)(type => [connection_1.Connection]),
|
137
137
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
138
138
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
139
139
|
tslib_1.__metadata("design:type", Function),
|