File tree Expand file tree Collapse file tree 5 files changed +29
-15
lines changed
__fixtures__/ddb-doc-client Expand file tree Collapse file tree 5 files changed +29
-15
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " aws-sdk-js-codemod " : patch
3+ ---
4+
5+ Check if parameters are passed during DocumentClient creation
Original file line number Diff line number Diff line change 1+ import AWS from "aws-sdk" ;
2+
3+ const documentClient = new AWS . DynamoDB . DocumentClient ( ) ;
Original file line number Diff line number Diff line change 1+ import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb" ;
2+ import { DynamoDB } from "@aws-sdk/client-dynamodb" ;
3+
4+ const documentClient = DynamoDBDocument . from ( new DynamoDB ( ) ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export const getDynamoDBDocClientArgs = (
1515
1616 const v2DocClientArgs = v2DocClientNewExpression . node . arguments || [ ] ;
1717
18- // Add DocumentClient option convertEmptyValues.
18+ // Add DocumentClient option convertEmptyValues/wrapNumbers .
1919 if ( v2DocClientArgs . length > 0 ) {
2020 const params = v2DocClientArgs [ 0 ] ;
2121 if ( params . type === "ObjectExpression" ) {
Original file line number Diff line number Diff line change @@ -42,23 +42,25 @@ export const getDynamoDBForDocClient = (
4242 const v3DocClientNewExpressionArgs = [ ] ;
4343
4444 // Remove DocumentClient option convertEmptyValues and wrapNumbers.
45- if ( v3DocClientArgs . type === "ObjectExpression" ) {
46- v3DocClientArgs . properties = v3DocClientArgs . properties . filter ( ( property ) => {
47- if ( ! OBJECT_PROPERTY_TYPE_LIST . includes ( property . type ) ) {
48- return true ;
49- }
50- const propertyKey = ( property as Property | ObjectProperty ) . key ;
51- if ( propertyKey . type !== "Identifier" ) {
52- return true ;
53- }
54- return ! [ "convertEmptyValues" , "wrapNumbers" ] . includes ( propertyKey . name ) ;
55- } ) ;
45+ if ( v3DocClientArgs ) {
46+ if ( v3DocClientArgs . type === "ObjectExpression" ) {
47+ v3DocClientArgs . properties = v3DocClientArgs . properties . filter ( ( property ) => {
48+ if ( ! OBJECT_PROPERTY_TYPE_LIST . includes ( property . type ) ) {
49+ return true ;
50+ }
51+ const propertyKey = ( property as Property | ObjectProperty ) . key ;
52+ if ( propertyKey . type !== "Identifier" ) {
53+ return true ;
54+ }
55+ return ! [ "convertEmptyValues" , "wrapNumbers" ] . includes ( propertyKey . name ) ;
56+ } ) ;
5657
57- if ( v3DocClientArgs . properties . length > 0 ) {
58+ if ( v3DocClientArgs . properties . length > 0 ) {
59+ v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
60+ }
61+ } else {
5862 v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
5963 }
60- } else {
61- v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
6264 }
6365
6466 return j . newExpression (
You can’t perform that action at this time.
0 commit comments