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 = (
15
15
16
16
const v2DocClientArgs = v2DocClientNewExpression . node . arguments || [ ] ;
17
17
18
- // Add DocumentClient option convertEmptyValues.
18
+ // Add DocumentClient option convertEmptyValues/wrapNumbers .
19
19
if ( v2DocClientArgs . length > 0 ) {
20
20
const params = v2DocClientArgs [ 0 ] ;
21
21
if ( params . type === "ObjectExpression" ) {
Original file line number Diff line number Diff line change @@ -42,23 +42,25 @@ export const getDynamoDBForDocClient = (
42
42
const v3DocClientNewExpressionArgs = [ ] ;
43
43
44
44
// 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
+ } ) ;
56
57
57
- if ( v3DocClientArgs . properties . length > 0 ) {
58
+ if ( v3DocClientArgs . properties . length > 0 ) {
59
+ v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
60
+ }
61
+ } else {
58
62
v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
59
63
}
60
- } else {
61
- v3DocClientNewExpressionArgs . push ( v3DocClientArgs ) ;
62
64
}
63
65
64
66
return j . newExpression (
You can’t perform that action at this time.
0 commit comments