Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hot-dancers-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Transform types imported without clients
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import AWS = require("aws-sdk");

const ddbClient = new AWS.DynamoDB();
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = {};

const stsClient = new AWS.STS();
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = {};

const lambdaClient = new AWS.Lambda();
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
.promise();
const invokeOutput: AWS.Lambda.InvocationResponse = {};
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import AWS_client_dynamodb = require("@aws-sdk/client-dynamodb");
import DynamoDB = AWS_client_dynamodb.DynamoDB;
import ListTablesCommandOutput = AWS_client_dynamodb.ListTablesCommandOutput;
import ListTablesCommandInput = AWS_client_dynamodb.ListTablesCommandInput;
import AWS_client_lambda = require("@aws-sdk/client-lambda");
import Lambda = AWS_client_lambda.Lambda;
import InvokeCommandOutput = AWS_client_lambda.InvokeCommandOutput;
import InvokeCommandInput = AWS_client_lambda.InvokeCommandInput;
import AWS_client_sts = require("@aws-sdk/client-sts");
import STS = AWS_client_sts.STS;
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};

const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
const invokeOutput: InvokeCommandOutput = {};
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import AWS from "aws-sdk";

const ddbClient = new AWS.DynamoDB();
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = {};

const stsClient = new AWS.STS();
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = {};

const lambdaClient = new AWS.Lambda();
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
.promise();
const invokeOutput: AWS.Lambda.InvocationResponse = {};
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
import { ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};

const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
const invokeOutput: InvokeCommandOutput = {};
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
import Lambda, { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
import { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
import { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
import { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesInput = { Limit: 10 };
const listTablesOutput: ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();
const listTablesOutput: ListTablesOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityRequest = {};
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
const getCallerIdentityOutput: GetCallerIdentityResponse = {};

const lambdaClient = new Lambda();
const invokeInput: InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: InvocationResponse = await lambdaClient
.invoke(invokeInput)
.promise();
const invokeOutput: InvocationResponse = {};
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
import { ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};

const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
const invokeOutput: InvokeCommandOutput = {};
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@ import DynamoDB = require("aws-sdk/clients/dynamodb");
import Lambda = require("aws-sdk/clients/lambda");
import STS = require("aws-sdk/clients/sts");

const ddbClient = new DynamoDB();
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();
const listTablesOutput: DynamoDB.ListTablesOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = {};

const lambdaClient = new Lambda();
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
.promise();
const invokeOutput: Lambda.InvocationResponse = {};
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import AWS_client_dynamodb = require("@aws-sdk/client-dynamodb");
import DynamoDB = AWS_client_dynamodb.DynamoDB;
import ListTablesCommandOutput = AWS_client_dynamodb.ListTablesCommandOutput;
import ListTablesCommandInput = AWS_client_dynamodb.ListTablesCommandInput;
import AWS_client_lambda = require("@aws-sdk/client-lambda");
import Lambda = AWS_client_lambda.Lambda;
import InvokeCommandOutput = AWS_client_lambda.InvokeCommandOutput;
import InvokeCommandInput = AWS_client_lambda.InvokeCommandInput;
import AWS_client_sts = require("@aws-sdk/client-sts");
import STS = AWS_client_sts.STS;
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};

const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
const invokeOutput: InvokeCommandOutput = {};
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { DynamoDB, Lambda, STS } from "aws-sdk";

const ddbClient = new DynamoDB();
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();
const listTablesOutput: DynamoDB.ListTablesOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = {};

const lambdaClient = new Lambda();
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
.invoke(invokeInput)
.promise();
const invokeOutput: Lambda.InvocationResponse = {};

Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
import { ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { InvokeCommandInput, InvokeCommandOutput } from "@aws-sdk/client-lambda";
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const ddbClient = new DynamoDB();
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = {};

const stsClient = new STS();
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};

const lambdaClient = new Lambda();
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
const invokeOutput: InvokeCommandOutput = await lambdaClient
.invoke(invokeInput);
const invokeOutput: InvokeCommandOutput = {};

This file was deleted.

This file was deleted.

18 changes: 15 additions & 3 deletions src/transforms/v2-to-v3/client-names/getClientNamesRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ export const getClientNamesRecord = (
importType: ImportType
) => {
const clientNamesFromDeepImport = getClientNamesFromDeepImport(source.toSource());
return importType === ImportType.REQUIRE
? getClientNamesRecordFromRequire(j, source, clientNamesFromDeepImport)
: getClientNamesRecordFromImport(j, source, clientNamesFromDeepImport);

const clientNamesRecord =
importType === ImportType.REQUIRE
? getClientNamesRecordFromRequire(j, source, clientNamesFromDeepImport)
: getClientNamesRecordFromImport(j, source, clientNamesFromDeepImport);

// Populate client names for type transformations
// Ref: https://github.com/awslabs/aws-sdk-js-codemod/issues/663
for (const clientName of clientNamesFromDeepImport) {
if (!(clientName in clientNamesRecord)) {
clientNamesRecord[clientName] = clientName;
}
}

return clientNamesRecord;
};