@evva/nest-mqtt 1.0.4 → 1.2.0

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.
@@ -2,3 +2,5 @@ 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 TOPIC_VAR_REGEX: RegExp;
6
+ export declare const MAX_VAR_TOPIC_LENGTH = 2048;
@@ -6,6 +6,7 @@ export interface MqttModuleOptions extends IClientOptions {
6
6
  username: string;
7
7
  password?: string;
8
8
  passwordProvider?: () => Promise<string>;
9
+ topicResolver?: (varname: string) => string;
9
10
  queue?: boolean;
10
11
  share?: string;
11
12
  topic?: string;
@@ -1,24 +1,24 @@
1
1
  import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
2
  import { MqttClient, Packet, IClientPublishOptions, IClientSubscribeOptions, ISubscriptionGrant } from 'mqtt';
3
- import { MqttModuleOptions, MqttSubscribeOptions, MqttSubscriberParameter } from './mqtt.interface';
3
+ import { MqttModuleOptions } from './mqtt.interface';
4
4
  import { DiscoveryService, MetadataScanner } from '@nestjs/core';
5
5
  export declare class MqttService implements OnModuleInit, OnModuleDestroy {
6
6
  private readonly discoveryService;
7
7
  private readonly metadataScanner;
8
8
  private readonly options;
9
9
  private readonly logger;
10
- private client;
11
10
  private readonly reflector;
12
- private subscribers;
11
+ private readonly subscribers;
12
+ private client;
13
13
  constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, options: MqttModuleOptions);
14
14
  getClient(): MqttClient;
15
15
  connect(): Promise<void>;
16
16
  subscribe(topic: string | string[], opts?: IClientSubscribeOptions): Promise<ISubscriptionGrant[]>;
17
17
  unsubscribe(topic: string, opts?: IClientSubscribeOptions): Promise<Packet>;
18
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;
19
+ explore(): Promise<void>;
20
+ private preprocess;
21
+ private _subscribe;
22
22
  private getSubscriber;
23
23
  private static topicToRegexp;
24
24
  private static matchGroups;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evva/nest-mqtt",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
4
4
  "description": "MQTT Broker client for Nest.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -27,8 +27,11 @@
27
27
  "scripts": {
28
28
  "build": "rimraf dist && tsc -p tsconfig.build.json",
29
29
  "format": "prettier --write \"src/**/*.ts\"",
30
+ "fmt": "npm run lint:fix && npm run prettier:fix",
30
31
  "lint": "tslint -p tsconfig.json -c tslint.json",
31
- "fmt": "npx tslint -p tsconfig.json -c tslint.json --fix && npx prettier -- --write",
32
+ "lint:fix": "npm run lint -- --fix",
33
+ "prettier": "npx prettier \"**/*.{js,ts,jsx,tsx,cjs,cts,mjs,mts,vue,astro,css,scss,json}\" --check",
34
+ "prettier:fix": "npm run prettier -- --write",
32
35
  "test": "jest",
33
36
  "test:watch": "jest --watch",
34
37
  "test:cov": "jest --coverage",
@@ -42,31 +45,31 @@
42
45
  "mqtt": "^5.10.2"
43
46
  },
44
47
  "devDependencies": {
45
- "@nestjs/cli": "^11.0.2",
46
- "@nestjs/common": "^11.0.7",
47
- "@nestjs/config": "^4.0.0",
48
- "@nestjs/core": "^11.0.7",
49
- "@nestjs/event-emitter": "^3.0.0",
50
- "@nestjs/testing": "^11.0.7",
48
+ "@nestjs/cli": "^11.0.5",
49
+ "@nestjs/common": "^11.0.12",
50
+ "@nestjs/config": "^4.0.1",
51
+ "@nestjs/core": "^11.0.12",
52
+ "@nestjs/event-emitter": "^3.0.1",
53
+ "@nestjs/testing": "^11.0.12",
51
54
  "@release-it/conventional-changelog": "^10.0.0",
52
- "@types/express": "^5.0.0",
55
+ "@types/express": "^5.0.1",
53
56
  "@types/jest": "29.5.14",
54
- "@types/node": "^22.13.1",
57
+ "@types/node": "^22.13.14",
55
58
  "aedes": "0.51.3",
56
59
  "auto-changelog": "^2.5.0",
57
- "prettier": "3.4.2",
60
+ "prettier": "3.5.3",
58
61
  "reflect-metadata": "^0.2.2",
59
62
  "release-it": "^18.1.2",
60
63
  "rimraf": "^6.0.1",
61
- "rxjs": "^7.8.1",
62
- "supertest": "^7.0.0",
63
- "ts-jest": "29.2.5",
64
+ "rxjs": "^7.8.2",
65
+ "supertest": "^7.1.0",
66
+ "ts-jest": "29.3.0",
64
67
  "ts-loader": "^9.5.2",
65
68
  "ts-node": "^10.9.2",
66
69
  "tsc-watch": "6.2.1",
67
70
  "tsconfig-paths": "4.2.0",
68
71
  "tslint": "6.1.3",
69
- "typescript": "^5.7.3"
72
+ "typescript": "^5.8.2"
70
73
  },
71
74
  "jest": {
72
75
  "moduleFileExtensions": [