mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
feat(core): Automatically convert Luxon Dates to string (#3266)
This commit is contained in:
parent
8a8feb11c8
commit
3fcee14bf5
|
@ -1386,6 +1386,36 @@ export function getNode(node: INode): INode {
|
||||||
return JSON.parse(JSON.stringify(node));
|
return JSON.parse(JSON.stringify(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up parameter data to make sure that only valid data gets returned
|
||||||
|
* INFO: Currently only converts Luxon Dates as we know for sure it will not be breaking
|
||||||
|
*/
|
||||||
|
function cleanupParameterData(
|
||||||
|
inputData: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
|
||||||
|
): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] {
|
||||||
|
if (inputData === null || inputData === undefined) {
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(inputData)) {
|
||||||
|
inputData.forEach((value) => cleanupParameterData(value));
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputData.constructor.name === 'DateTime') {
|
||||||
|
// Is a special luxon date so convert to string
|
||||||
|
return inputData.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof inputData === 'object') {
|
||||||
|
Object.keys(inputData).forEach((key) => {
|
||||||
|
inputData[key] = cleanupParameterData(inputData[key]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the requested resolved (all expressions replaced) node parameters.
|
* Returns the requested resolved (all expressions replaced) node parameters.
|
||||||
*
|
*
|
||||||
|
@ -1437,6 +1467,8 @@ export function getNodeParameter(
|
||||||
timezone,
|
timezone,
|
||||||
additionalKeys,
|
additionalKeys,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
returnData = cleanupParameterData(returnData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
e.message += ` [Error in parameter: "${parameterName}"]`;
|
e.message += ` [Error in parameter: "${parameterName}"]`;
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in a new issue