From 6bd04696e3d939c00e27aa573322cf26c8fbbef1 Mon Sep 17 00:00:00 2001
From: AllanFly120
Date: Mon, 28 Oct 2019 17:39:08 -0700
Subject: [PATCH] feat: standardize plugins (#422)
---
.../.gitignore | 0
.../.npmignore | 0
.../CHANGELOG.md | 0
.../LICENSE | 0
.../README.md | 36 ++-
.../client-rds-data/RdsDataServiceClient.ts | 206 ++++++++++++++++++
.../commands/ExecuteStatementCommand.ts | 19 +-
clients/client-rds-data/index.ts | 2 +
.../lib/smithy.ts | 0
.../models/index.ts | 0
.../package.json | 8 +-
.../protocol/AwsRestJson1_1.ts | 0
.../runtimeConfig.browser.ts | 2 +-
.../runtimeConfig.ts | 2 +-
.../tsconfig.es.json | 0
.../tsconfig.json | 0
.../tsconfig.test.json | 0
.../client-rds-data-node/RDSDataClient.ts | 57 -----
.../RDSDataConfiguration.ts | 125 -----------
clients/node/client-rds-data-node/index.ts | 3 -
jest.config.js | 4 +-
package.json | 8 +-
.../config-resolver/src/EndpointsConfig.ts | 87 ++++----
.../config-resolver/src/ProtocolConfig.ts | 50 ++---
packages/config-resolver/src/RegionConfig.ts | 44 ++--
.../middleware-content-length/src/index.ts | 16 +-
.../.gitignore | 0
.../.npmignore | 0
.../CHANGELOG.md | 0
.../LICENSE | 0
packages/middleware-retry/README.md | 4 +
.../jest.config.js | 0
.../package.json | 2 +-
.../middleware-retry/src/configurations.ts | 28 +++
.../src/constants.ts | 0
.../src/defaultStrategy.ts | 0
.../src/delayDecider.spec.ts | 0
.../src/delayDecider.ts | 0
.../src/index.spec.ts | 18 +-
.../src/index.ts | 0
.../src/retryDecider.spec.ts | 0
.../src/retryDecider.ts | 0
.../middleware-retry/src/retryMiddleware.ts | 31 +++
.../tsconfig.json | 0
.../tsconfig.test.json | 0
packages/middleware-serde/src/serdePlugin.ts | 22 +-
.../.gitignore | 0
.../.npmignore | 0
.../CHANGELOG.md | 0
.../LICENSE | 0
packages/middleware-signing/README.md | 4 +
.../jest.config.js | 0
.../package.json | 2 +-
.../middleware-signing/src/configurations.ts | 63 ++++++
.../src/index.ts | 0
.../src/middleware.spec.ts | 0
.../src/middleware.ts | 22 +-
.../tsconfig.json | 0
.../tsconfig.test.json | 0
packages/middleware-stack/src/index.ts | 9 +-
.../src/configurations.ts | 38 ++--
.../middleware-user-agent/src/middleware.ts | 22 +-
packages/retry-middleware/README.md | 4 -
.../retry-middleware/src/configurations.ts | 31 ---
.../retry-middleware/src/retryMiddleware.ts | 16 +-
.../retryMiddleware.ts | 4 +-
.../signatureCustomizations.ts | 10 +-
.../src/internalImports.ts | 8 +-
packages/signing-middleware/README.md | 4 -
.../signing-middleware/src/configurations.ts | 68 ------
packages/smithy-client/src/client.ts | 5 +-
packages/smithy-client/src/command.ts | 4 -
packages/smithy-client/tsconfig.json | 1 +
packages/types/src/middleware.ts | 4 +-
packages/types/src/transfer.ts | 5 +
yarn.lock | 20 +-
76 files changed, 588 insertions(+), 530 deletions(-)
rename clients/{node/client-rds-data-node => client-rds-data}/.gitignore (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/.npmignore (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/CHANGELOG.md (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/LICENSE (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/README.md (74%)
create mode 100644 clients/client-rds-data/RdsDataServiceClient.ts
rename clients/{node/client-rds-data-node => client-rds-data}/commands/ExecuteStatementCommand.ts (82%)
create mode 100644 clients/client-rds-data/index.ts
rename clients/{node/client-rds-data-node => client-rds-data}/lib/smithy.ts (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/models/index.ts (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/package.json (94%)
rename clients/{node/client-rds-data-node => client-rds-data}/protocol/AwsRestJson1_1.ts (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/runtimeConfig.browser.ts (95%)
rename clients/{node/client-rds-data-node => client-rds-data}/runtimeConfig.ts (95%)
rename clients/{node/client-rds-data-node => client-rds-data}/tsconfig.es.json (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/tsconfig.json (100%)
rename clients/{node/client-rds-data-node => client-rds-data}/tsconfig.test.json (100%)
delete mode 100644 clients/node/client-rds-data-node/RDSDataClient.ts
delete mode 100644 clients/node/client-rds-data-node/RDSDataConfiguration.ts
delete mode 100644 clients/node/client-rds-data-node/index.ts
rename packages/{retry-middleware => middleware-retry}/.gitignore (100%)
rename packages/{retry-middleware => middleware-retry}/.npmignore (100%)
rename packages/{retry-middleware => middleware-retry}/CHANGELOG.md (100%)
rename packages/{retry-middleware => middleware-retry}/LICENSE (100%)
create mode 100644 packages/middleware-retry/README.md
rename packages/{retry-middleware => middleware-retry}/jest.config.js (100%)
rename packages/{retry-middleware => middleware-retry}/package.json (94%)
create mode 100644 packages/middleware-retry/src/configurations.ts
rename packages/{retry-middleware => middleware-retry}/src/constants.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/defaultStrategy.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/delayDecider.spec.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/delayDecider.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/index.spec.ts (88%)
rename packages/{retry-middleware => middleware-retry}/src/index.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/retryDecider.spec.ts (100%)
rename packages/{retry-middleware => middleware-retry}/src/retryDecider.ts (100%)
create mode 100644 packages/middleware-retry/src/retryMiddleware.ts
rename packages/{retry-middleware => middleware-retry}/tsconfig.json (100%)
rename packages/{retry-middleware => middleware-retry}/tsconfig.test.json (100%)
rename packages/{signing-middleware => middleware-signing}/.gitignore (100%)
rename packages/{signing-middleware => middleware-signing}/.npmignore (100%)
rename packages/{signing-middleware => middleware-signing}/CHANGELOG.md (100%)
rename packages/{signing-middleware => middleware-signing}/LICENSE (100%)
create mode 100644 packages/middleware-signing/README.md
rename packages/{signing-middleware => middleware-signing}/jest.config.js (100%)
rename packages/{signing-middleware => middleware-signing}/package.json (94%)
create mode 100644 packages/middleware-signing/src/configurations.ts
rename packages/{signing-middleware => middleware-signing}/src/index.ts (100%)
rename packages/{signing-middleware => middleware-signing}/src/middleware.spec.ts (100%)
rename packages/{signing-middleware => middleware-signing}/src/middleware.ts (67%)
rename packages/{signing-middleware => middleware-signing}/tsconfig.json (100%)
rename packages/{signing-middleware => middleware-signing}/tsconfig.test.json (100%)
delete mode 100644 packages/retry-middleware/README.md
delete mode 100644 packages/retry-middleware/src/configurations.ts
delete mode 100644 packages/signing-middleware/README.md
delete mode 100644 packages/signing-middleware/src/configurations.ts
diff --git a/clients/node/client-rds-data-node/.gitignore b/clients/client-rds-data/.gitignore
similarity index 100%
rename from clients/node/client-rds-data-node/.gitignore
rename to clients/client-rds-data/.gitignore
diff --git a/clients/node/client-rds-data-node/.npmignore b/clients/client-rds-data/.npmignore
similarity index 100%
rename from clients/node/client-rds-data-node/.npmignore
rename to clients/client-rds-data/.npmignore
diff --git a/clients/node/client-rds-data-node/CHANGELOG.md b/clients/client-rds-data/CHANGELOG.md
similarity index 100%
rename from clients/node/client-rds-data-node/CHANGELOG.md
rename to clients/client-rds-data/CHANGELOG.md
diff --git a/clients/node/client-rds-data-node/LICENSE b/clients/client-rds-data/LICENSE
similarity index 100%
rename from clients/node/client-rds-data-node/LICENSE
rename to clients/client-rds-data/LICENSE
diff --git a/clients/node/client-rds-data-node/README.md b/clients/client-rds-data/README.md
similarity index 74%
rename from clients/node/client-rds-data-node/README.md
rename to clients/client-rds-data/README.md
index 3d0ab51937e3..d6f5c2ef0480 100644
--- a/clients/node/client-rds-data-node/README.md
+++ b/clients/client-rds-data/README.md
@@ -1,7 +1,7 @@
-# @aws-sdk/client-rds-data-node
+# @aws-sdk/client-rds-data
-[![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)
-[![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)
+[![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)
+[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/client-rds-data.svg)](https://www.npmjs.com/package/@aws-sdk/client-rds-data)
## Description
@@ -18,29 +18,29 @@ Serverless in the Amazon Aurora User Guide.
To install the this package using NPM, simply type the following into a terminal window:
```
-npm install @aws-sdk/client-rds-data-node
+npm install @aws-sdk/client-rds-data
```
## Getting Started
### Import
-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`:
+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`:
```javascript
//JavaScript
const {
- RDSDataClient
-} = require("@aws-sdk/client-rds-data-node/RDSDataClient");
-const {
+ RdsDataServiceClient,
BatchExecuteStatementCommand
-} = require("@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand");
+} = require("@aws-sdk/client-rds-data");
```
```javascript
//TypeScript
-import { RDSDataClient } from "@aws-sdk/client-rds-data-node/RDSDataClient";
-import { BatchExecuteStatementCommand } from "@aws-sdk/client-rds-data-node/commands/BatchExecuteStatementCommand";
+import {
+ RdsDataServiceClient,
+ BatchExecuteStatementCommand
+} from "@aws-sdk/client-rds-data";
```
### Usage
@@ -53,7 +53,7 @@ To send a request, you:
- If you are using a custom http handler, you may call `destroy()` to close open connections.
```javascript
-const rDSData = new RDSDataClient({region: 'region'});
+const rDSData = new RdsDataServiceClient({region: 'region'});
//clients can be shared by different commands
const params = {
resourceArn: /**a string value*/,
@@ -87,16 +87,6 @@ rDSData.send(batchExecuteStatementCommand, (err, data) => {
});
```
-The SDK can also send requests using the simplified callback style from version 2 of the SDK.
-
-```javascript
-import * as AWS from "@aws-sdk/@aws-sdk/client-rds-data-node/RDSData";
-const rDSData = new AWS.RDSData({ region: "region" });
-rDSData.batchExecuteStatement(params, (err, data) => {
- //do something
-});
-```
-
### Troubleshooting
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
## Contributing
-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][].
+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][].
## License
diff --git a/clients/client-rds-data/RdsDataServiceClient.ts b/clients/client-rds-data/RdsDataServiceClient.ts
new file mode 100644
index 000000000000..051c131f7fee
--- /dev/null
+++ b/clients/client-rds-data/RdsDataServiceClient.ts
@@ -0,0 +1,206 @@
+import {
+ BatchExecuteStatementRequest,
+ BatchExecuteStatementResponse,
+ BeginTransactionRequest,
+ BeginTransactionResponse,
+ CommitTransactionRequest,
+ CommitTransactionResponse,
+ ExecuteSqlRequest,
+ ExecuteSqlResponse,
+ ExecuteStatementRequest,
+ ExecuteStatementResponse,
+ RollbackTransactionRequest,
+ RollbackTransactionResponse
+} from "./models/index";
+import { RDSRuntimeConfiguration } from "./runtimeConfig";
+import {
+ Credentials,
+ Provider,
+ HashConstructor,
+ UrlParser,
+ Protocol,
+ StreamCollector,
+ Decoder,
+ Encoder
+} from "@aws-sdk/types";
+import {
+ EndpointsConfigInput,
+ EndpointsConfigResolved,
+ resolveEndpointsConfig,
+ ClientProtocolConfigInput,
+ ClientProtocolConfigResolved,
+ resolveClientProtocolConfig,
+ destroyClientProtocolConfig,
+ RegionConfigInput,
+ RegionConfigResolved,
+ resolveRegionConfig
+} from "@aws-sdk/config-resolver";
+import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
+import {
+ UserAgentConfigInput,
+ UserAgentConfigResolved,
+ resolveUserAgentConfig,
+ getUserAgentPlugin
+} from "@aws-sdk/middleware-user-agent";
+import {
+ RetryConfigInput,
+ RetryConfigResolved,
+ resolveRetryConfig,
+ getRetryPlugin
+} from "@aws-sdk/middleware-retry";
+import {
+ AwsAuthConfigInput,
+ AwsAuthConfigResolved,
+ resolveAwsAuthConfig,
+ getAwsAuthPlugin
+} from "@aws-sdk/middleware-signing";
+import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
+import {
+ Client as SmithyClient,
+ SmithyResolvedConfiguration
+} from "@aws-sdk/smithy-client";
+import { HttpOptions as __HttpOptions } from "@aws-sdk/types";
+
+export type ServiceInputTypes =
+ | RollbackTransactionRequest
+ | CommitTransactionRequest
+ | ExecuteSqlRequest
+ | BeginTransactionRequest
+ | ExecuteStatementRequest
+ | BatchExecuteStatementRequest;
+
+export type ServiceOutputTypes =
+ | RollbackTransactionResponse
+ | CommitTransactionResponse
+ | ExecuteSqlResponse
+ | BeginTransactionResponse
+ | ExecuteStatementResponse
+ | BatchExecuteStatementResponse;
+
+export interface RDSDataRuntimeDependencies {
+ /**
+ * The HTTP handler to use. Fetch in browser and Https in Nodejs
+ */
+ httpHandler?: HttpHandler;
+
+ /**
+ * 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
+ */
+ sha256?: HashConstructor;
+
+ /**
+ * Default credentials provider; Not available in browser runtime
+ */
+ credentialDefaultProvider?: (input: any) => Provider;
+
+ /**
+ * Provider function that return promise of a region string
+ */
+ regionDefaultProvider?: (input: any) => Provider;
+
+ /**
+ * The function that will be used to convert strings into HTTP endpoints
+ */
+ urlParser?: UrlParser;
+
+ /**
+ * A function that can calculate the length of a request body.
+ */
+ bodyLengthChecker?: (body: any) => number | undefined;
+
+ /**
+ * A function that converts a stream into an array of bytes.
+ */
+ streamCollector?: StreamCollector;
+
+ /**
+ * The function that will be used to convert a base64-encoded string to a byte array
+ */
+ base64Decoder?: Decoder;
+
+ /**
+ * The function that will be used to convert binary data to a base64-encoded string
+ */
+ base64Encoder?: Encoder;
+
+ /**
+ * The function that will be used to convert a UTF8-encoded string to a byte array
+ */
+ utf8Decoder?: Decoder;
+
+ /**
+ * The function that will be used to convert binary data to a UTF-8 encoded string
+ */
+ utf8Encoder?: Encoder;
+
+ /**
+ * The function that will be used to populate default value in 'User-Agent' header
+ */
+ defaultUserAgent?: string;
+
+ /**
+ * The function that will be used to populate serializing protocol
+ */
+ protocolDefaultProvider?: (
+ handler: HttpHandler
+ ) => Protocol;
+
+ /**
+ * The service name with which to sign requests.
+ */
+ signingName?: string;
+
+ /**
+ * The service name with which to construct endpoints.
+ */
+ service?: string;
+}
+
+export type RdsDataServiceConfig = RDSDataRuntimeDependencies &
+ AwsAuthConfigInput &
+ RegionConfigInput &
+ RetryConfigInput &
+ EndpointsConfigInput &
+ ClientProtocolConfigInput &
+ UserAgentConfigInput;
+
+export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration<
+ __HttpOptions
+> &
+ Required &
+ AwsAuthConfigResolved &
+ RegionConfigResolved &
+ RetryConfigResolved &
+ EndpointsConfigResolved &
+ ClientProtocolConfigResolved &
+ UserAgentConfigResolved;
+
+export class RdsDataService extends SmithyClient<
+ __HttpOptions,
+ ServiceInputTypes,
+ ServiceOutputTypes
+> {
+ readonly config: RdsDataServiceResolvedConfig;
+
+ constructor(configuration: RdsDataServiceConfig) {
+ const _config_0 = resolveClientProtocolConfig({
+ ...RDSRuntimeConfiguration,
+ ...configuration
+ });
+ let _config_1 = resolveRegionConfig(_config_0);
+ let _config_2 = resolveAwsAuthConfig(_config_1);
+ let _config_3 = resolveEndpointsConfig(_config_2);
+ let _config_4 = resolveRetryConfig(_config_3);
+ let _config_5 = resolveUserAgentConfig(_config_4);
+ super(_config_5);
+ this.config = _config_5;
+ this.middlewareStack.use(getContentLengthPlugin(this.config));
+ this.middlewareStack.use(getAwsAuthPlugin(this.config));
+ this.middlewareStack.use(getRetryPlugin(this.config));
+ this.middlewareStack.use(getUserAgentPlugin(this.config));
+ }
+
+ destroy(): void {
+ destroyClientProtocolConfig(this.config);
+ }
+}
diff --git a/clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts b/clients/client-rds-data/commands/ExecuteStatementCommand.ts
similarity index 82%
rename from clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts
rename to clients/client-rds-data/commands/ExecuteStatementCommand.ts
index 65bee0aabc51..0d8b7d0b9308 100644
--- a/clients/node/client-rds-data-node/commands/ExecuteStatementCommand.ts
+++ b/clients/client-rds-data/commands/ExecuteStatementCommand.ts
@@ -1,5 +1,5 @@
import { Command } from "@aws-sdk/smithy-client";
-import { serdePlugin } from "@aws-sdk/middleware-serde";
+import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import {
HttpOptions,
Handler,
@@ -8,16 +8,17 @@ import {
MiddlewareStack,
SerdeContext
} from "@aws-sdk/types";
-import { RDSDataResolvedConfiguration } from "../RDSDataConfiguration";
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import {
executeStatementAwsRestJson1_1Serialize,
executeStatementAwsRestJson1_1Deserialize
} from "../protocol/AwsRestJson1_1";
import { ExecuteStatementRequest, ExecuteStatementResponse } from "../models";
-
-type InputTypesUnion = any;
-type OutputTypesUnion = any;
+import {
+ ServiceInputTypes,
+ ServiceOutputTypes,
+ RdsDataServiceResolvedConfig
+} from "../RdsDataServiceClient";
export class ExecuteStatementCommand extends Command<
ExecuteStatementRequest,
@@ -28,15 +29,17 @@ export class ExecuteStatementCommand extends Command<
}
resolveMiddleware(
- clientStack: MiddlewareStack,
- configuration: RDSDataResolvedConfiguration,
+ clientStack: MiddlewareStack,
+ configuration: RdsDataServiceResolvedConfig,
options?: HttpOptions
): Handler {
const {
protocol: { handler }
} = configuration;
- this.use(serdePlugin(configuration, this.serialize, this.deserialize));
+ this.middlewareStack.use(
+ getSerdePlugin(configuration, this.serialize, this.deserialize)
+ );
const stack = clientStack.concat(this.middlewareStack);
diff --git a/clients/client-rds-data/index.ts b/clients/client-rds-data/index.ts
new file mode 100644
index 000000000000..22f1e0d74f7e
--- /dev/null
+++ b/clients/client-rds-data/index.ts
@@ -0,0 +1,2 @@
+export * from "./RdsDataServiceClient";
+export * from "./commands/ExecuteStatementCommand";
diff --git a/clients/node/client-rds-data-node/lib/smithy.ts b/clients/client-rds-data/lib/smithy.ts
similarity index 100%
rename from clients/node/client-rds-data-node/lib/smithy.ts
rename to clients/client-rds-data/lib/smithy.ts
diff --git a/clients/node/client-rds-data-node/models/index.ts b/clients/client-rds-data/models/index.ts
similarity index 100%
rename from clients/node/client-rds-data-node/models/index.ts
rename to clients/client-rds-data/models/index.ts
diff --git a/clients/node/client-rds-data-node/package.json b/clients/client-rds-data/package.json
similarity index 94%
rename from clients/node/client-rds-data-node/package.json
rename to clients/client-rds-data/package.json
index 0b02f9f33ef1..61156b98ce12 100644
--- a/clients/node/client-rds-data-node/package.json
+++ b/clients/client-rds-data/package.json
@@ -1,11 +1,11 @@
{
- "name": "@aws-sdk/client-rds-data-node",
+ "name": "@aws-sdk/client-rds-data",
"description": "Node SDK for AWS RDS DataService",
"version": "0.1.0-preview.3",
"scripts": {
"clean": "npm run remove-definitions && npm run remove-maps && npm run remove-js",
"build-documentation": "npm run clean && typedoc ./",
- "prepublishOnly": "tsc",
+ "prepublishOnly": "yarn build",
"pretest": "tsc",
"remove-definitions": "rimraf *.d.ts && rimraf ./commands/*.d.ts && rimraf ./model/*.d.ts rimraf ./types/*.d.ts && rimraf ./protocol/*.d.ts",
"remove-documentation": "rimraf ./docs",
@@ -44,9 +44,9 @@
"@aws-sdk/node-http-handler": "^0.1.0-preview.6",
"@aws-sdk/protocol-rest-json": "^0.1.0-preview.5",
"@aws-sdk/region-provider": "^0.1.0-preview.5",
- "@aws-sdk/retry-middleware": "^0.1.0-preview.5",
+ "@aws-sdk/middleware-retry": "^0.1.0-preview.5",
"@aws-sdk/signature-v4": "^0.1.0-preview.7",
- "@aws-sdk/signing-middleware": "^0.1.0-preview.7",
+ "@aws-sdk/middleware-signing": "^0.1.0-preview.7",
"@aws-sdk/stream-collector-node": "^0.1.0-preview.6",
"@aws-sdk/stream-collector-browser": "^0.1.0-preview.5",
"@aws-sdk/types": "^0.1.0-preview.5",
diff --git a/clients/node/client-rds-data-node/protocol/AwsRestJson1_1.ts b/clients/client-rds-data/protocol/AwsRestJson1_1.ts
similarity index 100%
rename from clients/node/client-rds-data-node/protocol/AwsRestJson1_1.ts
rename to clients/client-rds-data/protocol/AwsRestJson1_1.ts
diff --git a/clients/node/client-rds-data-node/runtimeConfig.browser.ts b/clients/client-rds-data/runtimeConfig.browser.ts
similarity index 95%
rename from clients/node/client-rds-data-node/runtimeConfig.browser.ts
rename to clients/client-rds-data/runtimeConfig.browser.ts
index 1b0b420a864b..8ce6759932fd 100644
--- a/clients/node/client-rds-data-node/runtimeConfig.browser.ts
+++ b/clients/client-rds-data/runtimeConfig.browser.ts
@@ -9,7 +9,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { name, version } from "./package.json";
-import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
+import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
export const RDSRuntimeConfiguration: Required = {
protocolDefaultProvider: handler => new RestJsonProtocol(handler),
diff --git a/clients/node/client-rds-data-node/runtimeConfig.ts b/clients/client-rds-data/runtimeConfig.ts
similarity index 95%
rename from clients/node/client-rds-data-node/runtimeConfig.ts
rename to clients/client-rds-data/runtimeConfig.ts
index 670cd8ebe69d..f5c967be9b7e 100644
--- a/clients/node/client-rds-data-node/runtimeConfig.ts
+++ b/clients/client-rds-data/runtimeConfig.ts
@@ -10,7 +10,7 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
import { name, version } from "./package.json";
-import { RDSDataRuntimeDependencies } from "./RDSDataConfiguration";
+import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
export const RDSRuntimeConfiguration: Required = {
protocolDefaultProvider: handler => new RestJsonProtocol(handler),
diff --git a/clients/node/client-rds-data-node/tsconfig.es.json b/clients/client-rds-data/tsconfig.es.json
similarity index 100%
rename from clients/node/client-rds-data-node/tsconfig.es.json
rename to clients/client-rds-data/tsconfig.es.json
diff --git a/clients/node/client-rds-data-node/tsconfig.json b/clients/client-rds-data/tsconfig.json
similarity index 100%
rename from clients/node/client-rds-data-node/tsconfig.json
rename to clients/client-rds-data/tsconfig.json
diff --git a/clients/node/client-rds-data-node/tsconfig.test.json b/clients/client-rds-data/tsconfig.test.json
similarity index 100%
rename from clients/node/client-rds-data-node/tsconfig.test.json
rename to clients/client-rds-data/tsconfig.test.json
diff --git a/clients/node/client-rds-data-node/RDSDataClient.ts b/clients/node/client-rds-data-node/RDSDataClient.ts
deleted file mode 100644
index 557826e5cee8..000000000000
--- a/clients/node/client-rds-data-node/RDSDataClient.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { contentLengthPlugin } from "@aws-sdk/middleware-content-length";
-import {
- userAgentPlugin,
- UserAgentConfig
-} from "@aws-sdk/middleware-user-agent";
-import { retryPlugin, RetryConfig } from "@aws-sdk/retry-middleware";
-import {
- awsAuthPlugin,
- AwsAuthConfiguration
-} from "@aws-sdk/signing-middleware";
-import {
- RDSDataConfiguration,
- RDSDataResolvedConfiguration
-} from "./RDSDataConfiguration";
-import { RDSRuntimeConfiguration } from "./runtimeConfig";
-import {
- RegionConfiguration,
- EndpointsConfig,
- ProtocolConfig
-} from "@aws-sdk/config-resolver";
-import { HttpOptions, MetadataBearer } from "@aws-sdk/types";
-import { Client as SmithyClient } from "@aws-sdk/smithy-client";
-
-type InputTypesUnion = any;
-type OutputTypesUnion = MetadataBearer;
-
-export class RDSDataClient extends SmithyClient<
- HttpOptions,
- InputTypesUnion,
- OutputTypesUnion
-> {
- readonly config: RDSDataResolvedConfiguration;
-
- constructor(configuration: RDSDataConfiguration) {
- const intermediaConfig_0 = ProtocolConfig.resolve({
- ...RDSRuntimeConfiguration,
- ...configuration
- });
- let intermediaConfig_1 = RegionConfiguration.resolve(intermediaConfig_0);
- let intermediaConfig_2 = AwsAuthConfiguration.resolve(intermediaConfig_1);
- let intermediaConfig_3 = EndpointsConfig.resolve(intermediaConfig_2);
- let intermediaConfig_4 = RetryConfig.resolve(intermediaConfig_3);
- let intermediaConfig_5 = UserAgentConfig.resolve(intermediaConfig_4);
- super(intermediaConfig_0);
- this.config = intermediaConfig_5;
- super.use(contentLengthPlugin(this.config));
- super.use(retryPlugin(this.config));
- super.use(awsAuthPlugin(this.config));
- super.use(userAgentPlugin(this.config));
- }
-
- destroy(): void {
- if (typeof this.config.httpHandler.destroy === "function") {
- this.config.httpHandler.destroy();
- }
- }
-}
diff --git a/clients/node/client-rds-data-node/RDSDataConfiguration.ts b/clients/node/client-rds-data-node/RDSDataConfiguration.ts
deleted file mode 100644
index b821f9c333f8..000000000000
--- a/clients/node/client-rds-data-node/RDSDataConfiguration.ts
+++ /dev/null
@@ -1,125 +0,0 @@
-import {
- AwsAuthConfiguration,
- AwsAuthConfigurationInput
-} from "@aws-sdk/signing-middleware";
-import {
- UserAgentConfig,
- UserAgentConfigInput
-} from "@aws-sdk/middleware-user-agent";
-import { RetryConfig, RetryConfigInput } from "@aws-sdk/retry-middleware";
-import {
- RegionConfiguration,
- RegionConfigurationInput,
- EndpointsConfig,
- EndpointsConfigInput,
- ProtocolConfig,
- ProtocolConfigInput
-} from "@aws-sdk/config-resolver";
-import {
- Credentials,
- Provider,
- HashConstructor,
- UrlParser,
- Protocol,
- StreamCollector,
- Decoder,
- Encoder
-} from "@aws-sdk/types";
-import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
-
-export interface RDSDataRuntimeDependencies {
- /**
- * The HTTP handler to use. Fetch in browser and Https in Nodejs
- */
- httpHandler?: HttpHandler;
-
- /**
- * 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
- */
- sha256?: HashConstructor;
-
- /**
- * Default credentials provider; Not available in browser runtime
- */
- credentialDefaultProvider?: (input: any) => Provider;
-
- /**
- * Provider function that return promise of a region string
- */
- regionDefaultProvider?: (input: any) => Provider;
-
- /**
- * The function that will be used to convert strings into HTTP endpoints
- */
- urlParser?: UrlParser;
-
- /**
- * A function that can calculate the length of a request body.
- */
- bodyLengthChecker?: (body: any) => number | undefined;
-
- /**
- * A function that converts a stream into an array of bytes.
- */
- streamCollector?: StreamCollector;
-
- /**
- * The function that will be used to convert a base64-encoded string to a byte array
- */
- base64Decoder?: Decoder;
-
- /**
- * The function that will be used to convert binary data to a base64-encoded string
- */
- base64Encoder?: Encoder;
-
- /**
- * The function that will be used to convert a UTF8-encoded string to a byte array
- */
- utf8Decoder?: Decoder;
-
- /**
- * The function that will be used to convert binary data to a UTF-8 encoded string
- */
- utf8Encoder?: Encoder;
-
- /**
- * The function that will be used to populate default value in 'User-Agent' header
- */
- defaultUserAgent?: string;
-
- /**
- * The function that will be used to populate serializing protocol
- */
- protocolDefaultProvider?: (
- handler: HttpHandler
- ) => Protocol;
-
- /**
- * The service name with which to sign requests.
- */
- signingName?: string;
-
- /**
- * The service name with which to construct endpoints.
- */
- service?: string;
-}
-
-export type RDSDataConfiguration = RDSDataRuntimeDependencies &
- AwsAuthConfigurationInput &
- RegionConfigurationInput &
- RetryConfigInput &
- EndpointsConfigInput &
- ProtocolConfigInput &
- UserAgentConfigInput;
-
-export type RDSDataResolvedConfiguration = Required<
- RDSDataRuntimeDependencies
-> &
- AwsAuthConfiguration.Resolved &
- RegionConfiguration.Resolved &
- RetryConfig.Resolved &
- EndpointsConfig.Resolved &
- ProtocolConfig.Resolved &
- UserAgentConfig.Resolved;
diff --git a/clients/node/client-rds-data-node/index.ts b/clients/node/client-rds-data-node/index.ts
deleted file mode 100644
index c1112a29fc2a..000000000000
--- a/clients/node/client-rds-data-node/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from "./RDSDataClient";
-export * from "./RDSDataConfiguration";
-export * from "./commands/ExecuteStatementCommand";
diff --git a/jest.config.js b/jest.config.js
index b296b881fcc1..5715d043240f 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -5,14 +5,14 @@ module.exports = {
projects: ["/packages/*/jest.config.js"],
testPathIgnorePatterns: [
"/packages/add-glacier-checksum-headers-browser",
- "/clients/.*/client-.*"
+ "/clients/client-.*"
],
coveragePathIgnorePatterns: [
"/node_modules/",
"/packages/add-glacier-checksum-headers-browser",
"/packages/crypto-sjcl-*",
"/packages/xml-body-parser/vendor/",
- "/clients/.*/client-.*",
+ "/clients/client-.*",
"/__fixtures__/"
]
};
diff --git a/package.json b/package.json
index b7b72c5b3fc2..158c76a43c35 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"copy-models": "node ./scripts/copyModels.js",
"update-clients": "node ./packages/package-generator/build/cli.js import-all --matching './models/*/*/service-2.json'",
"build:crypto-dependencies": "lerna run --scope '@aws-sdk/types' --scope '@aws-sdk/util-utf8-browser' --scope '@aws-sdk/util-locate-window' --scope '@aws-sdk/hash-node' --include-filtered-dependencies pretest",
- "build:smithy-client": "lerna run --scope '@aws-sdk/client-rds-data-node' --include-filtered-dependencies pretest",
+ "build:smithy-client": "lerna run --scope '@aws-sdk/client-rds-data' --include-filtered-dependencies pretest",
"pretest": "yarn build:crypto-dependencies && yarn build:smithy-client",
"test": "jest --coverage --passWithNoTests",
"pretest-all": "lerna run pretest",
@@ -48,9 +48,7 @@
},
"workspaces": [
"packages/*",
- "clients/browser/*",
- "clients/node/*",
- "clients/universal/*"
+ "clients/*"
],
"husky": {
"hooks": {
@@ -64,4 +62,4 @@
"git add"
]
}
-}
\ No newline at end of file
+}
diff --git a/packages/config-resolver/src/EndpointsConfig.ts b/packages/config-resolver/src/EndpointsConfig.ts
index 79157e40835e..1f34a14cb853 100644
--- a/packages/config-resolver/src/EndpointsConfig.ts
+++ b/packages/config-resolver/src/EndpointsConfig.ts
@@ -14,51 +14,48 @@ export function normalizeEndpoint(
return endpoint!;
}
-export namespace EndpointsConfig {
- export interface Input {
- /**
- * 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).
- */
- endpoint?: string | Endpoint | Provider;
+export interface EndpointsConfigInput {
+ /**
+ * 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).
+ */
+ endpoint?: string | Endpoint | Provider;
- /**
- * The endpoint provider to call if no endpoint is provided
- */
- endpointProvider?: any;
+ /**
+ * The endpoint provider to call if no endpoint is provided
+ */
+ endpointProvider?: any;
- /**
- * Whether TLS is enabled for requests.
- */
- tls?: boolean;
- }
- interface PreviouslyResolved {
- urlParser: UrlParser;
- region: Provider;
- service: string;
- }
- export interface Resolved extends Required {
- endpoint: Provider;
- }
- export function resolve(
- input: T & Input & PreviouslyResolved
- ): T & Resolved {
- const tls = input.tls || true;
- const defaultProvider = (tls: boolean, region: string) => ({
- protocol: tls ? "https:" : "http:",
- path: "/",
- hostname: `${input.service}.${region}.amazonaws.com`
- });
- const endpointProvider = input.endpointProvider || defaultProvider;
- let endpoint: Provider = input.endpoint
- ? normalizeEndpoint(input.endpoint, input.urlParser)
- : () => input.region().then(region => endpointProvider(tls, region));
- return {
- ...input,
- endpointProvider,
- endpoint,
- tls
- };
- }
+ /**
+ * Whether TLS is enabled for requests.
+ */
+ tls?: boolean;
+}
+interface PreviouslyResolved {
+ urlParser: UrlParser;
+ region: Provider;
+ service: string;
+}
+export interface EndpointsConfigResolved
+ extends Required {
+ endpoint: Provider;
+}
+export function resolveEndpointsConfig(
+ input: T & EndpointsConfigInput & PreviouslyResolved
+): T & EndpointsConfigResolved {
+ const tls = input.tls || true;
+ const defaultProvider = (tls: boolean, region: string) => ({
+ protocol: tls ? "https:" : "http:",
+ path: "/",
+ hostname: `${input.service}.${region}.amazonaws.com`
+ });
+ const endpointProvider = input.endpointProvider || defaultProvider;
+ const endpoint: Provider = input.endpoint
+ ? normalizeEndpoint(input.endpoint, input.urlParser)
+ : () => input.region().then(region => endpointProvider(tls, region));
+ return {
+ ...input,
+ endpointProvider,
+ endpoint,
+ tls
+ };
}
-//export separately for showing comment block in Intellisense
-export type EndpointsConfigInput = EndpointsConfig.Input;
diff --git a/packages/config-resolver/src/ProtocolConfig.ts b/packages/config-resolver/src/ProtocolConfig.ts
index 3851ecf3ddd7..51225b0e5892 100644
--- a/packages/config-resolver/src/ProtocolConfig.ts
+++ b/packages/config-resolver/src/ProtocolConfig.ts
@@ -1,29 +1,29 @@
import { Protocol, HttpOptions } from "@aws-sdk/types";
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
-export namespace ProtocolConfig {
- export interface Input {
- /**
- * The serializing protocol to used in request
- */
- protocol?: Protocol;
- }
- interface PreviouslyResolved {
- httpHandler: HttpHandler;
- protocolDefaultProvider: (
- handler: HttpHandler
- ) => Protocol;
- }
- export type Resolved = Required;
- export function resolve(
- input: T & Input & PreviouslyResolved
- ): T & Resolved {
- return {
- ...input,
- protocol:
- input.protocol || input.protocolDefaultProvider(input.httpHandler)
- };
- }
+export interface ClientProtocolConfigInput {
+ /**
+ * The serializing protocol to used in request
+ */
+ protocol?: Protocol;
+}
+interface PreviouslyResolved {
+ httpHandler: HttpHandler;
+ protocolDefaultProvider: (
+ handler: HttpHandler
+ ) => Protocol;
+}
+export type ClientProtocolConfigResolved = Required;
+export function resolveClientProtocolConfig(
+ input: T & ClientProtocolConfigInput & PreviouslyResolved
+): T & ClientProtocolConfigResolved {
+ return {
+ ...input,
+ protocol: input.protocol || input.protocolDefaultProvider(input.httpHandler)
+ };
+}
+export function destroyClientProtocolConfig(
+ config: ClientProtocolConfigResolved
+): void {
+ config.protocol.destroy();
}
-//export separately for showing comment block in Intellisense
-export type ProtocolConfigInput = ProtocolConfig.Input;
diff --git a/packages/config-resolver/src/RegionConfig.ts b/packages/config-resolver/src/RegionConfig.ts
index 67be54fd208c..2a16eb5d2499 100644
--- a/packages/config-resolver/src/RegionConfig.ts
+++ b/packages/config-resolver/src/RegionConfig.ts
@@ -1,30 +1,26 @@
import { Provider } from "@aws-sdk/types";
-export namespace RegionConfiguration {
- export interface Input {
- /**
- * The AWS region to which this client will send requests
- */
- region?: string | Provider;
- }
- interface PreviouslyResolved {
- regionDefaultProvider: (input: any) => Provider;
- }
- export interface Resolved {
- region: Provider;
- }
- export function resolve(
- input: T & Input & PreviouslyResolved
- ): T & Resolved {
- let region = input.region || input.regionDefaultProvider(input as any);
- return {
- ...input,
- region: normalizeRegion(region)
- };
- }
+export interface RegionConfigInput {
+ /**
+ * The AWS region to which this client will send requests
+ */
+ region?: string | Provider;
+}
+interface PreviouslyResolved {
+ regionDefaultProvider: (input: any) => Provider;
+}
+export interface RegionConfigResolved {
+ region: Provider;
+}
+export function resolveRegionConfig(
+ input: T & RegionConfigInput & PreviouslyResolved
+): T & RegionConfigResolved {
+ let region = input.region || input.regionDefaultProvider(input as any);
+ return {
+ ...input,
+ region: normalizeRegion(region)
+ };
}
-//export separately for showing comment block in Intellisense
-export type RegionConfigurationInput = RegionConfiguration.Input;
function normalizeRegion(region: string | Provider): Provider {
if (typeof region === "string") {
diff --git a/packages/middleware-content-length/src/index.ts b/packages/middleware-content-length/src/index.ts
index cff54e7911d5..868833bbf427 100644
--- a/packages/middleware-content-length/src/index.ts
+++ b/packages/middleware-content-length/src/index.ts
@@ -44,11 +44,13 @@ export function contentLengthMiddleware(
};
}
-export const contentLengthPlugin = (options: {
+export const getContentLengthPlugin = (options: {
bodyLengthChecker: BodyLengthCalculator;
-}): Pluggable => clientStack => {
- clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), {
- step: "build",
- tags: { SET_CONTENT_LENGTH: true }
- });
-};
+}): Pluggable => ({
+ applyToStack: clientStack => {
+ clientStack.add(contentLengthMiddleware(options.bodyLengthChecker), {
+ step: "build",
+ tags: { SET_CONTENT_LENGTH: true }
+ });
+ }
+});
diff --git a/packages/retry-middleware/.gitignore b/packages/middleware-retry/.gitignore
similarity index 100%
rename from packages/retry-middleware/.gitignore
rename to packages/middleware-retry/.gitignore
diff --git a/packages/retry-middleware/.npmignore b/packages/middleware-retry/.npmignore
similarity index 100%
rename from packages/retry-middleware/.npmignore
rename to packages/middleware-retry/.npmignore
diff --git a/packages/retry-middleware/CHANGELOG.md b/packages/middleware-retry/CHANGELOG.md
similarity index 100%
rename from packages/retry-middleware/CHANGELOG.md
rename to packages/middleware-retry/CHANGELOG.md
diff --git a/packages/retry-middleware/LICENSE b/packages/middleware-retry/LICENSE
similarity index 100%
rename from packages/retry-middleware/LICENSE
rename to packages/middleware-retry/LICENSE
diff --git a/packages/middleware-retry/README.md b/packages/middleware-retry/README.md
new file mode 100644
index 000000000000..80ed6d075aba
--- /dev/null
+++ b/packages/middleware-retry/README.md
@@ -0,0 +1,4 @@
+# @aws-sdk/middleware-retry
+
+[![NPM version](https://img.shields.io/npm/v/@aws-sdk/middleware-retry/preview.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-retry)
+[![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/middleware-retry.svg)](https://www.npmjs.com/package/@aws-sdk/middleware-retry)
diff --git a/packages/retry-middleware/jest.config.js b/packages/middleware-retry/jest.config.js
similarity index 100%
rename from packages/retry-middleware/jest.config.js
rename to packages/middleware-retry/jest.config.js
diff --git a/packages/retry-middleware/package.json b/packages/middleware-retry/package.json
similarity index 94%
rename from packages/retry-middleware/package.json
rename to packages/middleware-retry/package.json
index cd8acef83917..66b655ba758d 100644
--- a/packages/retry-middleware/package.json
+++ b/packages/middleware-retry/package.json
@@ -1,5 +1,5 @@
{
- "name": "@aws-sdk/retry-middleware",
+ "name": "@aws-sdk/middleware-retry",
"version": "0.1.0-preview.5",
"scripts": {
"prepublishOnly": "tsc",
diff --git a/packages/middleware-retry/src/configurations.ts b/packages/middleware-retry/src/configurations.ts
new file mode 100644
index 000000000000..daf6a6643298
--- /dev/null
+++ b/packages/middleware-retry/src/configurations.ts
@@ -0,0 +1,28 @@
+import { RetryStrategy } from "@aws-sdk/types";
+import { ExponentialBackOffStrategy } from "./defaultStrategy";
+
+export interface RetryConfigInput {
+ /**
+ * The maximum number of times requests that encounter potentially transient failures should be retried
+ */
+ maxRetries?: number;
+ /**
+ * The strategy to retry the request. Using built-in exponential backoff strategy by default.
+ */
+ retryStrategy?: RetryStrategy;
+}
+export interface RetryConfigResolved {
+ maxRetries: number;
+ retryStrategy: RetryStrategy;
+}
+export function resolveRetryConfig(
+ input: T & RetryConfigInput
+): T & RetryConfigResolved {
+ const maxRetries = input.maxRetries === undefined ? 3 : input.maxRetries;
+ return {
+ ...input,
+ maxRetries,
+ retryStrategy:
+ input.retryStrategy || new ExponentialBackOffStrategy(maxRetries)
+ };
+}
diff --git a/packages/retry-middleware/src/constants.ts b/packages/middleware-retry/src/constants.ts
similarity index 100%
rename from packages/retry-middleware/src/constants.ts
rename to packages/middleware-retry/src/constants.ts
diff --git a/packages/retry-middleware/src/defaultStrategy.ts b/packages/middleware-retry/src/defaultStrategy.ts
similarity index 100%
rename from packages/retry-middleware/src/defaultStrategy.ts
rename to packages/middleware-retry/src/defaultStrategy.ts
diff --git a/packages/retry-middleware/src/delayDecider.spec.ts b/packages/middleware-retry/src/delayDecider.spec.ts
similarity index 100%
rename from packages/retry-middleware/src/delayDecider.spec.ts
rename to packages/middleware-retry/src/delayDecider.spec.ts
diff --git a/packages/retry-middleware/src/delayDecider.ts b/packages/middleware-retry/src/delayDecider.ts
similarity index 100%
rename from packages/retry-middleware/src/delayDecider.ts
rename to packages/middleware-retry/src/delayDecider.ts
diff --git a/packages/retry-middleware/src/index.spec.ts b/packages/middleware-retry/src/index.spec.ts
similarity index 88%
rename from packages/retry-middleware/src/index.spec.ts
rename to packages/middleware-retry/src/index.spec.ts
index 7e0c5696b90a..b21b37aaa879 100644
--- a/packages/retry-middleware/src/index.spec.ts
+++ b/packages/middleware-retry/src/index.spec.ts
@@ -3,18 +3,18 @@ import {
THROTTLING_RETRY_DELAY_BASE
} from "./constants";
import { retryMiddleware } from "./retryMiddleware";
-import { RetryConfig } from "./configurations";
+import { resolveRetryConfig } from "./configurations";
import * as delayDeciderModule from "./delayDecider";
import { ExponentialBackOffStrategy, RetryDecider } from "./defaultStrategy";
import { HttpRequest } from "@aws-sdk/protocol-http";
-import { SdkError } from '@aws-sdk/types';
+import { SdkError } from "@aws-sdk/types";
describe("retryMiddleware", () => {
it("should not retry when the handler completes successfully", async () => {
const next = jest.fn().mockResolvedValue({ output: { $metadata: {} } });
- const retryHandler = retryMiddleware(
- RetryConfig.resolve({ maxRetries: 0 })
- )(next);
+ const retryHandler = retryMiddleware(resolveRetryConfig({ maxRetries: 0 }))(
+ next
+ );
const {
output: { $metadata }
@@ -30,7 +30,7 @@ describe("retryMiddleware", () => {
const error = new Error();
error.name = "ProvisionedThroughputExceededException";
const next = jest.fn().mockRejectedValue(error);
- const retryHandler = retryMiddleware(RetryConfig.resolve({ maxRetries }))(
+ const retryHandler = retryMiddleware(resolveRetryConfig({ maxRetries }))(
next
);
@@ -45,9 +45,9 @@ describe("retryMiddleware", () => {
const error = new Error();
error.name = "ValidationException";
const next = jest.fn().mockRejectedValue(error);
- const retryHandler = retryMiddleware(
- RetryConfig.resolve({ maxRetries: 3 })
- )(next);
+ const retryHandler = retryMiddleware(resolveRetryConfig({ maxRetries: 3 }))(
+ next
+ );
await expect(
retryHandler({ input: {}, request: new HttpRequest({}) })
diff --git a/packages/retry-middleware/src/index.ts b/packages/middleware-retry/src/index.ts
similarity index 100%
rename from packages/retry-middleware/src/index.ts
rename to packages/middleware-retry/src/index.ts
diff --git a/packages/retry-middleware/src/retryDecider.spec.ts b/packages/middleware-retry/src/retryDecider.spec.ts
similarity index 100%
rename from packages/retry-middleware/src/retryDecider.spec.ts
rename to packages/middleware-retry/src/retryDecider.spec.ts
diff --git a/packages/retry-middleware/src/retryDecider.ts b/packages/middleware-retry/src/retryDecider.ts
similarity index 100%
rename from packages/retry-middleware/src/retryDecider.ts
rename to packages/middleware-retry/src/retryDecider.ts
diff --git a/packages/middleware-retry/src/retryMiddleware.ts b/packages/middleware-retry/src/retryMiddleware.ts
new file mode 100644
index 000000000000..87b404ece2cf
--- /dev/null
+++ b/packages/middleware-retry/src/retryMiddleware.ts
@@ -0,0 +1,31 @@
+import {
+ FinalizeHandler,
+ FinalizeHandlerArguments,
+ MetadataBearer,
+ FinalizeHandlerOutput,
+ Pluggable
+} from "@aws-sdk/types";
+import { RetryConfigResolved } from "./configurations";
+
+export function retryMiddleware(options: RetryConfigResolved) {
+ return