powerplatform-review-tool
Version:
Evaluate Power Platform solution zip files based on best practice patterns
33 lines (32 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeclaredVariables = getDeclaredVariables;
exports.getVariablesUsedInVariableActions = getVariablesUsedInVariableActions;
function getDeclaredVariables(jsonContent) {
const actions = jsonContent?.properties?.definition?.actions || {};
const declaredVariables = [];
// Loop through each action in the actions object
Object.keys(actions).forEach((actionName) => {
const action = actions[actionName];
// Check if the action has inputs and variables
if (action.inputs?.variables) {
// Push the variables to the declaredVariables array
declaredVariables.push(...action.inputs.variables);
}
});
return declaredVariables;
}
function getVariablesUsedInVariableActions(jsonContent) {
const actions = jsonContent?.properties?.definition?.actions || {};
const usedVariables = new Set();
// Loop through each action in the actions object
Object.keys(actions).forEach((actionName) => {
const action = actions[actionName];
// Check if the action has inputs and name
if (action?.inputs?.name) {
// Add the variables to the usedVariables set
usedVariables.add(action.inputs.name);
}
});
return usedVariables;
}