Skip to content

Refactor workflow resource handling and introduce new models for bett…#9982

Open
nishagii wants to merge 1 commit intowso2:masterfrom
nishagii:claim-rules-ui-support
Open

Refactor workflow resource handling and introduce new models for bett…#9982
nishagii wants to merge 1 commit intowso2:masterfrom
nishagii:claim-rules-ui-support

Conversation

@nishagii
Copy link
Copy Markdown
Contributor

This pull request introduces type safety improvements and better normalization for workflow resource data handling in the approval workflows feature. The main changes include the introduction of new workflow-scoped resource interfaces and types, refactoring of hooks and utility functions to use these types, and removal of unnecessary type assertions and explicit any usage.

Type system improvements:

  • Added new workflow-scoped interfaces and a union type (WorkflowResourceListResponse) in workflow-resources.ts to represent the possible resource list responses (roles, groups, applications, user stores) in a type-safe manner.
  • Updated the useGetWorkflowResources hook to use WorkflowResourceListResponse as the default data type, improving type safety for all consumers of the hook. [1] [2]

Refactoring and code cleanup:

  • Refactored component usage of useGetWorkflowResources (role-audience-value-selector.tsx, workflow-resource-autocomplete.tsx, workflow-resource-list-select.tsx) to remove unnecessary any types and type assertions, and to use the new workflow resource types. [1] [2] [3]
  • Updated the normalizeResourceResponse utility to accept the new union type and improved its logic for handling different resource response shapes, with more explicit type narrowing and comments. [1] [2] [3]

Dependency updates:

  • Updated imports in affected files to use the new workflow resource models and types. [1] [2] [3]

These changes collectively improve type safety, maintainability, and clarity when working with workflow-related resources in the admin approval workflows feature.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

Warning

Rate limit exceeded

@nishagii has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 57 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 57 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: b578693c-67b3-468c-b8e9-1eaf47bc72cf

📥 Commits

Reviewing files that changed from the base of the PR and between 6bc990c and 9d6408b.

📒 Files selected for processing (6)
  • features/admin.approval-workflows.v1/components/rules/role-audience-value-selector.tsx
  • features/admin.approval-workflows.v1/components/rules/workflow-resource-autocomplete.tsx
  • features/admin.approval-workflows.v1/components/rules/workflow-resource-list-select.tsx
  • features/admin.approval-workflows.v1/hooks/use-get-workflow-resources.ts
  • features/admin.approval-workflows.v1/models/workflow-resources.ts
  • features/admin.approval-workflows.v1/utils/resource-utils.ts
📝 Walkthrough

Walkthrough

The pull request introduces new workflow-scoped resource type definitions and updates the approval workflows module to use proper TypeScript typing instead of any types. A new models file defines workflow list response interfaces, the hook is updated with a specific default generic type, and components are refactored to use typed destructuring.

Changes

Cohort / File(s) Summary
Models Definition
features/admin.approval-workflows.v1/models/workflow-resources.ts
Added new exported interfaces (WorkflowRoleListInterface, WorkflowGroupListInterface, WorkflowApplicationListInterface, WorkflowUserStoreListItemInterface) and WorkflowResourceListResponse union type that extend existing resource list interfaces.
Hook and Utilities
features/admin.approval-workflows.v1/hooks/use-get-workflow-resources.ts, features/admin.approval-workflows.v1/utils/resource-utils.ts
Updated useGetWorkflowResources hook's generic default from unknown to WorkflowResourceListResponse. Updated normalizeResourceResponse function signature from (response: any) to (response: WorkflowResourceListResponse | undefined) with explicit type guards and casting.
Component Type Improvements
features/admin.approval-workflows.v1/components/rules/role-audience-value-selector.tsx, features/admin.approval-workflows.v1/components/rules/workflow-resource-autocomplete.tsx, features/admin.approval-workflows.v1/components/rules/workflow-resource-list-select.tsx
Replaced any typing with properly typed destructuring from useGetWorkflowResources hook, removing ESLint suppressions and enabling type-safe access to hook return values.

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 inconclusive)

