-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split getClientNewExpression into global/local name (#899)
- Loading branch information
Showing
10 changed files
with
99 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Split getClientNewExpression into global/local name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
src/transforms/v2-to-v3/utils/getClientNewExpressionFromGlobalName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { NewExpression } from "jscodeshift"; | ||
|
||
export const getClientNewExpressionFromGlobalName = ( | ||
v2GlobalName: string, | ||
v2ClientName?: string | ||
): NewExpression => { | ||
if (v2ClientName) { | ||
// Support for DynamoDB.DocumentClient | ||
const [clientName, subClientName] = v2ClientName.split("."); | ||
|
||
if (subClientName) { | ||
return { | ||
type: "NewExpression", | ||
callee: { | ||
type: "MemberExpression", | ||
object: { | ||
type: "MemberExpression", | ||
object: { type: "Identifier", name: v2GlobalName }, | ||
property: { type: "Identifier", name: clientName }, | ||
}, | ||
property: { type: "Identifier", name: subClientName }, | ||
}, | ||
} as NewExpression; | ||
} | ||
|
||
return { | ||
type: "NewExpression", | ||
callee: { | ||
object: { type: "Identifier", name: v2GlobalName }, | ||
property: { type: "Identifier", name: clientName }, | ||
}, | ||
} as NewExpression; | ||
} | ||
|
||
return { | ||
type: "NewExpression", | ||
callee: { | ||
object: { type: "Identifier", name: v2GlobalName }, | ||
property: { type: "Identifier" }, | ||
}, | ||
} as NewExpression; | ||
}; |
21 changes: 21 additions & 0 deletions
21
src/transforms/v2-to-v3/utils/getClientNewExpressionFromLocalName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { NewExpression } from "jscodeshift"; | ||
|
||
export const getClientNewExpressionFromLocalName = (v2ClientLocalName: string): NewExpression => { | ||
// Support for DynamoDB.DocumentClient | ||
const [clientName, subClientName] = v2ClientLocalName.split("."); | ||
|
||
if (subClientName) { | ||
return { | ||
type: "NewExpression", | ||
callee: { | ||
object: { type: "Identifier", name: clientName }, | ||
property: { type: "Identifier", name: subClientName }, | ||
}, | ||
} as NewExpression; | ||
} | ||
|
||
return { | ||
type: "NewExpression", | ||
callee: { type: "Identifier", name: clientName }, | ||
} as NewExpression; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters