Skip to content

Commit b017b59

Browse files
authored
Transform types imported without clients (#664)
1 parent 5e0ff08 commit b017b59

14 files changed

+62
-132
lines changed

.changeset/hot-dancers-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Transform types imported without clients
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import AWS = require("aws-sdk");
22

3-
const ddbClient = new AWS.DynamoDB();
43
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
5-
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
6-
.listTables(listTablesInput)
7-
.promise();
4+
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = {};
85

9-
const stsClient = new AWS.STS();
106
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
11-
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
12-
.getCallerIdentity(getCallerIdentityInput)
13-
.promise();
7+
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = {};
148

15-
const lambdaClient = new AWS.Lambda();
169
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
17-
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
18-
.invoke(invokeInput)
19-
.promise();
10+
const invokeOutput: AWS.Lambda.InvocationResponse = {};
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
import AWS_client_dynamodb = require("@aws-sdk/client-dynamodb");
2-
import DynamoDB = AWS_client_dynamodb.DynamoDB;
32
import ListTablesCommandOutput = AWS_client_dynamodb.ListTablesCommandOutput;
43
import ListTablesCommandInput = AWS_client_dynamodb.ListTablesCommandInput;
54
import AWS_client_lambda = require("@aws-sdk/client-lambda");
6-
import Lambda = AWS_client_lambda.Lambda;
75
import InvokeCommandOutput = AWS_client_lambda.InvokeCommandOutput;
86
import InvokeCommandInput = AWS_client_lambda.InvokeCommandInput;
97
import AWS_client_sts = require("@aws-sdk/client-sts");
10-
import STS = AWS_client_sts.STS;
118
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
129
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;
1310

14-
const ddbClient = new DynamoDB();
1511
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
16-
const listTablesOutput: ListTablesCommandOutput = await ddbClient
17-
.listTables(listTablesInput);
12+
const listTablesOutput: ListTablesCommandOutput = {};
1813

19-
const stsClient = new STS();
2014
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
21-
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
22-
.getCallerIdentity(getCallerIdentityInput);
15+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};
2316

24-
const lambdaClient = new Lambda();
2517
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
26-
const invokeOutput: InvokeCommandOutput = await lambdaClient
27-
.invoke(invokeInput);
18+
const invokeOutput: InvokeCommandOutput = {};
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import AWS from "aws-sdk";
22

3-
const ddbClient = new AWS.DynamoDB();
43
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
5-
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
6-
.listTables(listTablesInput)
7-
.promise();
4+
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = {};
85

9-
const stsClient = new AWS.STS();
106
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
11-
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
12-
.getCallerIdentity(getCallerIdentityInput)
13-
.promise();
7+
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = {};
148

15-
const lambdaClient = new AWS.Lambda();
169
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
17-
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
18-
.invoke(invokeInput)
19-
.promise();
10+
const invokeOutput: AWS.Lambda.InvocationResponse = {};
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2-
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
3-
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
1+
import { ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2+
import { InvokeCommandInput, InvokeCommandOutput } from "@aws-sdk/client-lambda";
3+
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";
44

5-
const ddbClient = new DynamoDB();
65
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
7-
const listTablesOutput: ListTablesCommandOutput = await ddbClient
8-
.listTables(listTablesInput);
6+
const listTablesOutput: ListTablesCommandOutput = {};
97

10-
const stsClient = new STS();
118
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
12-
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
13-
.getCallerIdentity(getCallerIdentityInput);
9+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};
1410

