Skip to content

Commit

Permalink
[aws-iot-device-sdk] - Fix references to the mqtt types (DefinitelyTy…
Browse files Browse the repository at this point in the history
…ped#20344)

* Update index.d.ts

Fix mqtt type references.

* Make the tests compatible with noImplicitAny: true.

* Update version.

* Add package.json for mqtt type dependency.

* Remove mqtt in favour of original package definitions.

* Update notNeededPackages.

* Add private flag to package.json.

* Trigger travis

* Update subscribe options.

* Fix subscribe callback.
  • Loading branch information
thchia authored and weswigham committed Oct 11, 2017
1 parent 3b0846c commit 53665b2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 502 deletions.
6 changes: 6 additions & 0 deletions notNeededPackages.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@
"sourceRepoURL": "http://www.mendix.com",
"asOfVersion": "0.8.1"
},
{
"libraryName": "MQTT",
"typingsPackageName": "mqtt",
"sourceRepoURL": "https://github.com/mqttjs/MQTT.js",
"asOfVersion": "2.5.0"
},
{
"libraryName": "mobservable",
"typingsPackageName": "mobservable",
Expand Down
14 changes: 6 additions & 8 deletions types/aws-iot-device-sdk/aws-iot-device-sdk-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const device = new awsIot.device({
clientId: "",
region: "",
baseReconnectTimeMs: 1000,
keepalive: 10,
protocol: "wss",
port: 443,
host: "",
Expand All @@ -39,7 +38,7 @@ device
console.log("offline");
});
device
.on("error", function(error) {
.on("error", function(error: Error | string) {
console.log("error", error);
});
device
Expand All @@ -55,7 +54,6 @@ const thingShadows = new awsIot.thingShadow({
clientId: "",
region: "",
baseReconnectTimeMs: 1000,
keepalive: 10,
protocol: "mqtts",
port: 0,
host: "",
Expand All @@ -65,10 +63,10 @@ const thingShadows = new awsIot.thingShadow({
thingShadows.register(
"thingName",
{ ignoreDeltas: false },
(err: Error, failedTopics: mqtt.Granted[]) => { }
(err: Error, failedTopics: mqtt.ISubscriptionGrant[]) => { }
);

thingShadows.subscribe("topic", {}, (error: any, granted: mqtt.Granted) => {});
thingShadows.subscribe("topic", { qos: 1 }, (error: any, granted: mqtt.ISubscriptionGrant[]) => {});

thingShadows.on("connect", function() {
console.log("connected to AWS IoT");
Expand All @@ -87,7 +85,7 @@ const thingShadows = new awsIot.thingShadow({
console.log("offline");
});

thingShadows.on("error", function(error) {
thingShadows.on("error", function(error: Error) {
console.log("error", error);
});

Expand All @@ -98,8 +96,8 @@ const thingShadows = new awsIot.thingShadow({
thingShadows.on("status", function(thingName: string, stat: "accepted" | "rejected", clientToken: string, stateObject: any) {
});

thingShadows.on("delta", function(thingName, stateObject) {
thingShadows.on("delta", function(thingName: string, stateObject: any) {
});

thingShadows.on("timeout", function(thingName, clientToken) {
thingShadows.on("timeout", function(thingName: string, clientToken: string) {
});
18 changes: 9 additions & 9 deletions types/aws-iot-device-sdk/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for aws-iot-device-sdk 1.0.13
// Type definitions for aws-iot-device-sdk 2.1.0
// Project: https://github.com/aws/aws-iot-device-sdk-js
// Definitions by: Markus Olsson <https://github.com/niik>
// Margus Lamp <https://github.com/mlamp>
Expand All @@ -9,7 +9,7 @@
import * as mqtt from "mqtt";
import * as WebSocket from "ws";

export interface DeviceOptions extends mqtt.ClientOptions {
export interface DeviceOptions extends mqtt.IClientOptions {
/** the AWS IoT region you will operate in (default "us-east-1") */
region?: string;

Expand Down Expand Up @@ -179,15 +179,15 @@ export class device extends NodeJS.EventEmitter {
* @param publish options
* @param called when publish succeeds or fails
*/
publish(topic: string, message: Buffer | string, options?: mqtt.ClientPublishOptions, callback?: (error?: Error) => void): mqtt.Client;
publish(topic: string, message: Buffer | string, options?: mqtt.IClientPublishOptions, callback?: (error?: Error) => void): mqtt.Client;

/**
* Subscribe to a topic or topics
* @param topic to subscribe to or an Array of topics to subscribe to. It can also be an object.
* @param the options to subscribe with
* @param callback fired on suback
*/
subscribe(topic: string | string[] | mqtt.Topic, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;
subscribe(topic: string | string[], options?: mqtt.IClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;

/**
* Unsubscribe from a topic or topics
Expand All @@ -196,7 +196,7 @@ export class device extends NodeJS.EventEmitter {
* @param options
* @param callback fired on unsuback
*/
unsubscribe(topic: string | string[], options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;
unsubscribe(topic: string | string[], options?: mqtt.IClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;

/**
* end - close connection
Expand Down Expand Up @@ -257,7 +257,7 @@ export class thingShadow extends NodeJS.EventEmitter {
* for all shadow topics). Applications should wait until shadow
* registration is complete before performing update/get/delete operations.
*/
register(thingName: string, options?: RegisterOptions, callback?: (error: Error, failedTopics: mqtt.Granted[]) => void): void
register(thingName: string, options?: RegisterOptions, callback?: (error: Error, failedTopics: mqtt.ISubscriptionGrant[]) => void): void

/**
* Unregister interest in the Thing Shadow named thingName.
Expand Down Expand Up @@ -334,15 +334,15 @@ export class thingShadow extends NodeJS.EventEmitter {
* @param options
* @param callback
*/
publish(topic: string, message: Buffer | string, options?: mqtt.ClientPublishOptions, callback?: Function): mqtt.Client;
publish(topic: string, message: Buffer | string, options?: mqtt.IClientPublishOptions, callback?: Function): mqtt.Client;

/**
* Subscribe to a topic or topics
* @param topic to subscribe to or an Array of topics to subscribe to. It can also be an object.
* @param the options to subscribe with
* @param callback fired on suback
*/
subscribe(topic: string | string[] | mqtt.Topic, options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;
subscribe(topic: string | string[], options?: { qos: 0 | 1 }, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;

/**
* Unsubscribe from a topic or topics
Expand All @@ -351,7 +351,7 @@ export class thingShadow extends NodeJS.EventEmitter {
* @param options
* @param callback fired on unsuback
*/
unsubscribe(topic: string | string[], options?: mqtt.ClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;
unsubscribe(topic: string | string[], options?: mqtt.IClientSubscribeOptions, callback?: mqtt.ClientSubscribeCallback): mqtt.Client;

/**
* end - close connection
Expand Down
6 changes: 6 additions & 0 deletions types/aws-iot-device-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"mqtt": "^2.13.0"
}
}
Loading

0 comments on commit 53665b2

Please sign in to comment.