[Customer Portal][Backend] Add change request details endpoint and support soft delete in deployed product update - #276
Conversation
…ed product update
📝 WalkthroughWalkthroughAdds a GET change-request-by-id endpoint, new ChangeRequestResponse types and mappings, date/product field changes, deployed-product update payload validation, and entity-level fetch logic. Several new functions and types appear duplicated in their respective files. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Service as Service API
participant Auth as Auth Handler
participant Entity as Entity Module
participant Remote as Remote API
Client->>Service: GET /change-requests/[id]
Service->>Auth: Authenticate user
alt Authentication Failed
Auth-->>Service: 401 Unauthorized
Service-->>Client: 401 Unauthorized
else Authenticated
Auth-->>Service: User context
Service->>Entity: getChangeRequestDetails(idToken, id)
Entity->>Remote: GET /change-requests/[id]
alt Request Successful
Remote-->>Entity: ChangeRequestResponse
Entity-->>Service: ChangeRequestResponse
Service->>Service: mapChangeRequestResponse()
Service-->>Client: 200 ChangeRequestResponse
else Not Found
Remote-->>Entity: 404 Not Found
Entity-->>Service: Error
Service-->>Client: 404 Not Found
else Forbidden
Remote-->>Entity: 403 Forbidden
Entity-->>Service: Error
Service-->>Client: 403 Forbidden
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/customer-portal/backend/modules/entity/utils.bal`:
- Around line 233-248: The validator
validateDeployedProductUpdatePayload(DeployedProductUpdatePayload) is currently
isolated and never invoked; make it public (remove isolated and mark public) and
call it from the deployed-product PATCH handler immediately after parsing the
request payload; if the function returns a non-empty string, return an
http:BadRequest with that message (matching the pattern used by other endpoints
like deployment/case/call-request) so the request is rejected when validation
fails.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/customer-portal/backend/modules/entity/entity.balapps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/entity/utils.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
apps/customer-portal/backend/utils.bal (1)
714-756: Consider extracting shared change-request field mapping.
mapChangeRequestResponse()andmapChangeRequestSearchResponse()now duplicate a large common mapping block, which increases drift risk over time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/customer-portal/backend/modules/entity/types.bal`:
- Line 269: item.id is declared as int|string so the direct comparisons at the
filter (the unsafe expression comparing item.id != entity:caseStateIds.closed &&
item.id != entity:caseStateIds.solutionProposed) can fail when item.id is a
string; normalize item.id to a consistent type before comparing (e.g., call
item.id.toString() or cast the constants to strings) so both comparisons use the
same representation; update the condition that references item.id, and mirror
the normalization approach used later in the select clause (where
item.id.toString() is used) to ensure filtering correctly excludes
caseStateIds.closed and caseStateIds.solutionProposed.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/entity/utils.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/customer-portal/backend/modules/entity/utils.bal
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/customer-portal/backend/utils.bal (1)
715-757: Extract shared change-request mapping to reduce drift risk.
mapChangeRequestResponseduplicates most of the reference/date/state/impact mapping already present inmapChangeRequestSearchResponse. A small shared helper for common fields would reduce future divergence bugs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/customer-portal/backend/utils.bal` around lines 715 - 757, mapChangeRequestResponse duplicates much of the reference/date/state/impact mapping found in mapChangeRequestSearchResponse; extract the shared mapping into a small helper (e.g., mapCommonChangeRequestFields or buildChangeRequestBase) that accepts a ChangeRequestResponse (or its common subset) and returns the common mapped fields (project, case, deployment, deployedProduct, product, state, impact, id/number/title/dates/duration/flags/etc.); then have mapChangeRequestResponse and mapChangeRequestSearchResponse call that helper and merge any function-specific fields (description, justification, etc.) to avoid future drift and keep naming consistent with the existing symbols mapChangeRequestResponse and mapChangeRequestSearchResponse.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/customer-portal/backend/utils.bal`:
- Around line 715-757: mapChangeRequestResponse duplicates much of the
reference/date/state/impact mapping found in mapChangeRequestSearchResponse;
extract the shared mapping into a small helper (e.g.,
mapCommonChangeRequestFields or buildChangeRequestBase) that accepts a
ChangeRequestResponse (or its common subset) and returns the common mapped
fields (project, case, deployment, deployedProduct, product, state, impact,
id/number/title/dates/duration/flags/etc.); then have mapChangeRequestResponse
and mapChangeRequestSearchResponse call that helper and merge any
function-specific fields (description, justification, etc.) to avoid future
drift and keep naming consistent with the existing symbols
mapChangeRequestResponse and mapChangeRequestSearchResponse.
4fad454
into
wso2-open-operations:customer-portal-milestone-1
Description
This PR introduces a new endpoint to retrieve change request details and enhances the deployed product update endpoint to support soft delete functionality.
Changes
1️⃣ Add Change Request Details Endpoint
Reason:
Detailed change request information was not previously exposed via API. This endpoint enables:
2️⃣ Support Soft Delete in Deployed Product Update
Reason:
Soft delete ensures:
Impact
Testing
Related PRs
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Other