diff --git a/clients/client-rds-data/RdsDataServiceClient.ts b/clients/client-rds-data/RdsDataServiceClient.ts index 051c131f7fee..e82798f7846d 100644 --- a/clients/client-rds-data/RdsDataServiceClient.ts +++ b/clients/client-rds-data/RdsDataServiceClient.ts @@ -18,7 +18,6 @@ import { Provider, HashConstructor, UrlParser, - Protocol, StreamCollector, Decoder, Encoder @@ -27,10 +26,7 @@ import { EndpointsConfigInput, EndpointsConfigResolved, resolveEndpointsConfig, - ClientProtocolConfigInput, - ClientProtocolConfigResolved, - resolveClientProtocolConfig, - destroyClientProtocolConfig, + destroyRequestHandlerConfig, RegionConfigInput, RegionConfigResolved, resolveRegionConfig @@ -54,7 +50,7 @@ import { resolveAwsAuthConfig, getAwsAuthPlugin } from "@aws-sdk/middleware-signing"; -import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http"; +import { HttpHandler } from "@aws-sdk/protocol-http"; import { Client as SmithyClient, SmithyResolvedConfiguration @@ -78,10 +74,15 @@ export type ServiceOutputTypes = | BatchExecuteStatementResponse; export interface RDSDataRuntimeDependencies { + /** + * The function that will be used to populate serializing protocol + */ + protocol: string; + /** * The HTTP handler to use. Fetch in browser and Https in Nodejs */ - httpHandler?: HttpHandler; + requestHandler?: 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 @@ -138,13 +139,6 @@ export interface RDSDataRuntimeDependencies { */ defaultUserAgent?: string; - /** - * The function that will be used to populate serializing protocol - */ - protocolDefaultProvider?: ( - handler: HttpHandler - ) => Protocol; - /** * The service name with which to sign requests. */ @@ -161,7 +155,6 @@ export type RdsDataServiceConfig = RDSDataRuntimeDependencies & RegionConfigInput & RetryConfigInput & EndpointsConfigInput & - ClientProtocolConfigInput & UserAgentConfigInput; export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration< @@ -172,21 +165,21 @@ export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration< RegionConfigResolved & RetryConfigResolved & EndpointsConfigResolved & - ClientProtocolConfigResolved & UserAgentConfigResolved; export class RdsDataService extends SmithyClient< __HttpOptions, ServiceInputTypes, - ServiceOutputTypes + ServiceOutputTypes, + RdsDataServiceResolvedConfig > { readonly config: RdsDataServiceResolvedConfig; constructor(configuration: RdsDataServiceConfig) { - const _config_0 = resolveClientProtocolConfig({ + const _config_0 = { ...RDSRuntimeConfiguration, ...configuration - }); + }; let _config_1 = resolveRegionConfig(_config_0); let _config_2 = resolveAwsAuthConfig(_config_1); let _config_3 = resolveEndpointsConfig(_config_2); @@ -201,6 +194,6 @@ export class RdsDataService extends SmithyClient< } destroy(): void { - destroyClientProtocolConfig(this.config); + destroyRequestHandlerConfig(this.config); } } diff --git a/clients/client-rds-data/commands/ExecuteStatementCommand.ts b/clients/client-rds-data/commands/ExecuteStatementCommand.ts index 0d8b7d0b9308..a0e1b1f5beeb 100644 --- a/clients/client-rds-data/commands/ExecuteStatementCommand.ts +++ b/clients/client-rds-data/commands/ExecuteStatementCommand.ts @@ -21,8 +21,11 @@ import { } from "../RdsDataServiceClient"; export class ExecuteStatementCommand extends Command< + ServiceInputTypes, ExecuteStatementRequest, - ExecuteStatementResponse + ServiceOutputTypes, + ExecuteStatementResponse, + RdsDataServiceResolvedConfig > { constructor(readonly input: ExecuteStatementRequest) { super(); @@ -33,9 +36,7 @@ export class ExecuteStatementCommand extends Command< configuration: RdsDataServiceResolvedConfig, options?: HttpOptions ): Handler { - const { - protocol: { handler } - } = configuration; + const { requestHandler } = configuration; this.middlewareStack.use( getSerdePlugin(configuration, this.serialize, this.deserialize) @@ -49,7 +50,7 @@ export class ExecuteStatementCommand extends Command< return stack.resolve( (request: FinalizeHandlerArguments) => - handler.handle(request.request as HttpRequest, options || {}), + requestHandler.handle(request.request as HttpRequest, options || {}), handlerExecutionContext ); } diff --git a/clients/client-rds-data/package.json b/clients/client-rds-data/package.json index 61156b98ce12..26ab57558c6a 100644 --- a/clients/client-rds-data/package.json +++ b/clients/client-rds-data/package.json @@ -42,7 +42,6 @@ "@aws-sdk/middleware-user-agent": "^0.1.0-preview.1", "@aws-sdk/middleware-stack": "^0.1.0-preview.6", "@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/middleware-retry": "^0.1.0-preview.5", "@aws-sdk/signature-v4": "^0.1.0-preview.7", diff --git a/clients/client-rds-data/runtimeConfig.browser.ts b/clients/client-rds-data/runtimeConfig.browser.ts index 8ce6759932fd..b4faad01236c 100644 --- a/clients/client-rds-data/runtimeConfig.browser.ts +++ b/clients/client-rds-data/runtimeConfig.browser.ts @@ -4,7 +4,6 @@ import { FetchHttpHandler } from "@aws-sdk/fetch-http-handler"; import { parseUrl } from "@aws-sdk/url-parser-browser"; import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; import { streamCollector } from "@aws-sdk/stream-collector-browser"; -import { RestJsonProtocol } from "@aws-sdk/protocol-rest-json"; 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"; @@ -12,10 +11,10 @@ import { name, version } from "./package.json"; import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient"; export const RDSRuntimeConfiguration: Required = { - protocolDefaultProvider: handler => new RestJsonProtocol(handler), + protocol: "aws.rest-json-1.1", signingName: "rds-data", service: "rds-data", - httpHandler: new FetchHttpHandler(), + requestHandler: new FetchHttpHandler(), sha256: Sha256, credentialDefaultProvider: invalidFunction("Credential is missing") as any, regionDefaultProvider: invalidFunction("Region is missing") as any, diff --git a/clients/client-rds-data/runtimeConfig.ts b/clients/client-rds-data/runtimeConfig.ts index f5c967be9b7e..4131d4d6d6e4 100644 --- a/clients/client-rds-data/runtimeConfig.ts +++ b/clients/client-rds-data/runtimeConfig.ts @@ -5,7 +5,6 @@ import { defaultProvider as regionDefaultProvider } from "@aws-sdk/region-provid import { parseUrl } from "@aws-sdk/url-parser-node"; import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; import { streamCollector } from "@aws-sdk/stream-collector-node"; -import { RestJsonProtocol } from "@aws-sdk/protocol-rest-json"; 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"; @@ -13,10 +12,10 @@ import { name, version } from "./package.json"; import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient"; export const RDSRuntimeConfiguration: Required = { - protocolDefaultProvider: handler => new RestJsonProtocol(handler), + protocol: "aws.rest-json-1.1", signingName: "rds-data", service: "rds-data", - httpHandler: new NodeHttpHandler(), + requestHandler: new NodeHttpHandler(), sha256: Hash.bind(null, "sha256"), credentialDefaultProvider, regionDefaultProvider, diff --git a/package.json b/package.json index a483c2fa6358..3b99a99ddb6e 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "lerna": "3.18.3", "lint-staged": "^9.0.0", "prettier": "1.19.1", - "typescript": "3.7.0-dev.20190926", + "typescript": "^3.7.0", "yarn": "1.17.3" }, "workspaces": [ diff --git a/packages/config-resolver/src/HandlerConfig.ts b/packages/config-resolver/src/HandlerConfig.ts new file mode 100644 index 000000000000..8c31152d907a --- /dev/null +++ b/packages/config-resolver/src/HandlerConfig.ts @@ -0,0 +1,7 @@ +import { RequestHandler } from "@aws-sdk/types"; + +export function destroyRequestHandlerConfig(config: { + requestHandler: RequestHandler; +}): void { + if (config.requestHandler.destroy) config.requestHandler.destroy(); +} diff --git a/packages/config-resolver/src/ProtocolConfig.ts b/packages/config-resolver/src/ProtocolConfig.ts deleted file mode 100644 index 51225b0e5892..000000000000 --- a/packages/config-resolver/src/ProtocolConfig.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Protocol, HttpOptions } from "@aws-sdk/types"; -import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http"; - -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(); -} diff --git a/packages/config-resolver/src/index.ts b/packages/config-resolver/src/index.ts index 629edb514c01..a31f76040105 100644 --- a/packages/config-resolver/src/index.ts +++ b/packages/config-resolver/src/index.ts @@ -1,3 +1,3 @@ export * from "./EndpointsConfig"; export * from "./RegionConfig"; -export * from "./ProtocolConfig"; +export * from "./HandlerConfig"; diff --git a/packages/middleware-serde/src/deserializerMiddleware.ts b/packages/middleware-serde/src/deserializerMiddleware.ts index d239625c8b6c..a700d1fb74fa 100644 --- a/packages/middleware-serde/src/deserializerMiddleware.ts +++ b/packages/middleware-serde/src/deserializerMiddleware.ts @@ -4,7 +4,7 @@ import { DeserializeHandler, DeserializeHandlerArguments, DeserializeHandlerOutput, - Protocol + RequestHandler } from "@aws-sdk/types"; export function deserializerMiddleware< @@ -12,7 +12,10 @@ export function deserializerMiddleware< Output extends object, RuntimeUtils = any >( - options: { protocol: Protocol } & RuntimeUtils, + options: { + requestHandler: RequestHandler; + protocol: string; + } & RuntimeUtils, deserializer: ResponseDeserializer ): DeserializeMiddleware { return ( @@ -21,11 +24,7 @@ export function deserializerMiddleware< args: DeserializeHandlerArguments ): Promise> => { const { response } = await next(args); - const parsed = await options.protocol.deserialize( - deserializer, - response, - options - ); + const parsed = await deserializer(response, options.protocol, options); return { response, output: parsed as Output diff --git a/packages/middleware-serde/src/serdePlugin.ts b/packages/middleware-serde/src/serdePlugin.ts index 32d40964ddb4..5a7f32f2deb0 100644 --- a/packages/middleware-serde/src/serdePlugin.ts +++ b/packages/middleware-serde/src/serdePlugin.ts @@ -2,24 +2,25 @@ import { RequestSerializer, ResponseDeserializer, Pluggable, - Protocol, MetadataBearer, MiddlewareStack, - EndpointBearer + EndpointBearer, + RequestHandler } from "@aws-sdk/types"; import { deserializerMiddleware } from "./deserializerMiddleware"; import { serializerMiddleware } from "./serializerMiddleware"; export function getSerdePlugin< InputType extends object, - SerializerRuntimeUtils extends EndpointBearer, - OutputType extends MetadataBearer, - DeserializerRuntimeUtils + SerDeContext extends EndpointBearer, + OutputType extends MetadataBearer >( - config: SerializerRuntimeUtils & - DeserializerRuntimeUtils & { protocol: Protocol }, - serializer: RequestSerializer, - deserializer: ResponseDeserializer + config: SerDeContext & { + protocol: string; + requestHandler: RequestHandler; + }, + serializer: RequestSerializer, + deserializer: ResponseDeserializer ): Pluggable { return { applyToStack: (commandStack: MiddlewareStack) => { diff --git a/packages/middleware-serde/src/serializerMiddleware.ts b/packages/middleware-serde/src/serializerMiddleware.ts index c479e5d3f8cc..c574eb611988 100644 --- a/packages/middleware-serde/src/serializerMiddleware.ts +++ b/packages/middleware-serde/src/serializerMiddleware.ts @@ -4,8 +4,8 @@ import { SerializeHandlerArguments, SerializeHandlerOutput, SerializeMiddleware, - Protocol, - EndpointBearer + EndpointBearer, + RequestHandler } from "@aws-sdk/types"; export function serializerMiddleware< @@ -13,7 +13,10 @@ export function serializerMiddleware< Output extends object, RuntimeUtils extends EndpointBearer >( - options: { protocol: Protocol } & RuntimeUtils, + options: { + requestHandler: RequestHandler; + protocol: string; + } & RuntimeUtils, serializer: RequestSerializer ): SerializeMiddleware { return ( @@ -25,9 +28,9 @@ export function serializerMiddleware< ...options, endpoint: await options.endpoint() }; - const request = options.protocol.serialize( - serializer, + const request = serializer( args.input, + options.protocol, endpointResolvedOptions ); return next({ diff --git a/packages/protocol-http/src/httpHandler.ts b/packages/protocol-http/src/httpHandler.ts index 528219f586b2..dfbe69b7b6d0 100644 --- a/packages/protocol-http/src/httpHandler.ts +++ b/packages/protocol-http/src/httpHandler.ts @@ -1,8 +1,8 @@ import { HttpRequest } from "./httpRequest"; import { HttpResponse } from "./httpResponse"; -import { TransferHandler, HttpOptions } from "@aws-sdk/types"; +import { RequestHandler, HttpOptions } from "@aws-sdk/types"; -export type HttpHandler = TransferHandler< +export type HttpHandler = RequestHandler< HttpRequest, HttpResponse, HttpOptions diff --git a/packages/protocol-rest-json/.gitignore b/packages/protocol-rest-json/.gitignore deleted file mode 100644 index 3d1714c9806e..000000000000 --- a/packages/protocol-rest-json/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/node_modules/ -/build/ -/coverage/ -/docs/ -*.tsbuildinfo -*.tgz -*.log -package-lock.json diff --git a/packages/protocol-rest-json/.npmignore b/packages/protocol-rest-json/.npmignore deleted file mode 100644 index 4b9fe3abf33a..000000000000 --- a/packages/protocol-rest-json/.npmignore +++ /dev/null @@ -1,13 +0,0 @@ -/src/ -/coverage/ -/docs/ -tsconfig.test.json -*.tsbuildinfo - -*.spec.js -*.spec.d.ts -*.spec.js.map - -*.fixture.js -*.fixture.d.ts -*.fixture.js.map diff --git a/packages/protocol-rest-json/LICENSE b/packages/protocol-rest-json/LICENSE deleted file mode 100644 index e907b58668da..000000000000 --- a/packages/protocol-rest-json/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/protocol-rest-json/package.json b/packages/protocol-rest-json/package.json deleted file mode 100644 index 4edea6ea4c36..000000000000 --- a/packages/protocol-rest-json/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "@aws-sdk/protocol-rest-json", - "version": "0.1.0-preview.5", - "scripts": { - "prepublishOnly": "tsc", - "pretest": "tsc -p tsconfig.test.json", - "test": "jest" - }, - "main": "./build/index.js", - "types": "./build/index.d.ts", - "author": { - "name": "AWS SDK for JavaScript Team", - "email": "", - "url": "https://aws.amazon.com/javascript/" - }, - "license": "Apache-2.0", - "dependencies": { - "tslib": "^1.8.0", - "@aws-sdk/types": "^0.1.0-preview.4", - "@aws-sdk/protocol-http": "^0.1.0-preview.1" - }, - "devDependencies": { - "@types/jest": "^24.0.12", - "typescript": "~3.4.0", - "jest": "^24.7.1" - } -} diff --git a/packages/protocol-rest-json/src/index.ts b/packages/protocol-rest-json/src/index.ts deleted file mode 100644 index f17a17ae9726..000000000000 --- a/packages/protocol-rest-json/src/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { - RequestSerializer, - ResponseDeserializer, - Protocol, - TransferHandler, - HttpOptions, - SerdeContext -} from "@aws-sdk/types"; -import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http"; - -export class RestJsonProtocol extends Protocol< - HttpRequest, - HttpResponse, - HttpOptions -> { - constructor( - handler: TransferHandler - ) { - super(handler); - } - serialize( - serializer: RequestSerializer, - input: any, - utils: SerdeContext - ) { - return serializer(input, "aws.rest-json-1.1", utils); - } - deserialize( - deserializer: ResponseDeserializer, - output: HttpResponse, - utils: SerdeContext - ) { - return deserializer(output, "aws.rest-json-1.1", utils) as any; - } -} diff --git a/packages/protocol-rest-json/tsconfig.json b/packages/protocol-rest-json/tsconfig.json deleted file mode 100644 index 38b94cda274e..000000000000 --- a/packages/protocol-rest-json/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "declaration": true, - "strict": true, - "sourceMap": true, - "downlevelIteration": true, - "importHelpers": true, - "noEmitHelpers": true, - "lib": [ - "es5", - "es2015.promise", - "es2015.collection", - "es2015.iterable", - "es2015.symbol.wellknown" - ], - "rootDir": "./src", - "outDir": "./build", - "incremental": true - } -} diff --git a/packages/protocol-rest-json/tsconfig.test.json b/packages/protocol-rest-json/tsconfig.test.json deleted file mode 100644 index 17d0f1b7321f..000000000000 --- a/packages/protocol-rest-json/tsconfig.test.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "sourceMap": false, - "inlineSourceMap": true, - "inlineSources": true, - "rootDir": "./src", - "outDir": "./build", - "incremental": true - } -} diff --git a/packages/smithy-client/src/client.ts b/packages/smithy-client/src/client.ts index b7dc5e465149..7d4fc9620b89 100644 --- a/packages/smithy-client/src/client.ts +++ b/packages/smithy-client/src/client.ts @@ -1,8 +1,13 @@ import { MiddlewareStack } from "@aws-sdk/middleware-stack"; -import { Protocol, Command, MetadataBearer } from "@aws-sdk/types"; +import { + RequestHandler, + MetadataBearer, + Command, + Client as IClient +} from "@aws-sdk/types"; export interface SmithyConfiguration { - protocol: Protocol; + requestHandler: RequestHandler; } export type SmithyResolvedConfiguration = SmithyConfiguration< @@ -10,13 +15,16 @@ export type SmithyResolvedConfiguration = SmithyConfiguration< >; export class Client< - HandlerOptions = any, - ClientInput extends object = any, - ClientOutput extends MetadataBearer = any -> { + HandlerOptions, + ClientInput extends object, + ClientOutput extends MetadataBearer, + ResolvedClientConfiguration extends SmithyResolvedConfiguration< + HandlerOptions + > +> implements IClient { public middlewareStack = new MiddlewareStack(); - readonly config: SmithyResolvedConfiguration; - constructor(config: SmithyConfiguration) { + readonly config: ResolvedClientConfiguration; + constructor(config: ResolvedClientConfiguration) { this.config = config; } send( diff --git a/packages/smithy-client/src/command.ts b/packages/smithy-client/src/command.ts index fefccca45d49..9f003eb789dc 100644 --- a/packages/smithy-client/src/command.ts +++ b/packages/smithy-client/src/command.ts @@ -1,5 +1,26 @@ import { MiddlewareStack } from "@aws-sdk/middleware-stack"; +import { Command as ICommand, MetadataBearer, Handler } from "@aws-sdk/types"; -export class Command { - readonly middlewareStack = new MiddlewareStack(); +export abstract class Command< + ClientInput extends object, + Input extends ClientInput, + ClientOutput extends MetadataBearer, + Output extends ClientOutput, + ResolvedClientConfiguration +> + implements + ICommand< + ClientInput, + Input, + ClientOutput, + Output, + ResolvedClientConfiguration + > { + abstract input: Input; + readonly middlewareStack = new MiddlewareStack(); + abstract resolveMiddleware( + stack: MiddlewareStack, + configuration: ResolvedClientConfiguration, + options: any + ): Handler; } diff --git a/packages/types/src/client.ts b/packages/types/src/client.ts index 693968b5b4b0..f12df433c12c 100644 --- a/packages/types/src/client.ts +++ b/packages/types/src/client.ts @@ -1,95 +1,14 @@ import { MiddlewareStack } from "./middleware"; -import { Provider, Decoder, Encoder, UrlParser } from "./util"; -import { Endpoint } from "./http"; -import { TransferHandler } from "./transfer"; import { Command } from "./command"; import { MetadataBearer } from "./response"; -import { Credentials } from "./credentials"; -import { Hash, HashConstructor } from "./crypto"; - -export interface ConfigurationPropertyDefinition< - InputType, - ResolvedType extends InputType, - ServiceConfiguration extends { [key: string]: any }, - ResolvedConfiguration extends ServiceConfiguration -> { - /** - * Whether this property must be supplied by the user of a client. If value - * must be resolved but a default is available, this property should be - * `false` or undefined. - */ - required?: boolean; - - /** - * A static value to use as the default should none be supplied. - */ - defaultValue?: ResolvedType; - - /** - * A function that returns a default value for this property. It will be - * called if no value is supplied. - */ - defaultProvider?: { - (config: ResolvedConfiguration): ResolvedType; - }; - - /** - * A function that normalizes input to the subtype expected by the SDK. - */ - normalize?: { - (value: InputType, config: Partial): ResolvedType; - }; -} - -/** - * A map of configuration property names to configuration property definitions. - * - * Order is significant in the definition provided, as the config object passed - * to any `defaultProvider` and `apply` functions will only include properties - * that have already been resolved. - */ -export type ConfigurationDefinition< - Configuration extends { [key: string]: any }, - ResolvedConfiguration extends Configuration -> = { - readonly [P in keyof Configuration]: ConfigurationPropertyDefinition< - Configuration[P], - ResolvedConfiguration[P], - Configuration, - ResolvedConfiguration - >; -}; - -/** - * A general interface for service clients' configuration interface. - * It is idempotent among browser or node clients - */ -export interface ClientResolvedConfigurationBase { - credentials?: Provider; - profile?: string; - maxRedirects?: number; - maxRetries?: number; - region?: Provider; - sslEnabled?: boolean; - urlParser?: UrlParser; - endpointProvider?: any; - endpoint?: Provider; - base64Decoder?: Decoder; - base64Encoder?: Encoder; - utf8Decoder?: Decoder; - utf8Incoder?: Encoder; - _user_injected_http_handler?: boolean; - httpHandler?: TransferHandler; - md5?: { new (): Hash }; - sha256?: HashConstructor; -} /** * function definition for different overrides of client's 'send' function. */ interface InvokeFunction< InputTypes extends object, - OutputTypes extends MetadataBearer + OutputTypes extends MetadataBearer, + ResolvedClientConfiguration > { ( command: Command< @@ -97,7 +16,7 @@ interface InvokeFunction< InputType, OutputTypes, OutputType, - ClientResolvedConfigurationBase + ResolvedClientConfiguration >, options?: any ): Promise; @@ -107,7 +26,7 @@ interface InvokeFunction< InputType, OutputTypes, OutputType, - ClientResolvedConfigurationBase + ResolvedClientConfiguration >, options: any, cb: (err: any, data?: OutputType) => void @@ -118,7 +37,7 @@ interface InvokeFunction< InputType, OutputTypes, OutputType, - ClientResolvedConfigurationBase + ResolvedClientConfiguration >, options?: any, cb?: (err: any, data?: OutputType) => void @@ -128,8 +47,12 @@ interface InvokeFunction< /** * A general interface for service clients, idempotent to browser or node clients */ -export interface AWSClient { - // readonly config: ClientResolvedConfigurationBase; - middlewareStack: MiddlewareStack; - send: InvokeFunction; +export interface Client< + Input extends object, + Output extends MetadataBearer, + ResolvedClientConfiguration +> { + readonly config: ResolvedClientConfiguration; + middlewareStack: MiddlewareStack; + send: InvokeFunction; } diff --git a/packages/types/src/command.ts b/packages/types/src/command.ts index 07d58d376685..549cab4cd705 100644 --- a/packages/types/src/command.ts +++ b/packages/types/src/command.ts @@ -1,34 +1,8 @@ -import { AbortSignal } from "./abort"; -import { HttpOptions } from "./http"; import { Handler, MiddlewareStack } from "./middleware"; import { MetadataBearer } from "./response"; -import { OperationModel } from "./protocol"; - -export interface CommandInput { - /** - * The maximum number of times this operation should be retried. If set, this - * value will override the `maxRetries` configuration set on the client for - * this command. - */ - $maxRetries?: number; - - /** - * An object that may be queried to determine if the underlying operation - * has been aborted. - * - * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal - */ - $abortSignal?: AbortSignal; - - /** - * Per-request HTTP configuration options. If set, any options specified will - * override the corresponding HTTP option set on the client for this command. - */ - $httpOptions?: HttpOptions; -} export interface Command< - ClientInput extends CommandInput, + ClientInput extends object, InputType extends ClientInput, ClientOutput extends MetadataBearer, OutputType extends ClientOutput, diff --git a/packages/types/src/middleware.ts b/packages/types/src/middleware.ts index b1ef7b16c5d7..d0025cc91dc4 100644 --- a/packages/types/src/middleware.ts +++ b/packages/types/src/middleware.ts @@ -1,5 +1,4 @@ import { Logger } from "./logger"; -import { AWSClient } from "./client"; export interface HandlerArguments { /** diff --git a/packages/types/src/transfer.ts b/packages/types/src/transfer.ts index 78b83120140c..2f630eadf1a9 100644 --- a/packages/types/src/transfer.ts +++ b/packages/types/src/transfer.ts @@ -1,8 +1,6 @@ -import { RequestSerializer, ResponseDeserializer } from "./serde"; +export type RequestHandlerOutput = { response: ResponseType }; -export type TransferHandlerOutput = { response: ResponseType }; - -export interface TransferHandler< +export interface RequestHandler< RequestType, ResponseType, HandlerOptions = {} @@ -11,26 +9,5 @@ export interface TransferHandler< handle: ( request: RequestType, handlerOptions: HandlerOptions - ) => Promise>; -} - -export abstract class Protocol { - constructor( - readonly handler: TransferHandler - ) {} - abstract serialize( - serializer: RequestSerializer, - input: any, - utils?: { [key: string]: any } - ): RequestType; - abstract deserialize>( - parser: T, - input: ResponseType, - utils?: { [key: string]: any } - ): ReturnType; - destroy(): void { - if (typeof this.handler.destroy === "function") { - this.handler.destroy(); - } - } + ) => Promise>; } diff --git a/yarn.lock b/yarn.lock index 138c3d5de393..9a79b53e1d65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9310,10 +9310,10 @@ typescript@3.2.x: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d" integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg== -typescript@3.7.0-dev.20190926: - version "3.7.0-dev.20190926" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.0-dev.20190926.tgz#2e90fa4e56fad0fddb87e4d837cd33c7e4a55e7c" - integrity sha512-uOQij3UHJnzxY/8Kv1kdmvWTjghgbCD0kBOgVGbY7Rni8ER51O8iPMmI4YpanZmaiZbPK6zUaS60b04/2C91bA== +typescript@^3.7.0, typescript@^3.7.0-dev.20190926: + version "3.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" + integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ== typescript@~3.4.0: version "3.4.5"