@cuppet/core 1.2.2 → 1.2.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.
|
@@ -258,24 +258,22 @@ class MqttManager {
|
|
|
258
258
|
async waitForSpecificMessage(topic, message, timeoutSeconds = 10) {
|
|
259
259
|
const timeoutMs = timeoutSeconds * 1000;
|
|
260
260
|
const startTime = Date.now();
|
|
261
|
-
|
|
261
|
+
let latestMessageString = null;
|
|
262
262
|
while (Date.now() - startTime < timeoutMs) {
|
|
263
263
|
const latestMessage = this.getLatestMessage(topic);
|
|
264
264
|
if (latestMessage) {
|
|
265
|
-
|
|
265
|
+
latestMessageString = JSON.stringify(latestMessage.message);
|
|
266
266
|
const expectedMessageString = JSON.stringify(message);
|
|
267
267
|
if (latestMessageString === expectedMessageString) {
|
|
268
268
|
return latestMessage;
|
|
269
|
-
} else {
|
|
270
|
-
throw new Error(
|
|
271
|
-
`Message: ${latestMessageString} on topic ${topic} does not match expected: ${expectedMessageString}`
|
|
272
|
-
);
|
|
273
269
|
}
|
|
274
270
|
}
|
|
275
271
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
276
272
|
}
|
|
277
273
|
|
|
278
|
-
throw new Error(
|
|
274
|
+
throw new Error(
|
|
275
|
+
`Timeout waiting for message on topic: ${topic} after ${timeoutSeconds} seconds. Latest message received: ${latestMessageString}`
|
|
276
|
+
);
|
|
279
277
|
}
|
|
280
278
|
|
|
281
279
|
/**
|
package/package.json
CHANGED
package/src/apiFunctions.js
CHANGED
|
@@ -22,8 +22,11 @@ module.exports = {
|
|
|
22
22
|
prepareUrl: async function (url) {
|
|
23
23
|
const path = await storage.checkForMultipleVariables(url);
|
|
24
24
|
if (!path.startsWith('http') && config.has('api.baseApiUrl')) {
|
|
25
|
-
|
|
25
|
+
// Replace placeholders in base path with variables
|
|
26
|
+
const resolveBasePath = await storage.checkForMultipleVariables(config.get('api.baseApiUrl'));
|
|
27
|
+
return resolveBasePath + path;
|
|
26
28
|
}
|
|
29
|
+
// Return the path as is if it's already an absolute URL or if no base path is configured
|
|
27
30
|
return path;
|
|
28
31
|
},
|
|
29
32
|
|