Skip to content

Commit 9e64aa4

Browse files
authored
Replace named imports for Request/Response types (#221)
1 parent 7fe7482 commit 9e64aa4

12 files changed

+101
-37
lines changed

.changeset/shy-mice-wonder.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+
Replace named imports for Request/Response types
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import AWS from "aws-sdk";
22

3-
const client = new AWS.DynamoDB({ region: "us-west-2" });
4-
3+
const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
54
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
6-
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await client
5+
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
76
.listTables(listTablesInput)
87
.promise();
98

9+
const stsClient = new AWS.STS({ region: "us-west-2" });
10+
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
11+
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
12+
.getCallerIdentity(getCallerIdentityInput)
13+
.promise();
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2+
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
6-
const listTablesOutput: ListTablesCommandOutput = await client
7-
.listTables(listTablesInput);
6+
const listTablesOutput: ListTablesCommandOutput = await ddbClient
7+
.listTables(listTablesInput);
8+
9+
const stsClient = new STS({ region: "us-west-2" });
10+
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
11+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
12+
.getCallerIdentity(getCallerIdentityInput);
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
const AWS = require("aws-sdk");
22

3-
const client = new AWS.DynamoDB({ region: "us-west-2" });
4-
3+
const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
54
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
6-
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await client
5+
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
76
.listTables(listTablesInput)
87
.promise();
98

9+
const stsClient = new AWS.STS({ region: "us-west-2" });
10+
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
11+
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
12+
.getCallerIdentity(getCallerIdentityInput)
13+
.promise();

src/transforms/v2-to-v3/__fixtures__/api-input-output-type/global-require.output.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ const {
44
ListTablesCommandOutput
55
} = require("@aws-sdk/client-dynamodb");
66

7-
const client = new DynamoDB({ region: "us-west-2" });
7+
const {
8+
STS,
9+
GetCallerIdentityCommandInput,
10+
GetCallerIdentityCommandOutput
11+
} = require("@aws-sdk/client-sts");
812

13+
const ddbClient = new DynamoDB({ region: "us-west-2" });
914
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
10-
const listTablesOutput: ListTablesCommandOutput = await client
11-
.listTables(listTablesInput);
15+
const listTablesOutput: ListTablesCommandOutput = await ddbClient
16+
.listTables(listTablesInput);
17+
18+
const stsClient = new STS({ region: "us-west-2" });
19+
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
20+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
21+
.getCallerIdentity(getCallerIdentityInput);
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
2+
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: ListTablesInput = { Limit: 10 };
6-
const listTablesOutput: ListTablesOutput = await client
6+
const listTablesOutput: ListTablesOutput = await ddbClient
77
.listTables(listTablesInput)
88
.promise();
9+
10+
const stsClient = new STS({ region: "us-west-2" });
11+
const getCallerIdentityInput: GetCallerIdentityRequest = {};
12+
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
13+
.getCallerIdentity(getCallerIdentityInput)
14+
.promise();
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2+
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
6-
const listTablesOutput: ListTablesCommandOutput = await client
7-
.listTables(listTablesInput);
6+
const listTablesOutput: ListTablesCommandOutput = await ddbClient
7+
.listTables(listTablesInput);
8+
9+
const stsClient = new STS({ region: "us-west-2" });
10+
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
11+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
12+
.getCallerIdentity(getCallerIdentityInput);
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import DynamoDB from "aws-sdk/clients/dynamodb";
2+
import STS from "aws-sdk/clients/sts";
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
6-
const listTablesOutput: DynamoDB.ListTablesOutput = await client
6+
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
77
.listTables(listTablesInput)
88
.promise();
9+
10+
const stsClient = new STS({ region: "us-west-2" });
11+
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
12+
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
13+
.getCallerIdentity(getCallerIdentityInput)
14+
.promise();
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
2+
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
6-
const listTablesOutput: ListTablesCommandOutput = await client
7-
.listTables(listTablesInput);
6+
const listTablesOutput: ListTablesCommandOutput = await ddbClient
7+
.listTables(listTablesInput);
8+
9+
const stsClient = new STS({ region: "us-west-2" });
10+
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
11+
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
12+
.getCallerIdentity(getCallerIdentityInput);
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
const DynamoDB = require("aws-sdk/clients/dynamodb");
2+
const STS = require("aws-sdk/clients/sts");
23

3-
const client = new DynamoDB({ region: "us-west-2" });
4-
4+
const ddbClient = new DynamoDB({ region: "us-west-2" });
55
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
6-
const listTablesOutput: DynamoDB.ListTablesOutput = await client
6+
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
77
.listTables(listTablesInput)
88
.promise();
9+
10+
const stsClient = new STS({ region: "us-west-2" });
11+
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
12+
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
13+
.getCallerIdentity(getCallerIdentityInput)
14+
.promise();

0 commit comments

Comments
 (0)