Skip to content

feat: Add Jmespath expression function in frontend - #19028

Merged
TomasEng merged 54 commits into
mainfrom
add-jmespath-function
Jun 18, 2026
Merged

feat: Add Jmespath expression function in frontend#19028
TomasEng merged 54 commits into
mainfrom
add-jmespath-function

Conversation

@TomasEng

@TomasEng TomasEng commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Important

This pull request is stacked upon #18982, which should be merged first.

Description

This pull request adds support for Jmespath queries in our expression language. This includes a new dependnecy; Jmespath JS.

This also includes a new function evaluator class; JmespathFunctionEvaluator. Since it follows the same pattern as ObjectFunctionEvaluator, I have also added an abstract class that both of them extend and moved them into a separate folder. In the future, we may consider refactoring more of the functions the same way in order to make expression-functions.ts easier to navigate.

Here is the corresponding implementation in backend: Altinn/app-lib-dotnet#1790

Verification

Summary by CodeRabbit

  • New Features
    • Introduced JMESPath query expressions to the expression system. Users can now perform advanced data querying and transformation using standard JMESPath syntax, including filtering, projecting data across lists, selecting properties, and evaluating built-in functions on complex data structures.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fad7bb82-889d-458a-9345-f62fee4508bc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds JMESPath expression function support to the expression evaluator system. It introduces a base evaluator class for standardised error handling, implements a JMESPath-specific evaluator, defines the schema contract, integrates the new function into the expression registry, refactors an existing evaluator to use the new base class, and includes comprehensive test fixtures.

Changes

JMESPath Expression Function Implementation

Layer / File(s) Summary
Validation and base evaluator infrastructure
src/App/frontend/src/features/expressions/validation.ts, src/App/frontend/src/features/expressions/function-evaluators/FunctionEvaluator.ts
Adds assertValidValue() assertion helper to enforce runtime validation of expression values, and introduces abstract FunctionEvaluator<Arguments, ReturnValue> base class that centralises evaluation context, argument storage, and exception handling via throwRuntimeException() method.
Validation assertion tests
src/App/frontend/src/features/expressions/validation.test.ts
Test suite for assertValidValue covering rejection of invalid types (BigInt) and acceptance of valid values (numbers and other primitives).
Expression schema definition
src/App/frontend/schemas/json/layout/expression.schema.v1.json
Adds func-jmespath JSON schema definition specifying the array-form expression ["jmespath", <data>, <query>] with exactly two parameters, and registers it in the definitions.any.anyOf union to enable schema validation.
JMESPath evaluator implementation
src/App/frontend/package.json, src/App/frontend/src/features/expressions/function-evaluators/JmespathFunctionEvaluator.ts
Adds jmespath v0.16.0 runtime dependency and implements JmespathFunctionEvaluator that executes JMESPath queries via jmespath.search(), validates results with assertValidValue, and propagates errors using the base class exception mechanism with type checking for the query parameter.
Expression function registration and wiring
src/App/frontend/src/features/expressions/expression-functions.ts
Registers the jmespath function in ExprFunctionDefinitions with (Any, String) parameters and Any return type, updates imports to reference JmespathFunctionEvaluator, and implements the runtime instantiation in ExprFunctionImplementations.
ObjectFunctionEvaluator base class migration
src/App/frontend/src/features/expressions/function-evaluators/ObjectFunctionEvaluator.ts
Refactors ObjectFunctionEvaluator to extend FunctionEvaluator<ValidValue[], ValidObject> base class, replacing private field storage with protected getters, and replacing direct ExprRuntimeError construction with throwRuntimeException() helper calls whilst preserving key validation and even/odd argument filtering logic.
JMESPath test fixture
src/App/frontend/src/features/expressions/shared-tests/functions/jmespath/jmespath.json
Comprehensive test fixture covering JMESPath operations: property selection, object and list returns, list projections, filtering, literal expressions, built-in functions (abs), and error cases validating expected exception messages for invalid queries, missing arguments, and type mismatches.

Sequence Diagram

sequenceDiagram
  participant ExprFunction as Expression Function
  participant Evaluator as JmespathFunctionEvaluator
  participant JMESPath as jmespath.search()
  participant Validation as assertValidValue
  ExprFunction->>Evaluator: new(context, [data, query])
  Evaluator->>JMESPath: search(data, query)
  JMESPath-->>Evaluator: result
  Evaluator->>Validation: assertValidValue(result)
  Validation-->>Evaluator: validated
  Evaluator-->>ExprFunction: return ValidValue
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

frontend, squad/data

Suggested reviewers

  • ivarne
  • olavsorl

🐰 A query language hops into the system,
JMESPath expressions now we can list 'em,
Base classes shared, no more duplication,
Validation firm, safe computation!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding JMESPath expression function support to the frontend.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description adequately covers the changes, includes relevant context about dependencies and architectural decisions, and verifies all required checklist items.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-jmespath-function

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added skip-releasenotes Issues that do not make sense to list in our release notes kind/dependencies Used for issues or pull requests that are dependency updates labels Jun 2, 2026
@TomasEng
TomasEng requested a review from olemartinorg June 16, 2026 14:03
Base automatically changed from support-objects-in-expressions to main June 18, 2026 12:57
@TomasEng
TomasEng merged commit 6dcca67 into main Jun 18, 2026
26 of 27 checks passed
@TomasEng
TomasEng deleted the add-jmespath-function branch June 18, 2026 19:06
@github-project-automation github-project-automation Bot moved this from 🔎 In review to ✅ Done in Team Altinn Studio Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend kind/dependencies Used for issues or pull requests that are dependency updates skip-releasenotes Issues that do not make sense to list in our release notes squad/data Issues that belongs to the named squad.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants