Skip to content

Improved TypeScript declarations for userProperties #103

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 2 commits into from
Feb 12, 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
30 changes: 16 additions & 14 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export declare type PacketCmd = 'auth' |
'unsuback' |
'unsubscribe'

export declare type UserProperties = {[index: string]: string | string[]}

export interface IPacket {
cmd: PacketCmd
messageId?: number
Expand All @@ -32,7 +34,7 @@ export interface IAuthPacket extends IPacket {
authenticationMethod?: string,
authenticationData?: Buffer,
reasonString?: string,
userProperties?: Object,
userProperties?: UserProperties,
}
}

Expand All @@ -57,7 +59,7 @@ export interface IConnectPacket extends IPacket {
contentType?: string,
responseTopic?: string,
correlationData?: Buffer,
userProperties?: Object
userProperties?: UserProperties
}
}
properties?: {
Expand All @@ -67,7 +69,7 @@ export interface IConnectPacket extends IPacket {
topicAliasMaximum?: number,
requestResponseInformation?: boolean,
requestProblemInformation?: boolean,
userProperties?: Object,
userProperties?: UserProperties,
authenticationMethod?: string,
authenticationData?: Buffer
}
Expand All @@ -86,7 +88,7 @@ export interface IPublishPacket extends IPacket {
topicAlias?: number,
responseTopic?: string,
correlationData?: Buffer,
userProperties?: Object,
userProperties?: UserProperties,
subscriptionIdentifier?: number,
contentType?: string
}
Expand All @@ -105,7 +107,7 @@ export interface IConnackPacket extends IPacket {
assignedClientIdentifier?: string,
topicAliasMaximum?: number,
reasonString?: string,
userProperties?: Object,
userProperties?: UserProperties,
wildcardSubscriptionAvailable?: boolean,
subscriptionIdentifiersAvailable?: boolean,
sharedSubscriptionAvailable?: boolean,
Expand All @@ -130,15 +132,15 @@ export interface ISubscribePacket extends IPacket {
subscriptions: ISubscription[],
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

export interface ISubackPacket extends IPacket {
cmd: 'suback',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
},
granted: number[] | Object[]
}
Expand All @@ -147,7 +149,7 @@ export interface IUnsubscribePacket extends IPacket {
cmd: 'unsubscribe',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
},
unsubscriptions: string[]
}
Expand All @@ -156,39 +158,39 @@ export interface IUnsubackPacket extends IPacket {
cmd: 'unsuback',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

export interface IPubackPacket extends IPacket {
cmd: 'puback',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

export interface IPubcompPacket extends IPacket {
cmd: 'pubcomp',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

export interface IPubrelPacket extends IPacket {
cmd: 'pubrel',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

export interface IPubrecPacket extends IPacket {
cmd: 'pubrec',
properties?: {
reasonString?: string,
userProperties?: Object
userProperties?: UserProperties
}
}

Expand All @@ -205,7 +207,7 @@ export interface IDisconnectPacket extends IPacket {
properties?: {
sessionExpiryInterval?: number,
reasonString?: string,
userProperties?: Object,
userProperties?: UserProperties,
serverReference?: string
}
}
Expand Down