mqtt-plus 1.4.0 → 1.4.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  ChangeLog
3
3
  =========
4
4
 
5
+ 1.4.1 (2026-02-21)
6
+ ------------------
7
+
8
+ - BUGFIX: fix file references and TypeScript configuration in test directory
9
+ - CLEANUP: cleanup code and tests
10
+
5
11
  1.4.0 (2026-02-21)
6
12
  ------------------
7
13
 
package/etc/stx.conf CHANGED
@@ -50,6 +50,7 @@ dev
50
50
 
51
51
  # run test suite
52
52
  test
53
+ tsc --project tst/tsc.json --noEmit && \
53
54
  eslint --config etc/eslint.mts tst/mqtt-plus-0-fixture.ts tst/mqtt-plus-0-mosquitto.ts tst/*.spec.ts && \
54
55
  NODE_OPTIONS="--import=tsx --trace-warnings" mocha --require tst/mqtt-plus-0-fixture.ts tst/*.spec.ts
55
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mqtt-plus",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "MQTT Communication Patterns",
5
5
  "keywords": [ "mqtt",
6
6
  "event", "emit",
@@ -61,7 +61,7 @@ describe("MQTT+ Sink Push", function () {
61
61
  info.buffer!.then((buf: Uint8Array) => {
62
62
  spy("buffer")
63
63
  expect(Buffer.from(buf)).to.deep.equal(data)
64
- })
64
+ }).catch(() => {})
65
65
  })
66
66
 
67
67
  /* push a buffer (instead of a stream) */
