Skip to content

Commit

Permalink
Major version upgrades for typescript and typedoc (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose authored Jul 11, 2022
1 parent 6dbde81 commit 0c2c240
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 523 deletions.
2 changes: 1 addition & 1 deletion lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Browser entry point for AWS IoT SDK.
* @packageDocumentation
* @module aws-iot-device-sdk
* @preferred
* @mergeTarget
*/

import { mqtt, http, io, iot, auth } from 'aws-crt/dist.browser/browser';
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @packageDocumentation
* @module aws-iot-device-sdk
* @preferred
* @mergeTarget
*/

import * as iotidentity from './iotidentity/iotidentityclient';
Expand Down
22 changes: 16 additions & 6 deletions lib/iotidentity/iotidentityclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export class IotIdentityClient {

private decoder = new TextDecoder('utf-8');

private static INVALID_PAYLOAD_PARSING_ERROR = "Invalid/unknown error parsing payload into response";

private static createClientError(err: any, payload: ArrayBuffer) : IotIdentityError {
if (err instanceof Error) {
return new IotIdentityError(err.message, payload);
} else {
return new IotIdentityError( IotIdentityClient.INVALID_PAYLOAD_PARSING_ERROR, payload);
}
}

constructor(private connection: mqtt.MqttClientConnection) {
}

Expand Down Expand Up @@ -113,7 +123,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.CreateKeysAndCertificateResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -160,7 +170,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -208,7 +218,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -255,7 +265,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.CreateCertificateFromCsrResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -331,7 +341,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.RegisterThingResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -378,7 +388,7 @@ export class IotIdentityClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotIdentityError(err.message, payload);
error = IotIdentityClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down
30 changes: 20 additions & 10 deletions lib/iotjobs/iotjobsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export class IotJobsClient {

private decoder = new TextDecoder('utf-8');

private static INVALID_PAYLOAD_PARSING_ERROR = "Invalid/unknown error parsing payload into response";

private static createClientError(err: any, payload: ArrayBuffer) : IotJobsError {
if (err instanceof Error) {
return new IotJobsError(err.message, payload);
} else {
return new IotJobsError( IotJobsClient.INVALID_PAYLOAD_PARSING_ERROR, payload);
}
}

constructor(private connection: mqtt.MqttClientConnection) {
}

Expand Down Expand Up @@ -87,7 +97,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.JobExecutionsChangedEvent;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -135,7 +145,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.StartNextJobExecutionResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -184,7 +194,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.RejectedErrorResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -232,7 +242,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.NextJobExecutionChangedEvent;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -281,7 +291,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.RejectedErrorResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -330,7 +340,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.UpdateJobExecutionResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -408,7 +418,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.DescribeJobExecutionResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -484,7 +494,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.GetPendingJobExecutionsResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -532,7 +542,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.RejectedErrorResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -580,7 +590,7 @@ export class IotJobsClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.RejectedErrorResponse;
} catch (err) {
error = new IotJobsError(err.message, payload);
error = IotJobsClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down
42 changes: 26 additions & 16 deletions lib/iotshadow/iotshadowclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export class IotShadowClient {

private decoder = new TextDecoder('utf-8');

private static INVALID_PAYLOAD_PARSING_ERROR = "Invalid/unknown error parsing payload into response";

private static createClientError(err: any, payload: ArrayBuffer) : IotShadowError {
if (err instanceof Error) {
return new IotShadowError(err.message, payload);
} else {
return new IotShadowError( IotShadowClient.INVALID_PAYLOAD_PARSING_ERROR, payload);
}
}

constructor(private connection: mqtt.MqttClientConnection) {
}

Expand Down Expand Up @@ -87,7 +97,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -135,7 +145,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ShadowDeltaUpdatedEvent;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -184,7 +194,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -233,7 +243,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -338,7 +348,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.DeleteShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -386,7 +396,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.GetShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -435,7 +445,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.GetShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -484,7 +494,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ShadowUpdatedEvent;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -532,7 +542,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ShadowUpdatedEvent;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -610,7 +620,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.DeleteShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -658,7 +668,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -706,7 +716,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -810,7 +820,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.UpdateShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -859,7 +869,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ErrorResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -937,7 +947,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.ShadowDeltaUpdatedEvent;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down Expand Up @@ -986,7 +996,7 @@ export class IotShadowClient {
const payload_text = this.decoder.decode(payload);
response = JSON.parse(payload_text) as model.UpdateShadowResponse;
} catch (err) {
error = new IotShadowError(err.message, payload);
error = IotShadowClient.createClientError(err, payload);
}
finally {
messageHandler(error, response);
Expand Down
Loading

0 comments on commit 0c2c240

Please sign in to comment.