Skip to content

Commit 064528e

Browse files
authored
Remove Client from getV3ClientDefaultLocalName (#398)
1 parent 15b19a4 commit 064528e

11 files changed

+20
-25
lines changed

scripts/generateNewClientTests/getGlobalImportEqualsOutput.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CLIENT_NAMES_MAP, CLIENT_PACKAGE_NAMES_MAP } from "../../src/transforms/v2-to-v3/config";
2-
import { getV3ClientDefaultLocalName } from "../../src/transforms/v2-to-v3/utils";
2+
import { getV3DefaultLocalName } from "../../src/transforms/v2-to-v3/utils";
33
import { CLIENTS_TO_TEST } from "./config";
44
import { getClientNamesSortedByPackageName } from "./getClientNamesSortedByPackageName";
55
import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
@@ -10,17 +10,15 @@ export const getGlobalImportEqualsOutput = (codegenComment: string) => {
1010
const sortedClientNames = getClientNamesSortedByPackageName(CLIENTS_TO_TEST);
1111

1212
for (const v2ClientName of sortedClientNames) {
13-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientName);
13+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientName);
1414
const v3ClientPackageName = `@aws-sdk/${CLIENT_PACKAGE_NAMES_MAP[v2ClientName]}`;
1515
globalImportEqualsOutputContent += `import ${v3ClientDefaultLocalName} = require("${v3ClientPackageName}");\n\n`;
1616

1717
const v3ClientName = CLIENT_NAMES_MAP[v2ClientName];
1818
const v3ObjectPattern =
1919
v3ClientName === v2ClientName ? v3ClientName : `${v3ClientName}: ${v2ClientName}`;
2020
globalImportEqualsOutputContent +=
21-
`const {\n` +
22-
` ${v3ObjectPattern}\n` +
23-
`} = ${getV3ClientDefaultLocalName(v2ClientName)};\n\n`;
21+
`const {\n` + ` ${v3ObjectPattern}\n` + `} = ${getV3DefaultLocalName(v2ClientName)};\n\n`;
2422
}
2523

2624
globalImportEqualsOutputContent += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST);

scripts/generateNewClientTests/getServiceImportEqualsOutput.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { CLIENT_NAMES_MAP, CLIENT_PACKAGE_NAMES_MAP } from "../../src/transforms/v2-to-v3/config";
2-
import { getV3ClientDefaultLocalName } from "../../src/transforms/v2-to-v3/utils";
2+
import { getV3DefaultLocalName } from "../../src/transforms/v2-to-v3/utils";
33
import { CLIENTS_TO_TEST } from "./config";
44
import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
55

66
export const getServiceImportEqualsOutput = (codegenComment: string) => {
77
let serviceImportEqualsOutputContent = `${codegenComment};\n`;
88

99
for (const v2ClientName of CLIENTS_TO_TEST) {
10-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientName);
10+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientName);
1111
const v3ClientPackageName = `@aws-sdk/${CLIENT_PACKAGE_NAMES_MAP[v2ClientName]}`;
1212
serviceImportEqualsOutputContent += `import ${v3ClientDefaultLocalName} = require("${v3ClientPackageName}");\n\n`;
1313

1414
const v3ClientName = CLIENT_NAMES_MAP[v2ClientName];
1515
const v3ObjectPattern =
1616
v3ClientName === v2ClientName ? v3ClientName : `${v3ClientName}: ${v2ClientName}`;
1717
serviceImportEqualsOutputContent +=
18-
`const {\n` +
19-
` ${v3ObjectPattern}\n` +
20-
`} = ${getV3ClientDefaultLocalName(v2ClientName)};\n\n`;
18+
`const {\n` + ` ${v3ObjectPattern}\n` + `} = ${getV3DefaultLocalName(v2ClientName)};\n\n`;
2119
}
2220

2321
serviceImportEqualsOutputContent += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST);

src/transforms/v2-to-v3/modules/addV3ClientDefaultImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, ImportDefaultSpecifier, JSCodeshift } from "jscodeshift";
22

