Skip to content

Commit 229451b

Browse files
committed
move handler init types to @smithy/types
1 parent abea341 commit 229451b

File tree

9 files changed

+80
-114
lines changed

9 files changed

+80
-114
lines changed

.changeset/dry-balloons-smell.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/many-ads-float.md renamed to .changeset/sixty-fireants-pay.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"@smithy/fetch-http-handler": minor
33
"@smithy/node-http-handler": minor
44
"@smithy/protocol-http": minor
5+
"@smithy/types": minor
56
---
67

7-
add static factory for http handlers
8+
move default fetch and http handler ctor types to the types package

.changeset/witty-pugs-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/signature-v4": patch
3+
---
4+
5+
add readme content for signature-v4

packages/fetch-http-handler/src/fetch-http-handler.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,8 @@ import { requestTimeout } from "./request-timeout";
66

77
declare let AbortController: any;
88

9-
/**
10-
* Represents the http options that can be passed to a browser http client.
11-
*/
12-
export interface FetchHttpHandlerOptions {
13-
/**
14-
* The number of milliseconds a request can take before being automatically
15-
* terminated.
16-
*/
17-
requestTimeout?: number;
18-
19-
/**
20-
* Whether to allow the request to outlive the page. Default value is false.
21-
*
22-
* There may be limitations to the payload size, number of concurrent requests,
23-
* request duration etc. when using keepalive in browsers.
24-
*
25-
* These may change over time, so look for up to date information about
26-
* these limitations before enabling keepalive.
27-
*/
28-
keepAlive?: boolean;
29-
}
9+
import type { FetchHttpHandlerOptions } from '@smithy/types';
10+
export { FetchHttpHandlerOptions }
3011

3112
type FetchHttpHandlerConfig = FetchHttpHandlerOptions;
3213

packages/node-http-handler/src/node-http-handler.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
22
import { buildQueryString } from "@smithy/querystring-builder";
3+
import type { NodeHttpHandlerOptions } from '@smithy/types';
34
import { HttpHandlerOptions, Provider } from "@smithy/types";
45
import { Agent as hAgent, request as hRequest } from "http";
5-
import { Agent as hsAgent, request as hsRequest, RequestOptions } from "https";
6+
import { Agent as hsAgent, request as hsRequest,RequestOptions } from "https";
67

78
import { NODEJS_TIMEOUT_ERROR_CODES } from "./constants";
89
import { getTransformedHeaders } from "./get-transformed-headers";
@@ -11,35 +12,7 @@ import { setSocketKeepAlive } from "./set-socket-keep-alive";
1112
import { setSocketTimeout } from "./set-socket-timeout";
1213
import { writeRequestBody } from "./write-request-body";
1314

14-
/**
15-
* Represents the http options that can be passed to a node http client.
16-
*/
17-
export interface NodeHttpHandlerOptions {
18-
/**
19-
* The maximum time in milliseconds that the connection phase of a request
20-
* may take before the connection attempt is abandoned.
21-
*
22-
* Defaults to 0, which disables the timeout.
23-
*/
24-
connectionTimeout?: number;
25-
26-
/**
27-
* The number of milliseconds a request can take before automatically being terminated.
28-
* Defaults to 0, which disables the timeout.
29-
*/
30-
requestTimeout?: number;
31-
32-
/**
33-
* @deprecated Use {@link requestTimeout}
34-
*
35-
* The maximum time in milliseconds that a socket may remain idle before it
36-
* is closed.
37-
*/
38-
socketTimeout?: number;
39-
40-
httpAgent?: hAgent;
41-
httpsAgent?: hsAgent;
42-
}
15+
export { NodeHttpHandlerOptions };
4316

4417
interface ResolvedNodeHttpHandlerConfig {
4518
requestTimeout?: number;

packages/protocol-http/package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
"main": "./dist-cjs/index.js",
1717
"module": "./dist-es/index.js",
1818
"types": "./dist-types/index.d.ts",
19-
"browser": {
20-
"./dist-es/httpHandlerInitialization": "./dist-es/httpHandlerInitialization.browser"
21-
},
22-
"react-native": {
23-
"./dist-es/httpHandlerInitialization": "./dist-es/httpHandlerInitialization.browser",
24-
"./dist-cjs/httpHandlerInitialization": "./dist-cjs/httpHandlerInitialization.browser"
25-
},
2619
"author": {
2720
"name": "AWS Smithy Team",
2821
"email": "",

packages/protocol-http/src/httpHandlerInitialization.browser.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/protocol-http/src/httpHandlerInitialization.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import type { Agent as hAgent } from "http";
2+
import type { Agent as hsAgent } from "https";
3+
4+
/**
5+
*
6+
* This type represents an alternate client constructor option for the entry
7+
* "requestHandler". Instead of providing an instance of a requestHandler, the user
8+
* may provide the requestHandler's constructor options for either the
9+
* NodeHttpHandler or FetchHttpHandler.
10+
*
11+
* For other RequestHandlers like HTTP2 or WebSocket,
12+
* constructor parameter passthrough is not currently available.
13+
*
14+
* @public
15+
*/
16+
export type RequestHandlerParams = NodeHttpHandlerOptions | FetchHttpHandlerOptions;
17+
18+
/**
19+
* Represents the http options that can be passed to a node http client.
20+
*/
21+
export interface NodeHttpHandlerOptions {
22+
/**
23+
* The maximum time in milliseconds that the connection phase of a request
24+
* may take before the connection attempt is abandoned.
25+
*
26+
* Defaults to 0, which disables the timeout.
27+
*/
28+
connectionTimeout?: number;
29+
30+
/**
31+
* The number of milliseconds a request can take before automatically being terminated.
32+
* Defaults to 0, which disables the timeout.
33+
*/
34+
requestTimeout?: number;
35+
36+
/**
37+
* @deprecated Use {@link requestTimeout}
38+
*
39+
* The maximum time in milliseconds that a socket may remain idle before it
40+
* is closed.
41+
*/
42+
socketTimeout?: number;
43+
44+
httpAgent?: hAgent;
45+
httpsAgent?: hsAgent;
46+
}
47+
48+
/**
49+
* Represents the http options that can be passed to a browser http client.
50+
*/
51+
export interface FetchHttpHandlerOptions {
52+
/**
53+
* The number of milliseconds a request can take before being automatically
54+
* terminated.
55+
*/
56+
requestTimeout?: number;
57+
58+
/**
59+
* Whether to allow the request to outlive the page. Default value is false.
60+
*
61+
* There may be limitations to the payload size, number of concurrent requests,
62+
* request duration etc. when using keepalive in browsers.
63+
*
64+
* These may change over time, so look for up to date information about
65+
* these limitations before enabling keepalive.
66+
*/
67+
keepAlive?: boolean;
68+
}

0 commit comments

Comments
 (0)