Skip to content

Conversation

@andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Jul 31, 2025

  • Replaced the JSONPath with the jsonata lib to allow the filter and transformations that will be required once the new exceptions structure is in place.
  • Adapt the load-consolidate-data BPMN, and a few workflows that were using the JSONPath expression.

Important note about the expressions

Assuming the below JSON (array with a single item).

{ 
  "courseDetails": [
      {
          "courseCode": "code",
          "courseName": "name"
      }
  ]
}

Using the expression below

courseDetails.{
  "courseCode": courseCode
}

will produce the result as an object, not an array.

{
  "courseCode": "code"
}

To produce an array even when there is only one item, the expression should be as below.

courseDetails[].{
  "courseCode": courseCode
}

to produce

[
  {
    "courseCode": "code"
  }
]

Manual tests

  • Created a new 2025-26 full-time application including two parents (one self-declare and the other doesn't) and also an exception.
  • Created a change request to remove one of the parents.
  • Create a full-time application including dependents.
  • Created a 2025-26 part-time application.
  • Created a 2024-25 application and an appeal to add dependents.

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the JSONPath library with the JSONata library to enable more advanced filtering and transformations needed for the new exceptions structure. This change allows for more powerful data manipulation capabilities in workflow expressions.

Key changes:

  • Replace JSONPath with JSONata library in package dependencies
  • Update all workflow BPMN files to use JSONata syntax instead of JSONPath expressions
  • Refactor utility functions to use JSONata's asynchronous evaluation API

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sources/packages/backend/package.json Updates dependency from jsonpath to jsonata library
sources/packages/backend/apps/workers/src/utilities/jsonpath/jsonpath-utils.ts Removes old JSONPath utility functions
sources/packages/backend/apps/workers/src/utilities/json/json-utils.ts Adds new JSONata utility functions with async support
sources/packages/backend/apps/workers/src/utilities/index.ts Updates export to use new json-utils instead of jsonpath-utils
sources/packages/backend/apps/workers/src/controllers/supporting-user/supporting-user.controller.ts Updates to use JSONata syntax and async evaluation
sources/packages/backend/apps/workers/src/controllers/assessment/assessment.controller.ts Updates to use async filterObjectProperties
sources/packages/backend/workflow/src/workflow-definitions/supporting-user-information-request.bpmn Updates JSONPath expressions to JSONata syntax
sources/packages/backend/workflow/src/workflow-definitions/load-assessment-consolidated-data.bpmn Updates all JSONPath expressions to JSONata syntax
sources/packages/backend/workflow/src/workflow-definitions/assessment-gateway-v2.bpmn Updates JSONPath expression to JSONata syntax
sims.code-workspace Adds jsonata to spell check dictionary and reorganizes entries
Files not reviewed (1)
  • sources/packages/backend/package-lock.json: Language not supported

* where the values for each property are the values
* resulting from the jsonata expressions execution.
*/
export async function filterObjectProperties(
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function processes filters sequentially in a for-of loop. Consider using Promise.all() to evaluate all JSONata expressions in parallel for better performance when dealing with multiple filters.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expressions are expected to be evaluated synchronously.

@andrewsignori-aot andrewsignori-aot marked this pull request as ready for review July 31, 2025 20:58
@andrewsignori-aot andrewsignori-aot self-assigned this Jul 31, 2025
@andrewsignori-aot andrewsignori-aot added Camunda Workers Camunda Worflow Involves camunda workflow changes labels Jul 31, 2025
currentProgramYear = await db.programYear
.createQueryBuilder("py")
.where("NOW() BETWEEN py.startDate AND py.endDate")
.where("CURRENT_DATE BETWEEN py.startDate AND py.endDate")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails on the last day of a program year because it uses a date+time when executing the comparison between two date-only columns.
It would pass tomorrow 😄

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 21.65% ( 4093 / 18903 )
Methods: 9.67% ( 234 / 2419 )
Lines: 25.01% ( 3540 / 14155 )
Branches: 13.7% ( 319 / 2329 )

@sonarqubecloud
Copy link

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 73.53% ( 714 / 971 )
Methods: 72.57% ( 82 / 113 )
Lines: 75.81% ( 564 / 744 )
Branches: 59.65% ( 68 / 114 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 86.43% ( 1548 / 1791 )
Methods: 84.62% ( 176 / 208 )
Lines: 88.75% ( 1278 / 1440 )
Branches: 65.73% ( 94 / 143 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 73.79% ( 7269 / 9851 )
Methods: 71.51% ( 896 / 1253 )
Lines: 77.22% ( 5623 / 7282 )
Branches: 56.99% ( 750 / 1316 )

@dheepak-aot dheepak-aot self-requested a review July 31, 2025 23:19
Copy link
Collaborator

@sh16011993 sh16011993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @andrewsignori-aot 👍 Thanks for clarifying my questions.

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.35.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0" camunda:diagramRelationId="f874f098-96b6-491d-81ec-ecf7a0d8c67a">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.37.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0" camunda:diagramRelationId="f874f098-96b6-491d-81ec-ecf7a0d8c67a">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

hasNOAApproval,
);
const outputVariables = filterObjectProperties(
const outputVariables = await filterObjectProperties(
Copy link
Collaborator

@dheepak-aot dheepak-aot Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an e2e test for assessment consolidated data based on the JSON path expression. Not sure how it is passing.
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "$" at the beginning is compatible with the new framework. I can remove from this to avoid confusion in the future.

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work finding the better way to parse json data and thanks for the sync up. One minor observation on E2E tests.

@andrewsignori-aot andrewsignori-aot added this pull request to the merge queue Aug 1, 2025
Merged via the queue into main with commit 135e634 Aug 1, 2025
22 checks passed
@andrewsignori-aot andrewsignori-aot deleted the feature/#4941-approve-exceptions-once-json-lib-replacement branch August 1, 2025 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Camunda Worflow Involves camunda workflow changes Camunda Workers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants