Skip to content

Commit 0de0a22

Browse files
AllanZhengYPtrivikr
authored andcommitted
feat: apply protocol and middleware update
1 parent e29478b commit 0de0a22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+855
-979
lines changed

Diff for: clients/node/client-rds-data-node/RDSDataConfiguration.ts

+22-137
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
11
import * as __aws_sdk_core_handler from "@aws-sdk/core-handler";
22
import * as __aws_sdk_credential_provider_node from "@aws-sdk/credential-provider-node";
33
import * as __aws_sdk_hash_node from "@aws-sdk/hash-node";
4-
import * as __aws_sdk_json_builder from "@aws-sdk/json-builder";
54
import * as __aws_sdk_json_error_unmarshaller from "@aws-sdk/json-error-unmarshaller";
65
import * as __aws_sdk_json_parser from "@aws-sdk/json-parser";
76
import * as __aws_sdk_middleware_serializer from "@aws-sdk/middleware-serializer";
87
import * as __aws_sdk_node_http_handler from "@aws-sdk/node-http-handler";
9-
import * as __aws_sdk_protocol_rest from "@aws-sdk/protocol-rest";
108
import * as __aws_sdk_region_provider from "@aws-sdk/region-provider";
119
import * as __aws_sdk_signature_v4 from "@aws-sdk/signature-v4";
1210
import * as __aws_sdk_signing_middleware from "@aws-sdk/signing-middleware";
13-
import * as __aws_sdk_stream_collector_node from "@aws-sdk/stream-collector-node";
1411
import * as __aws_sdk_types from "@aws-sdk/types";
1512
import * as __aws_sdk_url_parser_node from "@aws-sdk/url-parser-node";
16-
import * as __aws_sdk_util_base64_node from "@aws-sdk/util-base64-node";
1713
import * as __aws_sdk_util_body_length_node from "@aws-sdk/util-body-length-node";
18-
import * as __aws_sdk_util_utf8_node from "@aws-sdk/util-utf8-node";
19-
import * as _stream from "stream";
20-
import { OutputTypesUnion } from "./types/OutputTypesUnion";
14+
import { Protocol, TransferHandler } from "@aws-sdk/types";
15+
import { HttpRequest, HttpResponse, HttpHandler } from "@aws-sdk/protocol-http";
16+
import { RestJsonProtocol } from "@aws-sdk/protocol-rest-json";
2117

2218
export interface RDSDataConfiguration {
23-
/**
24-
* The function that will be used to convert a base64-encoded string to a byte array
25-
*/
26-
base64Decoder?: __aws_sdk_types.Decoder;
27-
28-
/**
29-
* The function that will be used to convert binary data to a base64-encoded string
30-
*/
31-
base64Encoder?: __aws_sdk_types.Encoder;
32-
3319
/**
3420
* The credentials used to sign requests.
3521
*
3622
* If no static credentials are supplied, the SDK will attempt to credentials from known environment variables, from shared configuration and credentials files, and from the EC2 Instance Metadata Service, in that order.
3723
*/
3824
credentials?:
39-
| __aws_sdk_types.Credentials
40-
| __aws_sdk_types.Provider<__aws_sdk_types.Credentials>;
25+
| __aws_sdk_types.Credentials
26+
| __aws_sdk_types.Provider<__aws_sdk_types.Credentials>;
4127

4228
/**
4329
* A function that determines how long (in milliseconds) the SDK should wait before retrying a request
@@ -48,24 +34,19 @@ export interface RDSDataConfiguration {
4834
* The fully qualified endpoint of the webservice. This is only required when using a custom endpoint (for example, when using a local version of S3).
4935
*/
5036
endpoint?:
51-
| string
52-
| __aws_sdk_types.HttpEndpoint
53-
| __aws_sdk_types.Provider<__aws_sdk_types.HttpEndpoint>;
37+
| string
38+
| __aws_sdk_types.HttpEndpoint
39+
| __aws_sdk_types.Provider<__aws_sdk_types.HttpEndpoint>;
5440

5541
/**
5642
* The endpoint provider to call if no endpoint is provided
5743
*/
5844
endpointProvider?: any;
5945

60-
/**
61-
* The handler to use as the core of the client's middleware stack
62-
*/
63-
handler?: __aws_sdk_types.Terminalware<any, _stream.Readable>;
64-
6546
/**
6647
* The HTTP handler to use
6748
*/
68-
httpHandler?: __aws_sdk_types.HttpHandler<_stream.Readable>;
49+
httpHandler?: HttpHandler;
6950

7051
/**
7152
* Whether sockets should be kept open even when there are no outstanding requests so that future requests can forgo having to reestablish a TCP or TLS connection. Defaults to true.
@@ -117,25 +98,15 @@ export interface RDSDataConfiguration {
11798
*/
11899
sslEnabled?: boolean;
119100

120-
/**
121-
* A function that converts a stream into an array of bytes.
122-
*/
123-
streamCollector?: __aws_sdk_types.StreamCollector<_stream.Readable>;
124-
125101
/**
126102
* The function that will be used to convert strings into HTTP endpoints
127103
*/
128104
urlParser?: __aws_sdk_types.UrlParser;
129105

130106
/**
131-
* The function that will be used to convert a UTF8-encoded string to a byte array
132-
*/
133-
utf8Decoder?: __aws_sdk_types.Decoder;
134-
135-
/**
136-
* The function that will be used to convert binary data to a UTF-8 encoded string
107+
*
137108
*/
138-
utf8Encoder?: __aws_sdk_types.Encoder;
109+
protocol?: Protocol<any, any>;
139110
}
140111

