Skip to content

Commit 746c0bc

Browse files
committed
Improved TypeScript declarations for userProperties
userProperties changed from being object to being {[index: string]: string[]} (name-value string pairs) Also changed OnConnectCallback and OnMessageCallback to use IConnectPacket and IPublishPacket respectively. These are the specific packets relevant to these callbacks rather than the more generic Packet. NB Also changed package.json to link to version of mqtt-packet with the equivalent changes which are required. This needs to be updated prior to Pulling.
1 parent 37b12cb commit 746c0bc

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"help-me": "^1.0.1",
6969
"inherits": "^2.0.3",
7070
"minimist": "^1.2.5",
71-
"mqtt-packet": "^6.6.0",
71+
"mqtt-packet": "git://github.com/bkp7/mqtt-packet.git#8647df5315909bb3ac17b6b5635bcd659e172fce",
7272
"pump": "^3.0.0",
7373
"readable-stream": "^3.6.0",
7474
"reinterval": "^1.1.0",

types/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ export {
2323
IPingreqPacket,
2424
IPingrespPacket,
2525
IDisconnectPacket,
26-
Packet
26+
Packet,
27+
UserProperties
2728
} from 'mqtt-packet'

types/lib/client-options.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { MqttClient } from './client'
22
import { Store } from './store'
3-
import { QoS } from 'mqtt-packet'
3+
import { QoS, UserProperties } from 'mqtt-packet'
44

55
export declare type StorePutCallback = () => void
66

@@ -99,7 +99,7 @@ export interface IClientOptions extends ISecureClientOptions {
9999
contentType?: string,
100100
responseTopic?: string,
101101
correlationData?: Buffer,
102-
userProperties?: Object
102+
userProperties?: UserProperties
103103
}
104104
}
105105
transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string,
@@ -110,7 +110,7 @@ export interface IClientOptions extends ISecureClientOptions {
110110
topicAliasMaximum?: number,
111111
requestResponseInformation?: boolean,
112112
requestProblemInformation?: boolean,
113-
userProperties?: Object,
113+
userProperties?: UserProperties,
114114
authenticationMethod?: string,
115115
authenticationData?: Buffer
116116
}
@@ -152,7 +152,7 @@ export interface IClientPublishOptions {
152152
topicAlias?: string,
153153
responseTopic?: string,
154154
correlationData?: Buffer,
155-
userProperties?: Object,
155+
userProperties?: UserProperties,
156156
subscriptionIdentifier?: number,
157157
contentType?: string
158158
}

types/lib/client.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
IClientReconnectOptions
99
} from './client-options'
1010
import { Store } from './store'
11-
import { Packet, QoS } from 'mqtt-packet'
11+
import { Packet, IConnectPacket, IPublishPacket, QoS } from 'mqtt-packet'
1212

1313
export interface ISubscriptionGrant {
1414
/**
@@ -66,9 +66,9 @@ export interface ISubscriptionMap {
6666
}
6767
}
6868

69-
export declare type OnConnectCallback = (packet: Packet) => void
69+
export declare type OnConnectCallback = (packet: IConnectPacket) => void
7070
export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
71-
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: Packet) => void
71+
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void
7272
export declare type OnPacketCallback = (packet: Packet) => void
7373
export declare type OnErrorCallback = (error: Error) => void
7474
export declare type PacketCallback = (error?: Error, packet?: Packet) => any

0 commit comments

Comments
 (0)