Skip to content

Commit 6bd0469

Browse files
authored
feat: standardize plugins (#422)
1 parent dc95c81 commit 6bd0469

Some content is hidden

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

76 files changed

+588
-530
lines changed

clients/node/client-rds-data-node/README.md renamed to clients/client-rds-data/README.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# @aws-sdk/client-rds-data-node
1+
# @aws-sdk/client-rds-data
22

3-
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/client-rds-data-node/preview.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data-node)
4-
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/client-rds-data-node.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data-node)
3+
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/client-rds-data/preview.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)
4+
[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/client-rds-data.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)
55

66
## Description
77

@@ -18,29 +18,29 @@ Serverless</a> in the <i>Amazon Aurora User Guide</i>.</p>
1818
To install the this package using NPM, simply type the following into a terminal window:
1919

2020
```
21-
npm install @aws-sdk/client-rds-data-node
21+
npm install @aws-sdk/client-rds-data
2222
```
2323

2424
## Getting Started
2525

2626
### Import
2727

28-
The AWS SDK is modulized by clients and commands in CommonJS modules. To send a request, you only need to import the client(`RDSDataClient`) and the commands you need, for example `BatchExecuteStatementCommand`:
28+
The AWS SDK is modulized by clients and commands in CommonJS modules. To send a request, you only need to import the client(`RdsDataServiceClient`) and the commands you need, for example `BatchExecuteStatementCommand`:
2929

3030
```javascript
3131
//JavaScript
3232
const {
33-
RDSDataClient
34-
} = require("@aws-sdk/client-rds-data-node/RDSDataClient");
35-
const {
33+
RdsDataServiceClient,
3634
BatchExecuteStatementCommand
37-
} = require("@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand");
35+
} = require("@aws-sdk/client-rds-data");
3836
```
3937

4038
```javascript
4139
//TypeScript
42-
import { RDSDataClient } from "@aws-sdk/client-rds-data-node/RDSDataClient";
43-
import { BatchExecuteStatementCommand } from "@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand";
40+
import {
41+
RdsDataServiceClient,
42+
BatchExecuteStatementCommand
43+
} from "@aws-sdk/client-rds-data";
4444
```
4545

4646
### Usage
@@ -53,7 +53,7 @@ To send a request, you:
5353
- If you are using a custom http handler, you may call `destroy()` to close open connections.
5454

5555
```javascript
56-
const rDSData = new RDSDataClient({region: 'region'});
56+
const rDSData = new RdsDataServiceClient({region: 'region'});
5757
//clients can be shared by different commands
5858
const params = {
5959
resourceArn: /**a string value*/,
@@ -87,16 +87,6 @@ rDSData.send(batchExecuteStatementCommand, (err, data) => {
8787
});
8888
```
8989

90-
The SDK can also send requests using the simplified callback style from version 2 of the SDK.
91-
92-
```javascript
93-
import * as AWS from "@aws-sdk/@aws-sdk/client-rds-data-node/RDSData";
94-
const rDSData = new AWS.RDSData({ region: "region" });
95-
rDSData.batchExecuteStatement(params, (err, data) => {
96-
//do something
97-
});
98-
```
99-
10090
### Troubleshooting
10191

10292
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
@@ -131,7 +121,7 @@ Please use these community resources for getting help. We use the GitHub issues
131121

132122
## Contributing
133123

134-
This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-rds-data-node' package is updated. To contribute to SDK you can checkout our [code generator package][].
124+
This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-rds-data' package is updated. To contribute to SDK you can checkout our [code generator package][].
135125

