|
1 |
| -import type { |
2 |
| - Collection, |
3 |
| - JSCodeshift, |
4 |
| - NewExpression, |
5 |
| - ObjectExpression, |
6 |
| - ObjectProperty, |
7 |
| - Property, |
8 |
| -} from "jscodeshift"; |
| 1 | +import type { Collection, JSCodeshift, NewExpression, ObjectExpression } from "jscodeshift"; |
9 | 2 |
|
10 |
| -import { OBJECT_PROPERTY_TYPE_LIST } from "../config"; |
11 | 3 | import type { ClientIdentifier } from "../types";
|
12 | 4 | import { getClientApiCallExpression } from "./getClientApiCallExpression";
|
13 | 5 | import { getCommandName } from "./getCommandName";
|
@@ -41,26 +33,26 @@ export const replaceS3GetSignedUrlApi = (
|
41 | 33 | if (params.type === "ObjectExpression") {
|
42 | 34 | // Check if params has property 'Expires' and add it to options.
|
43 | 35 | for (const property of params.properties) {
|
44 |
| - if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) continue; |
45 |
| - const propertyKey = (property as Property | ObjectProperty).key; |
46 |
| - const propertyValue = (property as Property | ObjectProperty).value; |
47 |
| - if (propertyKey.type === "Identifier") { |
48 |
| - const propertyKeyName = propertyKey.name; |
49 |
| - if (propertyKeyName === "Expires") { |
| 36 | + if (property.type !== "Property" && property.type !== "ObjectProperty") { |
| 37 | + continue; |
| 38 | + } |
| 39 | + if (property.key.type === "Identifier") { |
| 40 | + if (property.key.name === "Expires") { |
50 | 41 | // Add 'expiresIn' property to options.
|
51 | 42 | options.properties.push(
|
52 | 43 | j.objectProperty.from({
|
53 | 44 | key: j.identifier("expiresIn"),
|
54 |
| - value: propertyValue, |
| 45 | + value: property.value, |
55 | 46 | shorthand: true,
|
56 | 47 | })
|
57 | 48 | );
|
58 | 49 | // Remove 'Expires' property from params.
|
59 | 50 | params.properties = params.properties.filter((property) => {
|
60 |
| - if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) return true; |
61 |
| - const propertyKey = (property as Property | ObjectProperty).key; |
62 |
| - if (propertyKey.type !== "Identifier") return true; |
63 |
| - return propertyKey.name !== "Expires"; |
| 51 | + if (property.type !== "Property" && property.type !== "ObjectProperty") { |
| 52 | + return true; |
| 53 | + } |
| 54 | + if (property.key.type !== "Identifier") return true; |
| 55 | + return property.key.name !== "Expires"; |
64 | 56 | });
|
65 | 57 | }
|
66 | 58 | }
|
|
0 commit comments