@mysetup/mqtt 1.14.5 → 1.14.7
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/README.md +27 -0
- package/dist/mqttClient.d.ts +3 -3
- package/dist/mqttClient.d.ts.map +1 -1
- package/dist/mqttClient.js +1 -0
- package/dist/test/test-mqtt.js +2 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Getting Started
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
import { logger } from "@mysetup/logger";
|
|
5
|
+
import { mqttCreateConnection } from "../mqttClient";
|
|
6
|
+
|
|
7
|
+
const CLIENT_ID = `testClient-${Math.random().toString(16).slice(2, 8)}`;
|
|
8
|
+
|
|
9
|
+
mqttCreateConnection({
|
|
10
|
+
clientId: CLIENT_ID,
|
|
11
|
+
config: {
|
|
12
|
+
host: "localhost",
|
|
13
|
+
port: 1883,
|
|
14
|
+
protocol: "mqtt",
|
|
15
|
+
path: "",
|
|
16
|
+
username: process.env.MQTT_USERNAME,
|
|
17
|
+
password: process.env.MQTT_PASSWORD,
|
|
18
|
+
},
|
|
19
|
+
topicList: ["mj/ems/test"],
|
|
20
|
+
messageCallback: (topic, message) => {
|
|
21
|
+
logger.info(
|
|
22
|
+
`Message received → topic: ${topic}, message: ${message.toString()}`,
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
```
|
package/dist/mqttClient.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import mqtt from "mqtt";
|
|
|
2
2
|
import type { MqttClient } from "mqtt";
|
|
3
3
|
export type { MqttClient };
|
|
4
4
|
interface MqttConfigProps {
|
|
5
|
-
protocol:
|
|
5
|
+
protocol: "mqtt" | "mqtts" | "ws" | "wss";
|
|
6
6
|
port: number;
|
|
7
7
|
host: string;
|
|
8
8
|
path: string;
|
|
9
|
-
username?: string
|
|
10
|
-
password?: string
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
11
|
}
|
|
12
12
|
interface ConnectionProps {
|
|
13
13
|
clientId: string;
|
package/dist/mqttClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mqttClient.d.ts","sourceRoot":"","sources":["../mqttClient.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,UAAU,eAAe;IACrB,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mqttClient.d.ts","sourceRoot":"","sources":["../mqttClient.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,UAAU,eAAe;IACrB,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,eAAe;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAmED,QAAA,MAAM,OAAO,GACT,WAAW,MAAM,EAAE,EACnB,UAAU,MAAM,EAChB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,EAC1D,cAAc,MAAM,SA0BvB,CAAC;AAEF,QAAA,MAAM,SAAS,GACX,WAAW,MAAM,EAAE,EACnB,UAAU,MAAM,EAChB,cAAc,MAAM,SAoBvB,CAAC;AAEF,QAAA,MAAM,cAAc,GAChB,OAAO,eAAe,EACtB,QAAQ,OAAO,EACf,cAAc,MAAM,SAgBvB,CAAC;AAeF,QAAA,MAAM,WAAW,GACb,OAAO,MAAM,EACb,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,cAAc,MAAM,SAqBvB,CAAC;AAsBF,QAAA,MAAM,oBAAoB,GAAI,OAAO,eAAe,2BAEnD,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,IAAI,MAAM,2BAEhC,CAAC;AAOF,OAAO,EACH,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,GAChB,CAAC"}
|
package/dist/mqttClient.js
CHANGED
|
@@ -12,6 +12,7 @@ var checkInitConnect = function (props) {
|
|
|
12
12
|
var _a = props.config, protocol = _a.protocol, host = _a.host, port = _a.port, path = _a.path, username = _a.username, password = _a.password;
|
|
13
13
|
var connectUrl = "".concat(protocol, "://").concat(host, ":").concat(port).concat(path);
|
|
14
14
|
var client = mqtt_1.default.connect(connectUrl, {
|
|
15
|
+
protocol: protocol,
|
|
15
16
|
clientId: props.clientId,
|
|
16
17
|
clean: false, /// for retaining previous message purpose
|
|
17
18
|
rejectUnauthorized: true,
|
package/dist/test/test-mqtt.js
CHANGED
|
@@ -10,6 +10,8 @@ var CLIENT_ID = "testClient-".concat(Math.random().toString(16).slice(2, 8));
|
|
|
10
10
|
port: 1883,
|
|
11
11
|
protocol: "mqtt",
|
|
12
12
|
path: "",
|
|
13
|
+
username: process.env.MQTT_USERNAME,
|
|
14
|
+
password: process.env.MQTT_PASSWORD,
|
|
13
15
|
},
|
|
14
16
|
topicList: ["mj/ems/test"],
|
|
15
17
|
messageCallback: function (topic, message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysetup/mqtt",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"prettier": "@mysetup/prettier-config",
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
43
|
+
"node": ">=20.15.1"
|
|
44
44
|
},
|
|
45
45
|
"packageManager": "pnpm@9.9.0"
|
|
46
46
|
}
|