@kronos-integration/service-mqtt 1.0.7 → 1.0.9
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/.github/workflows/ci.yml
CHANGED
|
@@ -22,6 +22,13 @@ jobs:
|
|
|
22
22
|
steps:
|
|
23
23
|
- name: checkout
|
|
24
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'
|
|
25
32
|
- name: prepare node
|
|
26
33
|
uses: actions/setup-node@v4.4.0
|
|
27
34
|
with:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/service-mqtt",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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.
|
|
39
|
+
"@kronos-integration/service": "^11.2.16",
|
|
40
40
|
"model-attributes": "^4.3.0",
|
|
41
41
|
"mqtt": "^5.13.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@
|
|
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",
|
package/src/service-mqtt.mjs
CHANGED
package/src/topic-endpoint.mjs
CHANGED
package/tests/mqtt-ava.mjs
CHANGED
|
@@ -6,18 +6,46 @@ 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
|
|
|
13
12
|
const mqtt = await sp.declareService({
|
|
14
13
|
type: ServiceMQTT,
|
|
15
14
|
endpoints: {
|
|
16
|
-
s1: { topic:
|
|
15
|
+
s1: { topic: true, connected: r1 },
|
|
16
|
+
s2: { topic: "s2b", connected: r1 }
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
t.is(mqtt.endpoints["s1"].name, "s1");
|
|
21
|
+
t.is(mqtt.endpoints["s2"].name, "s2");
|
|
21
22
|
t.true(mqtt.endpoints["s1"] instanceof TopicEndpoint);
|
|
22
|
-
t.deepEqual(mqtt.topics, ["s1"]);
|
|
23
|
+
t.deepEqual(mqtt.topics, ["s1", "s2b"]);
|
|
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");
|
|
23
51
|
});
|