- Introduced compileWorkflowScripts function to parse and validate workflow scripts, supporting both linear and DAG execution modes. - Added runLinearSteps and runDagSteps functions for executing compiled workflows based on their structure. - Updated createRegistry function to utilize the new workflow compilation and execution logic. - Enhanced script sandbox with meta extraction and instantiation capabilities for better script management. - Improved API endpoints to return script metadata and handle errors more effectively. - Removed deprecated scripts and updated workflows to reflect new structure and functionality.
28 lines
818 B
JavaScript
28 lines
818 B
JavaScript
import jsonata from "jsonata";
|
|
|
|
function jsonataFn(ctx) {
|
|
log.info({ctx}, "jsonata: context")
|
|
log.info("jsonata: evaluating expression %s", ctx.config.expression);
|
|
const expression = jsonata(ctx.config.expression);
|
|
const result = expression.evaluate(ctx.data);
|
|
log.info({result}, "jsonata: expression result");
|
|
return result;
|
|
}
|
|
|
|
jsonataFn.meta = {
|
|
description: "Evaluate a JSONata expression against ctx.data and return the result as the next context",
|
|
config: {
|
|
expression: { type: "string", required: true, description: "JSONata expression" },
|
|
},
|
|
input: {},
|
|
output: {},
|
|
example: {
|
|
data: { title: "Hello", url: "https://example.com" },
|
|
config: {
|
|
expression: '{"data": {"title": title, "message": title, "attach": url}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
export default jsonataFn;
|