@kronos-integration/service-mqtt 1.0.8 → 1.0.10

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.
@@ -0,0 +1,3 @@
1
+ listener 1883
2
+ log_timestamp false
3
+ allow_anonymous true
@@ -18,11 +18,17 @@ jobs:
18
18
  os:
19
19
  - ubuntu-latest
20
20
  node-version:
21
- - 22.17.1
22
21
  - 24.4.1
23
22
  steps:
24
23
  - name: checkout
25
24
  uses: actions/checkout@v4.2.2
25
+ - name: Start Mosquitto
26
+ uses: namoshek/mosquitto-github-action@v1
27
+ with:
28
+ version: '2.0.22'
29
+ ports: '1883:1883 8883:8883'
30
+ config: ${{ github.workspace }}/.github/mosquitto/mosquitto.conf
31
+ container-name: 'mqtt'
26
32
  - name: prepare node
27
33
  uses: actions/setup-node@v4.4.0
28
34
  with:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service-mqtt",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -36,13 +36,12 @@
36
36
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
37
37
  },
38
38
  "dependencies": {
39
- "@kronos-integration/service": "^11.2.15",
39
+ "@kronos-integration/service": "^11.2.17",
40
40
  "model-attributes": "^4.3.0",
41
41
  "mqtt": "^5.13.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@kronos-integration/test-interceptor": "^7.0.29",
45
- "@types/node": "^24.0.14",
44
+ "@types/node": "^24.0.15",
46
45
  "ava": "^6.4.1",
47
46
  "c8": "^10.1.3",
48
47
  "documentation": "^14.0.3",
@@ -6,7 +6,6 @@ import { ServiceMQTT, TopicEndpoint } from "@kronos-integration/service-mqtt";
6
6
 
7
7
  test("endpoint factory", async t => {
8
8
  const sp = new StandaloneServiceProvider();
9
-
10
9
  const r1 = new ReceiveEndpoint("r1", sp);
11
10
  r1.receive = async () => "OK R1";
12
11
 
@@ -23,3 +22,30 @@ test("endpoint factory", async t => {
23
22
  t.true(mqtt.endpoints["s1"] instanceof TopicEndpoint);
24
23
  t.deepEqual(mqtt.topics, ["s1", "s2b"]);
25
24
  });
25
+
26
+ test("start / stop", async t => {
27
+ const sp = new StandaloneServiceProvider();
28
+
29
+ const r1 = new ReceiveEndpoint("r1", sp);
30
+ r1.receive = async () => "OK R1";
31
+
32
+ const mqtt = await sp.declareService({
33
+ type: ServiceMQTT,
34
+ url: "mqtt://localhost",
35
+ clientId: "test",
36
+ clean: true,
37
+ connectTimeout: 4000,
38
+ reconnectPeriod: 1000,
39
+ endpoints: {
40
+ s1: { topic: true, connected: r1 }
41
+ }
42
+ });
43
+
44
+ t.is(mqtt.endpoints["s1"].name, "s1");
45
+
46
+ await mqtt.start();
47
+ t.is(mqtt.state, "running");
48
+
49
+ await mqtt.stop();
50
+ t.is(mqtt.state, "stopped");
51
+ });