Skip to content

Commit 2d477e0

Browse files
authored
Support transformation of waiter configuration (#389)
1 parent b264bbc commit 2d477e0

24 files changed

+471
-51
lines changed

.changeset/eighty-lemons-cheer.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+
Support transformation of waiter configuration

src/transforms/v2-to-v3/__fixtures__/waiters/global-import-equals.input.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });
55

66
await client.waitFor("bucketNotExists", { Bucket }).promise();
77
await client.createBucket({ Bucket }).promise();
8-
await client.waitFor("bucketExists", { Bucket }).promise();
8+
await client.waitFor("bucketExists", { Bucket }).promise();
9+
10+
// Waiter configuration: delay
11+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();
12+
13+
// Waiter configuration: maxAttempts
14+
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();
15+
16+
// Waiter configuration: delay+maxAttempts
17+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();

src/transforms/v2-to-v3/__fixtures__/waiters/global-import-equals.output.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,36 @@ const client = new S3({ region: "REGION" });
1111

1212
await waitUntilBucketNotExists({
1313
client,
14-
maxWaitTime: 180
14+
maxWaitTime: 200
1515
}, { Bucket });
1616
await client.createBucket({ Bucket });
1717
await waitUntilBucketExists({
1818
client,
19-
maxWaitTime: 180
20-
}, { Bucket });
19+
maxWaitTime: 200
20+
}, { Bucket });
21+
22+
// Waiter configuration: delay
23+
await waitUntilBucketExists({
24+
client,
25+
minDelay: 2,
26+
maxWaitTime: 40
27+
}, {
28+
Bucket
29+
});
30+
31+
// Waiter configuration: maxAttempts
32+
await waitUntilBucketExists({
33+
client,
34+
maxWaitTime: 100
35+
}, {
36+
Bucket
37+
});
38+
39+
// Waiter configuration: delay+maxAttempts
40+
await waitUntilBucketExists({
41+
client,
42+
minDelay: 2,
43+
maxWaitTime: 20
44+
}, {
45+
Bucket
46+
});

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });
55

66
await client.waitFor("bucketNotExists", { Bucket }).promise();
77
await client.createBucket({ Bucket }).promise();
8-
await client.waitFor("bucketExists", { Bucket }).promise();
8+
await client.waitFor("bucketExists", { Bucket }).promise();
9+
10+
// Waiter configuration: delay
11+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();
12+
13+
// Waiter configuration: maxAttempts
14+
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();
15+
16+
// Waiter configuration: delay+maxAttempts
17+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,36 @@ const client = new S3({ region: "REGION" });
55

66
await waitUntilBucketNotExists({
77
client,
8-
maxWaitTime: 180
8+
maxWaitTime: 200
99
}, { Bucket });
1010
await client.createBucket({ Bucket });
1111
await waitUntilBucketExists({
1212
client,
13-
maxWaitTime: 180
14-
}, { Bucket });
13+
maxWaitTime: 200
14+
}, { Bucket });
15+
16+
// Waiter configuration: delay
17+
await waitUntilBucketExists({
18+
client,
19+
minDelay: 2,
20+
maxWaitTime: 40
21+
}, {
22+
Bucket
23+
});
24+
25+
// Waiter configuration: maxAttempts
26+
await waitUntilBucketExists({
27+
client,
28+
maxWaitTime: 100
29+
}, {
30+
Bucket
31+
});
32+
33+
// Waiter configuration: delay+maxAttempts
34+
await waitUntilBucketExists({
35+
client,
36+
minDelay: 2,
37+
maxWaitTime: 20
38+
}, {
39+
Bucket
40+
});

src/transforms/v2-to-v3/__fixtures__/waiters/global-require-property.input.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });
55

66
await client.waitFor("bucketNotExists", { Bucket }).promise();
77
await client.createBucket({ Bucket }).promise();
8-
await client.waitFor("bucketExists", { Bucket }).promise();
8+
await client.waitFor("bucketExists", { Bucket }).promise();
9+
10+
// Waiter configuration: delay
11+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();
12+
13+
// Waiter configuration: maxAttempts
14+
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();
15+
16+
// Waiter configuration: delay+maxAttempts
17+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();

