@evva/nest-mqtt 1.0.0 → 1.0.2
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 +15 -2
- package/dist/mqtt.constants.js +1 -2
- package/dist/mqtt.constants.js.map +1 -1
- package/dist/mqtt.module-definition.js +4 -2
- package/dist/mqtt.module-definition.js.map +1 -1
- package/dist/mqtt.module.js +2 -0
- package/dist/mqtt.module.js.map +1 -1
- package/dist/mqtt.service.js +161 -11
- package/dist/mqtt.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/mqtt.constants.d.ts +0 -1
- package/dist/types/mqtt.interface.d.ts +1 -0
- package/dist/types/mqtt.module-definition.d.ts +1 -1
- package/dist/types/mqtt.service.d.ts +16 -4
- package/package.json +6 -5
- package/dist/mqtt.explorer.js +0 -183
- package/dist/mqtt.explorer.js.map +0 -1
- package/dist/types/mqtt.explorer.d.ts +0 -21
|
@@ -2,4 +2,3 @@ export declare const MQTT_SUBSCRIBE_OPTIONS = "__mqtt_subscribe_options";
|
|
|
2
2
|
export declare const MQTT_SUBSCRIBER_PARAMS = "__mqtt_subscriber_params";
|
|
3
3
|
export declare const MQTT_CLIENT_INSTANCE = "MQTT_CLIENT_INSTANCE";
|
|
4
4
|
export declare const MQTT_OPTION_PROVIDER = "MQTT_OPTION_PROVIDER";
|
|
5
|
-
export declare const MQTT_LOGGER_PROVIDER = "MQTT_LOGGER_PROVIDER";
|
|
@@ -8,6 +8,7 @@ export interface MqttModuleOptions extends IClientOptions {
|
|
|
8
8
|
passwordProvider?: () => Promise<string>;
|
|
9
9
|
queue?: boolean;
|
|
10
10
|
share?: string;
|
|
11
|
+
topic?: string;
|
|
11
12
|
beforeHandle?: (topic: string, payload: Buffer, packet: Packet) => any;
|
|
12
13
|
}
|
|
13
14
|
export type MqttMessageTransformer = (payload: Buffer) => any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MqttModuleOptions } from './mqtt.interface';
|
|
2
|
-
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<MqttModuleOptions, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol
|
|
2
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<MqttModuleOptions, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<MqttModuleOptions, "create"> & Partial<{}>;
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { Packet, IClientPublishOptions, IClientSubscribeOptions, ISubscriptionGrant } from 'mqtt';
|
|
3
|
-
import { MqttModuleOptions } from './mqtt.interface';
|
|
2
|
+
import { MqttClient, Packet, IClientPublishOptions, IClientSubscribeOptions, ISubscriptionGrant } from 'mqtt';
|
|
3
|
+
import { MqttModuleOptions, MqttSubscribeOptions, MqttSubscriberParameter } from './mqtt.interface';
|
|
4
|
+
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
4
5
|
export declare class MqttService implements OnModuleInit, OnModuleDestroy {
|
|
6
|
+
private readonly discoveryService;
|
|
7
|
+
private readonly metadataScanner;
|
|
5
8
|
private readonly options;
|
|
6
9
|
private readonly logger;
|
|
7
10
|
private client;
|
|
8
|
-
|
|
11
|
+
private readonly reflector;
|
|
12
|
+
private subscribers;
|
|
13
|
+
constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, options: MqttModuleOptions);
|
|
14
|
+
getClient(): MqttClient;
|
|
9
15
|
connect(): Promise<void>;
|
|
10
16
|
subscribe(topic: string | string[], opts?: IClientSubscribeOptions): Promise<ISubscriptionGrant[]>;
|
|
11
17
|
unsubscribe(topic: string, opts?: IClientSubscribeOptions): Promise<Packet>;
|
|
12
18
|
publish(topic: string, message: string | Buffer | object, opts?: IClientPublishOptions): Promise<Packet>;
|
|
19
|
+
preprocess(subscribeOptions: MqttSubscribeOptions): string | string[];
|
|
20
|
+
_subscribe(options: MqttSubscribeOptions, parameters: MqttSubscriberParameter[], handle: any, provider: any): void;
|
|
21
|
+
explore(): void;
|
|
22
|
+
private getSubscriber;
|
|
23
|
+
private static topicToRegexp;
|
|
24
|
+
private static matchGroups;
|
|
13
25
|
onModuleInit(): Promise<void>;
|
|
14
|
-
onModuleDestroy(): void
|
|
26
|
+
onModuleDestroy(): Promise<void>;
|
|
15
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evva/nest-mqtt",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MQTT Broker client for Nest.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:watch": "jest --watch",
|
|
34
34
|
"test:cov": "jest --coverage",
|
|
35
35
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
36
|
-
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
36
|
+
"test:e2e": "jest --config ./test/jest-e2e.json --detectOpenHandles",
|
|
37
37
|
"prepack": "npx nest build"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -44,13 +44,15 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nestjs/cli": "^10.4.8",
|
|
46
46
|
"@nestjs/common": "^10.4.7",
|
|
47
|
-
"@nestjs/core": "^10.4.7",
|
|
48
47
|
"@nestjs/config": "^3.3.0",
|
|
48
|
+
"@nestjs/core": "^10.4.7",
|
|
49
|
+
"@nestjs/event-emitter": "^2.1.1",
|
|
49
50
|
"@nestjs/testing": "^10.4.7",
|
|
50
51
|
"@release-it/conventional-changelog": "^9.0.3",
|
|
51
52
|
"@types/express": "^5.0.0",
|
|
52
53
|
"@types/jest": "29.5.14",
|
|
53
54
|
"@types/node": "^22.9.0",
|
|
55
|
+
"aedes": "0.51.3",
|
|
54
56
|
"auto-changelog": "^2.5.0",
|
|
55
57
|
"prettier": "3.3.3",
|
|
56
58
|
"reflect-metadata": "^0.2.2",
|
|
@@ -64,8 +66,7 @@
|
|
|
64
66
|
"tsc-watch": "6.2.1",
|
|
65
67
|
"tsconfig-paths": "4.2.0",
|
|
66
68
|
"tslint": "6.1.3",
|
|
67
|
-
"typescript": "^5.6.3"
|
|
68
|
-
"aedes": "^0.51.2"
|
|
69
|
+
"typescript": "^5.6.3"
|
|
69
70
|
},
|
|
70
71
|
"jest": {
|
|
71
72
|
"moduleFileExtensions": [
|
package/dist/mqtt.explorer.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var MqttExplorer_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.MqttExplorer = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const core_1 = require("@nestjs/core");
|
|
19
|
-
const mqtt_constants_1 = require("./mqtt.constants");
|
|
20
|
-
const mqtt_1 = require("mqtt");
|
|
21
|
-
const mqtt_transform_1 = require("./mqtt.transform");
|
|
22
|
-
let MqttExplorer = MqttExplorer_1 = class MqttExplorer {
|
|
23
|
-
constructor(discoveryService, metadataScanner, logger, client, options) {
|
|
24
|
-
this.discoveryService = discoveryService;
|
|
25
|
-
this.metadataScanner = metadataScanner;
|
|
26
|
-
this.logger = logger;
|
|
27
|
-
this.client = client;
|
|
28
|
-
this.options = options;
|
|
29
|
-
this.reflector = new core_1.Reflector();
|
|
30
|
-
this.subscribers = [];
|
|
31
|
-
}
|
|
32
|
-
onModuleInit() {
|
|
33
|
-
this.logger.log('MqttModule dependencies initialized');
|
|
34
|
-
this.explore();
|
|
35
|
-
}
|
|
36
|
-
preprocess(options) {
|
|
37
|
-
const processTopic = (topic) => {
|
|
38
|
-
const queue = typeof options.queue === 'boolean' ? options.queue : this.options.queue;
|
|
39
|
-
const share = typeof options.share === 'string' ? options.share : this.options.share;
|
|
40
|
-
topic = topic
|
|
41
|
-
.replace('$queue/', '')
|
|
42
|
-
.replace(/^\$share\/([A-Za-z0-9]+)\//, '');
|
|
43
|
-
if (queue) {
|
|
44
|
-
return `$queue/${topic}`;
|
|
45
|
-
}
|
|
46
|
-
if (share) {
|
|
47
|
-
return `$share/${share}/${topic}`;
|
|
48
|
-
}
|
|
49
|
-
return topic;
|
|
50
|
-
};
|
|
51
|
-
if (Array.isArray(options.topic)) {
|
|
52
|
-
return options.topic.map(processTopic);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return processTopic(options.topic);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
subscribe(options, parameters, handle, provider) {
|
|
59
|
-
const topic = this.preprocess(options);
|
|
60
|
-
this.client.subscribe(topic, (err) => {
|
|
61
|
-
if (!err) {
|
|
62
|
-
if (!Array.isArray(options.topic)) {
|
|
63
|
-
const topics = new Array();
|
|
64
|
-
topics.push(options.topic);
|
|
65
|
-
options.topic = topics;
|
|
66
|
-
}
|
|
67
|
-
options.topic.forEach((aTopic) => {
|
|
68
|
-
this.subscribers.push({
|
|
69
|
-
topic: aTopic,
|
|
70
|
-
route: aTopic
|
|
71
|
-
.replace('$queue/', '')
|
|
72
|
-
.replace(/^\$share\/([A-Za-z0-9]+)\//, ''),
|
|
73
|
-
regexp: MqttExplorer_1.topicToRegexp(aTopic),
|
|
74
|
-
provider,
|
|
75
|
-
handle,
|
|
76
|
-
options,
|
|
77
|
-
parameters,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.logger.error(`subscribe topic [${options.topic} failed]`);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
explore() {
|
|
87
|
-
const providers = this.discoveryService.getProviders();
|
|
88
|
-
providers.forEach((wrapper) => {
|
|
89
|
-
const { instance } = wrapper;
|
|
90
|
-
if (!instance) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
this.metadataScanner.scanFromPrototype(instance, Object.getPrototypeOf(instance), (key) => {
|
|
94
|
-
const subscribeOptions = this.reflector.get(mqtt_constants_1.MQTT_SUBSCRIBE_OPTIONS, instance[key]);
|
|
95
|
-
const parameters = this.reflector.get(mqtt_constants_1.MQTT_SUBSCRIBER_PARAMS, instance[key]);
|
|
96
|
-
if (subscribeOptions) {
|
|
97
|
-
this.subscribe(subscribeOptions, parameters, instance[key], instance);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
this.client.on('message', (topic, payload, packet) => {
|
|
102
|
-
const subscriber = this.getSubscriber(topic);
|
|
103
|
-
if (subscriber) {
|
|
104
|
-
const parameters = subscriber.parameters || [];
|
|
105
|
-
const scatterParameters = [];
|
|
106
|
-
for (const parameter of parameters) {
|
|
107
|
-
scatterParameters[parameter.index] = parameter;
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const transform = (0, mqtt_transform_1.getTransform)(subscriber.options.transform);
|
|
111
|
-
if (this.options.beforeHandle) {
|
|
112
|
-
this.options.beforeHandle(topic, payload, packet);
|
|
113
|
-
}
|
|
114
|
-
subscriber.handle.bind(subscriber.provider)(...scatterParameters.map((parameter) => {
|
|
115
|
-
switch (parameter === null || parameter === void 0 ? void 0 : parameter.type) {
|
|
116
|
-
case 'payload':
|
|
117
|
-
return transform(payload);
|
|
118
|
-
case 'topic':
|
|
119
|
-
return topic;
|
|
120
|
-
case 'packet':
|
|
121
|
-
return packet;
|
|
122
|
-
case 'params':
|
|
123
|
-
return MqttExplorer_1.matchGroups(topic, subscriber.regexp);
|
|
124
|
-
default:
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
this.logger.error(err);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
getSubscriber(topic) {
|
|
136
|
-
for (const subscriber of this.subscribers) {
|
|
137
|
-
subscriber.regexp.lastIndex = 0;
|
|
138
|
-
if (subscriber.regexp.test(topic)) {
|
|
139
|
-
return subscriber;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
static topicToRegexp(topic) {
|
|
145
|
-
return new RegExp('^' +
|
|
146
|
-
topic
|
|
147
|
-
.replace('$queue/', '')
|
|
148
|
-
.replace(/^\$share\/([A-Za-z0-9]+)\//, '')
|
|
149
|
-
.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g, '\\$1')
|
|
150
|
-
.replace(/\+/g, '([^/]+)')
|
|
151
|
-
.replace(/\/#$/, '(/.*)?') +
|
|
152
|
-
'$', 'y');
|
|
153
|
-
}
|
|
154
|
-
static matchGroups(str, regex) {
|
|
155
|
-
regex.lastIndex = 0;
|
|
156
|
-
let m = regex.exec(str);
|
|
157
|
-
const matches = [];
|
|
158
|
-
while (m !== null) {
|
|
159
|
-
if (m.index === regex.lastIndex) {
|
|
160
|
-
regex.lastIndex++;
|
|
161
|
-
}
|
|
162
|
-
m.forEach((match, groupIndex) => {
|
|
163
|
-
if (groupIndex !== 0) {
|
|
164
|
-
matches.push(match);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
m = regex.exec(str);
|
|
168
|
-
}
|
|
169
|
-
return matches;
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
exports.MqttExplorer = MqttExplorer;
|
|
173
|
-
exports.MqttExplorer = MqttExplorer = MqttExplorer_1 = __decorate([
|
|
174
|
-
(0, common_1.Injectable)(),
|
|
175
|
-
__param(2, (0, common_1.Inject)(mqtt_constants_1.MQTT_LOGGER_PROVIDER)),
|
|
176
|
-
__param(3, (0, common_1.Inject)(mqtt_constants_1.MQTT_CLIENT_INSTANCE)),
|
|
177
|
-
__param(4, (0, common_1.Inject)(mqtt_constants_1.MQTT_OPTION_PROVIDER)),
|
|
178
|
-
__metadata("design:paramtypes", [core_1.DiscoveryService,
|
|
179
|
-
core_1.MetadataScanner,
|
|
180
|
-
common_1.Logger,
|
|
181
|
-
mqtt_1.MqttClient, Object])
|
|
182
|
-
], MqttExplorer);
|
|
183
|
-
//# sourceMappingURL=mqtt.explorer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mqtt.explorer.js","sourceRoot":"","sources":["../src/mqtt.explorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,uCAA4E;AAE5E,qDAM0B;AAC1B,+BAAkC;AAElC,qDAAgD;AASzC,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAIvB,YACmB,gBAAkC,EAClC,eAAgC,EACnB,MAA+B,EAC/B,MAAmC,EACnC,OAA2C;QAJxD,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,oBAAe,GAAf,eAAe,CAAiB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estjs/core';
|
|
3
|
-
import { MqttClient } from 'mqtt';
|
|
4
|
-
import { MqttModuleOptions, MqttSubscribeOptions, MqttSubscriber, MqttSubscriberParameter } from './mqtt.interface';
|
|
5
|
-
export declare class MqttExplorer implements OnModuleInit {
|
|
6
|
-
private readonly discoveryService;
|
|
7
|
-
private readonly metadataScanner;
|
|
8
|
-
private readonly logger;
|
|
9
|
-
private readonly client;
|
|
10
|
-
private readonly options;
|
|
11
|
-
private readonly reflector;
|
|
12
|
-
subscribers: MqttSubscriber[];
|
|
13
|
-
constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, logger: Logger, client: MqttClient, options: MqttModuleOptions);
|
|
14
|
-
onModuleInit(): void;
|
|
15
|
-
preprocess(options: MqttSubscribeOptions): string | string[];
|
|
16
|
-
subscribe(options: MqttSubscribeOptions, parameters: MqttSubscriberParameter[], handle: any, provider: any): void;
|
|
17
|
-
explore(): void;
|
|
18
|
-
private getSubscriber;
|
|
19
|
-
private static topicToRegexp;
|
|
20
|
-
private static matchGroups;
|
|
21
|
-
}
|