feat: register $first/$last JSONata functions in moderator #377
Reference in New Issue
Block a user
Delete Branch "feat/376-first-last-jsonata"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Register
$first(role)and$last(role)custom functions in the JSONata evaluator for workflow conditions.Why
steps[-1].output.statusis verbose and imprecise —steps[-1]may not be the role you care about in bounce-back scenarios, and.outputis always the frontmatter wrapper.$last('planner').statussays exactly what you mean.Changes
findByRole()helper + register$first/$lastviaexpr.registerFunction()$last, added 3 new tests ($last, $first, unmatched role)$last$lastAPI
Ref
Fixes #376
Register custom $first(role) and $last(role) functions in the JSONata evaluator. These search the steps array and return the matching role's frontmatter (output) directly, replacing verbose steps[-1].output.x expressions with semantic $last('role').field syntax. - workflow-moderator: register functions via expr.registerFunction() - Updated all condition expressions in .workflows/ and examples/ - Added tests for $last, $first, and unmatched role (undefined) Fixes #376LGTM ✅
findByRole实现简洁,$last/$first解决了 bounce-back 场景下steps[-1]语义不精确的问题。测试覆盖到位($last、$first、unmatched role)。— 小墨 🖊️