3-
import { getV3ClientDefaultLocalName } from "../utils";
3+
import { getV3DefaultLocalName } from "../utils";
44
import { getImportSpecifiers } from "./getImportSpecifiers";
55
import { getV2ImportDeclaration } from "./getV2ImportDeclaration";
66
import { V3ClientModulesOptions } from "./types";
@@ -10,7 +10,7 @@ export const addV3ClientDefaultImport = (
1010
source: Collection<unknown>,
1111
{ v2ClientLocalName, v2ClientName, v3ClientPackageName }: V3ClientModulesOptions
1212
) => {
13-
const localName = getV3ClientDefaultLocalName(v2ClientLocalName);
13+
const localName = getV3DefaultLocalName(v2ClientLocalName);
1414
const defaultImportSpecifier = j.importDefaultSpecifier(j.identifier(localName));
1515

1616
const importDeclarations = source.find(j.ImportDeclaration, {

src/transforms/v2-to-v3/modules/addV3ClientDefaultImportEquals.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV3ClientDefaultLocalName } from "../utils";
3+
import { getV3DefaultLocalName } from "../utils";
44
import { getImportEqualsDeclaration } from "./getImportEqualsDeclaration";
55
import { getV2ImportEqualsDeclaration } from "./getV2ImportEqualsDeclaration";
66
import { V3ClientModulesOptions } from "./types";
@@ -10,7 +10,7 @@ export const addV3ClientDefaultImportEquals = (
1010
source: Collection<unknown>,
1111
{ v2ClientLocalName, v2ClientName, v2GlobalName, v3ClientPackageName }: V3ClientModulesOptions
1212
) => {
13-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientLocalName);
13+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientLocalName);
1414
const existingImportEquals = source.find(
1515
j.TSImportEqualsDeclaration,
1616
getImportEqualsDeclaration(v3ClientPackageName)

src/transforms/v2-to-v3/modules/addV3ClientDefaultRequire.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV3ClientDefaultLocalName } from "../utils";
3+
import { getV3DefaultLocalName } from "../utils";
44
import { getRequireDeclarators } from "./getRequireDeclarators";
55
import { getV2RequireDeclarator } from "./getV2RequireDeclarator";
66
import { V3ClientModulesOptions } from "./types";
@@ -10,7 +10,7 @@ export const addV3ClientDefaultRequire = (
1010
source: Collection<unknown>,
1111
{ v2ClientName, v2ClientLocalName, v3ClientPackageName, v2GlobalName }: V3ClientModulesOptions
1212
) => {
13-
const identifierName = getV3ClientDefaultLocalName(v2ClientLocalName);
13+
const identifierName = getV3DefaultLocalName(v2ClientLocalName);
1414
const existingRequires = getRequireDeclarators(j, source, v3ClientPackageName);
1515

1616
if (

src/transforms/v2-to-v3/modules/addV3ClientNamedImportEquals.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3-
import { getV3ClientDefaultLocalName } from "../utils";
3+
import { getV3DefaultLocalName } from "../utils";
44
import { addV3ClientDefaultImportEquals } from "./addV3ClientDefaultImportEquals";
55
import { getImportEqualsDeclaration } from "./getImportEqualsDeclaration";
66
import { getV3ClientRequireProperty } from "./getV3ClientRequireProperty";
@@ -15,7 +15,7 @@ export const addV3ClientNamedImportEquals = (
1515
const { keyName, valueName, ...v3ClientModulesOptions } = options;
1616
const { v2ClientLocalName, v3ClientPackageName } = v3ClientModulesOptions;
1717

18-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientLocalName);
18+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientLocalName);
1919
const namedImportObjectProperty = getV3ClientRequireProperty(j, { keyName, valueName });
2020

2121
const existingVarDeclarator = source.find(j.VariableDeclarator, {

src/transforms/v2-to-v3/modules/addV3ClientNamedRequire.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collection, JSCodeshift, ObjectPattern, ObjectProperty, Property } from "jscodeshift";
22

33
import { OBJECT_PROPERTY_TYPE_LIST } from "../config";
4-
import { getV3ClientDefaultLocalName } from "../utils";
4+
import { getV3DefaultLocalName } from "../utils";
55
import { getRequireDeclarators } from "./getRequireDeclarators";
66
import { getRequireDeclaratorsWithIdentifier } from "./getRequireDeclaratorsWithIdentifier";
77
import { getV2RequireDeclarator } from "./getV2RequireDeclarator";
@@ -17,7 +17,7 @@ export const addV3ClientNamedRequire = (
1717
const { keyName, v2ClientName, v2ClientLocalName, v2GlobalName, v3ClientPackageName } = options;
1818
const valueName = options.valueName ?? keyName;
1919

20-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientLocalName);
20+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientLocalName);
2121
const v3ClientObjectProperty = getV3ClientRequireProperty(j, { keyName, valueName });
2222
const existingRequires = getRequireDeclarators(j, source, v3ClientPackageName);
2323

src/transforms/v2-to-v3/ts-type/getV3ClientTypeReference.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
V2_CLIENT_INPUT_SUFFIX_LIST,
66
V2_CLIENT_OUTPUT_SUFFIX_LIST,
77
} from "../config";
8-
import { getV3ClientDefaultLocalName } from "../utils";
8+
import { getV3DefaultLocalName } from "../utils";
99
import { getTypeRefForString } from "./getTypeRefForString";
1010

1111
export interface GetV3ClientTypeReferenceOptions {
@@ -25,7 +25,7 @@ export const getV3ClientTypeReference = (
2525
{ v2ClientLocalName, v2ClientName, v2ClientTypeName }: GetV3ClientTypeReferenceOptions
2626
): TSType => {
2727
const clientTypesMap = CLIENT_TYPES_MAP[v2ClientName];
28-
const v3ClientDefaultLocalName = getV3ClientDefaultLocalName(v2ClientLocalName);
28+
const v3ClientDefaultLocalName = getV3DefaultLocalName(v2ClientLocalName);
2929

3030
if (Object.keys(clientTypesMap).includes(v2ClientTypeName)) {
3131
return getTypeRefForString(j, v3ClientDefaultLocalName, clientTypesMap[v2ClientTypeName]);

src/transforms/v2-to-v3/utils/getV3ClientDefaultLocalName.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getV3DefaultLocalName = (localNameSuffix: string) => `AWS_${localNameSuffix}`;

0 commit comments

Comments
 (0)