136126
## License
137127

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import {
2+
BatchExecuteStatementRequest,
3+
BatchExecuteStatementResponse,
4+
BeginTransactionRequest,
5+
BeginTransactionResponse,
6+
CommitTransactionRequest,
7+
CommitTransactionResponse,
8+
ExecuteSqlRequest,
9+
ExecuteSqlResponse,
10+
ExecuteStatementRequest,
11+
ExecuteStatementResponse,
12+
RollbackTransactionRequest,
13+
RollbackTransactionResponse
14+
} from "./models/index";
15+
import { RDSRuntimeConfiguration } from "./runtimeConfig";
16+
import {
17+
Credentials,
18+
Provider,
19+
HashConstructor,
20+
UrlParser,
21+
Protocol,
22+
StreamCollector,
23+
Decoder,
24+
Encoder
25+
} from "@aws-sdk/types";
26+
import {
27+
EndpointsConfigInput,
28+
EndpointsConfigResolved,
29+
resolveEndpointsConfig,
30+
ClientProtocolConfigInput,
31+
ClientProtocolConfigResolved,
32+
resolveClientProtocolConfig,
33+
destroyClientProtocolConfig,
34+
RegionConfigInput,
35+
RegionConfigResolved,
36+
resolveRegionConfig
37+
} from "@aws-sdk/config-resolver";
38+
import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
39+
import {
40+
UserAgentConfigInput,
41+
UserAgentConfigResolved,
42+
resolveUserAgentConfig,
43+
getUserAgentPlugin
44+
} from "@aws-sdk/middleware-user-agent";
45+
import {
46+
RetryConfigInput,
47+
RetryConfigResolved,
48+
resolveRetryConfig,
49+
getRetryPlugin
50+
} from "@aws-sdk/middleware-retry";
51+
import {
52+
AwsAuthConfigInput,
53+
AwsAuthConfigResolved,
54+
resolveAwsAuthConfig,
55+
getAwsAuthPlugin
56+
} from "@aws-sdk/middleware-signing";
57+
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
58+
import {
59+
Client as SmithyClient,
60+
SmithyResolvedConfiguration
61+
} from "@aws-sdk/smithy-client";
62+
import { HttpOptions as __HttpOptions } from "@aws-sdk/types";
63+
64+
export type ServiceInputTypes =
65+
| RollbackTransactionRequest
66+
| CommitTransactionRequest
67+
| ExecuteSqlRequest
68+
| BeginTransactionRequest
69+
| ExecuteStatementRequest
70+
| BatchExecuteStatementRequest;
71+
72+
export type ServiceOutputTypes =
73+
| RollbackTransactionResponse
74+
| CommitTransactionResponse
75+
| ExecuteSqlResponse
76+
| BeginTransactionResponse
77+
| ExecuteStatementResponse
78+
| BatchExecuteStatementResponse;
79+
80+
export interface RDSDataRuntimeDependencies {
81+
/**
82+
* The HTTP handler to use. Fetch in browser and Https in Nodejs
83+
*/
84+
httpHandler?: HttpHandler;
85+
86+
/**
87+
* A constructor for a class implementing the @aws-sdk/types.Hash interface that computes the SHA-256 HMAC or checksum of a string or binary buffer
88+
*/
89+
sha256?: HashConstructor;
90+
91+
/**
92+
* Default credentials provider; Not available in browser runtime
93+
*/
94+
credentialDefaultProvider?: (input: any) => Provider<Credentials>;
95+
96+
/**
97+
* Provider function that return promise of a region string
98+
*/
99+
regionDefaultProvider?: (input: any) => Provider<string>;
100+
101+
/**
102+
* The function that will be used to convert strings into HTTP endpoints
103+
*/
104+
urlParser?: UrlParser;
105+
106+
/**
107+
* A function that can calculate the length of a request body.
108+
*/
109+
bodyLengthChecker?: (body: any) => number | undefined;
110+
111+
/**
112+
* A function that converts a stream into an array of bytes.
113+
*/
114+
streamCollector?: StreamCollector;
115+
116+
/**
117+
* The function that will be used to convert a base64-encoded string to a byte array
118+
*/
119+
base64Decoder?: Decoder;
120+
121+
/**
122+
* The function that will be used to convert binary data to a base64-encoded string
123+
*/
124+
base64Encoder?: Encoder;
125+
126+
/**
127+
* The function that will be used to convert a UTF8-encoded string to a byte array
128+
*/
129+
utf8Decoder?: Decoder;
130+
131+
/**
132+
* The function that will be used to convert binary data to a UTF-8 encoded string
133+
*/
134+
utf8Encoder?: Encoder;
135+
136+
/**
137+
* The function that will be used to populate default value in 'User-Agent' header
138+
*/
139+
defaultUserAgent?: string;
140+
141+
/**
142+
* The function that will be used to populate serializing protocol
143+
*/
144+
protocolDefaultProvider?: (
145+
handler: HttpHandler
146+
) => Protocol<HttpRequest, HttpResponse>;
147+
148+
/**
149+
* The service name with which to sign requests.
150+
*/
151+
signingName?: string;
152+
153+
/**
154+
* The service name with which to construct endpoints.
155+
*/
156+
service?: string;
157+
}
158+
159+
export type RdsDataServiceConfig = RDSDataRuntimeDependencies &
160+
AwsAuthConfigInput &
161+
RegionConfigInput &
162+
RetryConfigInput &
163+
EndpointsConfigInput &
164+
ClientProtocolConfigInput &
165+
UserAgentConfigInput;
166+
167+
export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration<
168+
__HttpOptions
169+
> &
170+
Required<RDSDataRuntimeDependencies> &
171+
AwsAuthConfigResolved &
172+
RegionConfigResolved &
173+
RetryConfigResolved &
174+
EndpointsConfigResolved &
175+
ClientProtocolConfigResolved &
176+
UserAgentConfigResolved;
177+
178+
export class RdsDataService extends SmithyClient<
179+
__HttpOptions,
180+
ServiceInputTypes,
181+
ServiceOutputTypes
182+
> {
183+
readonly config: RdsDataServiceResolvedConfig;
184+
185+
constructor(configuration: RdsDataServiceConfig) {
186+
const _config_0 = resolveClientProtocolConfig({
187+
...RDSRuntimeConfiguration,
188+
...configuration
189+
});
190+
let _config_1 = resolveRegionConfig(_config_0);
191+
let _config_2 = resolveAwsAuthConfig(_config_1);
192+
let _config_3 = resolveEndpointsConfig(_config_2);
193+
let _config_4 = resolveRetryConfig(_config_3);
194+
let _config_5 = resolveUserAgentConfig(_config_4);
195+
super(_config_5);
196+
this.config = _config_5;
197+
this.middlewareStack.use(getContentLengthPlugin(this.config));
198+
this.middlewareStack.use(getAwsAuthPlugin(this.config));
199+
this.middlewareStack.use(getRetryPlugin(this.config));
200+
this.middlewareStack.use(getUserAgentPlugin(this.config));
201+
}
202+
203+
destroy(): void {
204+
destroyClientProtocolConfig(this.config);
205+
}
206+
}

clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts renamed to clients/client-rds-data/commands/ExecuteStatementCommand.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command } from "@aws-sdk/smithy-client";
2-
import { serdePlugin } from "@aws-sdk/middleware-serde";
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
33
import {
44
HttpOptions,
55
Handler,
@@ -8,16 +8,17 @@ import {
88
MiddlewareStack,
99
SerdeContext
1010
} from "@aws-sdk/types";
11-
import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
1211
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
1312
import {
1413
executeStatementAwsRestJson1_1Serialize,
1514
executeStatementAwsRestJson1_1Deserialize
1615
} from "../protocol/AwsRestJson1_1";
1716
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";
18-
19-
type InputTypesUnion = any;
20-
type OutputTypesUnion = any;
17+
import {
18+
ServiceInputTypes,
19+
ServiceOutputTypes,
20+
RdsDataServiceResolvedConfig
21+
} from "../RdsDataServiceClient";
2122

2223
export class ExecuteStatementCommand extends Command<
2324
ExecuteStatementRequest,
@@ -28,15 +29,17 @@ export class ExecuteStatementCommand extends Command<
2829
}
2930

3031
resolveMiddleware(
31-
clientStack: MiddlewareStack<InputTypesUnion, OutputTypesUnion>,
32-
configuration: RDSDataResolvedConfiguration,
32+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
33+
configuration: RdsDataServiceResolvedConfig,
3334
options?: HttpOptions
3435
): Handler<ExecuteStatementRequest, ExecuteStatementResponse> {
3536
const {
3637
protocol: { handler }
3738
} = configuration;
3839

39-
this.use(serdePlugin(configuration, this.serialize, this.deserialize));
40+
this.middlewareStack.use(
41+
getSerdePlugin(configuration, this.serialize, this.deserialize)
42+
);
4043

4144
const stack = clientStack.concat(this.middlewareStack);
4245

clients/client-rds-data/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./RdsDataServiceClient";
2+
export * from "./commands/ExecuteStatementCommand";

clients/node/client-rds-data-node/package.json renamed to clients/client-rds-data/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"name": "@aws-sdk/client-rds-data-node",
2+
"name": "@aws-sdk/client-rds-data",
33
"description": "Node SDK for AWS RDS DataService",
44
"version": "0.1.0-preview.3",
55
"scripts": {
66
"clean": "npm run remove-definitions && npm run remove-maps && npm run remove-js",
77
"build-documentation": "npm run clean && typedoc ./",
8-
"prepublishOnly": "tsc",
8+
"prepublishOnly": "yarn build",
99
"pretest": "tsc",
1010
"remove-definitions": "rimraf *.d.ts && rimraf ./commands/*.d.ts && rimraf ./model/*.d.ts rimraf ./types/*.d.ts && rimraf ./protocol/*.d.ts",
1111
"remove-documentation": "rimraf ./docs",
@@ -44,9 +44,9 @@
4444
"@aws-sdk/node-http-handler": "^0.1.0-preview.6",
4545
"@aws-sdk/protocol-rest-json": "^0.1.0-preview.5",
4646
"@aws-sdk/region-provider": "^0.1.0-preview.5",
47-
"@aws-sdk/retry-middleware": "^0.1.0-preview.5",
47+
"@aws-sdk/middleware-retry": "^0.1.0-preview.5",
4848
"@aws-sdk/signature-v4": "^0.1.0-preview.7",
49-
"@aws-sdk/signing-middleware": "^0.1.0-preview.7",
49+
"@aws-sdk/middleware-signing": "^0.1.0-preview.7",
5050
"@aws-sdk/stream-collector-node": "^0.1.0-preview.6",
5151
"@aws-sdk/stream-collector-browser": "^0.1.0-preview.5",
5252
"@aws-sdk/types": "^0.1.0-preview.5",

clients/node/client-rds-data-node/runtimeConfig.browser.ts renamed to clients/client-rds-data/runtimeConfig.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser";
99
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser";
1010
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
1111
import { name, version } from "./package.json";
12-
import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
12+
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
1313

1414
export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
1515
protocolDefaultProvider: handler => new RestJsonProtocol(handler),

clients/node/client-rds-data-node/runtimeConfig.ts renamed to clients/client-rds-data/runtimeConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node";
1010
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node";
1111
import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
1212
import { name, version } from "./package.json";
13-
import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
13+
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
1414

1515
export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
1616
protocolDefaultProvider: handler => new RestJsonProtocol(handler),

0 commit comments

Comments
 (0)