@kronos-integration/service-mqtt 4.0.11 → 4.0.13

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 CHANGED
@@ -1,10 +1,12 @@
1
+ [![npm](https://img.shields.io/npm/v/@kronos-integration/service-mqtt.svg)](https://www.npmjs.com/package/@kronos-integration/service-mqtt)
1
2
  [![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
3
+ [![bundlejs](https://deno.bundlejs.com/?q=@kronos-integration/service-mqtt\&badge=detailed)](https://bundlejs.com/?q=@kronos-integration/service-mqtt)
4
+ [![downloads](http://img.shields.io/npm/dm/@kronos-integration/service-mqtt.svg?style=flat-square)](https://npmjs.org/package/@kronos-integration/service-mqtt)
2
5
  [![GitHub Issues](https://img.shields.io/github/issues/Kronos-Integration/service-mqtt.svg?style=flat-square)](https://github.com/Kronos-Integration/service-mqtt/issues)
3
6
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FKronos-Integration%2Fservice-mqtt%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/Kronos-Integration/service-mqtt/goto)
4
7
  [![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
5
8
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6
9
  [![Known Vulnerabilities](https://snyk.io/test/github/Kronos-Integration/service-mqtt/badge.svg)](https://snyk.io/test/github/Kronos-Integration/service-mqtt)
7
- [![Coverage Status](https://coveralls.io/repos/Kronos-Integration/service-mqtt/badge.svg)](https://coveralls.io/github/Kronos-Integration/service-mqtt)
8
10
 
9
11
  # @kronos-integration/service-mqtt
10
12
 
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@kronos-integration/service-mqtt",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
+ "packageManager": "npm@11.6.4+sha512.1118cab46a05a50aee6bff5b1b4fa1df18afff89d57465620a3518035026955db87c5bdf9d207b07b7487d99f2490d450cb774655ad63ec2cba7bf1d0ad25d45",
8
9
  "types": "./types/service-mqtt.d.mts",
9
10
  "exports": {
10
11
  ".": {
11
- "default": "./src/service-mqtt.mjs",
12
- "types": "./types/service-mqtt.d.mts"
12
+ "types": "./types/service-mqtt.d.mts",
13
+ "default": "./src/service-mqtt.mjs"
13
14
  }
14
15
  },
15
16
  "description": "MQTT service",
16
17
  "keywords": [
17
- "mqtt",
18
- "kronos-service"
18
+ "kronos-service",
19
+ "mqtt"
19
20
  ],
20
21
  "contributors": [
21
22
  {
@@ -23,19 +24,19 @@
23
24
  "email": "markus.felten@gmx.de"
24
25
  }
25
26
  ],
26
- "license": "BSD-2-Clause",
27
+ "license": "0BSD",
27
28
  "scripts": {
28
29
  "test": "node --run test:ava",
29
30
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
30
31
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
31
- "docs": "documentation readme --section=API ./src/**/*.mjs",
32
+ "docs": "documentation readme --section=API ./src**/*.mjs",
32
33
  "lint": "node --run lint:docs",
33
- "lint:docs": "documentation lint ./src/**/*.mjs"
34
+ "lint:docs": "documentation lint ./src**/*.mjs"
34
35
  },
35
36
  "dependencies": {
36
- "@kronos-integration/service": "^15.1.1",
37
+ "@kronos-integration/service": "^15.1.2",
37
38
  "mqtt": "^5.14.1",
38
- "pacc": "^5.1.0"
39
+ "pacc": "^5.2.0"
39
40
  },
40
41
  "devDependencies": {
41
42
  "ava": "^6.4.1",
@@ -50,11 +51,14 @@
50
51
  "type": "git",
51
52
  "url": "git+https://github.com/Kronos-Integration/service-mqtt.git"
52
53
  },
54
+ "bugs": {
55
+ "url": "https://github.com/Kronos-Integration/service-mqtt/issues"
56
+ },
57
+ "homepage": "https://github.com/Kronos-Integration/service-mqtt#readme",
53
58
  "template": {
54
59
  "inheritFrom": [
55
60
  "arlac77/template-arlac77-github",
56
61
  "arlac77/template-kronos-component"
57
62
  ]
58
- },
59
- "packageManager": "npm@11.6.4+sha512.1118cab46a05a50aee6bff5b1b4fa1df18afff89d57465620a3518035026955db87c5bdf9d207b07b7487d99f2490d450cb774655ad63ec2cba7bf1d0ad25d45"
63
+ }
60
64
  }
@@ -50,8 +50,8 @@ export class ServiceMQTT extends Service {
50
50
  ...integer_attribute_writable,
51
51
  connectionOption: true
52
52
  },
53
- username: { ...username_attribute, credential: true },
54
- password: { ...password_attribute, credential: true }
53
+ username: username_attribute,
54
+ password: password_attribute
55
55
  },
56
56
  Service.attributes
57
57
  );
@@ -86,16 +86,14 @@ export class ServiceMQTT extends Service {
86
86
  async _start() {
87
87
  await super._start();
88
88
 
89
- const options = getAttributesJSON(
90
- this,
91
- this.attributes,
92
- (name, attribute) => attribute.connectionOption
93
- );
94
-
95
- options.username = await this.getCredential("username");
96
- options.password = await this.getCredential("password");
97
-
98
- const client = connect(this.url, options);
89
+ const client = connect(this.url, {
90
+ ...getAttributesJSON(
91
+ this,
92
+ this.attributes,
93
+ (name, attribute) => attribute.connectionOption
94
+ ),
95
+ ...(await this.getCredentials())
96
+ });
99
97
 
100
98
  this.client = client;
101
99
 
@@ -1,19 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: npm
4
- directory: /
5
- schedule:
6
- interval: daily
7
- commit-message:
8
- prefix: "fix(deps):"
9
- prefix-development: "chore(deps):"
10
- labels:
11
- - npm dependencies
12
- - package-ecosystem: github-actions
13
- directory: /
14
- schedule:
15
- interval: daily
16
- commit-message:
17
- prefix: "chore(action):"
18
- labels:
19
- - dependencies
@@ -1,3 +0,0 @@
1
- listener 1883
2
- log_timestamp false
3
- allow_anonymous true
@@ -1,61 +0,0 @@
1
- ci:
2
- - changed-files:
3
- - any-glob-to-any-file:
4
- - .github/workflows/*
5
- - .travis.yml
6
- dependencies:
7
- - changed-files:
8
- - any-glob-to-any-file:
9
- - package-lock.json
10
- - yarn.lockfile
11
- deployment:
12
- - changed-files:
13
- - any-glob-to-any-file:
14
- - netlify.toml
15
- - _redirects
16
- documentation:
17
- - changed-files:
18
- - any-glob-to-any-file:
19
- - docs/**/*
20
- - "**/*.md"
21
- github:
22
- - changed-files:
23
- - any-glob-to-any-file:
24
- - .github/**/*
25
- git:
26
- - changed-files:
27
- - any-glob-to-any-file:
28
- - .gitignore
29
- labels:
30
- - changed-files:
31
- - any-glob-to-any-file:
32
- - .github/pr_labeler.yml
33
- lint:
34
- - changed-files:
35
- - any-glob-to-any-file:
36
- - .stylelintrc.json
37
- npm:
38
- - changed-files:
39
- - any-glob-to-any-file:
40
- - .npmignore
41
- - package.json
42
- - package-lock.json
43
- openapi:
44
- - changed-files:
45
- - any-glob-to-any-file:
46
- - openapi/*
47
- rollup:
48
- - changed-files:
49
- - any-glob-to-any-file:
50
- - rollup.config.mjs
51
- styling:
52
- - changed-files:
53
- - any-glob-to-any-file:
54
- - "**/*.css"
55
- test:
56
- - changed-files:
57
- - any-glob-to-any-file: tests/**/*
58
- vscode:
59
- - changed-files:
60
- - any-glob-to-any-file:
61
- - .vscode/*
@@ -1,13 +0,0 @@
1
- name: Auto approve
2
- on: pull_request_target
3
- jobs:
4
- auto-approve:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: hmarr/auto-approve-action@v4.0.0
8
- if: github.actor == 'dependabot[bot]'
9
- with:
10
- github-token: ${{ secrets.GITHUB_TOKEN }}
11
- review-message: Auto approved automated PR
12
- permissions:
13
- pull-requests: write
@@ -1,82 +0,0 @@
1
- name: CI
2
- on:
3
- push:
4
- branches:
5
- - master
6
- - next
7
- pull_request:
8
- branches:
9
- - master
10
- - next
11
- permissions:
12
- contents: read
13
- id-token: write
14
- jobs:
15
- test-node:
16
- runs-on: ubuntu-latest
17
- strategy:
18
- matrix:
19
- os:
20
- - ubuntu-latest
21
- node-version:
22
- - 24.11.1
23
- steps:
24
- - name: checkout
25
- uses: actions/checkout@v6.0.1
26
- - name: Start Mosquitto
27
- uses: namoshek/mosquitto-github-action@v1
28
- with:
29
- version: 2.0.22
30
- ports: 1883:1883 8883:8883
31
- config: ${{ github.workspace }}/.github/mosquitto/mosquitto.conf
32
- container-name: mqtt
33
- - name: prepare node
34
- uses: actions/setup-node@v6.1.0
35
- with:
36
- node-version: ${{ matrix.node-version }}
37
- - name: install
38
- run: npm ci
39
- - name: test and coverage
40
- run: npm run cover --if-present
41
- - name: coveralls
42
- uses: coverallsapp/github-action@v2
43
- with:
44
- github-token: ${{ secrets.GITHUB_TOKEN }}
45
- flag-name: run-${{ matrix.test_number }}
46
- path-to-lcov: build/coverage/lcov.info
47
- parallel: true
48
- continue-on-error: true
49
- release:
50
- needs:
51
- - test-node
52
- runs-on: ubuntu-latest
53
- permissions:
54
- contents: write
55
- issues: write
56
- pull-requests: write
57
- id-token: write
58
- steps:
59
- - name: checkout
60
- uses: actions/checkout@v6.0.1
61
- - name: prepare node
62
- uses: actions/setup-node@v6.1.0
63
- with:
64
- node-version: 24.11.1
65
- - name: install
66
- run: npm ci
67
- - name: release
68
- run: npx semantic-release
69
- env:
70
- CI: "true"
71
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72
- finish:
73
- needs:
74
- - test-node
75
- runs-on: ubuntu-latest
76
- steps:
77
- - name: finish coveralls
78
- uses: coverallsapp/github-action@v2
79
- with:
80
- github-token: ${{ secrets.GITHUB_TOKEN }}
81
- path-to-lcov: build/coverage/lcov.info
82
- parallel-finished: true
@@ -1,30 +0,0 @@
1
- name: CodeQL
2
- on:
3
- push:
4
- branches:
5
- - master
6
- pull_request:
7
- branches:
8
- - master
9
- jobs:
10
- analyze:
11
- name: Analyze
12
- runs-on: ubuntu-latest
13
- steps:
14
- - name: checkout
15
- uses: actions/checkout@v6.0.1
16
- - name: git checkout
17
- run: git checkout
18
- if: ${{ github.event_name == 'pull_request' }}
19
- - name: initialize CodeQL
20
- uses: github/codeql-action/init@v4
21
- with:
22
- languages: javascript
23
- - name: prepare node
24
- uses: actions/setup-node@v6.1.0
25
- with:
26
- node-version: 24.11.1
27
- - name: install
28
- run: npm ci
29
- - name: perform CodeQL analysis
30
- uses: github/codeql-action/analyze@v4
@@ -1,14 +0,0 @@
1
- name: Pull Request Labeler
2
- on: pull_request_target
3
- jobs:
4
- triage:
5
- permissions:
6
- contents: read
7
- pull-requests: write
8
- runs-on: ubuntu-latest
9
- steps:
10
- - uses: actions/labeler@v6
11
- with:
12
- repo-token: ${{ secrets.GITHUB_TOKEN }}
13
- configuration-path: .github/pr_labeler.yml
14
- sync-labels: false
@@ -1,36 +0,0 @@
1
- name: Update package lock
2
- on:
3
- push:
4
- paths:
5
- - package.json
6
- schedule:
7
- - cron: 13 8 * * 6
8
- jobs:
9
- update_package_lock:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: checkout
13
- uses: actions/checkout@v6.0.1
14
- - name: prepare node
15
- uses: actions/setup-node@v6.1.0
16
- with:
17
- node-version: 24.11.1
18
- - name: remove lock
19
- run: rm package-lock.json
20
- - name: install playwright
21
- run: npx playwright install
22
- - name: test
23
- run: npm install-test
24
- env:
25
- BROWSER: chrome
26
- - name: create pull request
27
- uses: gr2m/create-or-update-pull-request-action@v1.10.1
28
- env:
29
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
- with:
31
- path: package-lock.json
32
- title: Regenerate package lock
33
- body: bring lock in sync
34
- branch: package-lock
35
- labels: npm
36
- commit-message: "chore(deps): lock"
@@ -1,32 +0,0 @@
1
- name: API to readme
2
- on:
3
- schedule:
4
- - cron: 31 14 * * 6
5
- push:
6
- paths:
7
- - src/*
8
- jobs:
9
- update_readme_api:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: checkout
13
- uses: actions/checkout@v6.0.1
14
- - name: prepare node
15
- uses: actions/setup-node@v6.1.0
16
- with:
17
- node-version: 24.11.1
18
- - name: install
19
- run: npm ci
20
- - name: run docs
21
- run: npm run docs
22
- - uses: gr2m/create-or-update-pull-request-action@v1.10.1
23
- env:
24
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25
- with:
26
- path: README.md
27
- title: Sync API into README
28
- branch: readme-api
29
- commit-message: "docs(README): sync API"
30
- permissions:
31
- contents: write
32
- pull-requests: write
@@ -1,60 +0,0 @@
1
- import test from "ava";
2
-
3
- import { ReceiveEndpoint } from "@kronos-integration/endpoint";
4
- import { StandaloneServiceProvider } from "@kronos-integration/service";
5
- import { ServiceMQTT, TopicEndpoint } from "@kronos-integration/service-mqtt";
6
-
7
- test("factory", async t => {
8
- const sp = new StandaloneServiceProvider();
9
- const r1 = new ReceiveEndpoint("r1", sp);
10
- r1.receive = async () => "OK R1";
11
-
12
- const mqtt = await sp.declareService({
13
- type: ServiceMQTT,
14
- clean: true,
15
- clientId: "test",
16
- url: "mqtt://localhost",
17
- endpoints: {
18
- s1: { topic: true, connected: r1 },
19
- s2: { topic: "s2b", connected: r1 },
20
- "s2/*/a": { topic: true, connected: r1 }
21
- }
22
- });
23
-
24
- t.is(mqtt.clean, true);
25
- t.is(mqtt.clientId, "test");
26
- t.is(mqtt.endpoints["s1"].name, "s1");
27
- t.is(mqtt.endpoints["s2"].name, "s2");
28
- t.true(mqtt.endpoints["s1"] instanceof TopicEndpoint);
29
- t.deepEqual(mqtt.topics, ["s1", "s2b", "s2/*/a"]);
30
- });
31
-
32
- test("start / stop", async t => {
33
- const sp = new StandaloneServiceProvider();
34
-
35
- const r1 = new ReceiveEndpoint("r1", sp);
36
-
37
- const received = [];
38
-
39
- r1.receive = async message => received.push(message);
40
-
41
- const mqtt = await sp.declareService({
42
- type: ServiceMQTT,
43
- url: "mqtt://localhost",
44
- clientId: "test",
45
- clean: true,
46
- connectTimeout: 4000,
47
- reconnectPeriod: 1000,
48
- endpoints: {
49
- s1: { topic: true, connected: r1 }
50
- }
51
- });
52
-
53
- t.is(mqtt.endpoints["s1"].name, "s1");
54
-
55
- await mqtt.start();
56
- t.is(mqtt.state, "running");
57
-
58
- await mqtt.stop();
59
- t.is(mqtt.state, "stopped");
60
- });