@transitive-sdk/utils-web 0.16.1 → 0.16.2
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/utils-web.js +22 -4
- package/package.json +1 -1
package/dist/utils-web.js
CHANGED
|
@@ -723,7 +723,8 @@ var require_MqttSync = __commonJS({
|
|
|
723
723
|
encodeTopicElement,
|
|
724
724
|
visitAncestor,
|
|
725
725
|
getRandomId,
|
|
726
|
-
selectorPathToMetaPath
|
|
726
|
+
selectorPathToMetaPath,
|
|
727
|
+
selectorToMetaTopic
|
|
727
728
|
} = require_common();
|
|
728
729
|
var { DataCache } = require_DataCache();
|
|
729
730
|
var log2 = getLogger2("MqttSync");
|
|
@@ -807,9 +808,6 @@ var require_MqttSync = __commonJS({
|
|
|
807
808
|
path = path.slice(sliceTopic);
|
|
808
809
|
topic = pathToTopic2(path);
|
|
809
810
|
}
|
|
810
|
-
if (!inclMeta && path.some((field) => field[0] == "$")) {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
811
|
const rpcHandler = this.getRPCHandler(topic);
|
|
814
812
|
if (rpcHandler) {
|
|
815
813
|
const json = mqttParsePayload(payload);
|
|
@@ -818,6 +816,9 @@ var require_MqttSync = __commonJS({
|
|
|
818
816
|
const json = mqttParsePayload(payload);
|
|
819
817
|
this.handleRPCResponse(topic, json);
|
|
820
818
|
} else if (packet.retain || ignoreRetain) {
|
|
819
|
+
if (!inclMeta && path.slice(0, 5).some((field) => field[0] == "$")) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
821
822
|
if (this.isPublished(topic)) {
|
|
822
823
|
const json = mqttParsePayload(payload);
|
|
823
824
|
this.publishedMessages.updateFromArray([...path, specialKey], json);
|
|
@@ -1317,6 +1318,23 @@ var require_MqttSync = __commonJS({
|
|
|
1317
1318
|
const storageRequest = pathToTopic2(path);
|
|
1318
1319
|
this.mqtt.publish(storageRequest, String(ttl), { retain: true });
|
|
1319
1320
|
}
|
|
1321
|
+
/** Query a topics history (if stored). Convenience function to make RPC call
|
|
1322
|
+
* to the mqtt2clickhouse service.
|
|
1323
|
+
* @param params = {topic, since, until, orderBy, limit} */
|
|
1324
|
+
async queryHistory(params) {
|
|
1325
|
+
const path = topicToPath2(params.topic);
|
|
1326
|
+
const rpc = selectorToMetaTopic(`${pathToTopic2(path.slice(0, 5))}/$queryMQTTHistory`);
|
|
1327
|
+
const query = {
|
|
1328
|
+
subtopic: pathToTopic2(path.slice(5)),
|
|
1329
|
+
...params
|
|
1330
|
+
};
|
|
1331
|
+
delete query.topic;
|
|
1332
|
+
query.since && (query.since = query.since.getTime());
|
|
1333
|
+
query.until && (query.until = query.until.getTime());
|
|
1334
|
+
log2.info("queryHistory", { rpc, query });
|
|
1335
|
+
const result = await this.call(rpc, query);
|
|
1336
|
+
return result;
|
|
1337
|
+
}
|
|
1320
1338
|
};
|
|
1321
1339
|
module2.exports = MqttSync3;
|
|
1322
1340
|
}
|