From b0756b9a752bb3a85413b6e3c7caded48cbf4fe9 Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 7 Dec 2023 16:09:47 -0500 Subject: [PATCH] fix(client-workspaces-thin-client): add compatibility alias (#5555) --- .../src/index.ts | 14 ++++++++ codegen/config/checkstyle/checkstyle.xml | 2 +- .../customizations/workspaces-thin-client.js | 33 +++++++++++++++++++ scripts/generate-clients/index.js | 2 ++ scripts/generate-clients/single-service.js | 4 +++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 scripts/generate-clients/customizations/workspaces-thin-client.js diff --git a/clients/client-workspaces-thin-client/src/index.ts b/clients/client-workspaces-thin-client/src/index.ts index 77296746ae596..8576e31677c5c 100644 --- a/clients/client-workspaces-thin-client/src/index.ts +++ b/clients/client-workspaces-thin-client/src/index.ts @@ -28,3 +28,17 @@ export * from "./models"; import "@aws-sdk/util-endpoints"; export { WorkSpacesThinClientServiceException } from "./models/WorkSpacesThinClientServiceException"; + +import { WorkSpacesThinClient } from "./WorkSpacesThinClient"; + +/** + * @deprecated use {WorkSpacesThinClient} (renamed) instead. + * The aggregated client is called WorkSpacesThinClient, + * and the barebones client is called WorkSpacesThinClientClient. + * + * Due to some code generation issues with the word "Client" in the service name, + * we are maintaining a few backwards compatible aliases here. + */ +export const WorkSpacesThin = WorkSpacesThinClient; + +export type { WorkSpacesThinClientPaginationConfiguration as WorkSpacesThinPaginationConfiguration } from "./pagination/Interfaces"; diff --git a/codegen/config/checkstyle/checkstyle.xml b/codegen/config/checkstyle/checkstyle.xml index 33f580b16b442..b78fff817b838 100644 --- a/codegen/config/checkstyle/checkstyle.xml +++ b/codegen/config/checkstyle/checkstyle.xml @@ -22,7 +22,7 @@ + value="/\*\n \* Copyright( 20(19|20|21|22|23)|) Amazon\.com, Inc\. or its affiliates\. All Rights Reserved\.\n"/> diff --git a/scripts/generate-clients/customizations/workspaces-thin-client.js b/scripts/generate-clients/customizations/workspaces-thin-client.js new file mode 100644 index 0000000000000..940edaecf658a --- /dev/null +++ b/scripts/generate-clients/customizations/workspaces-thin-client.js @@ -0,0 +1,33 @@ +const fs = require("fs"); +const path = require("path"); + +const root = path.join(__dirname, "..", "..", ".."); + +const indexTs = path.join(root, "clients", "client-workspaces-thin-client", "src", "index.ts"); + +/** + * Exports aliases from the index of WorkSpacesThinClient. + */ +module.exports = function () { + const indexContents = fs.readFileSync(indexTs, "utf-8"); + if (!indexContents.includes(`backwards compatible aliases`)) + fs.writeFileSync( + indexTs, + indexContents + + ` +import { WorkSpacesThinClient } from "./WorkSpacesThinClient"; + +/** + * @deprecated use {WorkSpacesThinClient} (renamed) instead. + * The aggregated client is called WorkSpacesThinClient, + * and the barebones client is called WorkSpacesThinClientClient. + * + * Due to some code generation issues with the word "Client" in the service name, + * we are maintaining a few backwards compatible aliases here. + */ +export const WorkSpacesThin = WorkSpacesThinClient; + +export type { WorkSpacesThinClientPaginationConfiguration as WorkSpacesThinPaginationConfiguration } from "./pagination/Interfaces"; +` + ); +}; diff --git a/scripts/generate-clients/index.js b/scripts/generate-clients/index.js index 1d74d77d8a2fd..599aeef6d97f8 100644 --- a/scripts/generate-clients/index.js +++ b/scripts/generate-clients/index.js @@ -132,6 +132,8 @@ const { emptyDirSync(TEMP_CODE_GEN_INPUT_DIR); rmdirSync(TEMP_CODE_GEN_INPUT_DIR); } + + require("./customizations/workspaces-thin-client")(); } catch (e) { console.log(e); process.exit(1); diff --git a/scripts/generate-clients/single-service.js b/scripts/generate-clients/single-service.js index 0c81236e52efe..cedfa1f8fb4ca 100644 --- a/scripts/generate-clients/single-service.js +++ b/scripts/generate-clients/single-service.js @@ -30,6 +30,10 @@ const { solo } = yargs(process.argv.slice(2)) ); await codeOrdering(join(SDK_CLIENTS_DIR, `client-${solo}`)); + if (solo === "workspaces-thin-client") { + require("./customizations/workspaces-thin-client")(); + } + // post-generation transforms const clientFolder = join(SDK_CLIENTS_DIR, `client-${solo}`); const libFolder = join(SDK_CLIENTS_DIR, "..", "lib", `lib-${solo}`);