src/transforms/v2-to-v3/__fixtures__/waiters/global-require-property.output.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,36 @@ const client = new S3({ region: "REGION" });
99

1010
await waitUntilBucketNotExists({
1111
client,
12-
maxWaitTime: 180
12+
maxWaitTime: 200
1313
}, { Bucket });
1414
await client.createBucket({ Bucket });
1515
await waitUntilBucketExists({
1616
client,
17-
maxWaitTime: 180
18-
}, { Bucket });
17+
maxWaitTime: 200
18+
}, { Bucket });
19+
20+
// Waiter configuration: delay
21+
await waitUntilBucketExists({
22+
client,
23+
minDelay: 2,
24+
maxWaitTime: 40
25+
}, {
26+
Bucket
27+
});
28+
29+
// Waiter configuration: maxAttempts
30+
await waitUntilBucketExists({
31+
client,
32+
maxWaitTime: 100
33+
}, {
34+
Bucket
35+
});
36+
37+
// Waiter configuration: delay+maxAttempts
38+
await waitUntilBucketExists({
39+
client,
40+
minDelay: 2,
41+
maxWaitTime: 20
42+
}, {
43+
Bucket
44+
});

src/transforms/v2-to-v3/__fixtures__/waiters/global-require.input.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@ const client = new AWS.S3({ region: "REGION" });
55

66
await client.waitFor("bucketNotExists", { Bucket }).promise();
77
await client.createBucket({ Bucket }).promise();
8-
await client.waitFor("bucketExists", { Bucket }).promise();
8+
await client.waitFor("bucketExists", { Bucket }).promise();
9+
10+
// Waiter configuration: delay
11+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();
12+
13+
// Waiter configuration: maxAttempts
14+
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();
15+
16+
// Waiter configuration: delay+maxAttempts
17+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();

src/transforms/v2-to-v3/__fixtures__/waiters/global-require.output.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,36 @@ const client = new S3({ region: "REGION" });
99

1010
await waitUntilBucketNotExists({
1111
client,
12-
maxWaitTime: 180
12+
maxWaitTime: 200
1313
}, { Bucket });
1414
await client.createBucket({ Bucket });
1515
await waitUntilBucketExists({
1616
client,
17-
maxWaitTime: 180
18-
}, { Bucket });
17+
maxWaitTime: 200
18+
}, { Bucket });
19+
20+
// Waiter configuration: delay
21+
await waitUntilBucketExists({
22+
client,
23+
minDelay: 2,
24+
maxWaitTime: 40
25+
}, {
26+
Bucket
27+
});
28+
29+
// Waiter configuration: maxAttempts
30+
await waitUntilBucketExists({
31+
client,
32+
maxWaitTime: 100
33+
}, {
34+
Bucket
35+
});
36+
37+
// Waiter configuration: delay+maxAttempts
38+
await waitUntilBucketExists({
39+
client,
40+
minDelay: 2,
41+
maxWaitTime: 20
42+
}, {
43+
Bucket
44+
});

src/transforms/v2-to-v3/__fixtures__/waiters/service-import-deep.input.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,13 @@ const client = new S3({ region: "REGION" });
55

66
await client.waitFor("bucketNotExists", { Bucket }).promise();
77
await client.createBucket({ Bucket }).promise();
8-
await client.waitFor("bucketExists", { Bucket }).promise();
8+
await client.waitFor("bucketExists", { Bucket }).promise();
9+
10+
// Waiter configuration: delay
11+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2 } }).promise();
12+
13+
// Waiter configuration: maxAttempts
14+
await client.waitFor("bucketExists", { Bucket, $waiter: { maxAttempts: 5 } }).promise();
15+
16+
// Waiter configuration: delay+maxAttempts
17+
await client.waitFor("bucketExists", { Bucket, $waiter: { delay: 2, maxAttempts: 5 } }).promise();

0 commit comments

Comments
 (0)