mqtt-plus 1.4.22 → 1.4.23
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/.ase/service.log +21 -0
- package/.ase/service.yaml +1 -1
- package/CHANGELOG.md +3 -1
- package/dst-stage1/mqtt-plus-base.js +13 -0
- package/dst-stage1/mqtt-plus-options.js +1 -3
- package/dst-stage2/mqtt-plus.cjs.cjs +5 -1
- package/dst-stage2/mqtt-plus.esm.js +5 -1
- package/dst-stage2/mqtt-plus.umd.js +2 -2
- package/package.json +1 -1
- package/src/mqtt-plus-base.ts +14 -0
- package/src/mqtt-plus-options.ts +1 -4
package/package.json
CHANGED
package/src/mqtt-plus-base.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { type MqttClient,
|
|
|
28
28
|
type IClientSubscribeOptions,
|
|
29
29
|
type IClientPublishOptions,
|
|
30
30
|
type IPublishPacket } from "mqtt"
|
|
31
|
+
import { nanoid } from "nanoid"
|
|
31
32
|
|
|
32
33
|
/* internal requirements */
|
|
33
34
|
import type { APISchema, Registration } from "./mqtt-plus-api"
|
|
@@ -79,6 +80,19 @@ export class BaseTrait<T extends APISchema = APISchema> extends TraceTrait<T> {
|
|
|
79
80
|
/* store MQTT client */
|
|
80
81
|
this.mqtt = mqtt
|
|
81
82
|
|
|
83
|
+
/* resolve the instance "id": if the user did not provide an
|
|
84
|
+
explicit one, fetch the "clientId" from the underlying MQTT
|
|
85
|
+
client, and only as a last resort fall back to a generated id
|
|
86
|
+
(e.g. for the fake proxy MQTT client without a real clientId) */
|
|
87
|
+
if (this.options.id === "") {
|
|
88
|
+
const clientId = (mqtt as any).isFakeProxy
|
|
89
|
+
? undefined
|
|
90
|
+
: mqtt.options?.clientId
|
|
91
|
+
this.options.id = (typeof clientId === "string" && clientId !== "")
|
|
92
|
+
? clientId
|
|
93
|
+
: nanoid()
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
/* hook into the MQTT message processing */
|
|
83
97
|
this.log("info", "hooking into MQTT client")
|
|
84
98
|
this.messageHandler = (topic, message, packet) => {
|
package/src/mqtt-plus-options.ts
CHANGED
|
@@ -22,9 +22,6 @@
|
|
|
22
22
|
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
/* external requirements */
|
|
26
|
-
import { nanoid } from "nanoid"
|
|
27
|
-
|
|
28
25
|
/* internal requirements */
|
|
29
26
|
import type { APISchema } from "./mqtt-plus-api"
|
|
30
27
|
|
|
@@ -55,7 +52,7 @@ export class OptionsTrait<_T extends APISchema = APISchema> {
|
|
|
55
52
|
) {
|
|
56
53
|
/* determine options and provide defaults */
|
|
57
54
|
this.options = {
|
|
58
|
-
id:
|
|
55
|
+
id: "", /* intentionally resolved later in BaseTrait */
|
|
59
56
|
codec: "cbor",
|
|
60
57
|
timeout: 10 * 1000,
|
|
61
58
|
share: "",
|