Skip to content

Commit

Permalink
Typescript upgrade (#332)
Browse files Browse the repository at this point in the history
* Update typescript to latest
* Update typedoc to almost-latest MV
* Update typedoc config to account for all the breaking changes
* Swap typedoc plugins to modern ones that still work and do approximately what we had plugins doing before.
* Rework how events are documented
* Move some private browser mqtt connection functionality to the bottom of the class definition
* Move some problematic type definitions that used CrtError (which is defined in browser/native) down to browser/native
* Expose checksums as an export
* Fix some messy type errors due to stricter checking in 4.x
* Update sample package.jsons
  • Loading branch information
bretambrose authored Jul 8, 2022
1 parent 66312a0 commit 816cc24
Show file tree
Hide file tree
Showing 38 changed files with 528 additions and 598 deletions.
34 changes: 26 additions & 8 deletions docsrc/typedoc-browser.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
{
"mode": "modules",
"inputFiles": "lib/browser.ts",
"tsconfig": "tsconfig.browser.json",
"out": "docs/browser",
"includeDeclarations": true,
"entryPoints": [
"../lib/browser/auth.ts",
"../lib/browser/aws_iot.ts",
"../lib/browser/crypto.ts",
"../lib/browser/error.ts",
"../lib/browser/http.ts",
"../lib/browser/io.ts",
"../lib/browser/mqtt.ts",
"../lib/browser/ws.ts",
"../lib/common/auth.ts",
"../lib/common/crypto.ts",
"../lib/common/event.ts",
"../lib/common/http.ts",
"../lib/common/io.ts",
"../lib/common/mqtt.ts"
],
"tsconfig": "../tsconfig.browser.json",
"out": "../docs/browser",
"excludeExternals": true,
"excludeNotExported": true,
"excludePrivate": true,
"stripInternal": true,
"excludeInternal": true,
"excludeProtected": true,
"disableSources": true,
"listInvalidSymbolLinks": true
"categorizeByGroup": true,
"validation": {
"invalidLink" : true
},
"treatWarningsAsErrors" : true,
"mergeModulesMergeMode": "module"
}

34 changes: 26 additions & 8 deletions docsrc/typedoc-node.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
{
"mode": "modules",
"inputFiles": ["lib/index.ts", "lib/native/*.ts", "lib/common/*.ts"],
"exclude": ["lib/native/binding.js", "lib/browser", "lib/native/*.spec.ts", "lib/common/*.spec.ts"],
"out": "docs/node",
"includeDeclarations": true,
"entryPoints": [
"../lib/native/auth.ts",
"../lib/native/aws_iot.ts",
"../lib/native/checksums.ts",
"../lib/native/crt.ts",
"../lib/native/crypto.ts",
"../lib/native/error.ts",
"../lib/native/http.ts",
"../lib/native/io.ts",
"../lib/native/mqtt.ts",
"../lib/native/binding.d.ts",
"../lib/common/auth.ts",
"../lib/common/crypto.ts",
"../lib/common/event.ts",
"../lib/common/http.ts",
"../lib/common/mqtt.ts",
"../lib/common/resource_safety.ts"
],
"out": "../docs/node",
"excludeExternals": true,
"excludeNotExported": true,
"excludePrivate": true,
"stripInternal": true,
"excludeInternal": true,
"excludeProtected": true,
"disableSources": true,
"categorizeByGroup": true,
"listInvalidSymbolLinks": true
"validation": {
"invalidLink" : true
},
"treatWarningsAsErrors" : true,
"mergeModulesMergeMode": "module"
}

5 changes: 0 additions & 5 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
* SPDX-License-Identifier: Apache-2.0.
*/

/**
* @packageDocumentation
* @module crt
*/

// This is the entry point for the browser AWS CRT shim library

/* common libs */
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @packageDocumentation
* @module auth
* @preferred
* @mergeTarget
*/

import { AwsSigningConfigBase } from '../common/auth';
Expand Down
4 changes: 2 additions & 2 deletions lib/browser/aws_iot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Module for AWS IoT configuration and connection establishment
*
* @packageDocumentation
* @module aws-iot
* @preferred
* @module aws_iot
* @mergeTarget
*/

import { CredentialsProvider, StaticCredentialProvider} from "./auth"
Expand Down
2 changes: 2 additions & 0 deletions lib/browser/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
*/

/**
* A module containing support for a variety of cryptographic operations.
*
* @packageDocumentation
* @module crypto
* @mergeTarget
*/

import * as Crypto from "crypto-js";
Expand Down
5 changes: 4 additions & 1 deletion lib/browser/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
*/

/**
* Library-specific error extension type
*
* @packageDocumentation
* @module crt
* @module error
* @mergeTarget
*/

/**
Expand Down
51 changes: 23 additions & 28 deletions lib/browser/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
*/

/**
*
* A module containing support for creating http connections and making requests on them.
*
* @packageDocumentation
* @module http
* @mergeTarget
*/

import {
Expand Down Expand Up @@ -267,31 +271,28 @@ export class HttpClientConnection extends BufferedEventEmitter {
/**
* Emitted when the connection is connected and ready to start streams
*
* @param event type of event (connect)
* @param listener event listener to use
*
* @event
*/
on(event: 'connect', listener: HttpClientConnectionConnected): this;
static CONNECT = 'connect';

/**
* Emitted when an error occurs on the connection
*
* @param event type of event (error)
* @param listener event listener to use
*
* @event
*/
on(event: 'error', listener: HttpClientConnectionError): this;
static ERROR = 'error';

/**
* Emitted when the connection has completed
*
* @param event type of event (close)
* @param listener event listener to use
*
* @event
*/
static CLOSE = 'close';

on(event: 'connect', listener: HttpClientConnectionConnected): this;

on(event: 'error', listener: HttpClientConnectionError): this;

on(event: 'close', listener: HttpClientConnectionClosed): this;

// Override to allow uncorking on ready
Expand Down Expand Up @@ -358,7 +359,6 @@ function stream_request(connection: HttpClientConnection, request: HttpRequest)
* @param status_code http response status code
* @param headers the response's set of headers
*
* @asMemberOf HttpClientStream
* @category HTTP
*/
export type HttpStreamResponse = (status_code: number, headers: HttpHeaders) => void;
Expand Down Expand Up @@ -402,42 +402,37 @@ export class HttpClientStream extends BufferedEventEmitter {
/**
* Emitted when the http response headers have arrived.
*
* @param event type of event (response)
* @param listener event listener to use
*
* @event
*/
on(event: 'response', listener: HttpStreamResponse): this;

static RESPONSE = 'response';

/**
* Emitted when http response data is available.
*
* @param event type of event (data)
* @param listener event listener to use
*
* @event
*/
on(event: 'data', listener: HttpStreamData): this;
static DATA = 'data';

/**
* Emitted when an error occurs in stream processing
*
* @param event type of event (error)
* @param listener event listener to use
*
* @event
*/
on(event: 'error', listener: HttpStreamError): this;
static ERROR = 'error';

/**
* Emitted when the stream has completed
*
* @param event type of event (end)
* @param listener event listener to use
*
* @event
*/
static END = 'end';

on(event: 'response', listener: HttpStreamResponse): this;

on(event: 'data', listener: HttpStreamData): this;

on(event: 'error', listener: HttpStreamError): this;

on(event: 'end', listener: HttpStreamComplete): this;

on(event: string | symbol, listener: (...args: any[]) => void): this {
Expand Down
14 changes: 12 additions & 2 deletions lib/browser/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@
*/

/**
*
* A module containing a grab bag of support for core network I/O functionality, including sockets, TLS, DNS, logging,
* error handling, streams, and connection -> thread mapping.
*
* Categories include:
* - Network: socket configuration
* - TLS: tls configuration
* - Logging: logging controls and configuration
* - IO: everything else
*
* @packageDocumentation
* @module IO
* @module io
* @mergeTarget
*/

export { TlsVersion, SocketType, SocketDomain } from "../common/io";
Expand All @@ -21,7 +31,7 @@ export function is_alpn_available(): boolean {
return false;
}

type BodyData = string | object | ArrayBuffer | ArrayBufferView | Blob | File;
export type BodyData = string | object | ArrayBuffer | ArrayBufferView | Blob | File;

/**
* Wrapper for any sort of body data in requests. As the browser does not implement streaming,
Expand Down
Loading

0 comments on commit 816cc24

Please sign in to comment.