Skip to content

Improved TypeScript declarations for userProperties #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@
"help-me": "^1.0.1",
"inherits": "^2.0.3",
"minimist": "^1.2.5",
"mqtt-packet": "^6.6.0",
"mqtt-packet": "^6.8.0",
"pump": "^3.0.0",
"readable-stream": "^3.6.0",
"reinterval": "^1.1.0",
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -23,5 +23,6 @@ export {
IPingreqPacket,
IPingrespPacket,
IDisconnectPacket,
Packet
Packet,
UserProperties
} from 'mqtt-packet'
8 changes: 4 additions & 4 deletions types/lib/client-options.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MqttClient } from './client'
import { Store } from './store'
import { QoS } from 'mqtt-packet'
import { QoS, UserProperties } from 'mqtt-packet'

export declare type StorePutCallback = () => void

@@ -99,7 +99,7 @@ export interface IClientOptions extends ISecureClientOptions {
contentType?: string,
responseTopic?: string,
correlationData?: Buffer,
userProperties?: Object
userProperties?: UserProperties
}
}
transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string,
@@ -110,7 +110,7 @@ export interface IClientOptions extends ISecureClientOptions {
topicAliasMaximum?: number,
requestResponseInformation?: boolean,
requestProblemInformation?: boolean,
userProperties?: Object,
userProperties?: UserProperties,
authenticationMethod?: string,
authenticationData?: Buffer
}
@@ -152,7 +152,7 @@ export interface IClientPublishOptions {
topicAlias?: string,
responseTopic?: string,
correlationData?: Buffer,
userProperties?: Object,
userProperties?: UserProperties,
subscriptionIdentifier?: number,
contentType?: string
}
13 changes: 10 additions & 3 deletions types/lib/client.d.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
IClientReconnectOptions
} from './client-options'
import { Store } from './store'
import { Packet, QoS } from 'mqtt-packet'
import { Packet, IConnectPacket, IPublishPacket, IDisconnectPacket, QoS } from 'mqtt-packet'

export interface ISubscriptionGrant {
/**
@@ -66,9 +66,10 @@ export interface ISubscriptionMap {
}
}

export declare type OnConnectCallback = (packet: Packet) => void
export declare type OnConnectCallback = (packet: IConnectPacket) => void
export declare type OnDisconnectCallback = (packet: IDisconnectPacket) => void
export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: Packet) => void
export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void
export declare type OnPacketCallback = (packet: Packet) => void
export declare type OnErrorCallback = (error: Error) => void
export declare type PacketCallback = (error?: Error, packet?: Packet) => any
@@ -101,13 +102,19 @@ export declare class MqttClient extends events.EventEmitter {
public on (event: 'connect', cb: OnConnectCallback): this
public on (event: 'message', cb: OnMessageCallback): this
public on (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
public on (event: 'disconnect', cb: OnDisconnectCallback): this
public on (event: 'error', cb: OnErrorCallback): this
public on (event: 'close', cb: OnCloseCallback): this
public on (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this
public on (event: string, cb: Function): this

public once (event: 'connect', cb: OnConnectCallback): this
public once (event: 'message', cb: OnMessageCallback): this
public once (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
public once (event: 'disconnect', cb: OnDisconnectCallback): this
public once (event: 'error', cb: OnErrorCallback): this
public once (event: 'close', cb: OnCloseCallback): this
public once (event: 'end' | 'reconnect' | 'offline' | 'outgoingEmpty', cb: () => void): this
public once (event: string, cb: Function): this

/**