Skip to content

Commit 53a49aa

Browse files
authored
Support transformation of DocumentClient input/output types (#469)
1 parent 00266aa commit 53a49aa

28 files changed

+341
-35
lines changed

.changeset/tricky-panthers-fetch.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+
Support transformation of DocumentClient input/output types

scripts/generateClientTypesMap/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import { writeFile } from "fs/promises";
22
import { join } from "path";
33
import { format } from "prettier";
44

5-
import { CLIENT_NAMES, DOCUMENT_CLIENT, DYNAMODB } from "../../src/transforms/v2-to-v3/config";
5+
import {
6+
CLIENT_NAMES,
7+
DOCUMENT_CLIENT,
8+
DYNAMODB,
9+
DYNAMODB_DOCUMENT_CLIENT,
10+
} from "../../src/transforms/v2-to-v3/config";
611
import { getClientTypesMap } from "./getClientTypesMap";
712

813
const codegenComment = `// This file is generated by scripts/generateClientTypesMap/index.ts
@@ -22,7 +27,7 @@ const relativeFilePath = join(__dirname, "..", "..", filePath);
2227
for (const clientName of CLIENT_NAMES) {
2328
clientTypesMap[clientName] = await getClientTypesMap(clientName);
2429
if (clientName === DYNAMODB) {
25-
clientTypesMap[DOCUMENT_CLIENT] = await getClientTypesMap(DOCUMENT_CLIENT);
30+
clientTypesMap[DYNAMODB_DOCUMENT_CLIENT] = await getClientTypesMap(DOCUMENT_CLIENT);
2631
}
2732
}
2833

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AWS = require("aws-sdk");
2+
3+
const docClient = new AWS.DynamoDB.DocumentClient({ region: "us-west-2" });
4+
5+
const docClientScanInput: AWS.DynamoDB.DocumentClient.ScanInput = {
6+
TableName: "TableName"
7+
};
8+
9+
const docClientScanOutput: AWS.DynamoDB.DocumentClient.ScanOutput = await docClient
10+
.scan(docClientScanInput)
11+
.promise();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import AWS_lib_dynamodb = require("@aws-sdk/lib-dynamodb");
2+
3+
const {
4+
DynamoDBDocument
5+
} = AWS_lib_dynamodb;
6+
7+
import AWS_DynamoDB = require("@aws-sdk/client-dynamodb");
8+
9+
const {
10+
DynamoDB
11+
} = AWS_DynamoDB;
12+
13+
const docClient = DynamoDBDocument.from(new DynamoDB({ region: "us-west-2" }));
14+
15+
const docClientScanInput: AWS_DynamoDBDocumentClient.ScanCommandInput = {
16+
TableName: "TableName"
17+
};
18+
19+
const docClientScanOutput: AWS_DynamoDBDocumentClient.ScanCommandOutput = await docClient
20+
.scan(docClientScanInput);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AWS from "aws-sdk";
2+
3+
const docClient = new AWS.DynamoDB.DocumentClient({ region: "us-west-2" });
4+
5+
const docClientScanInput: AWS.DynamoDB.DocumentClient.ScanInput = {
6+
TableName: "TableName"
7+
};
8+
9+
const docClientScanOutput: AWS.DynamoDB.DocumentClient.ScanOutput = await docClient
10+
.scan(docClientScanInput)
11+
.promise();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AWS_DynamoDBDocumentClient, { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";
2+
import { DynamoDB } from "@aws-sdk/client-dynamodb";
3+
4+
const docClient = DynamoDBDocument.from(new DynamoDB({ region: "us-west-2" }));
5+
6+
const docClientScanInput: AWS_DynamoDBDocumentClient.ScanCommandInput = {
7+
TableName: "TableName"
8+
};
9+
10+
const docClientScanOutput: AWS_DynamoDBDocumentClient.ScanCommandOutput = await docClient
11+
.scan(docClientScanInput);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const AWS = require("aws-sdk");
2+
3+
const docClient = new AWS.DynamoDB.DocumentClient({ region: "us-west-2" });
4+
5+
const docClientScanInput: AWS.DynamoDB.DocumentClient.ScanInput = {
6+
TableName: "TableName"
7+
};
8+
9+
const docClientScanOutput: AWS.DynamoDB.DocumentClient.ScanOutput = await docClient
10+
.scan(docClientScanInput)
11+
.promise();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const AWS_DynamoDBDocumentClient = require("@aws-sdk/lib-dynamodb"),
2+
{
3+
DynamoDBDocument
4+
} = AWS_DynamoDBDocumentClient,
5+
{
6+
DynamoDB
7+
} = require("@aws-sdk/client-dynamodb");
8+
9+
const docClient = DynamoDBDocument.from(new DynamoDB({ region: "us-west-2" }));
10+
11+
const docClientScanInput: AWS_DynamoDBDocumentClient.ScanCommandInput = {
12+
TableName: "TableName"
13+
};
14+
15+
const docClientScanOutput: AWS_DynamoDBDocumentClient.ScanCommandOutput = await docClient
16+
.scan(docClientScanInput);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import DynDB from "aws-sdk/clients/dynamodb";
2+
3+
const docClient = new DynDB.DocumentClient({ region: "us-west-2" });
4+
5+
const docClientScanInput: DynDB.DocumentClient.ScanInput = {
6+
TableName: "TableName"
7+
};
8+
9+
const docClientScanOutput: DynDB.DocumentClient.ScanOutput = await docClient
10+
.scan(docClientScanInput)
11+
.promise();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import AWS_DynDBDocumentClient, { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";
2+
import { DynamoDB as DynDB } from "@aws-sdk/client-dynamodb";
3+
4+
const docClient = DynamoDBDocument.from(new DynDB({ region: "us-west-2" }));
5+
6+
const docClientScanInput: AWS_DynDBDocumentClient.ScanCommandInput = {
7+
TableName: "TableName"
8+
};
9+
10+
const docClientScanOutput: AWS_DynDBDocumentClient.ScanCommandOutput = await docClient
11+
.scan(docClientScanInput);

0 commit comments

Comments
 (0)