smart-home-engine 1.9.1 → 1.9.3
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/web/assets/{index-D8KYTMHd.js → index-ByoSXq9N.js} +64 -64
- package/dist/web/assets/{index-D_NqSYjh.css → index-D3e4KUzX.css} +1 -1
- package/dist/web/assets/{tsMode-BprtWe5B.js → tsMode-CjIOSOpY.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/src/web/broker-api.js +8 -0
- package/src/web/log-ws.js +26 -1
- package/src/web/mqtt-api.js +8 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-ByoSXq9N.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -172,10 +172,10 @@
|
|
|
172
172
|
}
|
|
173
173
|
})();
|
|
174
174
|
</script>
|
|
175
|
-
<script type="module" crossorigin src="/assets/index-
|
|
175
|
+
<script type="module" crossorigin src="/assets/index-ByoSXq9N.js"></script>
|
|
176
176
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
|
|
177
177
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
178
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
178
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D3e4KUzX.css">
|
|
179
179
|
</head>
|
|
180
180
|
<body>
|
|
181
181
|
<div id="app"></div>
|
package/package.json
CHANGED
package/src/web/broker-api.js
CHANGED
|
@@ -25,6 +25,7 @@ const mosquittoConf = require('../lib/mosquitto-conf');
|
|
|
25
25
|
const ca = require('../lib/ca');
|
|
26
26
|
const sshDeploy = require('../lib/ssh-deploy');
|
|
27
27
|
const sheConfig = require('../config');
|
|
28
|
+
const { getBrokerLogBuffer } = require('./log-ws');
|
|
28
29
|
|
|
29
30
|
// Default SSH identity file respects the configured data directory
|
|
30
31
|
const DEFAULT_SSH_KEY = path.join(sheConfig['data-dir'], 'ssh', 'broker_id_ed25519');
|
|
@@ -938,6 +939,13 @@ router.post('/ca/trusted/addpath', async (req, res) => {
|
|
|
938
939
|
}
|
|
939
940
|
});
|
|
940
941
|
|
|
942
|
+
// GET /she/broker/logs?limit=<N> — recent broker log entries (ring buffer, max 500)
|
|
943
|
+
router.get('/logs', (req, res) => {
|
|
944
|
+
const limit = Math.min(Number(req.query.limit) || 500, 1000);
|
|
945
|
+
const all = getBrokerLogBuffer();
|
|
946
|
+
res.json(limit >= all.length ? all : all.slice(-limit));
|
|
947
|
+
});
|
|
948
|
+
|
|
941
949
|
module.exports = { router, setLogger, setStore };
|
|
942
950
|
|
|
943
951
|
// ── dynsec: ACL topic inspection ──────────────────────────────────────────────
|
package/src/web/log-ws.js
CHANGED
|
@@ -94,6 +94,31 @@ function getLogBuffer() {
|
|
|
94
94
|
return _logBuffer.slice();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Broadcast a structured broker (mosquitto) log entry to all connected
|
|
99
|
+
* WebSocket clients as { type: 'brokerLog', level, msg, ts }.
|
|
100
|
+
* Also stores the entry in a server-side ring buffer exposed via getBrokerLogBuffer().
|
|
101
|
+
* @param {string} level Single-letter mosquitto level: D|I|N|W|E
|
|
102
|
+
* @param {string} msg
|
|
103
|
+
* @param {number} ts Unix ms timestamp
|
|
104
|
+
*/
|
|
105
|
+
const _brokerLogBuffer = [];
|
|
106
|
+
const BROKER_LOG_BUFFER_MAX = 500;
|
|
107
|
+
|
|
108
|
+
function broadcastBrokerLog(level, msg, ts) {
|
|
109
|
+
_brokerLogBuffer.push({ level, msg, ts });
|
|
110
|
+
if (_brokerLogBuffer.length > BROKER_LOG_BUFFER_MAX) _brokerLogBuffer.shift();
|
|
111
|
+
broadcast({ type: 'brokerLog', level, msg, ts });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Return a snapshot of recent broker log entries (oldest first).
|
|
116
|
+
* @returns {{ level: string, msg: string, ts: number }[]}
|
|
117
|
+
*/
|
|
118
|
+
function getBrokerLogBuffer() {
|
|
119
|
+
return _brokerLogBuffer.slice();
|
|
120
|
+
}
|
|
121
|
+
|
|
97
122
|
/**
|
|
98
123
|
* Close the WebSocket server.
|
|
99
124
|
* @returns {Promise<void>}
|
|
@@ -109,4 +134,4 @@ function closeWss() {
|
|
|
109
134
|
});
|
|
110
135
|
}
|
|
111
136
|
|
|
112
|
-
module.exports = { attachWss, broadcast, broadcastLog, closeWss, getLogBuffer, setWelcomeProvider };
|
|
137
|
+
module.exports = { attachWss, broadcast, broadcastBrokerLog, broadcastLog, closeWss, getBrokerLogBuffer, getLogBuffer, setWelcomeProvider };
|
package/src/web/mqtt-api.js
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
const express = require('express');
|
|
19
|
-
const { broadcast } = require('./log-ws');
|
|
19
|
+
const { broadcast, broadcastBrokerLog } = require('./log-ws');
|
|
20
|
+
|
|
21
|
+
const BROKER_LOG_TOPICS = new Set(['D', 'I', 'N', 'W', 'E'].map(l => `$SYS/broker/log/${l}`));
|
|
20
22
|
|
|
21
23
|
const router = express.Router();
|
|
22
24
|
|
|
@@ -35,7 +37,11 @@ function init(store, getMqttClient) {
|
|
|
35
37
|
// Forward every mqtt:: state change to connected WebSocket clients
|
|
36
38
|
store.on('change', (key, val, obj) => {
|
|
37
39
|
if (!key.startsWith('mqtt::')) return;
|
|
38
|
-
|
|
40
|
+
const topic = key.slice(6);
|
|
41
|
+
broadcast({ type: 'mqtt', topic, val: obj.val, ts: obj.ts });
|
|
42
|
+
if (BROKER_LOG_TOPICS.has(topic)) {
|
|
43
|
+
broadcastBrokerLog(topic.slice('$SYS/broker/log/'.length), String(obj.val), obj.ts);
|
|
44
|
+
}
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
|