aws-sdk-js-codemod
Version:
Collection of codemod scripts that help update AWS SDK for JavaScript APIs
39 lines (38 loc) • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getClientNewExpressionFromGlobalName = void 0;
const getClientNewExpressionFromGlobalName = (v2GlobalName, v2ClientName) => {
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 },
},
};
}
return {
type: "NewExpression",
callee: {
object: { type: "Identifier", name: v2GlobalName },
property: { type: "Identifier", name: clientName },
},
};
}
return {
type: "NewExpression",
callee: {
object: { type: "Identifier", name: v2GlobalName },
property: { type: "Identifier" },
},
};
};
exports.getClientNewExpressionFromGlobalName = getClientNewExpressionFromGlobalName;