fix: Adjust info.json files to work with formattedData field
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
6a8ec97c31
commit
e73f33f3db
@@ -41,12 +41,19 @@ class Processor {
|
||||
key,
|
||||
type,
|
||||
parameters: rawParameters = {},
|
||||
id
|
||||
id,
|
||||
} = step;
|
||||
const isTrigger = type === 'trigger';
|
||||
const AppClass = (await import(`../apps/${appKey}`)).default;
|
||||
const computedParameters = Processor.computeParameters(rawParameters, priorExecutionSteps);
|
||||
const appInstance = new AppClass(appData, connection.data, computedParameters);
|
||||
const computedParameters = Processor.computeParameters(
|
||||
rawParameters,
|
||||
priorExecutionSteps
|
||||
);
|
||||
const appInstance = new AppClass(
|
||||
appData,
|
||||
connection.formattedData,
|
||||
computedParameters
|
||||
);
|
||||
const commands = isTrigger ? appInstance.triggers : appInstance.actions;
|
||||
const command = commands[key];
|
||||
fetchedData = await command.run();
|
||||
@@ -70,30 +77,35 @@ class Processor {
|
||||
return fetchedData;
|
||||
}
|
||||
|
||||
static computeParameters(parameters: Step["parameters"], executionSteps: ExecutionSteps): Step["parameters"] {
|
||||
static computeParameters(
|
||||
parameters: Step['parameters'],
|
||||
executionSteps: ExecutionSteps
|
||||
): Step['parameters'] {
|
||||
const entries = Object.entries(parameters);
|
||||
return entries.reduce((result, [key, value]: [string, string]) => {
|
||||
const parts = value.split(Processor.variableRegExp);
|
||||
|
||||
const computedValue = parts.map((part: string) => {
|
||||
const isVariable = part.match(Processor.variableRegExp);
|
||||
if (isVariable) {
|
||||
const stepIdAndKeyPath = part.replace(/{{step.|}}/g, '') as string;
|
||||
const [stepId, ...keyPaths] = stepIdAndKeyPath.split('.');
|
||||
const keyPath = keyPaths.join('.');
|
||||
const executionStep = executionSteps[stepId.toString() as string];
|
||||
const data = executionStep?.dataOut;
|
||||
const dataValue = get(data, keyPath);
|
||||
return dataValue;
|
||||
}
|
||||
const computedValue = parts
|
||||
.map((part: string) => {
|
||||
const isVariable = part.match(Processor.variableRegExp);
|
||||
if (isVariable) {
|
||||
const stepIdAndKeyPath = part.replace(/{{step.|}}/g, '') as string;
|
||||
const [stepId, ...keyPaths] = stepIdAndKeyPath.split('.');
|
||||
const keyPath = keyPaths.join('.');
|
||||
const executionStep = executionSteps[stepId.toString() as string];
|
||||
const data = executionStep?.dataOut;
|
||||
const dataValue = get(data, keyPath);
|
||||
return dataValue;
|
||||
}
|
||||
|
||||
return part;
|
||||
}).join('');
|
||||
return part;
|
||||
})
|
||||
.join('');
|
||||
|
||||
return {
|
||||
...result,
|
||||
[key]: computedValue,
|
||||
}
|
||||
};
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user