Skip to content

Commit 8de1c52

Browse files
authored
Use CLIENT_REQ_RESP_TYPES_MAP for input/output transformation (#581)
1 parent 531767c commit 8de1c52

19 files changed

+165
-43
lines changed

.changeset/tender-rules-flow.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": minor
3+
---
4+
5+
Transform Input/Output types without operation name prefix

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
1313
.promise();
14+
15+
const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
16+
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
17+
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
18+
.invoke(invokeInput)
19+
.promise();

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const {
44
DynamoDB
55
} = AWS_DynamoDB;
66

7+
import AWS_Lambda = require("@aws-sdk/client-lambda");
8+
9+
const {
10+
Lambda
11+
} = AWS_Lambda;
12+
713
import AWS_STS = require("@aws-sdk/client-sts");
814

915
const {
@@ -18,4 +24,9 @@ const listTablesOutput: AWS_DynamoDB.ListTablesCommandOutput = await ddbClient
1824
const stsClient = new STS({ region: "us-west-2" });
1925
const getCallerIdentityInput: AWS_STS.GetCallerIdentityCommandInput = {};
2026
const getCallerIdentityOutput: AWS_STS.GetCallerIdentityCommandOutput = await stsClient
21-
.getCallerIdentity(getCallerIdentityInput);
27+
.getCallerIdentity(getCallerIdentityInput);
28+
29+
const lambdaClient = new Lambda({ region: "us-west-2" });
30+
const invokeInput: AWS_Lambda.InvokeCommandInput = { FunctionName: "my-function" };
31+
const invokeOutput: AWS_Lambda.InvokeCommandOutput = await lambdaClient
32+
.invoke(invokeInput);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ const getCallerIdentityInput: AWS.STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: AWS.STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
1313
.promise();
14+
15+
const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
16+
const invokeInput: AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
17+
const invokeOutput: AWS.Lambda.InvocationResponse = await lambdaClient
18+
.invoke(invokeInput)
19+
.promise();

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const {
44
DynamoDB
55
} = AWS_DynamoDB;
66

7+
import * as AWS_Lambda from "@aws-sdk/client-lambda";
8+
9+
const {
10+
Lambda
11+
} = AWS_Lambda;
12+
713
import * as AWS_STS from "@aws-sdk/client-sts";
814

915
const {
@@ -18,4 +24,9 @@ const listTablesOutput: AWS_DynamoDB.ListTablesCommandOutput = await ddbClient
1824
const stsClient = new STS({ region: "us-west-2" });
1925
const getCallerIdentityInput: AWS_STS.GetCallerIdentityCommandInput = {};
2026
const getCallerIdentityOutput: AWS_STS.GetCallerIdentityCommandOutput = await stsClient
21-
.getCallerIdentity(getCallerIdentityInput);
27+
.getCallerIdentity(getCallerIdentityInput);
28+
29+
const lambdaClient = new Lambda({ region: "us-west-2" });
30+
const invokeInput: AWS_Lambda.InvokeCommandInput = { FunctionName: "my-function" };
31+
const invokeOutput: AWS_Lambda.InvokeCommandOutput = await lambdaClient
32+
.invoke(invokeInput);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@ const stsClient = new AWS.STS({ region: "us-west-2" });
1010
const getCallerIdentityInput: typeof AWS.STS.GetCallerIdentityRequest = {};
1111
const getCallerIdentityOutput: typeof AWS.STS.GetCallerIdentityResponse = await stsClient
1212
.getCallerIdentity(getCallerIdentityInput)
13-
.promise();
13+
.promise();
14+
15+
const lambdaClient = new AWS.Lambda({ region: "us-west-2" });
16+
const invokeInput: typeof AWS.Lambda.InvocationRequest = { FunctionName: "my-function" };
17+
const invokeOutput: typeof AWS.Lambda.InvocationResponse = await lambdaClient
18+
.invoke(invokeInput)
19+
.promise();
20+

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const AWS_DynamoDB = require("@aws-sdk/client-dynamodb"),
22
{
33
DynamoDB
44
} = AWS_DynamoDB,
5+
AWS_Lambda = require("@aws-sdk/client-lambda"),
6+
{
7+
Lambda
8+
} = AWS_Lambda,
59
AWS_STS = require("@aws-sdk/client-sts"),
610
{
711
STS
@@ -15,4 +19,9 @@ const listTablesOutput: typeof AWS_DynamoDB.ListTablesCommandOutput = await ddbC
1519
const stsClient = new STS({ region: "us-west-2" });
1620
const getCallerIdentityInput: typeof AWS_STS.GetCallerIdentityCommandInput = {};
1721
const getCallerIdentityOutput: typeof AWS_STS.GetCallerIdentityCommandOutput = await stsClient
18-
.getCallerIdentity(getCallerIdentityInput);
22+
.getCallerIdentity(getCallerIdentityInput);
23+
24+
const lambdaClient = new Lambda({ region: "us-west-2" });
25+
const invokeInput: typeof AWS_Lambda.InvokeCommandInput = { FunctionName: "my-function" };
26+
const invokeOutput: typeof AWS_Lambda.InvokeCommandOutput = await lambdaClient
27+
.invoke(invokeInput);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import DynamoDB, { ListTablesInput, ListTablesOutput } from "aws-sdk/clients/dynamodb";
2+
import Lambda, { InvocationRequest, InvocationResponse } from "aws-sdk/clients/lambda";
23
import STS, { GetCallerIdentityRequest, GetCallerIdentityResponse } from "aws-sdk/clients/sts";
34

45
const ddbClient = new DynamoDB({ region: "us-west-2" });
@@ -11,4 +12,10 @@ const stsClient = new STS({ region: "us-west-2" });
1112
const getCallerIdentityInput: GetCallerIdentityRequest = {};
1213
const getCallerIdentityOutput: GetCallerIdentityResponse = await stsClient
1314
.getCallerIdentity(getCallerIdentityInput)
15+
.promise();
16+
17+
const lambdaClient = new Lambda({ region: "us-west-2" });
18+
const invokeInput: InvocationRequest = { FunctionName: "my-function" };
19+
const invokeOutput: InvocationResponse = await lambdaClient
20+
.invoke(invokeInput)
1421
.promise();

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const {
44
DynamoDB
55
} = AWS_DynamoDB;
66

7+
import * as AWS_Lambda from "@aws-sdk/client-lambda";
8+
9+
const {
10+
Lambda
11+
} = AWS_Lambda;
12+
713
import * as AWS_STS from "@aws-sdk/client-sts";
814

915
const {
@@ -18,4 +24,9 @@ const listTablesOutput: AWS_DynamoDB.ListTablesCommandOutput = await ddbClient
1824
const stsClient = new STS({ region: "us-west-2" });
1925
const getCallerIdentityInput: AWS_STS.GetCallerIdentityCommandInput = {};
2026
const getCallerIdentityOutput: AWS_STS.GetCallerIdentityCommandOutput = await stsClient
21-
.getCallerIdentity(getCallerIdentityInput);
27+
.getCallerIdentity(getCallerIdentityInput);
28+
29+
const lambdaClient = new Lambda({ region: "us-west-2" });
30+
const invokeInput: AWS_Lambda.InvokeCommandInput = { FunctionName: "my-function" };
31+
const invokeOutput: AWS_Lambda.InvokeCommandOutput = await lambdaClient
32+
.invoke(invokeInput);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import DynamoDB = require("aws-sdk/clients/dynamodb");
2+
import Lambda = require("aws-sdk/clients/lambda");
23
import STS = require("aws-sdk/clients/sts");
34

45
const ddbClient = new DynamoDB({ region: "us-west-2" });
@@ -11,4 +12,10 @@ const stsClient = new STS({ region: "us-west-2" });
1112
const getCallerIdentityInput: STS.GetCallerIdentityRequest = {};
1213
const getCallerIdentityOutput: STS.GetCallerIdentityResponse = await stsClient
1314
.getCallerIdentity(getCallerIdentityInput)
15+
.promise();
16+
17+
const lambdaClient = new Lambda({ region: "us-west-2" });
18+
const invokeInput: Lambda.InvocationRequest = { FunctionName: "my-function" };
19+
const invokeOutput: Lambda.InvocationResponse = await lambdaClient
20+
.invoke(invokeInput)
1421
.promise();

0 commit comments

Comments
 (0)