Skip to content

Commit

Permalink
Replace named imports for Request/Response types (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Dec 27, 2022
1 parent 7fe7482 commit 9e64aa4
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 37 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-mice-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Replace named imports for Request/Response types
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import AWS from "aws-sdk";

const client = new AWS.DynamoDB({ region: "us-west-2" });

const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await client
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new AWS.STS({ region: "us-west-2" });
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await client
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const AWS = require("aws-sdk");

const client = new AWS.DynamoDB({ region: "us-west-2" });

const ddbClient = new AWS.DynamoDB({ region: "us-west-2" });
const listTablesInput: AWS.DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await client
const listTablesOutput: AWS.DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new AWS.STS({ region: "us-west-2" });
const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ const {
ListTablesCommandOutput
} = require("@aws-sdk/client-dynamodb");

const client = new DynamoDB({ region: "us-west-2" });
const {
STS,
GetCallerIdentityCommandInput,
GetCallerIdentityCommandOutput
} = require("@aws-sdk/client-sts");

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await client
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesInput = { Limit: 10 };
const listTablesOutput: ListTablesOutput = await client
const listTablesOutput: ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityRequest = {};
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await client
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import DynamoDB from "aws-sdk/clients/dynamodb";
import STS from "aws-sdk/clients/sts";

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await client
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { DynamoDB, ListTablesCommandInput, ListTablesCommandOutput } from "@aws-sdk/client-dynamodb";
import { STS, GetCallerIdentityCommandInput, GetCallerIdentityCommandOutput } from "@aws-sdk/client-sts";

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await client
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const DynamoDB = require("aws-sdk/clients/dynamodb");
const STS = require("aws-sdk/clients/sts");

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: DynamoDB.ListTablesInput = { Limit: 10 };
const listTablesOutput: DynamoDB.ListTablesOutput = await client
const listTablesOutput: DynamoDB.ListTablesOutput = await ddbClient
.listTables(listTablesInput)
.promise();

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
.getCallerIdentity(getCallerIdentityInput)
.promise();
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ const {
ListTablesCommandInput,
ListTablesCommandOutput
} = require("@aws-sdk/client-dynamodb");
const {
STS,
GetCallerIdentityCommandInput,
GetCallerIdentityCommandOutput
} = require("@aws-sdk/client-sts");

const client = new DynamoDB({ region: "us-west-2" });

const ddbClient = new DynamoDB({ region: "us-west-2" });
const listTablesInput: ListTablesCommandInput = { Limit: 10 };
const listTablesOutput: ListTablesCommandOutput = await client
.listTables(listTablesInput);
const listTablesOutput: ListTablesCommandOutput = await ddbClient
.listTables(listTablesInput);

const stsClient = new STS({ region: "us-west-2" });
const getCallerIdentityInput: GetCallerIdentityCommandInput = {};
const getCallerIdentityOutput: GetCallerIdentityCommandOutput = await stsClient
.getCallerIdentity(getCallerIdentityInput);
5 changes: 2 additions & 3 deletions src/transforms/v2-to-v3/utils/config/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const PACKAGE_NAME = "aws-sdk";

// ToDo: Add Request and Response suffixes in future version.
export const V2_CLIENT_INPUT_SUFFIX_LIST = ["Input"];
export const V2_CLIENT_OUTPUT_SUFFIX_LIST = ["Output"];
export const V2_CLIENT_INPUT_SUFFIX_LIST = ["Input", "Request"];
export const V2_CLIENT_OUTPUT_SUFFIX_LIST = ["Output", "Response"];

0 comments on commit 9e64aa4

Please sign in to comment.