@@ -93,7 +93,7 @@ describe("MQTT+ Sink Push", function () {
93
93
  if (name !== "foo")
94
94
  throw new Error("invalid sink push")
95
95
  expect(name).to.be.equal("foo")
96
- expect(info).to.be.of.an("object")
96
+ expect(info).to.be.an("object")
97
97
  expect(info.stream).to.be.instanceOf(stream.Readable)
98
98
  const chunks: Buffer[] = []
99
99
  info.stream!.on("data", (chunk: Buffer) => {
@@ -148,7 +148,7 @@ describe("MQTT+ Sink Push", function () {
148
148
  info.buffer!.then((buf: Uint8Array) => {
149
149
  spy("buffer")
150
150
  expect(Buffer.from(buf)).to.deep.equal(data)
151
- })
151
+ }).catch(() => {})
152
152
  })
153
153
 
154
154
  /* push with metadata */
@@ -65,7 +65,7 @@ describe("MQTT+ Source Fetch", function () {
65
65
  expect(error2).to.be.equal("invalid source")
66
66
 
67
67
  /* fetch non-existing source (invalid source name) */
68
- const result3 = await ctx.apiC.fetch("example/server/download-invalid", "foo").catch((err) => err.message)
68
+ const result3 = await ctx.apiC.fetch("example/server/download-invalid", "foo")
69
69
  const error3 = await result3.buffer.catch((err: Error) => {
70
70
  return err.message
71
71
  })
@@ -110,7 +110,7 @@ describe("MQTT+ Source Fetch", function () {
110
110
  ctx.apiS.meta("server-version", "1.0")
111
111
 
112
112
  /* establish source */
113
- const sourcing = await ctx.apiS.source("example/server/download", async (filename, info) => {
113
+ const sourcing = await ctx.apiS.source("example/server/download", async (_filename, info) => {
114
114
  info.buffer = Promise.resolve(Buffer.from("data"))
115
115
  })
116
116
 
@@ -121,7 +121,7 @@ describe("MQTT+ Source Fetch", function () {
121
121
  expect(meta!["server-version"]).to.be.equal("1.0")
122
122
 
123
123
  /* cleanup */
124
- ctx.apiS.meta("server-version", undefined)
124
+ ctx.apiS.meta("server-version", null)
125
125
  await sourcing.destroy()
126
126
  })
127
127
  })
@@ -46,7 +46,7 @@ const { expect } = chai
46
46
 
47
47
  /* test suite */
48
48
  describe("MQTT+ Miscellaneous", function () {
49
- /* test case: Dry-Run & Last-Will */
49
+ /* test case: Dry-Run & Last-Will */
50
50
  it("MQTT+ Dry-Run & MQTT Last-Will", async function () {
51
51
  this.timeout(3000)
52
52
 
@@ -67,7 +67,7 @@ describe("MQTT+ Miscellaneous", function () {
67
67
 
68
68
  /* observe connection events */
69
69
  const spy = sinon.spy()
70
- apiServer.event("example/server/connection", (state) => {
70
+ const eventReg = await apiServer.event("example/server/connection", (state) => {
71
71
  expect(state).to.match(/^(?:open|close)$/)
72
72
  spy(state)
73
73
  })
@@ -96,8 +96,9 @@ describe("MQTT+ Miscellaneous", function () {
96
96
  await new Promise((resolve) => { setTimeout(resolve, 1000) })
97
97
 
98
98
  /* perform regular destruction of client */
99
+ await eventReg.destroy()
99
100
  apiServer.destroy()
100
- mqttServer.end()
101
+ await mqttServer.endAsync()
101
102
 
102
103
  /* ensure connection open and close events were seen */
103
104
  expect(spy.getCalls().map((call) => call.firstArg))
@@ -141,13 +142,12 @@ describe("MQTT+ Miscellaneous", function () {
141
142
  })
142
143
 
143
144
  /* call service (without token) */
144
- await ctx.apiC.call("example/server/hello", "world", 42).then(async (result) => {
145
+ await ctx.apiC.call("example/server/hello", "world", 42).then(async (_result) => {
145
146
  spy("call1-success")
146
- }).catch((err: Error) => {
147
+ }).catch((_err: Error) => {
147
148
  spy("call1-error")
148
149
  })
149
- expect(spy.getCalls()
150
- .map((call) => call.firstArg))
150
+ expect(spy.getCalls().map((call) => call.firstArg))
151
151
  .to.be.deep.equal([ "call1-error" ])
152
152
  spy.resetHistory()
153
153
 
@@ -155,35 +155,32 @@ describe("MQTT+ Miscellaneous", function () {
155
155
  await ctx.apiC.call("example/server/login", userCred).then(async (token) => {
156
156
  spy("login-success")
157
157
  expect(token).to.be.equal(userToken)
158
- }).catch((err: Error) => {
158
+ }).catch((_err: Error) => {
159
159
  spy("login-error")
160
160
  })
161
- expect(spy.getCalls()
162
- .map((call) => call.firstArg))
161
+ expect(spy.getCalls().map((call) => call.firstArg))
163
162
  .to.be.deep.equal([ "login", "login-success" ])
164
163
  spy.resetHistory()
165
164
 
166
165
  /* call service (with wrong token) */
167
166
  await ctx.apiC.authenticate("wrong")
168
- await ctx.apiC.call("example/server/hello", "world", 42).then(async (result) => {
167
+ await ctx.apiC.call("example/server/hello", "world", 42).then(async (_result) => {
169
168
  spy("call2-success")
170
- }).catch((err: Error) => {
169
+ }).catch((_err: Error) => {
171
170
  spy("call2-error")
172
171
  })
173
- expect(spy.getCalls()
174
- .map((call) => call.firstArg))
172
+ expect(spy.getCalls().map((call) => call.firstArg))
175
173
  .to.be.deep.equal([ "call2-error" ])
176
174
  spy.resetHistory()
177
175
 
178
176
  /* call service (with correct token) */
179
177
  await ctx.apiC.authenticate(userToken)
180
- await ctx.apiC.call("example/server/hello", "world", 42).then(async (result) => {
178
+ await ctx.apiC.call("example/server/hello", "world", 42).then(async (_result) => {
181
179
  spy("call3-success")
182
- }).catch((err: Error) => {
180
+ }).catch((_err: Error) => {
183
181
  spy("call3-error")
184
182
  })
185
- expect(spy.getCalls()
186
- .map((call) => call.firstArg))
183
+ expect(spy.getCalls().map((call) => call.firstArg))
187
184
  .to.be.deep.equal([ "hello", "call3-success" ])
188
185
 
189
186
  /* destroy service */
package/tst/tsc.json CHANGED
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "include": [
25
- "../tst/**/*.spec.ts"
25
+ "*.ts"
26
26
  ],
27
27
  "exclude": [
28
28
  "../node_modules"