aws-sdk-js-codemod
Version:
Collection of codemod scripts that help update AWS SDK for JavaScript APIs
19 lines (18 loc) • 936 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceS3CreatePresignedPostApi = void 0;
const getClientApiCallExpression_1 = require("./getClientApiCallExpression");
// Updates `s3.createPresignedPost(params)` API with `await createPresignedPost(s3, params)` API.
const replaceS3CreatePresignedPostApi = (j, source, clientIdentifiers) => {
for (const clientId of clientIdentifiers) {
source
.find(j.CallExpression, (0, getClientApiCallExpression_1.getClientApiCallExpression)(clientId, "createPresignedPost"))
.replaceWith((callExpression) => j.awaitExpression.from({
argument: j.callExpression.from({
callee: j.identifier("createPresignedPost"),
arguments: [clientId, callExpression.node.arguments[0]],
}),
}));
}
};
exports.replaceS3CreatePresignedPostApi = replaceS3CreatePresignedPostApi;