Skip to content

Commit 9fede0e

Browse files
authored
Merge no params and params API calls (#355)
1 parent e669c11 commit 9fede0e

File tree

6 files changed

+261
-288
lines changed

6 files changed

+261
-288
lines changed

src/transforms/v2-to-v3/__fixtures__/api-promise/global-import.input.js

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,55 @@ import AWS from "aws-sdk";
22

33
const client = new AWS.DynamoDB();
44

5-
// Promise without params
6-
{
7-
// async/await
8-
try {
9-
await client.listTables().promise();
10-
console.log(data);
11-
} catch (err) {
12-
console.log(err, err.stack);
13-
}
5+
// async/await
6+
try {
7+
await client.listTables().promise();
8+
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
9+
console.log(data);
10+
} catch (err) {
11+
console.log(err, err.stack);
12+
}
1413

15-
// .then() and .catch()
16-
client
17-
.listTables()
18-
.promise()
19-
.then((data) => console.log(data))
20-
.catch((err) => console.log(err, err.stack));
21-
22-
// Client as class member
23-
class ClientClassMember {
24-
constructor(clientInCtr = new AWS.DynamoDB()) {
25-
this.clientInClass = clientInCtr;
26-
}
27-
28-
async listTables() {
29-
return await this.clientInClass.listTables().promise();
30-
}
14+
// .then() and .catch()
15+
client
16+
.listTables()
17+
.promise()
18+
.then((data) => console.log(data))
19+
.catch((err) => console.log(err, err.stack));
20+
client
21+
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
22+
.promise()
23+
.then((data) => console.log(data))
24+
.catch((err) => console.log(err, err.stack));
25+
26+
// Client as class member
27+
class ClientClassMember {
28+
constructor(clientInCtr = new AWS.DynamoDB()) {
29+
this.clientInClass = clientInCtr;
3130
}
3231

33-
// Variable declarator
34-
const listTablesPromise = client.listTables().promise();
35-
36-
// Promise call on request in variable declarator
37-
const listTablesRequest = client.listTables();
38-
listTablesRequest
39-
.promise()
40-
.then((data) => console.log(data))
41-
.catch((err) => console.log(err, err.stack));
42-
}
32+
async listTables() {
33+
return await this.clientInClass.listTables().promise();
34+
}
4335

44-
// Promise with params
45-
{
46-
// async/await
47-
try {
48-
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
49-
console.log(data);
50-
} catch (err) {
51-
console.log(err, err.stack);
36+
async listTagsOfResource() {
37+
return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
5238
}
39+
}
5340

54-
// .then() and .catch()
55-
client
56-
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
57-
.promise()
58-
.then((data) => console.log(data))
59-
.catch((err) => console.log(err, err.stack));
60-
}
41+
// Variable declarator
42+
const listTablesPromise = client.listTables().promise();
43+
const listTagsOfResourcePromise = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
44+
45+
// Promise call on request in variable declarator
46+
const listTablesRequest = client.listTables();
47+
listTablesRequest
48+
.promise()
49+
.then((data) => console.log(data))
50+
.catch((err) => console.log(err, err.stack));
51+
52+
const listTagsOfResourceRequest = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
53+
listTagsOfResourceRequest
54+
.promise()
55+
.then((data) => console.log(data))
56+
.catch((err) => console.log(err, err.stack));

src/transforms/v2-to-v3/__fixtures__/api-promise/global-import.output.js

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,51 @@ import { DynamoDB } from "@aws-sdk/client-dynamodb";
22

33
const client = new DynamoDB();
44

5-
// Promise without params
6-
{
7-
// async/await
8-
try {
9-
await client.listTables();
10-
console.log(data);
11-
} catch (err) {
12-
console.log(err, err.stack);
13-
}
5+
// async/await
6+
try {
7+
await client.listTables();
8+
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
9+
console.log(data);
10+
} catch (err) {
11+
console.log(err, err.stack);
12+
}
1413

15-
// .then() and .catch()
16-
client
17-
.listTables()
18-
.then((data) => console.log(data))
19-
.catch((err) => console.log(err, err.stack));
20-
21-
// Client as class member
22-
class ClientClassMember {
23-
constructor(clientInCtr = new DynamoDB()) {
24-
this.clientInClass = clientInCtr;
25-
}
26-
27-
async listTables() {
28-
return await this.clientInClass.listTables();
29-
}
14+
// .then() and .catch()
15+
client
16+
.listTables()
17+
.then((data) => console.log(data))
18+
.catch((err) => console.log(err, err.stack));
19+
client
20+
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
21+
.then((data) => console.log(data))
22+
.catch((err) => console.log(err, err.stack));
23+
24+
// Client as class member
25+
class ClientClassMember {
26+
constructor(clientInCtr = new DynamoDB()) {
27+
this.clientInClass = clientInCtr;
3028
}
3129

32-
// Variable declarator
33-
const listTablesPromise = client.listTables();
30+
async listTables() {
31+
return await this.clientInClass.listTables();
32+
}
3433

35-
// Promise call on request in variable declarator
36-
const listTablesRequest = client.listTables();
37-
listTablesRequest
38-
.then((data) => console.log(data))
39-
.catch((err) => console.log(err, err.stack));
34+
async listTagsOfResource() {
35+
return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
36+
}
4037
}
4138

42-
// Promise with params
43-
{
44-
// async/await
45-
try {
46-
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
47-
console.log(data);
48-
} catch (err) {
49-
console.log(err, err.stack);
50-
}
39+
// Variable declarator
40+
const listTablesPromise = client.listTables();
41+
const listTagsOfResourcePromise = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
42+
43+
// Promise call on request in variable declarator
44+
const listTablesRequest = client.listTables();
45+
listTablesRequest
46+
.then((data) => console.log(data))
47+
.catch((err) => console.log(err, err.stack));
5148

52-
// .then() and .catch()
53-
client
54-
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
55-
.then((data) => console.log(data))
56-
.catch((err) => console.log(err, err.stack));
57-
}
49+
const listTagsOfResourceRequest = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
50+
listTagsOfResourceRequest
51+
.then((data) => console.log(data))
52+
.catch((err) => console.log(err, err.stack));

src/transforms/v2-to-v3/__fixtures__/api-promise/service-import.input.js

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,55 @@ import DynamoDBClient from "aws-sdk/clients/dynamodb";
22

33
const client = new DynamoDBClient();
44

5-
// Promise without params
6-
{
7-
// async/await
8-
try {
9-
await client.listTables().promise();
10-
console.log(data);
11-
} catch (err) {
12-
console.log(err, err.stack);
13-
}
5+
// async/await
6+
try {
7+
await client.listTables().promise();
8+
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
9+
console.log(data);
10+
} catch (err) {
11+
console.log(err, err.stack);
12+
}
1413

15-
// .then() and .catch()
16-
client
17-
.listTables()
18-
.promise()
19-
.then((data) => console.log(data))
20-
.catch((err) => console.log(err, err.stack));
21-
22-
// Client as class member
23-
class ClientClassMember {
24-
constructor(clientInCtr = new DynamoDBClient()) {
25-
this.clientInClass = clientInCtr;
26-
}
27-
28-
async listTables() {
29-
return await this.clientInClass.listTables().promise();
30-
}
14+
// .then() and .catch()
15+
client
16+
.listTables()
17+
.promise()
18+
.then((data) => console.log(data))
19+
.catch((err) => console.log(err, err.stack));
20+
client
21+
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
22+
.promise()
23+
.then((data) => console.log(data))
24+
.catch((err) => console.log(err, err.stack));
25+
26+
// Client as class member
27+
class ClientClassMember {
28+
constructor(clientInCtr = new DynamoDBClient()) {
29+
this.clientInClass = clientInCtr;
3130
}
3231

33-
// Variable declarator
34-
const listTablesPromise = client.listTables().promise();
35-
36-
// Promise call on request in variable declarator
37-
const listTablesRequest = client.listTables();
38-
listTablesRequest
39-
.promise()
40-
.then((data) => console.log(data))
41-
.catch((err) => console.log(err, err.stack));
42-
}
32+
async listTables() {
33+
return await this.clientInClass.listTables().promise();
34+
}
4335

44-
// Promise with params
45-
{
46-
// async/await
47-
try {
48-
await client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
49-
console.log(data);
50-
} catch (err) {
51-
console.log(err, err.stack);
36+
async listTagsOfResource() {
37+
return await this.clientInClass.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
5238
}
39+
}
5340

54-
// .then() and .catch()
55-
client
56-
.listTagsOfResource({ ResourceArn: "STRING_VALUE" })
57-
.promise()
58-
.then((data) => console.log(data))
59-
.catch((err) => console.log(err, err.stack));
60-
}
41+
// Variable declarator
42+
const listTablesPromise = client.listTables().promise();
43+
const listTagsOfResourcePromise = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" }).promise();
44+
45+
// Promise call on request in variable declarator
46+
const listTablesRequest = client.listTables();
47+
listTablesRequest
48+
.promise()
49+
.then((data) => console.log(data))
50+
.catch((err) => console.log(err, err.stack));
51+
52+
const listTagsOfResourceRequest = client.listTagsOfResource({ ResourceArn: "STRING_VALUE" });
53+
listTagsOfResourceRequest
54+
.promise()
55+
.then((data) => console.log(data))
56+
.catch((err) => console.log(err, err.stack));

0 commit comments

Comments
 (0)