Check name Status Explanation Resolution
Changeset Required ❌ Error The PR modifies 6 files in the features/admin.approval-workflows.v1/ directory, which requires a changeset file. No .changeset/*.md file (excluding README.md) was found in the PR changes. Create a changeset file in .changeset/ directory (e.g., .changeset/workflow-resources-typing.md) documenting the changes to the workflow resource handling feature.
Title check ❓ Inconclusive The title is truncated and incomplete, ending with 'bett…' which obscures the full meaning and makes it unclear what 'bett' refers to. Provide the complete, untruncated title that clearly describes the main change. Consider: 'Refactor workflow resource handling and introduce new models for better type safety.'
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description comprehensively explains the changes, types improvements, and refactoring involved, but the required checklist items are not addressed or marked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@nishagii nishagii force-pushed the claim-rules-ui-support branch from 6bc990c to 9d6408b Compare March 27, 2026 06:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
features/admin.approval-workflows.v1/models/workflow-resources.ts (1)

24-46: Remove redundant JSDoc blocks for self-explanatory model declarations.

These comments only restate the symbol names and make the models file noisier.

✂️ Proposed cleanup
-/**
- * Workflow-scoped role list response interface.
- */
 export interface WorkflowRoleListInterface extends RoleListInterface {}

-/**
- * Workflow-scoped group list response interface.
- */
 export interface WorkflowGroupListInterface extends GroupListInterface {}

-/**
- * Workflow-scoped application list response interface.
- */
 export interface WorkflowApplicationListInterface extends ApplicationListInterface {}

-/**
- * Workflow-scoped user store list item interface.
- */
 export interface WorkflowUserStoreListItemInterface extends UserStoreListItem {}

-/**
- * Union of all possible workflow resource list response types.
- */
 export type WorkflowResourceListResponse =
     | WorkflowRoleListInterface
     | WorkflowGroupListInterface
     | WorkflowApplicationListInterface
     | WorkflowUserStoreListItemInterface[];

As per coding guidelines, "Interfaces and type definitions should skip JSDoc if the name and properties are self-explanatory" and "Remove comments that restate code, provide verbose step-by-step narration, or state obvious descriptions".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@features/admin.approval-workflows.v1/models/workflow-resources.ts` around
lines 24 - 46, Remove the redundant JSDoc comment blocks that simply restate
symbol names in this file: delete the comment lines above
WorkflowRoleListInterface, WorkflowGroupListInterface,
WorkflowApplicationListInterface, WorkflowUserStoreListItemInterface and the
final "Union of all possible workflow resource list response types." comment so
the file contains only the interface declarations (WorkflowRoleListInterface,
WorkflowGroupListInterface, WorkflowApplicationListInterface,
WorkflowUserStoreListItemInterface) without self-explanatory JSDoc noise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@features/admin.approval-workflows.v1/models/workflow-resources.ts`:
- Around line 24-46: Remove the redundant JSDoc comment blocks that simply
restate symbol names in this file: delete the comment lines above
WorkflowRoleListInterface, WorkflowGroupListInterface,
WorkflowApplicationListInterface, WorkflowUserStoreListItemInterface and the
final "Union of all possible workflow resource list response types." comment so
the file contains only the interface declarations (WorkflowRoleListInterface,
WorkflowGroupListInterface, WorkflowApplicationListInterface,
WorkflowUserStoreListItemInterface) without self-explanatory JSDoc noise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 21b10b57-c126-4508-9876-9e4db4459ca3

📥 Commits

Reviewing files that changed from the base of the PR and between 4bdde24 and 6bc990c.

📒 Files selected for processing (6)
  • features/admin.approval-workflows.v1/components/rules/role-audience-value-selector.tsx
  • features/admin.approval-workflows.v1/components/rules/workflow-resource-autocomplete.tsx
  • features/admin.approval-workflows.v1/components/rules/workflow-resource-list-select.tsx
  • features/admin.approval-workflows.v1/hooks/use-get-workflow-resources.ts
  • features/admin.approval-workflows.v1/models/workflow-resources.ts
  • features/admin.approval-workflows.v1/utils/resource-utils.ts

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.01%. Comparing base (9062eba) to head (9d6408b).
⚠️ Report is 273 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9982   +/-   ##
=======================================
  Coverage   56.01%   56.01%           
=======================================
  Files          42       42           
  Lines        1023     1023           
  Branches      254      231   -23     
=======================================
  Hits          573      573           
  Misses        450      450           
Flag Coverage Δ
@wso2is/core 56.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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