141112
export interface RDSDataResolvableConfiguration extends RDSDataConfiguration {
@@ -148,32 +119,12 @@ export interface RDSDataResolvableConfiguration extends RDSDataConfiguration {
148119
* A function that can calculate the length of a request body.
149120
*/
150121
bodyLengthChecker: (body: any) => number | undefined;
151-
152-
/**
153-
* The parser to use when converting HTTP responses to SDK output types
154-
*/
155-
parser: __aws_sdk_types.ResponseParser<_stream.Readable>;
156-
157-
/**
158-
* The serializer to use when converting SDK input to HTTP requests
159-
*/
160-
serializer: __aws_sdk_types.Provider<
161-
__aws_sdk_types.RequestSerializer<_stream.Readable>
162-
>;
163122
}
164123

165124
export interface RDSDataResolvedConfiguration
166-
extends RDSDataConfiguration,
167-
__aws_sdk_types.ClientResolvedConfigurationBase<
168-
OutputTypesUnion,
169-
_stream.Readable
170-
> {
125+
extends RDSDataConfiguration {
171126
_user_injected_http_handler: boolean;
172127

173-
base64Decoder: __aws_sdk_types.Decoder;
174-
175-
base64Encoder: __aws_sdk_types.Encoder;
176-
177128
bodyLengthChecker: (body: any) => number | undefined;
178129

179130
credentials: __aws_sdk_types.Provider<__aws_sdk_types.Credentials>;
@@ -182,24 +133,16 @@ export interface RDSDataResolvedConfiguration
182133

183134
endpointProvider: any;
184135

185-
handler: __aws_sdk_types.Terminalware<any, _stream.Readable>;
186-
187-
httpHandler: __aws_sdk_types.HttpHandler<_stream.Readable>;
136+
httpHandler: HttpHandler;
188137

189138
keepAlive: boolean;
190139

191140
maxRedirects: number;
192141

193142
maxRetries: number;
194143

195-
parser: __aws_sdk_types.ResponseParser<_stream.Readable>;
196-
197144
region: __aws_sdk_types.Provider<string>;
198145

199-
serializer: __aws_sdk_types.Provider<
200-
__aws_sdk_types.RequestSerializer<_stream.Readable>
201-
>;
202-
203146
sha256: __aws_sdk_types.HashConstructor;
204147

205148
signer: __aws_sdk_types.RequestSigner;
@@ -208,13 +151,9 @@ export interface RDSDataResolvedConfiguration
208151

209152
sslEnabled: boolean;
210153

211-
streamCollector: __aws_sdk_types.StreamCollector<_stream.Readable>;
212-
213154
urlParser: __aws_sdk_types.UrlParser;
214155

215-
utf8Decoder: __aws_sdk_types.Decoder;
216-
217-
utf8Encoder: __aws_sdk_types.Encoder;
156+
protocol: Protocol<any, any>;
218157
}
219158

220159
export const configurationProperties: __aws_sdk_types.ConfigurationDefinition<
@@ -292,58 +231,6 @@ export const configurationProperties: __aws_sdk_types.ConfigurationDefinition<
292231
return value!;
293232
}
294233
},
295-
base64Decoder: {
296-
defaultValue: __aws_sdk_util_base64_node.fromBase64
297-
},
298-
base64Encoder: {
299-
defaultValue: __aws_sdk_util_base64_node.toBase64
300-
},
301-
utf8Decoder: {
302-
defaultValue: __aws_sdk_util_utf8_node.fromUtf8
303-
},
304-
utf8Encoder: {
305-
defaultValue: __aws_sdk_util_utf8_node.toUtf8
306-
},
307-
streamCollector: {
308-
defaultValue: __aws_sdk_stream_collector_node.streamCollector
309-
},
310-
serializer: {
311-
defaultProvider: (configuration: {
312-
base64Encoder: __aws_sdk_types.Encoder;
313-
endpoint: __aws_sdk_types.Provider<__aws_sdk_types.HttpEndpoint>;
314-
utf8Decoder: __aws_sdk_types.Decoder;
315-
}) => {
316-
const promisified = configuration
317-
.endpoint()
318-
.then(
319-
endpoint =>
320-
new __aws_sdk_protocol_rest.RestSerializer<_stream.Readable>(
321-
endpoint,
322-
new __aws_sdk_json_builder.JsonBuilder(
323-
configuration.base64Encoder,
324-
configuration.utf8Decoder
325-
),
326-
configuration.base64Encoder,
327-
configuration.utf8Decoder
328-
)
329-
);
330-
return () => promisified;
331-
}
332-
},
333-
parser: {
334-
defaultProvider: (configuration: {
335-
base64Decoder: __aws_sdk_types.Decoder;
336-
streamCollector: __aws_sdk_types.StreamCollector<_stream.Readable>;
337-
utf8Encoder: __aws_sdk_types.Encoder;
338-
}) =>
339-
new __aws_sdk_protocol_rest.RestParser<_stream.Readable>(
340-
new __aws_sdk_json_parser.JsonParser(configuration.base64Decoder),
341-
configuration.streamCollector,
342-
__aws_sdk_json_error_unmarshaller.jsonErrorUnmarshaller,
343-
configuration.utf8Encoder,
344-
configuration.base64Decoder
345-
)
346-
},
347234
keepAlive: {
348235
defaultValue: true
349236
},
@@ -355,16 +242,6 @@ export const configurationProperties: __aws_sdk_types.ConfigurationDefinition<
355242
defaultProvider: (configuration: { keepAlive: boolean }) =>
356243
new __aws_sdk_node_http_handler.NodeHttpHandler(configuration)
357244
},
358-
handler: {
359-
defaultProvider: (configuration: {
360-
httpHandler: __aws_sdk_types.HttpHandler<_stream.Readable>;
361-
parser: __aws_sdk_types.ResponseParser<_stream.Readable>;
362-
}) =>
363-
__aws_sdk_core_handler.coreHandler<OutputTypesUnion, _stream.Readable>(
364-
configuration.httpHandler,
365-
configuration.parser
366-
)
367-
},
368245
bodyLengthChecker: {
369246
defaultValue: __aws_sdk_util_body_length_node.calculateBodyLength
370247
},
@@ -406,5 +283,13 @@ export const configurationProperties: __aws_sdk_types.ConfigurationDefinition<
406283
sha256: configuration.sha256,
407284
uriEscapePath: true
408285
})
286+
},
287+
protocol: {
288+
defaultProvider: (configuration: {
289+
httpHandler: TransferHandler<
290+
HttpRequest,
291+
HttpResponse
292+
>;
293+
}) => new RestJsonProtocol(configuration.httpHandler)
409294
}
410295
};

