Closed narekhovhannisyan closed 1 month ago
please post your thoughts on the solution to improve plugin developer experience as discussed in the planning call
const utils = require('@grnsft/if-core/utils/validations');
const {validate} = utils;
// This one should be in if-core, which will make if-core more reasonable
const PluginInterface = params => input => {
const {metadata, callback, validateInput, validateConfig, evaluateInput} =
params;
return {
metadata,
execute: () => {
const safeInput = validateInput(input);
const result = callback(safeInput);
return result;
},
};
};
const metadata = {
inputs: {},
outputs: {},
};
const callback = inputs => {
const result = inputs.map(input => (input['carbon-embodied'] = 1));
return result;
};
module.exports = PluginInterface({metadata, callback});
will integrate the inline arithmetic into this as well after merging #970
expecting the PR early next week
If-core part is here: https://github.com/Green-Software-Foundation/if-core/pull/25
What
As a developer, I want simple user experience while developing plugins. For that I need to less care about utility functions like mapConfigIfNeeded, mapOutputIfNeeded and so on. As a proposal for solution is to incapsulate mapConfigIfNeeded function in
validateConfig
(which is abstraction over out old validate function from if-core). mapInputIfNeeded can be incapsulated intovalidate
function.Why
Context
Prerequisites/resources
SoW (scope of work)
Acceptance criteria
Given (Setup): Describes the initial state of the system or the preconditions for a change.
When (Action): Describes the specific action or behavior that is being tested/changed.
Then (Assertion): Defines the expected outcome or behavior of the system after the action in the "When" step is performed.