@terraforge/terraform 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +21 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1966,6 +1966,23 @@ const formatAttributePath = (state) => {
|
|
|
1966
1966
|
});
|
|
1967
1967
|
});
|
|
1968
1968
|
};
|
|
1969
|
+
const getNestedValue = (obj, path) => {
|
|
1970
|
+
let current = obj;
|
|
1971
|
+
for (const key of path) {
|
|
1972
|
+
if (current === null || current === void 0) return current;
|
|
1973
|
+
if (Array.isArray(current)) current = current[key];
|
|
1974
|
+
else if (typeof current === "object") current = current[key];
|
|
1975
|
+
else return;
|
|
1976
|
+
}
|
|
1977
|
+
return current;
|
|
1978
|
+
};
|
|
1979
|
+
const filterRequiresReplace = (paths, priorState, proposedState) => {
|
|
1980
|
+
return paths.filter((path) => {
|
|
1981
|
+
const priorValue = getNestedValue(priorState, path);
|
|
1982
|
+
const proposedValue = getNestedValue(proposedState, path);
|
|
1983
|
+
return JSON.stringify(priorValue) !== JSON.stringify(proposedValue);
|
|
1984
|
+
});
|
|
1985
|
+
};
|
|
1969
1986
|
var IncorrectType = class extends TypeError {
|
|
1970
1987
|
constructor(type, path) {
|
|
1971
1988
|
super(`${path.join(".")} should be a ${type}`);
|
|
@@ -2018,7 +2035,7 @@ const formatInputState = (schema, state, includeSchemaFields = true, path = [])
|
|
|
2018
2035
|
throw new Error(`Unknown schema type: ${schema.type}`);
|
|
2019
2036
|
};
|
|
2020
2037
|
const formatOutputState = (schema, state, path = []) => {
|
|
2021
|
-
if (state === null) return;
|
|
2038
|
+
if (state === null) return null;
|
|
2022
2039
|
if (schema.type === "array") {
|
|
2023
2040
|
if (Array.isArray(state)) return state.map((item, i) => formatOutputState(schema.item, item, [...path, i]));
|
|
2024
2041
|
throw new IncorrectType(schema.type, path);
|
|
@@ -2050,7 +2067,7 @@ const formatOutputState = (schema, state, path = []) => {
|
|
|
2050
2067
|
object[camelCase(key)] = formatOutputState(prop, value, [...path, key]);
|
|
2051
2068
|
}
|
|
2052
2069
|
return object;
|
|
2053
|
-
} else return;
|
|
2070
|
+
} else return null;
|
|
2054
2071
|
throw new IncorrectType(schema.type, path);
|
|
2055
2072
|
}
|
|
2056
2073
|
return state;
|
|
@@ -2116,7 +2133,7 @@ const createPlugin5 = async ({ server, client }) => {
|
|
|
2116
2133
|
});
|
|
2117
2134
|
const plannedState = decodeDynamicValue(plan.plannedState);
|
|
2118
2135
|
return {
|
|
2119
|
-
requiresReplace: formatAttributePath(plan.requiresReplace),
|
|
2136
|
+
requiresReplace: filterRequiresReplace(formatAttributePath(plan.requiresReplace), preparedPriorState, preparedProposedState),
|
|
2120
2137
|
plannedState
|
|
2121
2138
|
};
|
|
2122
2139
|
},
|
|
@@ -2198,7 +2215,7 @@ const createPlugin6 = async ({ server, client }) => {
|
|
|
2198
2215
|
});
|
|
2199
2216
|
const plannedState = decodeDynamicValue(plan.plannedState);
|
|
2200
2217
|
return {
|
|
2201
|
-
requiresReplace: formatAttributePath(plan.requiresReplace),
|
|
2218
|
+
requiresReplace: filterRequiresReplace(formatAttributePath(plan.requiresReplace), preparedPriorState, preparedProposedState),
|
|
2202
2219
|
plannedState
|
|
2203
2220
|
};
|
|
2204
2221
|
},
|