Skip to content

AB#128968-use-user-context-fields#1224

Open
GhaziAlibi wants to merge 3 commits intonextfrom
AB#128968-use-user-context-fields
Open

AB#128968-use-user-context-fields#1224
GhaziAlibi wants to merge 3 commits intonextfrom
AB#128968-use-user-context-fields

Conversation

@GhaziAlibi
Copy link
Copy Markdown

@GhaziAlibi GhaziAlibi commented Apr 10, 2026

Description

Adds support for user contextual fields in calculated fields.

This updates the calculated field parser and aggregation pipeline to accept expressions such as {{user.country}} and resolve them from the logged-in user's attributes. Missing user attribute values now resolve to empty strings. The resource mutation logic was also updated so these direct user expressions can be saved safely as calculated fields.

Useful links

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (refactor or addition to existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Added a unit test for user contextual calculated fields
  • Tested {{user.country}} manually
  • Tested that empty user values return an empty string
  • Tested autocomplete in the UI

Screenshots

  • auto complete:
image
  • aggregetion view
image

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-backend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

More explanation

https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145

Copy link
Copy Markdown

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

Adds support for user contextual placeholders (e.g. {{user.country}}) in calculated fields by extending the expression parser and calculated-field aggregation pipeline to resolve values from the logged-in user’s attributes.

Changes:

  • Extend calculated field parsing to recognize user.* operators and return an Operator AST.
  • Thread context.user.attributes into calculated field pipeline generation and resolve missing attributes to empty strings.
  • Update resource mutation logic to safely persist direct (non-calc.*) expressions; add unit tests for the new behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tsconfig.json Adds Jest/Node types for TS compilation.
src/utils/schema/resolvers/Query/all.ts Passes user attributes into calculated-field pipeline builder.
src/utils/files/resourceExporter.ts Passes user attributes into calculated-field pipelines used for exports.
src/utils/context/getContextData.ts Passes user attributes into calculated-field pipelines used for context evaluation.
src/utils/aggregation/expressionFromString.ts Adds parsing support for {{user.*}} and returns an Operator instead of Operation.
src/utils/aggregation/buildCalculatedFieldPipeline.ts Resolves user operators during pipeline generation; supports direct (non-expression) placeholders.
src/schema/query/recordsAggregation.query.ts Passes user attributes into calculated-field pipeline builder for aggregations.
src/schema/mutation/editResource.mutation.ts Adjusts calculated field type inference to handle non-expression operators safely.
src/const/calculatedFields.ts Extends operator types to include user and allow null constants.
config/who-dev.js Changes dev config for Microsoft Graph usage.
tests/unit-tests/utils/aggregation/buildCalculatedFieldPipeline.spec.ts Adds unit tests for direct user placeholders and missing-attribute fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/aggregation/buildCalculatedFieldPipeline.ts
Comment thread src/utils/context/getContextData.ts
Comment thread config/who-dev.js Outdated
@GhaziAlibi GhaziAlibi changed the title feat: support user contextual fields in calculated fields AB#128968-use-user-context-fields Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants