@fastybird/smart-panel-backend 1.1.0-alpha.2 → 1.1.0-alpha.4
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/common/filters/conflict-exception.filter.d.ts +6 -0
- package/dist/common/filters/conflict-exception.filter.js +59 -0
- package/dist/common/filters/conflict-exception.filter.js.map +1 -0
- package/dist/common/filters/global-error.filter.js +1 -4
- package/dist/common/filters/global-error.filter.js.map +1 -1
- package/dist/common/filters/global-filters.d.ts +3 -0
- package/dist/common/filters/global-filters.js +22 -0
- package/dist/common/filters/global-filters.js.map +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.d.ts +1 -0
- package/dist/common/filters/unprocessable-entity-exception.filter.js +15 -3
- package/dist/common/filters/unprocessable-entity-exception.filter.js.map +1 -1
- package/dist/common/utils/transform.utils.js +3 -0
- package/dist/common/utils/transform.utils.js.map +1 -1
- package/dist/main.js +2 -7
- package/dist/main.js.map +1 -1
- package/dist/modules/platform/services/platform.service.d.ts +13 -4
- package/dist/modules/platform/services/platform.service.js +57 -35
- package/dist/modules/platform/services/platform.service.js.map +1 -1
- package/dist/modules/remote-access/dto/update-config.dto.js +5 -0
- package/dist/modules/remote-access/dto/update-config.dto.js.map +1 -1
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js +5 -2
- package/dist/modules/remote-access/validators/is-remote-access-url.validator.js.map +1 -1
- package/dist/modules/system/services/privileged-worker.service.d.ts +10 -0
- package/dist/modules/system/services/privileged-worker.service.js +137 -11
- package/dist/modules/system/services/privileged-worker.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +2 -0
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +143 -102
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +4 -0
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +18 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js +8 -11
- package/dist/plugins/devices-shelly-ng/devices-shelly-ng.constants.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js +4 -0
- package/dist/plugins/devices-shelly-ng/mappings/mapping-loader.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.d.ts +0 -1
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js +7 -12
- package/dist/plugins/devices-shelly-ng/services/shelly-ws-server.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.d.ts +2 -0
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.js +14 -1
- package/dist/plugins/devices-shelly-ng/utils/transform.utils.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js +26 -10
- package/dist/plugins/remote-access-tailscale/controllers/setup.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.d.ts +6 -1
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js +28 -3
- package/dist/plugins/remote-access-tailscale/controllers/status.controller.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.d.ts +19 -0
- package/dist/plugins/remote-access-tailscale/models/status.model.js +158 -1
- package/dist/plugins/remote-access-tailscale/models/status.model.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.d.ts +13 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js +27 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.exceptions.js.map +1 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.d.ts +2 -2
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js +2 -0
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.openapi.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/remote-access-tailscale.plugin.js +1 -1
- package/dist/plugins/remote-access-tailscale/scripts/tailscale-setup.sh +61 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.d.ts +9 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js +12 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-cli.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.d.ts +1 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js +23 -2
- package/dist/plugins/remote-access-tailscale/services/tailscale-login.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.d.ts +26 -0
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js +245 -29
- package/dist/plugins/remote-access-tailscale/services/tailscale-node-managed.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.d.ts +8 -3
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js +39 -12
- package/dist/plugins/remote-access-tailscale/services/tailscale-serve.service.js.map +1 -1
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.d.ts +14 -5
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js +51 -16
- package/dist/plugins/remote-access-tailscale/services/tailscale-setup.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -20,6 +20,10 @@ const system_constants_1 = require("../system.constants");
|
|
|
20
20
|
const system_exceptions_1 = require("../system.exceptions");
|
|
21
21
|
const STATUS_POLL_INTERVAL_MS = 3_000;
|
|
22
22
|
const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
23
|
+
const STDERR_CAPTURE_LIMIT_BYTES = 4 * 1024;
|
|
24
|
+
const IS_ACTIVE_PROBE_TIMEOUT_MS = 2_000;
|
|
25
|
+
const STOP_ATTEMPT_TIMEOUT_MS = 15_000;
|
|
26
|
+
const PRUNE_AFTER_MS = 5 * 60_000;
|
|
23
27
|
const VALID_TICK_STATES = new Set(['running', 'complete', 'failed']);
|
|
24
28
|
function isValidTickState(value) {
|
|
25
29
|
return typeof value === 'string' && VALID_TICK_STATES.has(value);
|
|
@@ -40,6 +44,11 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
40
44
|
throw new system_exceptions_1.PrivilegedWorkerUnavailableException(`Privileged workers are not supported on this platform (${this.platformService.getPlatformType()}).`);
|
|
41
45
|
}
|
|
42
46
|
if (this.busyUnits.has(spec.unit)) {
|
|
47
|
+
const busyJobId = this.busyUnits.get(spec.unit);
|
|
48
|
+
const busyRecord = busyJobId ? this.jobs.get(busyJobId) : undefined;
|
|
49
|
+
if (busyRecord?.lastStatus.state === 'timeout') {
|
|
50
|
+
throw new system_exceptions_1.PrivilegedWorkerUnavailableException(`Privileged worker unit "${spec.unit}" timed out previously and is still running after a stop attempt; it cannot be reused until the process is confirmed stopped.`);
|
|
51
|
+
}
|
|
43
52
|
throw new system_exceptions_1.PrivilegedWorkerUnavailableException(`Privileged worker unit "${spec.unit}" is already busy.`);
|
|
44
53
|
}
|
|
45
54
|
const id = (0, node_crypto_1.randomUUID)();
|
|
@@ -54,22 +63,34 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
54
63
|
lastStatus: { id, state: 'running', updatedAt: new Date().toISOString() },
|
|
55
64
|
handlers: new Set(),
|
|
56
65
|
mapStatus: spec.mapStatus,
|
|
66
|
+
redact: spec.redact,
|
|
67
|
+
stderrBuffer: Buffer.alloc(0),
|
|
57
68
|
loggedInvalidStatus: false,
|
|
69
|
+
pruneTimer: null,
|
|
58
70
|
};
|
|
59
71
|
this.jobs.set(id, record);
|
|
60
72
|
this.busyUnits.set(spec.unit, id);
|
|
61
73
|
try {
|
|
62
74
|
const setenvArgs = Object.entries(spec.env ?? {}).flatMap(([key, value]) => ['--setenv', `${key}=${value}`]);
|
|
63
|
-
const child = (0, node_child_process_1.spawn)('sudo', ['-n', 'systemd-run', '--scope', `--unit=${spec.unit}`, ...setenvArgs, 'bash', spec.script, ...spec.args], { detached: true, stdio: 'ignore' });
|
|
75
|
+
const child = (0, node_child_process_1.spawn)('sudo', ['-n', 'systemd-run', '--scope', `--unit=${spec.unit}`, ...setenvArgs, 'bash', spec.script, ...spec.args], { detached: true, stdio: ['ignore', 'ignore', 'pipe'] });
|
|
76
|
+
child.stderr?.unref?.();
|
|
77
|
+
child.stderr?.on('data', (chunk) => {
|
|
78
|
+
if (record.stderrBuffer.length >= STDERR_CAPTURE_LIMIT_BYTES) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
record.stderrBuffer = Buffer.concat([record.stderrBuffer, chunk]).subarray(0, STDERR_CAPTURE_LIMIT_BYTES);
|
|
82
|
+
});
|
|
64
83
|
child.on('error', (error) => {
|
|
65
84
|
if (record.lastStatus.state !== 'running') {
|
|
66
85
|
return;
|
|
67
86
|
}
|
|
68
|
-
|
|
87
|
+
const stderr = this.getCapturedStderr(record);
|
|
88
|
+
this.logger.error(`Privileged worker unit "${spec.unit}" failed to spawn: ${error.message}${stderr ? ` (${stderr})` : ''}`);
|
|
69
89
|
this.finishJob(record, {
|
|
70
90
|
id,
|
|
71
91
|
state: 'failed',
|
|
72
|
-
message: error.message,
|
|
92
|
+
message: this.buildFailureMessage(error.message, stderr),
|
|
93
|
+
stderr,
|
|
73
94
|
updatedAt: new Date().toISOString(),
|
|
74
95
|
});
|
|
75
96
|
});
|
|
@@ -81,11 +102,13 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
81
102
|
return;
|
|
82
103
|
}
|
|
83
104
|
const reason = signal ? `was terminated by signal ${signal}` : `exited with code ${code}`;
|
|
84
|
-
|
|
105
|
+
const stderr = this.getCapturedStderr(record);
|
|
106
|
+
this.logger.error(`Privileged worker unit "${spec.unit}" ${reason} before reporting completion${stderr ? ` (${stderr})` : ''}`);
|
|
85
107
|
this.finishJob(record, {
|
|
86
108
|
id,
|
|
87
109
|
state: 'failed',
|
|
88
|
-
message: `Worker process ${reason}`,
|
|
110
|
+
message: this.buildGenericFailureMessage(`Worker process ${reason} before reporting completion`, stderr),
|
|
111
|
+
stderr,
|
|
89
112
|
updatedAt: new Date().toISOString(),
|
|
90
113
|
});
|
|
91
114
|
});
|
|
@@ -124,11 +147,34 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
124
147
|
record.handlers.delete(handler);
|
|
125
148
|
};
|
|
126
149
|
}
|
|
150
|
+
getCapturedStderr(record) {
|
|
151
|
+
if (record.stderrBuffer.length === 0) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
const text = record.stderrBuffer.toString('utf-8');
|
|
155
|
+
const redact = record.redact;
|
|
156
|
+
if (!redact) {
|
|
157
|
+
return text;
|
|
158
|
+
}
|
|
159
|
+
return text
|
|
160
|
+
.split('\n')
|
|
161
|
+
.map((line) => redact(line))
|
|
162
|
+
.join('\n');
|
|
163
|
+
}
|
|
164
|
+
buildFailureMessage(summary, stderr) {
|
|
165
|
+
const detail = stderr ? ` (${stderr})` : '';
|
|
166
|
+
return `The smart-panel user cannot start privileged jobs: ${summary}${detail}. Re-run \`sudo smart-panel-service install\`, or add the sudoers grant from the installation guide.`;
|
|
167
|
+
}
|
|
168
|
+
buildGenericFailureMessage(summary, stderr) {
|
|
169
|
+
const detail = stderr ? ` (${stderr})` : '';
|
|
170
|
+
return `${summary}${detail}.`;
|
|
171
|
+
}
|
|
127
172
|
startPolling(record) {
|
|
128
173
|
record.pollTimer = setInterval(() => {
|
|
129
174
|
if (Date.now() - record.startedAt > record.timeoutMs) {
|
|
130
|
-
|
|
131
|
-
|
|
175
|
+
clearInterval(record.pollTimer);
|
|
176
|
+
record.pollTimer = null;
|
|
177
|
+
void this.handleTimeout(record);
|
|
132
178
|
return;
|
|
133
179
|
}
|
|
134
180
|
if (!(0, fs_1.existsSync)(record.statusFile)) {
|
|
@@ -157,14 +203,79 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
157
203
|
updatedAt: new Date().toISOString(),
|
|
158
204
|
};
|
|
159
205
|
record.lastStatus = status;
|
|
160
|
-
|
|
161
|
-
handler(status);
|
|
162
|
-
}
|
|
206
|
+
this.notifyHandlers(record, status);
|
|
163
207
|
if (status.state === 'complete' || status.state === 'failed') {
|
|
164
208
|
this.stopPolling(record);
|
|
165
209
|
}
|
|
166
210
|
}, STATUS_POLL_INTERVAL_MS);
|
|
167
211
|
}
|
|
212
|
+
stopUnit(unit) {
|
|
213
|
+
return new Promise((resolve) => {
|
|
214
|
+
let settled = false;
|
|
215
|
+
let timer = null;
|
|
216
|
+
const settle = () => {
|
|
217
|
+
if (settled) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
settled = true;
|
|
221
|
+
if (timer) {
|
|
222
|
+
clearTimeout(timer);
|
|
223
|
+
timer = null;
|
|
224
|
+
}
|
|
225
|
+
resolve();
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
const child = (0, node_child_process_1.spawn)('sudo', ['-n', 'systemd-run', '--scope', '--quiet', `--unit=${unit}-stop`, 'systemctl', 'stop', unit], { stdio: 'ignore' });
|
|
229
|
+
child.on('exit', settle);
|
|
230
|
+
child.on('error', settle);
|
|
231
|
+
timer = setTimeout(settle, STOP_ATTEMPT_TIMEOUT_MS);
|
|
232
|
+
timer.unref();
|
|
233
|
+
child.unref();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
settle();
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
isUnitActive(unit) {
|
|
241
|
+
return new Promise((resolve) => {
|
|
242
|
+
(0, node_child_process_1.execFile)('systemctl', ['is-active', unit], { timeout: IS_ACTIVE_PROBE_TIMEOUT_MS }, (error, stdout) => {
|
|
243
|
+
if (error) {
|
|
244
|
+
resolve(false);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
resolve((stdout ?? '').trim() === 'active');
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
async handleTimeout(record) {
|
|
252
|
+
this.logger.error(`Privileged worker unit "${record.unit}" timed out after ${record.timeoutMs}ms`);
|
|
253
|
+
await this.stopUnit(record.unit);
|
|
254
|
+
const stillActive = await this.isUnitActive(record.unit);
|
|
255
|
+
const stderr = this.getCapturedStderr(record);
|
|
256
|
+
if (record.lastStatus.state !== 'running') {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (stillActive) {
|
|
260
|
+
this.logger.error(`Privileged worker unit "${record.unit}" is still running after a timeout stop attempt; keeping it reserved.`);
|
|
261
|
+
const status = {
|
|
262
|
+
id: record.id,
|
|
263
|
+
state: 'timeout',
|
|
264
|
+
message: `Privileged worker unit "${record.unit}" timed out and is still running after a stop attempt; it remains reserved until confirmed stopped.`,
|
|
265
|
+
stderr,
|
|
266
|
+
updatedAt: new Date().toISOString(),
|
|
267
|
+
};
|
|
268
|
+
record.lastStatus = status;
|
|
269
|
+
this.notifyHandlers(record, status);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.finishJob(record, {
|
|
273
|
+
id: record.id,
|
|
274
|
+
state: 'timeout',
|
|
275
|
+
stderr,
|
|
276
|
+
updatedAt: new Date().toISOString(),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
168
279
|
logInvalidStatusOnce(record, reason) {
|
|
169
280
|
if (record.loggedInvalidStatus) {
|
|
170
281
|
return;
|
|
@@ -177,10 +288,13 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
177
288
|
return;
|
|
178
289
|
}
|
|
179
290
|
record.lastStatus = status;
|
|
291
|
+
this.notifyHandlers(record, status);
|
|
292
|
+
this.stopPolling(record);
|
|
293
|
+
}
|
|
294
|
+
notifyHandlers(record, status) {
|
|
180
295
|
for (const handler of [...record.handlers]) {
|
|
181
296
|
handler(status);
|
|
182
297
|
}
|
|
183
|
-
this.stopPolling(record);
|
|
184
298
|
}
|
|
185
299
|
stopPolling(record) {
|
|
186
300
|
if (record.pollTimer) {
|
|
@@ -189,7 +303,19 @@ let PrivilegedWorkerService = class PrivilegedWorkerService {
|
|
|
189
303
|
}
|
|
190
304
|
if (this.busyUnits.get(record.unit) === record.id) {
|
|
191
305
|
this.busyUnits.delete(record.unit);
|
|
306
|
+
this.schedulePrune(record);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
schedulePrune(record) {
|
|
310
|
+
if (record.pruneTimer) {
|
|
311
|
+
return;
|
|
192
312
|
}
|
|
313
|
+
record.pruneTimer = setTimeout(() => {
|
|
314
|
+
record.pruneTimer = null;
|
|
315
|
+
record.handlers.clear();
|
|
316
|
+
this.jobs.delete(record.id);
|
|
317
|
+
}, PRUNE_AFTER_MS);
|
|
318
|
+
record.pruneTimer.unref();
|
|
193
319
|
}
|
|
194
320
|
};
|
|
195
321
|
exports.PrivilegedWorkerService = PrivilegedWorkerService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privileged-worker.service.js","sourceRoot":"","sources":["../../../../src/modules/system/services/privileged-worker.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA8C;AAC9C,2DAA2C;AAC3C,6CAAyC;AAEzC,2CAA4C;AAE5C,mDAA+D;AAC/D,+EAA2E;AAC3E,0DAAyD;AACzD,4DAA4E;AA2D5E,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAK1C,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1F,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,gBAAgB,CAAC,KAA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tB,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAChC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QACzB,CAAC;QAKD,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACF,CAAC;CACD,CAAA;AA1SY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAOkC,kCAAe;GANjD,uBAAuB,CA0SnC"}
|
|
1
|
+
{"version":3,"file":"privileged-worker.service.js","sourceRoot":"","sources":["../../../../src/modules/system/services/privileged-worker.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA8C;AAC9C,2DAAqD;AACrD,6CAAyC;AAEzC,2CAA4C;AAE5C,mDAA+D;AAC/D,+EAA2E;AAC3E,0DAAyD;AACzD,4DAA4E;AAoF5E,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAG1C,MAAM,0BAA0B,GAAG,CAAC,GAAG,IAAI,CAAC;AAG5C,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEzC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AASvC,MAAM,cAAc,GAAG,CAAC,GAAG,MAAM,CAAC;AAKlC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1F,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,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EAAE,CAAC;YACnD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAMnC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IASO,aAAa,CAAC,MAAiB;QACtC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO;QACR,CAAC;QAED,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE;YACnC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;YACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC,EAAE,cAAc,CAAC,CAAC;QAEnB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACD,CAAA;AAniBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;qCAOkC,kCAAe;GANjD,uBAAuB,CAmiBnC"}
|
|
@@ -58,6 +58,8 @@ export declare class DelegatesManagerService {
|
|
|
58
58
|
private applyTransformer;
|
|
59
59
|
private handleChange;
|
|
60
60
|
private setDefaultPropertyValue;
|
|
61
|
+
private wireElectricalChannels;
|
|
62
|
+
private wireMeterProperty;
|
|
61
63
|
private determineCategory;
|
|
62
64
|
private handleNumericChange;
|
|
63
65
|
private scheduleWrite;
|
|
@@ -199,60 +199,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
199
199
|
await comp.set(val);
|
|
200
200
|
return true;
|
|
201
201
|
});
|
|
202
|
-
|
|
203
|
-
const electricalEnergy = await this.channelsService.findOneBy('identifier', `energy:${comp.id}`, device.id, devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
204
|
-
if (electricalEnergy === null) {
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
const consumption = await this.channelsPropertiesService.findOneBy('identifier', 'aenergy', electricalEnergy.id);
|
|
208
|
-
if (consumption === null) {
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
await this.setDefaultPropertyValue(device.id, consumption, (0, transform_utils_2.toEnergy)(comp.aenergy));
|
|
212
|
-
this.changeHandlers.set(`${delegate.id}|${comp.key}|aenergy`, (val) => {
|
|
213
|
-
this.handleNumericChange(comp.key, 'aenergy', consumption.id, val, (n) => this.handleChange(consumption, (0, transform_utils_2.toEnergy)(n), false));
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (typeof comp.apower !== 'undefined') {
|
|
219
|
-
const electricalPower = await this.channelsService.findOneBy('identifier', `power:${comp.id}`, device.id, devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
220
|
-
if (electricalPower === null) {
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
const power = await this.channelsPropertiesService.findOneBy('identifier', 'apower', electricalPower.id);
|
|
224
|
-
if (power === null) {
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
await this.setDefaultPropertyValue(device.id, power, Math.max(0, comp.apower));
|
|
228
|
-
this.changeHandlers.set(`${delegate.id}|${comp.key}|apower`, (val) => {
|
|
229
|
-
this.handleNumericChange(comp.key, 'apower', power.id, val, (n) => this.handleChange(power, Math.max(0, n), false));
|
|
230
|
-
});
|
|
231
|
-
if (typeof comp.voltage !== 'undefined') {
|
|
232
|
-
const voltage = await this.channelsPropertiesService.findOneBy('identifier', 'voltage', electricalPower.id);
|
|
233
|
-
if (voltage === null) {
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
await this.setDefaultPropertyValue(device.id, voltage, comp.voltage);
|
|
237
|
-
this.changeHandlers.set(`${delegate.id}|${comp.key}|voltage`, (val) => {
|
|
238
|
-
this.handleNumericChange(comp.key, 'voltage', voltage.id, val, (n) => this.handleChange(voltage, n, false));
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (typeof comp.current !== 'undefined') {
|
|
243
|
-
const current = await this.channelsPropertiesService.findOneBy('identifier', 'current', electricalPower.id);
|
|
244
|
-
if (current === null) {
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
await this.setDefaultPropertyValue(device.id, current, comp.current);
|
|
248
|
-
this.changeHandlers.set(`${delegate.id}|${comp.key}|current`, (val) => {
|
|
249
|
-
this.handleNumericChange(comp.key, 'current', current.id, val, (n) => this.handleChange(current, n, false));
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
202
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
256
203
|
}
|
|
257
204
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
258
205
|
return delegate;
|
|
@@ -314,6 +261,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
314
261
|
await comp.stop();
|
|
315
262
|
return true;
|
|
316
263
|
});
|
|
264
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
317
265
|
}
|
|
318
266
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
319
267
|
return delegate;
|
|
@@ -362,6 +310,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
362
310
|
return true;
|
|
363
311
|
});
|
|
364
312
|
}
|
|
313
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
365
314
|
}
|
|
366
315
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
367
316
|
return delegate;
|
|
@@ -495,6 +444,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
495
444
|
]);
|
|
496
445
|
return true;
|
|
497
446
|
});
|
|
447
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
498
448
|
}
|
|
499
449
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
500
450
|
return delegate;
|
|
@@ -653,6 +603,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
653
603
|
], Math.round((0, transform_utils_1.clampNumber)(whiteValue, 0, 255)));
|
|
654
604
|
return true;
|
|
655
605
|
});
|
|
606
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
656
607
|
}
|
|
657
608
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
658
609
|
return delegate;
|
|
@@ -746,6 +697,7 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
746
697
|
await comp.set(outputValue, Math.round((0, transform_utils_1.clampNumber)(brightnessValue, 0, 100)), Math.round((0, transform_utils_1.clampNumber)(ctValue, 2_700, 6_500)));
|
|
747
698
|
return true;
|
|
748
699
|
});
|
|
700
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
749
701
|
}
|
|
750
702
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
751
703
|
return delegate;
|
|
@@ -800,54 +752,59 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
800
752
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
801
753
|
return delegate;
|
|
802
754
|
for (const comp of delegate.pm1.values()) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
755
|
+
await this.wireElectricalChannels(delegate, device, comp);
|
|
756
|
+
}
|
|
757
|
+
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
758
|
+
return delegate;
|
|
759
|
+
for (const comp of delegate.em.values()) {
|
|
760
|
+
const phases = [
|
|
761
|
+
{ id: 'a', power: comp.a_act_power, voltage: comp.a_voltage, current: comp.a_current, freq: comp.a_freq },
|
|
762
|
+
{ id: 'b', power: comp.b_act_power, voltage: comp.b_voltage, current: comp.b_current, freq: comp.b_freq },
|
|
763
|
+
{ id: 'c', power: comp.c_act_power, voltage: comp.c_voltage, current: comp.c_current, freq: comp.c_freq },
|
|
764
|
+
];
|
|
765
|
+
for (const phase of phases) {
|
|
766
|
+
const channelIdentifier = `power:${comp.id}:${phase.id}`;
|
|
767
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_act_power`, `${phase.id}_act_power`, phase.power, true);
|
|
768
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_voltage`, `${phase.id}_voltage`, phase.voltage, true);
|
|
769
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_current`, `${phase.id}_current`, phase.current, true);
|
|
770
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_freq`, `${phase.id}_freq`, phase.freq, true);
|
|
771
|
+
}
|
|
772
|
+
const totalChannelIdentifier = `power:${comp.id}:total`;
|
|
773
|
+
await this.wireMeterProperty(delegate, device, comp.key, totalChannelIdentifier, 'total_act_power', 'total_act_power', comp.total_act_power, true);
|
|
774
|
+
await this.wireMeterProperty(delegate, device, comp.key, totalChannelIdentifier, 'total_current', 'total_current', comp.total_current, true);
|
|
775
|
+
}
|
|
776
|
+
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
777
|
+
return delegate;
|
|
778
|
+
for (const comp of delegate.emData.values()) {
|
|
779
|
+
const phases = [
|
|
780
|
+
{ id: 'a', energy: comp.a_total_act_energy, returned: comp.a_total_act_ret_energy },
|
|
781
|
+
{ id: 'b', energy: comp.b_total_act_energy, returned: comp.b_total_act_ret_energy },
|
|
782
|
+
{ id: 'c', energy: comp.c_total_act_energy, returned: comp.c_total_act_ret_energy },
|
|
783
|
+
];
|
|
784
|
+
for (const phase of phases) {
|
|
785
|
+
const channelIdentifier = `energy:${comp.id}:${phase.id}`;
|
|
786
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_total_act_energy`, `${phase.id}_total_act_energy`, phase.energy, false);
|
|
787
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, `${phase.id}_total_act_ret_energy`, `${phase.id}_total_act_ret_energy`, phase.returned, false);
|
|
788
|
+
}
|
|
789
|
+
const totalChannelIdentifier = `energy:${comp.id}:total`;
|
|
790
|
+
await this.wireMeterProperty(delegate, device, comp.key, totalChannelIdentifier, 'total_act', 'total_act', comp.total_act, false);
|
|
791
|
+
await this.wireMeterProperty(delegate, device, comp.key, totalChannelIdentifier, 'total_act_ret', 'total_act_ret', comp.total_act_ret, false);
|
|
792
|
+
}
|
|
793
|
+
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
794
|
+
return delegate;
|
|
795
|
+
for (const comp of delegate.em1.values()) {
|
|
796
|
+
const channelIdentifier = `power:${comp.id}`;
|
|
797
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'act_power', 'act_power', comp.act_power, true);
|
|
798
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'voltage', 'voltage', comp.voltage, true);
|
|
799
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'current', 'current', comp.current, true);
|
|
800
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'freq', 'freq', comp.freq, true);
|
|
801
|
+
}
|
|
802
|
+
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
803
|
+
return delegate;
|
|
804
|
+
for (const comp of delegate.em1Data.values()) {
|
|
805
|
+
const channelIdentifier = `energy:${comp.id}`;
|
|
806
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'total_act_energy', 'total_act_energy', comp.total_act_energy, false);
|
|
807
|
+
await this.wireMeterProperty(delegate, device, comp.key, channelIdentifier, 'total_act_ret_energy', 'total_act_ret_energy', comp.total_act_ret_energy, false);
|
|
851
808
|
}
|
|
852
809
|
if (this.insertGeneration.get(shelly.id) !== generation)
|
|
853
810
|
return delegate;
|
|
@@ -1142,6 +1099,87 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
1142
1099
|
}
|
|
1143
1100
|
set.add(property.id);
|
|
1144
1101
|
}
|
|
1102
|
+
async wireElectricalChannels(delegate, device, comp) {
|
|
1103
|
+
if (typeof comp.aenergy !== 'undefined') {
|
|
1104
|
+
const electricalEnergy = await this.channelsService.findOneBy('identifier', `energy:${comp.id}`, device.id, devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
1105
|
+
if (electricalEnergy === null) {
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
const consumption = await this.channelsPropertiesService.findOneBy('identifier', 'aenergy', electricalEnergy.id);
|
|
1109
|
+
if (consumption === null) {
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
await this.setDefaultPropertyValue(device.id, consumption, (0, transform_utils_2.toEnergy)(comp.aenergy));
|
|
1113
|
+
this.changeHandlers.set(`${delegate.id}|${comp.key}|aenergy.total`, (val) => {
|
|
1114
|
+
this.handleNumericChange(comp.key, 'aenergy.total', consumption.id, val, (n) => this.handleChange(consumption, (0, transform_utils_2.toEnergy)(n), false));
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
if (typeof comp.apower !== 'undefined' ||
|
|
1120
|
+
typeof comp.voltage !== 'undefined' ||
|
|
1121
|
+
typeof comp.current !== 'undefined') {
|
|
1122
|
+
const electricalPower = await this.channelsService.findOneBy('identifier', `power:${comp.id}`, device.id, devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
1123
|
+
if (electricalPower === null) {
|
|
1124
|
+
}
|
|
1125
|
+
else {
|
|
1126
|
+
if (typeof comp.apower !== 'undefined') {
|
|
1127
|
+
const power = await this.channelsPropertiesService.findOneBy('identifier', 'apower', electricalPower.id);
|
|
1128
|
+
if (power === null) {
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
await this.setDefaultPropertyValue(device.id, power, Math.max(0, comp.apower));
|
|
1132
|
+
this.changeHandlers.set(`${delegate.id}|${comp.key}|apower`, (val) => {
|
|
1133
|
+
this.handleNumericChange(comp.key, 'apower', power.id, val, (n) => this.handleChange(power, Math.max(0, n), false));
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (typeof comp.voltage !== 'undefined') {
|
|
1138
|
+
const voltage = await this.channelsPropertiesService.findOneBy('identifier', 'voltage', electricalPower.id);
|
|
1139
|
+
if (voltage === null) {
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
await this.setDefaultPropertyValue(device.id, voltage, comp.voltage);
|
|
1143
|
+
this.changeHandlers.set(`${delegate.id}|${comp.key}|voltage`, (val) => {
|
|
1144
|
+
this.handleNumericChange(comp.key, 'voltage', voltage.id, val, (n) => this.handleChange(voltage, n, false));
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (typeof comp.current !== 'undefined') {
|
|
1149
|
+
const current = await this.channelsPropertiesService.findOneBy('identifier', 'current', electricalPower.id);
|
|
1150
|
+
if (current === null) {
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
await this.setDefaultPropertyValue(device.id, current, comp.current);
|
|
1154
|
+
this.changeHandlers.set(`${delegate.id}|${comp.key}|current`, (val) => {
|
|
1155
|
+
this.handleNumericChange(comp.key, 'current', current.id, val, (n) => this.handleChange(current, n, false));
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
async wireMeterProperty(delegate, device, compKey, channelIdentifier, attr, propertyIdentifier, value, allowNull) {
|
|
1163
|
+
if (typeof value === 'undefined') {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
const channel = await this.channelsService.findOneBy('identifier', channelIdentifier, device.id, devices_shelly_ng_constants_1.DEVICES_SHELLY_NG_TYPE);
|
|
1167
|
+
if (channel === null) {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const property = await this.channelsPropertiesService.findOneBy('identifier', propertyIdentifier, channel.id);
|
|
1171
|
+
if (property === null) {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
if (value !== null) {
|
|
1175
|
+
await this.setDefaultPropertyValue(device.id, property, value);
|
|
1176
|
+
}
|
|
1177
|
+
this.changeHandlers.set(`${delegate.id}|${compKey}|${attr}`, (val) => {
|
|
1178
|
+
this.handleNumericChange(compKey, attr, property.id, val, (n) => this.handleChange(property, n, false), {
|
|
1179
|
+
allowNull,
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1145
1183
|
determineCategory(delegate) {
|
|
1146
1184
|
if (delegate.descriptor && delegate.descriptor.categories.length > 0) {
|
|
1147
1185
|
return delegate.descriptor.categories[0];
|
|
@@ -1164,6 +1202,9 @@ let DelegatesManagerService = DelegatesManagerService_1 = class DelegatesManager
|
|
|
1164
1202
|
return devices_constants_1.DeviceCategory.GENERIC;
|
|
1165
1203
|
}
|
|
1166
1204
|
handleNumericChange(compKey, attr, propertyId, val, write, opts) {
|
|
1205
|
+
if (val === null && opts?.allowNull) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1167
1208
|
const n = (0, transform_utils_1.coerceNumberSafe)(val, opts);
|
|
1168
1209
|
if (n === null || Number.isNaN(n)) {
|
|
1169
1210
|
this.logger.warn(`Dropping invalid numeric update for ${compKey}.${attr} -> ${(0, transform_utils_1.safeToString)(val)} (property=${propertyId})`);
|