aws-sdk-js-codemod
Version:
Collection of codemod scripts that help update AWS SDK for JavaScript APIs
31 lines (30 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getS3SignedUrlApiNames = void 0;
const getS3SignedUrlApiNames = (j, source, clientIdentifiers) => {
const apiNames = new Set();
for (const clientId of clientIdentifiers) {
for (const apiName of ["getSignedUrl", "getSignedUrlPromise"]) {
source
.find(j.CallExpression, {
callee: {
type: "MemberExpression",
object: clientId,
property: { type: "Identifier", name: apiName },
},
})
.forEach((callExpression) => {
const callExpressionArg = callExpression.value.arguments[0];
if (callExpressionArg.type !== "Literal" && callExpressionArg.type !== "StringLiteral") {
return;
}
if (typeof callExpressionArg.value !== "string") {
return;
}
apiNames.add(callExpressionArg.value);
});
}
}
return [...apiNames].sort();
};
exports.getS3SignedUrlApiNames = getS3SignedUrlApiNames;