@aws-sdk/middleware-websocket 3.511.0 → 3.518.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-cjs/index.js CHANGED
@@ -246,6 +246,19 @@ var _WebSocketFetchHandler = class _WebSocketFetchHandler {
246
246
  this.configPromise = Promise.resolve(options ?? {});
247
247
  }
248
248
  }
249
+ /**
250
+ * @returns the input if it is an HttpHandler of any class,
251
+ * or instantiates a new instance of this handler.
252
+ */
253
+ static create(instanceOrOptions, httpHandler = new import_fetch_http_handler.FetchHttpHandler()) {
254
+ if (typeof (instanceOrOptions == null ? void 0 : instanceOrOptions.handle) === "function") {
255
+ return instanceOrOptions;
256
+ }
257
+ return new _WebSocketFetchHandler(
258
+ instanceOrOptions,
259
+ httpHandler
260
+ );
261
+ }
249
262
  /**
250
263
  * Destroys the WebSocketHandler.
251
264
  * Closes all sockets from the socket pool.
@@ -5,6 +5,12 @@ import { HttpResponse } from "@smithy/protocol-http";
5
5
  import { isWebSocketRequest } from "./utils";
6
6
  const DEFAULT_WS_CONNECTION_TIMEOUT_MS = 2000;
7
7
  export class WebSocketFetchHandler {
8
+ static create(instanceOrOptions, httpHandler = new FetchHttpHandler()) {
9
+ if (typeof instanceOrOptions?.handle === "function") {
10
+ return instanceOrOptions;
11
+ }
12
+ return new WebSocketFetchHandler(instanceOrOptions, httpHandler);
13
+ }
8
14
  constructor(options, httpHandler = new FetchHttpHandler()) {
9
15
  this.metadata = {
10
16
  handlerProtocol: "websocket/h1.1",
@@ -1,4 +1,4 @@
1
- import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
1
+ import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
2
2
  import {
3
3
  Provider,
4
4
  RequestHandler,
@@ -12,6 +12,13 @@ export declare class WebSocketFetchHandler {
12
12
  private readonly configPromise;
13
13
  private readonly httpHandler;
14
14
  private readonly sockets;
15
+ static create(
16
+ instanceOrOptions?:
17
+ | HttpHandler<any>
18
+ | WebSocketFetchHandlerOptions
19
+ | Provider<WebSocketFetchHandlerOptions | void>,
20
+ httpHandler?: RequestHandler<any, any>
21
+ ): HttpHandler<any> | WebSocketFetchHandler;
15
22
  constructor(
16
23
  options?:
17
24
  | WebSocketFetchHandlerOptions
@@ -1,4 +1,4 @@
1
- import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
1
+ import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
2
2
  import { Provider, RequestHandler, RequestHandlerMetadata } from "@smithy/types";
3
3
  export interface WebSocketFetchHandlerOptions {
4
4
  /**
@@ -18,6 +18,11 @@ export declare class WebSocketFetchHandler {
18
18
  private readonly configPromise;
19
19
  private readonly httpHandler;
20
20
  private readonly sockets;
21
+ /**
22
+ * @returns the input if it is an HttpHandler of any class,
23
+ * or instantiates a new instance of this handler.
24
+ */
25
+ static create(instanceOrOptions?: HttpHandler<any> | WebSocketFetchHandlerOptions | Provider<WebSocketFetchHandlerOptions | void>, httpHandler?: RequestHandler<any, any>): HttpHandler<any> | WebSocketFetchHandler;
21
26
  constructor(options?: WebSocketFetchHandlerOptions | Provider<WebSocketFetchHandlerOptions>, httpHandler?: RequestHandler<any, any>);
22
27
  /**
23
28
  * Destroys the WebSocketHandler.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/middleware-websocket",
3
- "version": "3.511.0",
3
+ "version": "3.518.0",
4
4
  "main": "./dist-cjs/index.js",
5
5
  "module": "./dist-es/index.js",
6
6
  "types": "./dist-types/index.d.ts",
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@aws-sdk/middleware-signing": "3.511.0",
25
- "@aws-sdk/types": "3.511.0",
26
- "@aws-sdk/util-format-url": "3.511.0",
24
+ "@aws-sdk/middleware-signing": "3.515.0",
25
+ "@aws-sdk/types": "3.515.0",
26
+ "@aws-sdk/util-format-url": "3.515.0",
27
27
  "@smithy/eventstream-codec": "^2.1.1",
28
28
  "@smithy/eventstream-serde-browser": "^2.1.1",
29
29
  "@smithy/fetch-http-handler": "^2.4.1",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsconfig/recommended": "1.0.1",
38
- "@types/uuid": "^8.3.0",
38
+ "@types/uuid": "^9.0.4",
39
39
  "concurrently": "7.0.0",
40
40
  "downlevel-dts": "0.10.1",
41
41
  "jest-websocket-mock": "^2.0.2",