Diff for: clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts

+6-27
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,32 @@
11
import * as __aws_sdk_middleware_stack from "@aws-sdk/middleware-stack";
22
import * as __aws_sdk_types from "@aws-sdk/types";
3-
import * as _stream from "stream";
4-
import { ExecuteStatement } from "../model/operations/ExecuteStatement";
5-
import { InputTypesUnion } from "../types/InputTypesUnion";
6-
import { OutputTypesUnion } from "../types/OutputTypesUnion";
7-
import { ExecuteStatementInput } from "../types/ExecuteStatementInput";
8-
import { ExecuteStatementOutput } from "../types/ExecuteStatementOutput";
3+
import {coreHandler} from '@aws-sdk/core-handler';
94
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
10-
export * from "../types/ExecuteStatementInput";
11-
export * from "../types/ExecuteStatementOutput";
12-
export * from "../types/ExecuteStatementExceptionsUnion";
135

14-
export class ExecuteStatementCommand
15-
implements
16-
__aws_sdk_types.Command<
17-
InputTypesUnion,
18-
ExecuteStatementInput,
19-
OutputTypesUnion,
20-
ExecuteStatementOutput,
21-
RDSDataResolvedConfiguration,
22-
_stream.Readable
23-
> {
24-
readonly model = ExecuteStatement;
6+
export class ExecuteStatementCommand {
257
readonly middlewareStack = new __aws_sdk_middleware_stack.MiddlewareStack<
268
ExecuteStatementInput,
279
ExecuteStatementOutput,
28-
_stream.Readable
2910
>();
3011

3112
constructor(readonly input: ExecuteStatementInput) {}
3213

3314
resolveMiddleware(
3415
clientStack: __aws_sdk_middleware_stack.MiddlewareStack<
3516
InputTypesUnion,
36-
OutputTypesUnion,
37-
_stream.Readable
17+
OutputTypesUnion
3818
>,
3919
configuration: RDSDataResolvedConfiguration
4020
): __aws_sdk_types.Handler<ExecuteStatementInput, ExecuteStatementOutput> {
41-
const { handler } = configuration;
21+
const { httpHandler } = configuration;
4222
const stack = clientStack.concat(this.middlewareStack);
4323

4424
const handlerExecutionContext: __aws_sdk_types.HandlerExecutionContext = {
45-
logger: {} as any,
46-
model: this.model
25+
logger: {} as any
4726
};
4827

4928
return stack.resolve(
50-
handler<ExecuteStatementInput, ExecuteStatementOutput>(
29+
httpHandler<ExecuteStatementInput, ExecuteStatementOutput>(
5130
handlerExecutionContext
5231
),
5332
handlerExecutionContext

Diff for: packages/fetch-http-handler/src/fetch-http-handler.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
BrowserHttpOptions,
2+
HttpOptions,
33
Handler,
44
HeaderBag,
55
HttpHandler,
@@ -14,6 +14,17 @@ import { buildQueryString } from "@aws-sdk/querystring-builder";
1414

1515
declare var AbortController: any;
1616

17+
/**
18+
* Represents the http options that can be passed to a browser http client.
19+
*/
20+
export interface BrowserHttpOptions extends HttpOptions {
21+
/**
22+
* The number of milliseconds a request can take before being automatically
23+
* terminated.
24+
*/
25+
requestTimeout?: number;
26+
}
27+
1728
export class FetchHttpHandler implements HttpHandler<Blob, BrowserHttpOptions> {
1829
constructor(private readonly httpOptions: BrowserHttpOptions = {}) {}
1930

Diff for: packages/middleware-stack/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"author": {
1111
"name": "AWS SDK for JavaScript Team",
12+
"email": "",
1213
"url": "https://aws.amazon.com/javascript/"
1314
},
1415
"license": "Apache-2.0",

0 commit comments

Comments
 (0)