From e6065437ed3b804ea0fa9b0bf79769a014a84e6f Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Thu, 28 Oct 2021 11:26:22 -0700 Subject: [PATCH] feat(private): add generic client aws-echo-service (#2950) --- private/aws-echo-service/.gitignore | 9 + private/aws-echo-service/LICENSE | 201 +++++++++++++ private/aws-echo-service/jest.config.js | 4 + private/aws-echo-service/package.json | 94 +++++++ private/aws-echo-service/src/EchoService.ts | 52 ++++ .../aws-echo-service/src/EchoServiceClient.ts | 193 +++++++++++++ .../src/commands/EchoCommand.ts | 70 +++++ .../src/commands/LengthCommand.ts | 70 +++++ .../aws-echo-service/src/commands/index.ts | 2 + private/aws-echo-service/src/index.ts | 4 + private/aws-echo-service/src/models/index.ts | 1 + .../aws-echo-service/src/models/models_0.ts | 71 +++++ .../src/protocols/Aws_restJson1.ts | 265 ++++++++++++++++++ .../src/runtimeConfig.browser.ts | 36 +++ .../src/runtimeConfig.native.ts | 16 ++ .../src/runtimeConfig.shared.ts | 13 + private/aws-echo-service/src/runtimeConfig.ts | 39 +++ private/aws-echo-service/tsconfig.es.json | 10 + private/aws-echo-service/tsconfig.json | 32 +++ private/aws-echo-service/tsconfig.types.json | 10 + private/aws-protocoltests-ec2/.gitignore | 2 +- scripts/generate-clients/code-gen-dir.js | 2 + scripts/generate-clients/code-gen.js | 7 + scripts/generate-clients/index.js | 33 ++- 24 files changed, 1225 insertions(+), 11 deletions(-) create mode 100644 private/aws-echo-service/.gitignore create mode 100644 private/aws-echo-service/LICENSE create mode 100644 private/aws-echo-service/jest.config.js create mode 100644 private/aws-echo-service/package.json create mode 100644 private/aws-echo-service/src/EchoService.ts create mode 100644 private/aws-echo-service/src/EchoServiceClient.ts create mode 100644 private/aws-echo-service/src/commands/EchoCommand.ts create mode 100644 private/aws-echo-service/src/commands/LengthCommand.ts create mode 100644 private/aws-echo-service/src/commands/index.ts create mode 100644 private/aws-echo-service/src/index.ts create mode 100644 private/aws-echo-service/src/models/index.ts create mode 100644 private/aws-echo-service/src/models/models_0.ts create mode 100644 private/aws-echo-service/src/protocols/Aws_restJson1.ts create mode 100644 private/aws-echo-service/src/runtimeConfig.browser.ts create mode 100644 private/aws-echo-service/src/runtimeConfig.native.ts create mode 100644 private/aws-echo-service/src/runtimeConfig.shared.ts create mode 100644 private/aws-echo-service/src/runtimeConfig.ts create mode 100644 private/aws-echo-service/tsconfig.es.json create mode 100644 private/aws-echo-service/tsconfig.json create mode 100644 private/aws-echo-service/tsconfig.types.json diff --git a/private/aws-echo-service/.gitignore b/private/aws-echo-service/.gitignore new file mode 100644 index 000000000000..54f14c9aef25 --- /dev/null +++ b/private/aws-echo-service/.gitignore @@ -0,0 +1,9 @@ +/node_modules/ +/build/ +/coverage/ +/docs/ +/dist-* +*.tsbuildinfo +*.tgz +*.log +package-lock.json diff --git a/private/aws-echo-service/LICENSE b/private/aws-echo-service/LICENSE new file mode 100644 index 000000000000..f9e0c8672bca --- /dev/null +++ b/private/aws-echo-service/LICENSE @@ -0,0 +1,201 @@ + 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 2018-2021 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/private/aws-echo-service/jest.config.js b/private/aws-echo-service/jest.config.js new file mode 100644 index 000000000000..02eed352c6a8 --- /dev/null +++ b/private/aws-echo-service/jest.config.js @@ -0,0 +1,4 @@ +module.exports = { + preset: "ts-jest", + testMatch: ["**/*.spec.ts", "!**/*.browser.spec.ts", "!**/*.integ.spec.ts"], +}; diff --git a/private/aws-echo-service/package.json b/private/aws-echo-service/package.json new file mode 100644 index 000000000000..98f965e50687 --- /dev/null +++ b/private/aws-echo-service/package.json @@ -0,0 +1,94 @@ +{ + "name": "@aws-sdk/aws-echo-service", + "description": "@aws-sdk/aws-echo-service client", + "version": "1.0.0-alpha.1", + "scripts": { + "build": "yarn build:cjs && yarn build:es && yarn build:types", + "build:cjs": "tsc -p tsconfig.json", + "build:docs": "yarn clean:docs && typedoc ./", + "build:es": "tsc -p tsconfig.es.json", + "build:types": "tsc -p tsconfig.types.json", + "clean": "yarn clean:dist && yarn clean:docs", + "clean:dist": "rimraf ./dist-*", + "clean:docs": "rimraf ./docs", + "downlevel-dts": "downlevel-dts dist-types dist-types/ts3.4", + "test": "jest --coverage --passWithNoTests" + }, + "main": "./dist-cjs/index.js", + "types": "./dist-types/index.d.ts", + "module": "./dist-es/index.js", + "sideEffects": false, + "dependencies": { + "@aws-crypto/sha256-browser": "2.0.0", + "@aws-crypto/sha256-js": "2.0.0", + "@aws-sdk/config-resolver": "3.38.0", + "@aws-sdk/fetch-http-handler": "3.38.0", + "@aws-sdk/hash-node": "3.38.0", + "@aws-sdk/invalid-dependency": "3.38.0", + "@aws-sdk/middleware-content-length": "3.38.0", + "@aws-sdk/middleware-host-header": "3.38.0", + "@aws-sdk/middleware-logger": "3.38.0", + "@aws-sdk/middleware-retry": "3.38.0", + "@aws-sdk/middleware-serde": "3.38.0", + "@aws-sdk/middleware-stack": "3.38.0", + "@aws-sdk/middleware-user-agent": "3.38.0", + "@aws-sdk/node-config-provider": "3.38.0", + "@aws-sdk/node-http-handler": "3.38.0", + "@aws-sdk/protocol-http": "3.38.0", + "@aws-sdk/smithy-client": "3.38.0", + "@aws-sdk/types": "3.38.0", + "@aws-sdk/url-parser": "3.38.0", + "@aws-sdk/util-base64-browser": "3.37.0", + "@aws-sdk/util-base64-node": "3.37.0", + "@aws-sdk/util-body-length-browser": "3.37.0", + "@aws-sdk/util-body-length-node": "3.37.0", + "@aws-sdk/util-user-agent-browser": "3.38.0", + "@aws-sdk/util-user-agent-node": "3.38.0", + "@aws-sdk/util-utf8-browser": "3.37.0", + "@aws-sdk/util-utf8-node": "3.37.0", + "tslib": "^2.3.0", + "uuid": "^8.3.2" + }, + "devDependencies": { + "@aws-sdk/service-client-documentation-generator": "3.38.0", + "@types/node": "^12.7.5", + "@types/uuid": "^8.3.0", + "downlevel-dts": "0.7.0", + "jest": "^26.1.0", + "rimraf": "^3.0.0", + "ts-jest": "^26.4.1", + "typedoc": "^0.19.2", + "typescript": "~4.3.5" + }, + "engines": { + "node": ">=10.0.0" + }, + "typesVersions": { + "<4.0": { + "dist-types/*": [ + "dist-types/ts3.4/*" + ] + } + }, + "files": [ + "dist-*" + ], + "author": { + "name": "AWS SDK for JavaScript Team", + "url": "https://aws.amazon.com/javascript/" + }, + "license": "Apache-2.0", + "browser": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.browser" + }, + "react-native": { + "./dist-es/runtimeConfig": "./dist-es/runtimeConfig.native" + }, + "private": true, + "homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/clients/aws-echo-service", + "repository": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-js-v3.git", + "directory": "clients/aws-echo-service" + } +} diff --git a/private/aws-echo-service/src/EchoService.ts b/private/aws-echo-service/src/EchoService.ts new file mode 100644 index 000000000000..784137ea54c0 --- /dev/null +++ b/private/aws-echo-service/src/EchoService.ts @@ -0,0 +1,52 @@ +import { EchoServiceClient } from "./EchoServiceClient"; +import { EchoCommand, EchoCommandInput, EchoCommandOutput } from "./commands/EchoCommand"; +import { LengthCommand, LengthCommandInput, LengthCommandOutput } from "./commands/LengthCommand"; +import { HttpHandlerOptions as __HttpHandlerOptions } from "@aws-sdk/types"; + +export class EchoService extends EchoServiceClient { + public echo(args: EchoCommandInput, options?: __HttpHandlerOptions): Promise; + public echo(args: EchoCommandInput, cb: (err: any, data?: EchoCommandOutput) => void): void; + public echo( + args: EchoCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: EchoCommandOutput) => void + ): void; + public echo( + args: EchoCommandInput, + optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: EchoCommandOutput) => void), + cb?: (err: any, data?: EchoCommandOutput) => void + ): Promise | void { + const command = new EchoCommand(args); + if (typeof optionsOrCb === "function") { + this.send(command, optionsOrCb); + } else if (typeof cb === "function") { + if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`); + this.send(command, optionsOrCb || {}, cb); + } else { + return this.send(command, optionsOrCb); + } + } + + public length(args: LengthCommandInput, options?: __HttpHandlerOptions): Promise; + public length(args: LengthCommandInput, cb: (err: any, data?: LengthCommandOutput) => void): void; + public length( + args: LengthCommandInput, + options: __HttpHandlerOptions, + cb: (err: any, data?: LengthCommandOutput) => void + ): void; + public length( + args: LengthCommandInput, + optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: LengthCommandOutput) => void), + cb?: (err: any, data?: LengthCommandOutput) => void + ): Promise | void { + const command = new LengthCommand(args); + if (typeof optionsOrCb === "function") { + this.send(command, optionsOrCb); + } else if (typeof cb === "function") { + if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`); + this.send(command, optionsOrCb || {}, cb); + } else { + return this.send(command, optionsOrCb); + } + } +} diff --git a/private/aws-echo-service/src/EchoServiceClient.ts b/private/aws-echo-service/src/EchoServiceClient.ts new file mode 100644 index 000000000000..19a591c790ee --- /dev/null +++ b/private/aws-echo-service/src/EchoServiceClient.ts @@ -0,0 +1,193 @@ +import { EchoCommandInput, EchoCommandOutput } from "./commands/EchoCommand"; +import { LengthCommandInput, LengthCommandOutput } from "./commands/LengthCommand"; +import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig"; +import { + CustomEndpointsInputConfig, + CustomEndpointsResolvedConfig, + resolveCustomEndpointsConfig, +} from "@aws-sdk/config-resolver"; +import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length"; +import { + HostHeaderInputConfig, + HostHeaderResolvedConfig, + getHostHeaderPlugin, + resolveHostHeaderConfig, +} from "@aws-sdk/middleware-host-header"; +import { getLoggerPlugin } from "@aws-sdk/middleware-logger"; +import { RetryInputConfig, RetryResolvedConfig, getRetryPlugin, resolveRetryConfig } from "@aws-sdk/middleware-retry"; +import { + UserAgentInputConfig, + UserAgentResolvedConfig, + getUserAgentPlugin, + resolveUserAgentConfig, +} from "@aws-sdk/middleware-user-agent"; +import { HttpHandler as __HttpHandler } from "@aws-sdk/protocol-http"; +import { + Client as __Client, + SmithyConfiguration as __SmithyConfiguration, + SmithyResolvedConfiguration as __SmithyResolvedConfiguration, +} from "@aws-sdk/smithy-client"; +import { + Provider, + Decoder as __Decoder, + Encoder as __Encoder, + Hash as __Hash, + HashConstructor as __HashConstructor, + HttpHandlerOptions as __HttpHandlerOptions, + Logger as __Logger, + Provider as __Provider, + StreamCollector as __StreamCollector, + UrlParser as __UrlParser, + UserAgent as __UserAgent, +} from "@aws-sdk/types"; + +export type ServiceInputTypes = EchoCommandInput | LengthCommandInput; + +export type ServiceOutputTypes = EchoCommandOutput | LengthCommandOutput; + +export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> { + /** + * The HTTP handler to use. Fetch in browser and Https in Nodejs. + */ + requestHandler?: __HttpHandler; + + /** + * A constructor for a class implementing the {@link __Hash} interface + * that computes the SHA-256 HMAC or checksum of a string or binary buffer. + * @internal + */ + sha256?: __HashConstructor; + + /** + * The function that will be used to convert strings into HTTP endpoints. + * @internal + */ + urlParser?: __UrlParser; + + /** + * A function that can calculate the length of a request body. + * @internal + */ + bodyLengthChecker?: (body: any) => number | undefined; + + /** + * A function that converts a stream into an array of bytes. + * @internal + */ + streamCollector?: __StreamCollector; + + /** + * The function that will be used to convert a base64-encoded string to a byte array. + * @internal + */ + base64Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a base64-encoded string. + * @internal + */ + base64Encoder?: __Encoder; + + /** + * The function that will be used to convert a UTF8-encoded string to a byte array. + * @internal + */ + utf8Decoder?: __Decoder; + + /** + * The function that will be used to convert binary data to a UTF-8 encoded string. + * @internal + */ + utf8Encoder?: __Encoder; + + /** + * The runtime environment. + * @internal + */ + runtime?: string; + + /** + * Disable dyanamically changing the endpoint of the client based on the hostPrefix + * trait of an operation. + */ + disableHostPrefix?: boolean; + + /** + * Value for how many times a request will be made at most in case of retry. + */ + maxAttempts?: number | __Provider; + + /** + * Specifies which retry algorithm to use. + */ + retryMode?: string | __Provider; + + /** + * Optional logger for logging debug/info/warn/error. + */ + logger?: __Logger; + + /** + * The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header + * @internal + */ + defaultUserAgentProvider?: Provider<__UserAgent>; +} + +type EchoServiceClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> & + ClientDefaults & + CustomEndpointsInputConfig & + RetryInputConfig & + HostHeaderInputConfig & + UserAgentInputConfig; +/** + * The configuration interface of EchoServiceClient class constructor that set the region, credentials and other options. + */ +export interface EchoServiceClientConfig extends EchoServiceClientConfigType {} + +type EchoServiceClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> & + Required & + CustomEndpointsResolvedConfig & + RetryResolvedConfig & + HostHeaderResolvedConfig & + UserAgentResolvedConfig; +/** + * The resolved configuration interface of EchoServiceClient class. This is resolved and normalized from the {@link EchoServiceClientConfig | constructor configuration interface}. + */ +export interface EchoServiceClientResolvedConfig extends EchoServiceClientResolvedConfigType {} + +export class EchoServiceClient extends __Client< + __HttpHandlerOptions, + ServiceInputTypes, + ServiceOutputTypes, + EchoServiceClientResolvedConfig +> { + /** + * The resolved configuration of EchoServiceClient class. This is resolved and normalized from the {@link EchoServiceClientConfig | constructor configuration interface}. + */ + readonly config: EchoServiceClientResolvedConfig; + + constructor(configuration: EchoServiceClientConfig) { + let _config_0 = __getRuntimeConfig(configuration); + let _config_1 = resolveCustomEndpointsConfig(_config_0); + let _config_2 = resolveRetryConfig(_config_1); + let _config_3 = resolveHostHeaderConfig(_config_2); + let _config_4 = resolveUserAgentConfig(_config_3); + super(_config_4); + this.config = _config_4; + this.middlewareStack.use(getRetryPlugin(this.config)); + this.middlewareStack.use(getContentLengthPlugin(this.config)); + this.middlewareStack.use(getHostHeaderPlugin(this.config)); + this.middlewareStack.use(getLoggerPlugin(this.config)); + this.middlewareStack.use(getUserAgentPlugin(this.config)); + } + + /** + * Destroy underlying resources, like sockets. It's usually not necessary to do this. + * However in Node.js, it's best to explicitly shut down the client's agent when it is no longer needed. + * Otherwise, sockets might stay open for quite a long time before the server terminates them. + */ + destroy(): void { + super.destroy(); + } +} diff --git a/private/aws-echo-service/src/commands/EchoCommand.ts b/private/aws-echo-service/src/commands/EchoCommand.ts new file mode 100644 index 000000000000..8752be33e3a2 --- /dev/null +++ b/private/aws-echo-service/src/commands/EchoCommand.ts @@ -0,0 +1,70 @@ +import { EchoServiceClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EchoServiceClient"; +import { EchoInput, EchoOutput } from "../models/models_0"; +import { deserializeAws_restJson1EchoCommand, serializeAws_restJson1EchoCommand } from "../protocols/Aws_restJson1"; +import { getSerdePlugin } from "@aws-sdk/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http"; +import { Command as $Command } from "@aws-sdk/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + MiddlewareStack, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + SerdeContext as __SerdeContext, +} from "@aws-sdk/types"; + +export interface EchoCommandInput extends EchoInput {} +export interface EchoCommandOutput extends EchoOutput, __MetadataBearer {} + +export class EchoCommand extends $Command { + // Start section: command_properties + // End section: command_properties + + constructor(readonly input: EchoCommandInput) { + // Start section: command_constructor + super(); + // End section: command_constructor + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: EchoServiceClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "EchoServiceClient"; + const commandName = "EchoCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: EchoInput.filterSensitiveLog, + outputFilterSensitiveLog: EchoOutput.filterSensitiveLog, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + private serialize(input: EchoCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return serializeAws_restJson1EchoCommand(input, context); + } + + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return deserializeAws_restJson1EchoCommand(output, context); + } + + // Start section: command_body_extra + // End section: command_body_extra +} diff --git a/private/aws-echo-service/src/commands/LengthCommand.ts b/private/aws-echo-service/src/commands/LengthCommand.ts new file mode 100644 index 000000000000..a673472770b9 --- /dev/null +++ b/private/aws-echo-service/src/commands/LengthCommand.ts @@ -0,0 +1,70 @@ +import { EchoServiceClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EchoServiceClient"; +import { LengthInput, LengthOutput } from "../models/models_0"; +import { deserializeAws_restJson1LengthCommand, serializeAws_restJson1LengthCommand } from "../protocols/Aws_restJson1"; +import { getSerdePlugin } from "@aws-sdk/middleware-serde"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http"; +import { Command as $Command } from "@aws-sdk/smithy-client"; +import { + FinalizeHandlerArguments, + Handler, + HandlerExecutionContext, + MiddlewareStack, + HttpHandlerOptions as __HttpHandlerOptions, + MetadataBearer as __MetadataBearer, + SerdeContext as __SerdeContext, +} from "@aws-sdk/types"; + +export interface LengthCommandInput extends LengthInput {} +export interface LengthCommandOutput extends LengthOutput, __MetadataBearer {} + +export class LengthCommand extends $Command { + // Start section: command_properties + // End section: command_properties + + constructor(readonly input: LengthCommandInput) { + // Start section: command_constructor + super(); + // End section: command_constructor + } + + /** + * @internal + */ + resolveMiddleware( + clientStack: MiddlewareStack, + configuration: EchoServiceClientResolvedConfig, + options?: __HttpHandlerOptions + ): Handler { + this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); + + const stack = clientStack.concat(this.middlewareStack); + + const { logger } = configuration; + const clientName = "EchoServiceClient"; + const commandName = "LengthCommand"; + const handlerExecutionContext: HandlerExecutionContext = { + logger, + clientName, + commandName, + inputFilterSensitiveLog: LengthInput.filterSensitiveLog, + outputFilterSensitiveLog: LengthOutput.filterSensitiveLog, + }; + const { requestHandler } = configuration; + return stack.resolve( + (request: FinalizeHandlerArguments) => + requestHandler.handle(request.request as __HttpRequest, options || {}), + handlerExecutionContext + ); + } + + private serialize(input: LengthCommandInput, context: __SerdeContext): Promise<__HttpRequest> { + return serializeAws_restJson1LengthCommand(input, context); + } + + private deserialize(output: __HttpResponse, context: __SerdeContext): Promise { + return deserializeAws_restJson1LengthCommand(output, context); + } + + // Start section: command_body_extra + // End section: command_body_extra +} diff --git a/private/aws-echo-service/src/commands/index.ts b/private/aws-echo-service/src/commands/index.ts new file mode 100644 index 000000000000..38c600c91649 --- /dev/null +++ b/private/aws-echo-service/src/commands/index.ts @@ -0,0 +1,2 @@ +export * from "./EchoCommand"; +export * from "./LengthCommand"; diff --git a/private/aws-echo-service/src/index.ts b/private/aws-echo-service/src/index.ts new file mode 100644 index 000000000000..2f1437b1cbb1 --- /dev/null +++ b/private/aws-echo-service/src/index.ts @@ -0,0 +1,4 @@ +export * from "./EchoServiceClient"; +export * from "./EchoService"; +export * from "./commands"; +export * from "./models"; diff --git a/private/aws-echo-service/src/models/index.ts b/private/aws-echo-service/src/models/index.ts new file mode 100644 index 000000000000..09c5d6e09b8c --- /dev/null +++ b/private/aws-echo-service/src/models/index.ts @@ -0,0 +1 @@ +export * from "./models_0"; diff --git a/private/aws-echo-service/src/models/models_0.ts b/private/aws-echo-service/src/models/models_0.ts new file mode 100644 index 000000000000..b33e05e91c25 --- /dev/null +++ b/private/aws-echo-service/src/models/models_0.ts @@ -0,0 +1,71 @@ +import { MetadataBearer as $MetadataBearer, SmithyException as __SmithyException } from "@aws-sdk/types"; + +export interface EchoInput { + string?: string; +} + +export namespace EchoInput { + /** + * @internal + */ + export const filterSensitiveLog = (obj: EchoInput): any => ({ + ...obj, + }); +} + +export interface EchoOutput { + string?: string; +} + +export namespace EchoOutput { + /** + * @internal + */ + export const filterSensitiveLog = (obj: EchoOutput): any => ({ + ...obj, + }); +} + +/** + * For some reason, this service does not like palindromes! + */ +export interface PalindromeException extends __SmithyException, $MetadataBearer { + name: "PalindromeException"; + $fault: "client"; + message?: string; +} + +export namespace PalindromeException { + /** + * @internal + */ + export const filterSensitiveLog = (obj: PalindromeException): any => ({ + ...obj, + }); +} + +export interface LengthInput { + string: string | undefined; +} + +export namespace LengthInput { + /** + * @internal + */ + export const filterSensitiveLog = (obj: LengthInput): any => ({ + ...obj, + }); +} + +export interface LengthOutput { + length?: number; +} + +export namespace LengthOutput { + /** + * @internal + */ + export const filterSensitiveLog = (obj: LengthOutput): any => ({ + ...obj, + }); +} diff --git a/private/aws-echo-service/src/protocols/Aws_restJson1.ts b/private/aws-echo-service/src/protocols/Aws_restJson1.ts new file mode 100644 index 000000000000..9e51c017d0ce --- /dev/null +++ b/private/aws-echo-service/src/protocols/Aws_restJson1.ts @@ -0,0 +1,265 @@ +import { EchoCommandInput, EchoCommandOutput } from "../commands/EchoCommand"; +import { LengthCommandInput, LengthCommandOutput } from "../commands/LengthCommand"; +import { PalindromeException } from "../models/models_0"; +import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http"; +import { + expectInt32 as __expectInt32, + expectNonNull as __expectNonNull, + expectObject as __expectObject, + expectString as __expectString, + extendedEncodeURIComponent as __extendedEncodeURIComponent, +} from "@aws-sdk/smithy-client"; +import { + Endpoint as __Endpoint, + MetadataBearer as __MetadataBearer, + ResponseMetadata as __ResponseMetadata, + SerdeContext as __SerdeContext, + SmithyException as __SmithyException, +} from "@aws-sdk/types"; +import { v4 as generateIdempotencyToken } from "uuid"; + +export const serializeAws_restJson1EchoCommand = async ( + input: EchoCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = { + "content-type": "application/json", + }; + let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/echo"; + let body: any; + body = JSON.stringify({ + ...(input.string !== undefined && input.string !== null && { string: input.string }), + }); + return new __HttpRequest({ + protocol, + hostname, + port, + method: "POST", + headers, + path: resolvedPath, + body, + }); +}; + +export const serializeAws_restJson1LengthCommand = async ( + input: LengthCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const { hostname, protocol = "https", port, path: basePath } = await context.endpoint(); + const headers: any = {}; + let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/length/{string}"; + if (input.string !== undefined) { + const labelValue: string = input.string; + if (labelValue.length <= 0) { + throw new Error("Empty value provided for input HTTP label: string."); + } + resolvedPath = resolvedPath.replace("{string}", __extendedEncodeURIComponent(labelValue)); + } else { + throw new Error("No value provided for input HTTP label: string."); + } + let body: any; + return new __HttpRequest({ + protocol, + hostname, + port, + method: "GET", + headers, + path: resolvedPath, + body, + }); +}; + +export const deserializeAws_restJson1EchoCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return deserializeAws_restJson1EchoCommandError(output, context); + } + const contents: EchoCommandOutput = { + $metadata: deserializeMetadata(output), + string: undefined, + }; + const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + if (data.string !== undefined && data.string !== null) { + contents.string = __expectString(data.string); + } + return Promise.resolve(contents); +}; + +const deserializeAws_restJson1EchoCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + let response: __SmithyException & __MetadataBearer & { [key: string]: any }; + let errorCode: string = "UnknownError"; + errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "PalindromeException": + case "aws.test.generic#PalindromeException": + response = { + ...(await deserializeAws_restJson1PalindromeExceptionResponse(parsedOutput, context)), + name: errorCode, + $metadata: deserializeMetadata(output), + }; + break; + default: + const parsedBody = parsedOutput.body; + errorCode = parsedBody.code || parsedBody.Code || errorCode; + response = { + ...parsedBody, + name: `${errorCode}`, + message: parsedBody.message || parsedBody.Message || errorCode, + $fault: "client", + $metadata: deserializeMetadata(output), + } as any; + } + const message = response.message || response.Message || errorCode; + response.message = message; + delete response.Message; + return Promise.reject(Object.assign(new Error(message), response)); +}; + +export const deserializeAws_restJson1LengthCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode !== 200 && output.statusCode >= 300) { + return deserializeAws_restJson1LengthCommandError(output, context); + } + const contents: LengthCommandOutput = { + $metadata: deserializeMetadata(output), + length: undefined, + }; + const data: { [key: string]: any } = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body"); + if (data.length !== undefined && data.length !== null) { + contents.length = __expectInt32(data.length); + } + return Promise.resolve(contents); +}; + +const deserializeAws_restJson1LengthCommandError = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + const parsedOutput: any = { + ...output, + body: await parseBody(output.body, context), + }; + let response: __SmithyException & __MetadataBearer & { [key: string]: any }; + let errorCode: string = "UnknownError"; + errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + switch (errorCode) { + case "PalindromeException": + case "aws.test.generic#PalindromeException": + response = { + ...(await deserializeAws_restJson1PalindromeExceptionResponse(parsedOutput, context)), + name: errorCode, + $metadata: deserializeMetadata(output), + }; + break; + default: + const parsedBody = parsedOutput.body; + errorCode = parsedBody.code || parsedBody.Code || errorCode; + response = { + ...parsedBody, + name: `${errorCode}`, + message: parsedBody.message || parsedBody.Message || errorCode, + $fault: "client", + $metadata: deserializeMetadata(output), + } as any; + } + const message = response.message || response.Message || errorCode; + response.message = message; + delete response.Message; + return Promise.reject(Object.assign(new Error(message), response)); +}; + +const deserializeAws_restJson1PalindromeExceptionResponse = async ( + parsedOutput: any, + context: __SerdeContext +): Promise => { + const contents: PalindromeException = { + name: "PalindromeException", + $fault: "client", + $metadata: deserializeMetadata(parsedOutput), + message: undefined, + }; + const data: any = parsedOutput.body; + if (data.message !== undefined && data.message !== null) { + contents.message = __expectString(data.message); + } + return contents; +}; + +const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({ + httpStatusCode: output.statusCode, + requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"], + extendedRequestId: output.headers["x-amz-id-2"], + cfId: output.headers["x-amz-cf-id"], +}); + +// Collect low-level response body stream to Uint8Array. +const collectBody = (streamBody: any = new Uint8Array(), context: __SerdeContext): Promise => { + if (streamBody instanceof Uint8Array) { + return Promise.resolve(streamBody); + } + return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array()); +}; + +// Encode Uint8Array data into string with utf-8. +const collectBodyString = (streamBody: any, context: __SerdeContext): Promise => + collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); + +const isSerializableHeaderValue = (value: any): boolean => + value !== undefined && + value !== null && + value !== "" && + (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) && + (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0); + +const parseBody = (streamBody: any, context: __SerdeContext): any => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + return JSON.parse(encoded); + } + return {}; + }); + +/** + * Load an error code for the aws.rest-json-1.1 protocol. + */ +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { + const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); + + const sanitizeErrorCode = (rawValue: string): string => { + let cleanValue = rawValue; + if (cleanValue.indexOf(":") >= 0) { + cleanValue = cleanValue.split(":")[0]; + } + if (cleanValue.indexOf("#") >= 0) { + cleanValue = cleanValue.split("#")[1]; + } + return cleanValue; + }; + + const headerKey = findKey(output.headers, "x-amzn-errortype"); + if (headerKey !== undefined) { + return sanitizeErrorCode(output.headers[headerKey]); + } + + if (data.code !== undefined) { + return sanitizeErrorCode(data.code); + } + + if (data["__type"] !== undefined) { + return sanitizeErrorCode(data["__type"]); + } + + return ""; +}; diff --git a/private/aws-echo-service/src/runtimeConfig.browser.ts b/private/aws-echo-service/src/runtimeConfig.browser.ts new file mode 100644 index 000000000000..3ae8628dd97b --- /dev/null +++ b/private/aws-echo-service/src/runtimeConfig.browser.ts @@ -0,0 +1,36 @@ +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { Sha256 } from "@aws-crypto/sha256-browser"; +import { FetchHttpHandler, streamCollector } from "@aws-sdk/fetch-http-handler"; +import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@aws-sdk/middleware-retry"; +import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser"; +import { calculateBodyLength } from "@aws-sdk/util-body-length-browser"; +import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser"; +import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser"; +import { EchoServiceClientConfig } from "./EchoServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: EchoServiceClientConfig) => { + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "browser", + base64Decoder: config?.base64Decoder ?? fromBase64, + base64Encoder: config?.base64Encoder ?? toBase64, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? defaultUserAgent({ clientVersion: packageInfo.version }), + maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS, + requestHandler: config?.requestHandler ?? new FetchHttpHandler(), + retryMode: config?.retryMode ?? (() => Promise.resolve(DEFAULT_RETRY_MODE)), + sha256: config?.sha256 ?? Sha256, + streamCollector: config?.streamCollector ?? streamCollector, + utf8Decoder: config?.utf8Decoder ?? fromUtf8, + utf8Encoder: config?.utf8Encoder ?? toUtf8, + }; +}; diff --git a/private/aws-echo-service/src/runtimeConfig.native.ts b/private/aws-echo-service/src/runtimeConfig.native.ts new file mode 100644 index 000000000000..73ebbdf4be1a --- /dev/null +++ b/private/aws-echo-service/src/runtimeConfig.native.ts @@ -0,0 +1,16 @@ +import { Sha256 } from "@aws-crypto/sha256-js"; +import { EchoServiceClientConfig } from "./EchoServiceClient"; +import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: EchoServiceClientConfig) => { + const browserDefaults = getBrowserRuntimeConfig(config); + return { + ...browserDefaults, + ...config, + runtime: "react-native", + sha256: config?.sha256 ?? Sha256, + }; +}; diff --git a/private/aws-echo-service/src/runtimeConfig.shared.ts b/private/aws-echo-service/src/runtimeConfig.shared.ts new file mode 100644 index 000000000000..b692db5fdf72 --- /dev/null +++ b/private/aws-echo-service/src/runtimeConfig.shared.ts @@ -0,0 +1,13 @@ +import { Logger as __Logger } from "@aws-sdk/types"; +import { parseUrl } from "@aws-sdk/url-parser"; +import { EchoServiceClientConfig } from "./EchoServiceClient"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: EchoServiceClientConfig) => ({ + apiVersion: "2018-05-10", + disableHostPrefix: config?.disableHostPrefix ?? false, + logger: config?.logger ?? ({} as __Logger), + urlParser: config?.urlParser ?? parseUrl, +}); diff --git a/private/aws-echo-service/src/runtimeConfig.ts b/private/aws-echo-service/src/runtimeConfig.ts new file mode 100644 index 000000000000..6de63577e8b3 --- /dev/null +++ b/private/aws-echo-service/src/runtimeConfig.ts @@ -0,0 +1,39 @@ +// @ts-ignore: package.json will be imported from dist folders +import packageInfo from "../package.json"; // eslint-disable-line + +import { Hash } from "@aws-sdk/hash-node"; +import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@aws-sdk/middleware-retry"; +import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider"; +import { NodeHttpHandler, streamCollector } from "@aws-sdk/node-http-handler"; +import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node"; +import { calculateBodyLength } from "@aws-sdk/util-body-length-node"; +import { defaultUserAgent } from "@aws-sdk/util-user-agent-node"; +import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node"; +import { EchoServiceClientConfig } from "./EchoServiceClient"; +import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared"; +import { emitWarningIfUnsupportedVersion } from "@aws-sdk/smithy-client"; + +/** + * @internal + */ +export const getRuntimeConfig = (config: EchoServiceClientConfig) => { + emitWarningIfUnsupportedVersion(process.version); + const clientSharedValues = getSharedRuntimeConfig(config); + return { + ...clientSharedValues, + ...config, + runtime: "node", + base64Decoder: config?.base64Decoder ?? fromBase64, + base64Encoder: config?.base64Encoder ?? toBase64, + bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength, + defaultUserAgentProvider: + config?.defaultUserAgentProvider ?? defaultUserAgent({ clientVersion: packageInfo.version }), + maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS), + requestHandler: config?.requestHandler ?? new NodeHttpHandler(), + retryMode: config?.retryMode ?? loadNodeConfig(NODE_RETRY_MODE_CONFIG_OPTIONS), + sha256: config?.sha256 ?? Hash.bind(null, "sha256"), + streamCollector: config?.streamCollector ?? streamCollector, + utf8Decoder: config?.utf8Decoder ?? fromUtf8, + utf8Encoder: config?.utf8Encoder ?? toUtf8, + }; +}; diff --git a/private/aws-echo-service/tsconfig.es.json b/private/aws-echo-service/tsconfig.es.json new file mode 100644 index 000000000000..4c72364cd1a0 --- /dev/null +++ b/private/aws-echo-service/tsconfig.es.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "target": "es5", + "module": "esnext", + "moduleResolution": "node", + "lib": ["dom", "es5", "es2015.promise", "es2015.collection", "es2015.iterable", "es2015.symbol.wellknown"], + "outDir": "dist-es" + } +} diff --git a/private/aws-echo-service/tsconfig.json b/private/aws-echo-service/tsconfig.json new file mode 100644 index 000000000000..093039289c53 --- /dev/null +++ b/private/aws-echo-service/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "rootDir": "./src", + "alwaysStrict": true, + "target": "ES2018", + "module": "commonjs", + "strict": true, + "downlevelIteration": true, + "importHelpers": true, + "noEmitHelpers": true, + "incremental": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "outDir": "dist-cjs", + "removeComments": true + }, + "typedocOptions": { + "exclude": ["**/node_modules/**", "**/*.spec.ts", "**/protocols/*.ts", "**/e2e/*.ts", "**/endpoints.ts"], + "excludeNotExported": true, + "excludePrivate": true, + "hideGenerator": true, + "ignoreCompilerErrors": true, + "includeDeclarations": true, + "stripInternal": true, + "readme": "README.md", + "mode": "file", + "out": "docs", + "theme": "minimal", + "plugin": ["@aws-sdk/service-client-documentation-generator"] + }, + "exclude": ["test/**/*"] +} diff --git a/private/aws-echo-service/tsconfig.types.json b/private/aws-echo-service/tsconfig.types.json new file mode 100644 index 000000000000..4c3dfa7b3d25 --- /dev/null +++ b/private/aws-echo-service/tsconfig.types.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "removeComments": false, + "declaration": true, + "declarationDir": "dist-types", + "emitDeclarationOnly": true + }, + "exclude": ["test/**/*", "dist-types/**/*"] +} diff --git a/private/aws-protocoltests-ec2/.gitignore b/private/aws-protocoltests-ec2/.gitignore index bff6121c007d..54f14c9aef25 100644 --- a/private/aws-protocoltests-ec2/.gitignore +++ b/private/aws-protocoltests-ec2/.gitignore @@ -6,4 +6,4 @@ *.tsbuildinfo *.tgz *.log -package-lock.json \ No newline at end of file +package-lock.json diff --git a/scripts/generate-clients/code-gen-dir.js b/scripts/generate-clients/code-gen-dir.js index a328afd233a7..b4603978249f 100644 --- a/scripts/generate-clients/code-gen-dir.js +++ b/scripts/generate-clients/code-gen-dir.js @@ -12,6 +12,7 @@ const TEMP_CODE_GEN_INPUT_DIR = normalize(join(__dirname, ".aws-models")); const getCodeGenOutputDir = (dir) => normalize(join(__dirname, "..", "..", "codegen", dir, "build", "smithyprojections", dir)); const CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR = getCodeGenOutputDir("protocol-test-codegen"); +const CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR = getCodeGenOutputDir("generic-client-test-codegen"); const CODE_GEN_SDK_OUTPUT_DIR = getCodeGenOutputDir("sdk-codegen"); module.exports = { @@ -20,5 +21,6 @@ module.exports = { CODE_GEN_PROTOCOL_TESTS_ROOT, CODE_GEN_SDK_OUTPUT_DIR, CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, + CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR, TEMP_CODE_GEN_INPUT_DIR, }; diff --git a/scripts/generate-clients/code-gen.js b/scripts/generate-clients/code-gen.js index 2c8f09c01f65..1d7609061732 100644 --- a/scripts/generate-clients/code-gen.js +++ b/scripts/generate-clients/code-gen.js @@ -54,7 +54,14 @@ const generateProtocolTests = async () => { }); }; +const generateGenericClient = async () => { + await spawnProcess("./gradlew", [":smithy-aws-typescript-codegen:clean", ":generic-client-test-codegen:build"], { + cwd: CODE_GEN_ROOT, + }); +}; + module.exports = { generateClients, + generateGenericClient, generateProtocolTests, }; diff --git a/scripts/generate-clients/index.js b/scripts/generate-clients/index.js index 1d9086d65c29..6193548cae4b 100644 --- a/scripts/generate-clients/index.js +++ b/scripts/generate-clients/index.js @@ -2,10 +2,11 @@ const yargs = require("yargs"); const path = require("path"); const { emptyDirSync, rmdirSync } = require("fs-extra"); -const { generateClients, generateProtocolTests } = require("./code-gen"); +const { generateClients, generateGenericClient, generateProtocolTests } = require("./code-gen"); const { copyToClients, copyServerTests } = require("./copy-to-clients"); const { CODE_GEN_SDK_OUTPUT_DIR, + CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR, CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, TEMP_CODE_GEN_INPUT_DIR, } = require("./code-gen-dir"); @@ -13,13 +14,13 @@ const { prettifyCode } = require("./code-prettify"); const { eslintFixCode } = require("./code-eslint-fix"); const SDK_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "clients")); -const PROTOCOL_TESTS_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "private")); +const PRIVATE_CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "private")); const { models, globs, output: clientsDir, - noProtocolTest, + noPrivateClients, s: serverOnly, } = yargs .alias("m", "models") @@ -33,9 +34,9 @@ const { .string("o") .describe("o", "The output directory for built clients") .default("o", SDK_CLIENTS_DIR) - .alias("n", "noProtocolTest") + .alias("n", "noPrivateClients") .boolean("n") - .describe("n", "Disable generating protocol test files") + .describe("n", "Disable generating private clients") .alias("s", "server-artifacts") .boolean("s") .describe("s", "Generate server artifacts instead of client ones") @@ -48,7 +49,7 @@ const { await generateProtocolTests(); await eslintFixCode(); await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); - await copyServerTests(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PROTOCOL_TESTS_CLIENTS_DIR); + await copyServerTests(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PRIVATE_CLIENTS_DIR); emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); emptyDirSync(TEMP_CODE_GEN_INPUT_DIR); @@ -58,17 +59,29 @@ const { } await generateClients(models || globs); - if (!noProtocolTest) await generateProtocolTests(); + if (!noPrivateClients) { + await generateGenericClient(); + await generateProtocolTests(); + } await eslintFixCode(); await prettifyCode(CODE_GEN_SDK_OUTPUT_DIR); - if (!noProtocolTest) await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); + if (!noPrivateClients) { + await prettifyCode(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR); + await prettifyCode(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); + } await copyToClients(CODE_GEN_SDK_OUTPUT_DIR, clientsDir); - if (!noProtocolTest) await copyToClients(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PROTOCOL_TESTS_CLIENTS_DIR); + if (!noPrivateClients) { + await copyToClients(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR, PRIVATE_CLIENTS_DIR); + await copyToClients(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR, PRIVATE_CLIENTS_DIR); + } emptyDirSync(CODE_GEN_SDK_OUTPUT_DIR); - if (!noProtocolTest) emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); + if (!noPrivateClients) { + emptyDirSync(CODE_GEN_GENERIC_CLIENT_OUTPUT_DIR); + emptyDirSync(CODE_GEN_PROTOCOL_TESTS_OUTPUT_DIR); + } emptyDirSync(TEMP_CODE_GEN_INPUT_DIR); rmdirSync(TEMP_CODE_GEN_INPUT_DIR);