15-
const lambdaClient = new Lambda();
1611
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
17-
const invokeOutput: InvokeCommandOutput = await lambdaClient
18-
.invoke(invokeInput);
12+
const invokeOutput: InvokeCommandOutput = {};
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
2-
import Lambda, { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
3-
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
1+
import { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
2+
import { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
3+
import { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
44

5-
const ddbClient = new DynamoDB();
65
const listTablesInput: ListTablesInput = { Limit: 10 };
7-
const listTablesOutput: ListTablesOutput = await ddbClient
8-
.listTables(listTablesInput)
9-
.promise();
6+
const listTablesOutput: ListTablesOutput = {};
107

11-
const stsClient = new STS();
128
const getCallerIdentityInput: GetCallerIdentityRequest = {};
13-
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
14-
.getCallerIdentity(getCallerIdentityInput)
15-
.promise();
9+
const getCallerIdentityOutput: GetCallerIdentityResponse = {};
1610

17-
const lambdaClient = new Lambda();
1811
const invokeInput: InvocationRequest = { FunctionName: "my-function" };
19-
const invokeOutput: InvocationResponse = await lambdaClient
20-
.invoke(invokeInput)
21-
.promise();
12+
const invokeOutput: InvocationResponse = {};
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2-
import { InvokeCommandInput, InvokeCommandOutput, Lambda } from "@aws-sdk/client-lambda";
3-
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput, STS } from "@aws-sdk/client-sts";
1+
import { ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2+
import { InvokeCommandInput, InvokeCommandOutput } from "@aws-sdk/client-lambda";
3+
import { GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";
44

5-
const ddbClient = new DynamoDB();
65
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
7-
const listTablesOutput: ListTablesCommandOutput = await ddbClient
8-
.listTables(listTablesInput);
6+
const listTablesOutput: ListTablesCommandOutput = {};
97

10-
const stsClient = new STS();
118
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
12-
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
13-
.getCallerIdentity(getCallerIdentityInput);
9+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};
1410

15-
const lambdaClient = new Lambda();
1611
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
17-
const invokeOutput: InvokeCommandOutput = await lambdaClient
18-
.invoke(invokeInput);
12+
const invokeOutput: InvokeCommandOutput = {};

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/service-import-equals.input.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@ import DynamoDB = require("aws-sdk/clients/dynamodb");
22
import Lambda = require("aws-sdk/clients/lambda");
33
import STS = require("aws-sdk/clients/sts");
44

5-
const ddbClient = new DynamoDB();
65
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
7-
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
8-
.listTables(listTablesInput)
9-
.promise();
6+
const listTablesOutput: DynamoDB.ListTablesOutput = {};
107

11-
const stsClient = new STS();
128
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
13-
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
14-
.getCallerIdentity(getCallerIdentityInput)
15-
.promise();
9+
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = {};
1610

17-
const lambdaClient = new Lambda();
1811
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
19-
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
20-
.invoke(invokeInput)
21-
.promise();
12+
const invokeOutput: Lambda.InvocationResponse = {};
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
import AWS_client_dynamodb = require("@aws-sdk/client-dynamodb");
2-
import DynamoDB = AWS_client_dynamodb.DynamoDB;
32
import ListTablesCommandOutput = AWS_client_dynamodb.ListTablesCommandOutput;
43
import ListTablesCommandInput = AWS_client_dynamodb.ListTablesCommandInput;
54
import AWS_client_lambda = require("@aws-sdk/client-lambda");
6-
import Lambda = AWS_client_lambda.Lambda;
75
import InvokeCommandOutput = AWS_client_lambda.InvokeCommandOutput;
86
import InvokeCommandInput = AWS_client_lambda.InvokeCommandInput;
97
import AWS_client_sts = require("@aws-sdk/client-sts");
10-
import STS = AWS_client_sts.STS;
118
import GetCallerIdentityCommandOutput = AWS_client_sts.GetCallerIdentityCommandOutput;
129
import GetCallerIdentityCommandInput = AWS_client_sts.GetCallerIdentityCommandInput;
1310

14-
const ddbClient = new DynamoDB();
1511
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
16-
const listTablesOutput: ListTablesCommandOutput = await ddbClient
17-
.listTables(listTablesInput);
12+
const listTablesOutput: ListTablesCommandOutput = {};
1813

19-
const stsClient = new STS();
2014
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
21-
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
22-
.getCallerIdentity(getCallerIdentityInput);
15+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = {};
2316

24-
const lambdaClient = new Lambda();
2517
const invokeInput: InvokeCommandInput = { FunctionName: "my-function" };
26-
const invokeOutput: InvokeCommandOutput = await lambdaClient
27-
.invoke(invokeInput);
18+
const invokeOutput: InvokeCommandOutput = {};
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import { DynamoDB, Lambda, STS } from "aws-sdk";
22

3-
const ddbClient = new DynamoDB();
43
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
5-
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
6-
.listTables(listTablesInput)
7-
.promise();
4+
const listTablesOutput: DynamoDB.ListTablesOutput = {};
85

9-
const stsClient = new STS();
106
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
11-
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
12-
.getCallerIdentity(getCallerIdentityInput)
13-
.promise();
7+
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = {};
148

15-
const lambdaClient = new Lambda();
169
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
17-
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
18-
.invoke(invokeInput)
19-
.promise();
10+
const invokeOutput: Lambda.InvocationResponse = {};
2011

0 commit comments

Comments
 (0)