Skip to content

refactor: Update API's for better integration with UI#1574

Merged
sujitaw merged 3 commits intomainfrom
refactor/changes_for_ecosystem_ui_of_studio
Mar 2, 2026
Merged

refactor: Update API's for better integration with UI#1574
sujitaw merged 3 commits intomainfrom
refactor/changes_for_ecosystem_ui_of_studio

Conversation

@sujitaw
Copy link
Contributor

@sujitaw sujitaw commented Feb 27, 2026

What

  • updated API's with required attributes
  • added search as per requirement
  • removed unnecessary data from the response

Summary by CodeRabbit

  • New Features

    • Added endpoint to check status of pending ecosystem creation invitations.
    • Added org-scoped endpoint to retrieve ecosystem members with richer response details.
  • Breaking Changes

    • The orgId query parameter is now required when fetching ecosystems (previously optional).
  • Improvements

    • Input validation tightened for invitation/status flows with clearer error messages.
  • Chores

    • Updated success message: "Ecosystem members fetched successfully".

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
@sujitaw sujitaw requested a review from shitrerohit February 27, 2026 06:10
@sujitaw sujitaw self-assigned this Feb 27, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Adds org-scoped ecosystem listing and an invitation-status check: makes orgId required on the API Gateway GET /ecosystem endpoint and routes it to a new getEcosystemOrgs flow; introduces GET /invitation/status guarded endpoint; adds service/repository methods and new/updated interfaces for ecosystem org/member responses.

Changes

Cohort / File(s) Summary
API Gateway Controller
apps/api-gateway/src/ecosystem/ecosystem.controller.ts
orgId ApiQuery made required and ParseUUIDPipe non-optional; replaced call to getEcosystems with getEcosystemOrgs(orgId, pageDetail); added guarded GET /invitation/statusgetCreateEcosystemInvitationStatus.
API Gateway Service
apps/api-gateway/src/ecosystem/ecosystem.service.ts
Added client methods getEcosystemOrgs(orgId, pageDetail) and getCreateEcosystemInvitationStatus(email, status) used by controller.
Ecosystem Interfaces
apps/ecosystem/interfaces/ecosystem.interfaces.ts
Made several fields optional (logoUrl, autoEndorsement, user); added organisation to invitations; added/removed fields across earlier shapes; introduced IGetEcosystemOrgs, IGetEcosystemOrgsResponse, and IFromattedGetAllOrgs.
Ecosystem Repository
apps/ecosystem/repositories/ecosystem.repository.ts
Added getEcosystemOrgs(orgId, pageDetail) with orgId filtering, search, sort, nested selections and pagination; added getCreateEcosystemInvitationStatus(email, status) to check invitation existence; updated query/select shapes and logging.
Ecosystem Service / Controller (internal)
apps/ecosystem/src/ecosystem.service.ts, apps/ecosystem/src/ecosystem.controller.ts
Added message-pattern endpoints get-ecosystem-orgs-by-orgId and get-ecosystem-created-status; service methods getEcosystemOrgs and getCreateEcosystemInvitationStatus(email, status) returning paginated responses / boolean.
Response Messages
libs/common/src/response-messages/index.ts
Changed success message key fetchOrgs from "Ecosystem orgs fetched successfully" → "Ecosystem members fetched successfully".

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant APIGateway as API Gateway
  participant EcoSvc as Ecosystem Service
  participant Repo as Ecosystem Repository

  Client->>APIGateway: GET /ecosystem?orgId={uuid}&page...
  APIGateway->>EcoSvc: getEcosystemOrgs(orgId, pageDetail)
  EcoSvc->>Repo: getEcosystemOrgs(orgId, pageDetail)
  Repo-->>EcoSvc: Paginated IGetEcosystemOrgs
  EcoSvc-->>APIGateway: formatted Paginated response
  APIGateway-->>Client: 200 OK (members list)

  Client->>APIGateway: GET /invitation/status (auth)
  APIGateway->>EcoSvc: getCreateEcosystemInvitationStatus(email, status)
  EcoSvc->>Repo: getCreateEcosystemInvitationStatus(email, status)
  Repo-->>EcoSvc: boolean
  EcoSvc-->>APIGateway: { status: boolean }
  APIGateway-->>Client: 200 OK (invitation status)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • shitrerohit
  • pranalidhanavade
  • RinkalBhojani

Poem

🐰 I hopped from gateway to service lane,
I counted members, chased invites by name,
orgId in paw, pagination neat,
status checked quick — no missing beat,
A joyful rabbit tails the API game.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references generic 'API' updates for 'better integration' without clearly identifying the specific changes, such as the new invitation status endpoint or ecosystem orgs retrieval functionality. Use a more specific title that highlights the main technical change, such as 'refactor: Add ecosystem invitation status endpoint and orgs retrieval' or 'refactor: Enhance ecosystem API with new endpoints for UI integration'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/changes_for_ecosystem_ui_of_studio

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.

Copy link

@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.

Actionable comments posted: 5

🤖 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/api-gateway/src/ecosystem/ecosystem.controller.ts`:
- Around line 472-474: Replace the generic throw new Error('Email not Found')
check for missing reqUser.email with a NestJS BadRequestException so the
controller returns a 400 instead of a 500; import BadRequestException from
`@nestjs/common` and change the throw to throw new BadRequestException('Email not
Found') in the method on EcosystemController where the reqUser.email presence is
validated, and add the BadRequestException to the file's imports if not already
present.

In `@apps/ecosystem/repositories/ecosystem.repository.ts`:
- Around line 866-878: The queries building Prisma.ecosystem_orgsWhereInput (the
whereClause variable) and the other similar blocks at the other occurrences must
explicitly exclude soft-deleted rows by adding deletedAt: null to the
appropriate where filters; update the whereClause (and the analogous where
inputs around the other reported locations) to include deletedAt: null for the
org record and any membership/ecosystem relation filters so Prisma will only
return non-deleted rows (e.g., add deletedAt: null alongside ecosystemId and
inside the membership/ecosystem role filters where applicable).
- Around line 875-877: Replace uses of the auth enum `EcosystemRoles` with the
DB-facing enum `OrgRoles` in repository role filters: update the `ecosystemRole:
{ name: EcosystemRoles.ECOSYSTEM_MEMBER }` checks (and the similar occurrences
around lines noted) to use `OrgRoles` instead (e.g., `ecosystemRole.name` should
be compared against `OrgRoles.*`). Locate these occurrences by searching for
`ecosystemRole` and `EcosystemRoles` within this repository file (and the
similar blocks at the other mentioned lines) and swap the enum reference so
repository queries filter against `OrgRoles`.
- Around line 1654-1663: In getCreateEcosystemInvitationStatus validate the
incoming email before running the Prisma lookup: if email is falsy or blank
return false immediately (or reject) to avoid Prisma evaluating a broad filter;
then only call this.prisma.ecosystem_invitations.findFirst(...) when email is a
non-empty string so the query (in getCreateEcosystemInvitationStatus) reliably
checks Invitation.ACCEPTED, invitedOrg/ecosystemId/deletedAt nulls for that
specific email.

In `@apps/ecosystem/src/ecosystem.service.ts`:
- Around line 909-910: The destructuring "const [leadData] =
item?.ecosystem?.ecosystemOrgs" can throw when ecosystemOrgs is undefined;
update this to safely handle missing data by either defaulting ecosystemOrgs to
an empty array before destructuring (use nullish-coalescing or an explicit
guard) or by directly accessing the first element via optional chaining (e.g.,
get ecosystemOrgs?.[0]) so that leadData becomes undefined instead of causing a
TypeError; modify the line that declares leadData and keep subsequent
ternary/null checks intact.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2158c and c4208fa.

📒 Files selected for processing (7)
  • apps/api-gateway/src/ecosystem/ecosystem.controller.ts
  • apps/api-gateway/src/ecosystem/ecosystem.service.ts
  • apps/ecosystem/interfaces/ecosystem.interfaces.ts
  • apps/ecosystem/repositories/ecosystem.repository.ts
  • apps/ecosystem/src/ecosystem.controller.ts
  • apps/ecosystem/src/ecosystem.service.ts
  • libs/common/src/response-messages/index.ts

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
Copy link

@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.

♻️ Duplicate comments (2)
apps/ecosystem/repositories/ecosystem.repository.ts (2)

1621-1624: ⚠️ Potential issue | 🟠 Major

Use OrgRoles for repository role filtering.

Line 1623 is a DB-facing role comparison; this should use OrgRoles, not EcosystemRoles.

🔧 Proposed fix
                 ecosystemOrgs: {
                   where: {
+                    deletedAt: null,
                     ecosystemRole: {
-                      name: EcosystemRoles.ECOSYSTEM_LEAD
+                      name: OrgRoles.ECOSYSTEM_LEAD
                     }
                   },

Based on learnings: In the credebl/platform codebase, OrgRoles enum is used for actual database role values (e.g., in repository queries checking ecosystemRole.name), while EcosystemRoles enum is used for authorization guards.

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

In `@apps/ecosystem/repositories/ecosystem.repository.ts` around lines 1621 -
1624, The DB-facing role comparison is using the authorization enum
EcosystemRoles; update the query to use the DB enum OrgRoles instead (replace
EcosystemRoles.ECOSYSTEM_LEAD with OrgRoles.ECOSYSTEM_LEAD in the where: {
ecosystemRole: { name: ... } } clause), and adjust imports in
ecosystem.repository.ts to import OrgRoles (and remove unused EcosystemRoles if
no longer referenced) so repository role filtering uses the correct DB enum.

1592-1603: ⚠️ Potential issue | 🟠 Major

Exclude soft-deleted rows in the new org-scoped ecosystem query.

This new whereClause path can still return archived membership/ecosystem records because it does not enforce deletedAt: null on both layers.

🔧 Proposed fix
       const whereClause: Prisma.ecosystem_orgsWhereInput = {
         orgId,
-        ...(pageDetail.search && {
-          ecosystem: {
-            is: {
-              name: {
-                contains: pageDetail.search,
-                mode: 'insensitive'
-              }
-            }
-          }
-        })
+        deletedAt: null,
+        ecosystem: {
+          is: {
+            deletedAt: null,
+            ...(pageDetail.search && {
+              name: {
+                contains: pageDetail.search,
+                mode: 'insensitive'
+              }
+            })
+          }
+        }
       };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ecosystem/repositories/ecosystem.repository.ts` around lines 1592 -
1603, The whereClause (Prisma.ecosystem_orgsWhereInput) can return soft-deleted
rows; update it to require deletedAt: null on the membership record and on the
related ecosystem record by adding deletedAt: null at the top-level whereClause
and inside ecosystem.is (alongside name.contains) so both the org-scoped
ecosystem_orgs row and the joined ecosystem row exclude archived entries.
🧹 Nitpick comments (2)
apps/api-gateway/src/ecosystem/ecosystem.controller.ts (1)

219-221: Align orgId typing with the required query contract.

orgId is required and UUID-validated, so keeping it optional and sending null is unnecessary.

🔧 Proposed refactor
-    orgId?: string
+    orgId: string
   ): Promise<Response> {
-    const ecosystems = await this.ecosystemService.getEcosystemOrgs(orgId ?? null, paginationDto);
+    const ecosystems = await this.ecosystemService.getEcosystemOrgs(orgId, paginationDto);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts` around lines 219 -
221, The orgId parameter on the controller method is declared optional and
passed as orgId ?? null to getEcosystemOrgs, but the query contract requires a
UUID and orgId is required; change the method signature to accept orgId: string
(remove the optional '?'), stop passing null and call
this.ecosystemService.getEcosystemOrgs(orgId, paginationDto), and update any
related validation/decorators on the controller method (e.g., `@Query` or DTO
usage) so the UUID validation and required constraint are enforced.
apps/ecosystem/src/ecosystem.service.ts (1)

915-915: Harden memberCount against partial/null payloads.

If ecosystem payload is partial, this can produce NaN. A defensive default keeps the response stable.

🔧 Proposed refactor
-        memberCount: item?.ecosystem?._count.ecosystemOrgs - 1,
+        memberCount: Math.max((item?.ecosystem?._count?.ecosystemOrgs ?? 0) - 1, 0),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ecosystem/src/ecosystem.service.ts` at line 915, The memberCount
calculation can produce NaN when parts of the payload are missing; update the
expression that computes memberCount (currently using
item?.ecosystem?._count.ecosystemOrgs - 1) to defensively read ecosystemOrgs via
optional chaining and a numeric default, then subtract 1 and clamp to a
non-negative integer; locate the memberCount assignment in ecosystem.service.ts
and replace the expression with a safe fallback (e.g., use
item?.ecosystem?._count?.ecosystemOrgs ?? 0, subtract 1, and Math.max(0, ...) to
avoid negative/NaN results).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/ecosystem/repositories/ecosystem.repository.ts`:
- Around line 1621-1624: The DB-facing role comparison is using the
authorization enum EcosystemRoles; update the query to use the DB enum OrgRoles
instead (replace EcosystemRoles.ECOSYSTEM_LEAD with OrgRoles.ECOSYSTEM_LEAD in
the where: { ecosystemRole: { name: ... } } clause), and adjust imports in
ecosystem.repository.ts to import OrgRoles (and remove unused EcosystemRoles if
no longer referenced) so repository role filtering uses the correct DB enum.
- Around line 1592-1603: The whereClause (Prisma.ecosystem_orgsWhereInput) can
return soft-deleted rows; update it to require deletedAt: null on the membership
record and on the related ecosystem record by adding deletedAt: null at the
top-level whereClause and inside ecosystem.is (alongside name.contains) so both
the org-scoped ecosystem_orgs row and the joined ecosystem row exclude archived
entries.

---

Nitpick comments:
In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts`:
- Around line 219-221: The orgId parameter on the controller method is declared
optional and passed as orgId ?? null to getEcosystemOrgs, but the query contract
requires a UUID and orgId is required; change the method signature to accept
orgId: string (remove the optional '?'), stop passing null and call
this.ecosystemService.getEcosystemOrgs(orgId, paginationDto), and update any
related validation/decorators on the controller method (e.g., `@Query` or DTO
usage) so the UUID validation and required constraint are enforced.

In `@apps/ecosystem/src/ecosystem.service.ts`:
- Line 915: The memberCount calculation can produce NaN when parts of the
payload are missing; update the expression that computes memberCount (currently
using item?.ecosystem?._count.ecosystemOrgs - 1) to defensively read
ecosystemOrgs via optional chaining and a numeric default, then subtract 1 and
clamp to a non-negative integer; locate the memberCount assignment in
ecosystem.service.ts and replace the expression with a safe fallback (e.g., use
item?.ecosystem?._count?.ecosystemOrgs ?? 0, subtract 1, and Math.max(0, ...) to
avoid negative/NaN results).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4208fa and d038948.

📒 Files selected for processing (3)
  • apps/api-gateway/src/ecosystem/ecosystem.controller.ts
  • apps/ecosystem/repositories/ecosystem.repository.ts
  • apps/ecosystem/src/ecosystem.service.ts

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2026

Copy link

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api-gateway/src/ecosystem/ecosystem.controller.ts (1)

208-228: ⚠️ Potential issue | 🟡 Minor

Inconsistency between required: true and optional parameter type.

Line 210 declares orgId as required, but line 226 types it as orgId?: string (optional). Additionally, line 228 uses orgId ?? null which is unnecessary if orgId is truly required. Align the API contract with the TypeScript type.

🔧 Proposed fix
   `@ApiQuery`({
     name: 'orgId',
     required: true,
     type: String
   })
   `@Roles`(OrgRoles.PLATFORM_ADMIN, OrgRoles.ECOSYSTEM_LEAD)
   async getEcosystems(
     `@User`() reqUser: user,
     `@Res`() res: Response,
     `@Query`() paginationDto: PaginationGetAllEcosystem,
     `@Query`(
       'orgId',
       new ParseUUIDPipe({
         exceptionFactory: (): Error => {
           throw new BadRequestException(ResponseMessages.ecosystem.error.invalidOrgId);
         }
       })
     )
-    orgId?: string
+    orgId: string
   ): Promise<Response> {
-    const ecosystems = await this.ecosystemService.getEcosystemOrgs(orgId ?? null, paginationDto);
+    const ecosystems = await this.ecosystemService.getEcosystemOrgs(orgId, paginationDto);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts` around lines 208 -
228, The API docs mark orgId as required but the handler types it optional and
passes orgId ?? null; update getEcosystems so the orgId parameter is
non-optional and consistent with `@ApiQuery`: remove the optional marker on the
orgId parameter (change orgId?: string to orgId: string), keep the ParseUUIDPipe
validation, and remove the fallback orgId ?? null when calling
this.ecosystemService.getEcosystemOrgs so you pass the validated orgId directly;
ensure any downstream method (getEcosystemOrgs) signature accepts a non-null
string or update that signature if needed.
♻️ Duplicate comments (3)
apps/ecosystem/repositories/ecosystem.repository.ts (2)

1595-1600: ⚠️ Potential issue | 🟠 Major

Use OrgRoles instead of EcosystemRoles in repository role filter.

This repository query filters by persisted role names; using the auth enum EcosystemRoles risks mismatched database filtering.

🔧 Proposed fix
                 ecosystemOrgs: {
                   where: {
+                    deletedAt: null,
                     ecosystemRole: {
-                      name: EcosystemRoles.ECOSYSTEM_LEAD
+                      name: OrgRoles.ECOSYSTEM_LEAD
                     }
                   },

Based on learnings: In the credebl/platform codebase, OrgRoles enum is used for actual database role values (e.g., in repository queries checking ecosystemRole.name), while EcosystemRoles enum is used for authorization guards to control API access.

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

In `@apps/ecosystem/repositories/ecosystem.repository.ts` around lines 1595 -
1600, The repository query currently filters organization roles using the
authorization enum EcosystemRoles; replace that with the persisted database enum
OrgRoles so the where clause compares ecosystemRole.name to
OrgRoles.ECOSYSTEM_LEAD (or the equivalent member) instead of EcosystemRoles,
updating the filter inside the ecosystemOrgs -> where -> ecosystemRole block to
reference OrgRoles to ensure the DB query uses actual stored role values.

1567-1579: ⚠️ Potential issue | 🟠 Major

Exclude soft-deleted records in getEcosystemOrgs query.

The whereClause is missing deletedAt: null, which could return soft-deleted ecosystem org records.

🔧 Proposed fix
       const whereClause: Prisma.ecosystem_orgsWhereInput = {
         orgId,
+        deletedAt: null,
         ...(pageDetail.search && {
           ecosystem: {
             is: {
+              deletedAt: null,
               name: {
                 contains: pageDetail.search,
                 mode: 'insensitive'
               }
             }
           }
         })
       };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ecosystem/repositories/ecosystem.repository.ts` around lines 1567 -
1579, The whereClause in getEcosystemOrgs (Prisma.ecosystem_orgsWhereInput) is
missing a filter to exclude soft-deleted records; update the whereClause (the
variable named whereClause used in getEcosystemOrgs) to include deletedAt: null
at the appropriate level so only non-deleted ecosystem_orgs are returned while
preserving the existing orgId and pageDetail.search ecosystem.name contains
filter.
apps/ecosystem/src/ecosystem.service.ts (1)

892-915: ⚠️ Potential issue | 🟡 Minor

Guard against undefined _count to prevent NaN in memberCount.

If item?.ecosystem?._count is undefined, the subtraction at line 904 produces NaN. The destructuring fix at line 898 is correct.

🛡️ Proposed fix
       return {
         id: item?.ecosystem?.id,
         name: item?.ecosystem?.name,
         description: item?.ecosystem?.description,
-        memberCount: item?.ecosystem?._count.ecosystemOrgs - 1,
+        memberCount: (item?.ecosystem?._count?.ecosystemOrgs ?? 1) - 1,
         role: item?.ecosystemRole?.name,
         leadOrg: leadData
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ecosystem/src/ecosystem.service.ts` around lines 892 - 915, In
getEcosystemOrgs, the mapping computes memberCount using
item?.ecosystem?._count.ecosystemOrgs - 1 which yields NaN when _count is
undefined; change it to safely read the nested count (use
item?.ecosystem?._count?.ecosystemOrgs ?? 0), then compute memberCount as
Math.max(0, count - 1) to avoid negative or NaN results. Update the memberCount
computation inside the data.map in getEcosystemOrgs so it references the guarded
count variable before subtracting.
🧹 Nitpick comments (2)
apps/ecosystem/interfaces/ecosystem.interfaces.ts (1)

172-181: Typo in interface name: IFromattedGetAllOrgs should be IFormattedGetAllOrgs.

The interface name has a typo ("Fromatted" instead of "Formatted"). Consider renaming for consistency and readability.

✏️ Proposed fix
-export interface IFromattedGetAllOrgs {
+export interface IFormattedGetAllOrgs {
   id: string;
   email: string | null;
   status: string;
   createDateTime: Date;
   organisation: string | null;
   orgId: string;
   ecosystemName: string;
   ecosystemId: string;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ecosystem/interfaces/ecosystem.interfaces.ts` around lines 172 - 181,
Rename the malformed interface IFromattedGetAllOrgs to IFormattedGetAllOrgs
across the codebase: update the declaration in ecosystem.interfaces.ts and any
imports/usages (e.g., type annotations, exports) that reference
IFromattedGetAllOrgs so they use the corrected name IFormattedGetAllOrgs to
maintain consistency and avoid compile/type errors.
apps/api-gateway/src/ecosystem/ecosystem.controller.ts (1)

117-124: Linebreak in arrow function triggers ESLint warning.

The static analysis indicates an implicit-arrow-linebreak issue. Consider inlining or restructuring.

✨ Proposed fix
     `@Query`(
       'status',
       new ParseEnumPipe(Invitation, {
-        exceptionFactory: () =>
-          new BadRequestException(`Status must be one of: ${[Invitation.REJECTED, Invitation.ACCEPTED].join(', ')}`)
+        exceptionFactory: () => new BadRequestException(`Status must be one of: ${[Invitation.REJECTED, Invitation.ACCEPTED].join(', ')}`)
       })
     )
     status: Invitation
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts` around lines 117 -
124, The implicit-arrow-linebreak ESLint warning comes from the multi-line
exceptionFactory arrow in the ParseEnumPipe options; change the exceptionFactory
to a single-line arrow or a named function to remove the line break. Locate the
ParseEnumPipe usage in the decorator for the status parameter (symbols:
ParseEnumPipe, Invitation, exceptionFactory, BadRequestException, status) and
replace the multi-line exceptionFactory with a single-line expression (or
extract a const/function that returns new BadRequestException(...)) so the arrow
body is not split across lines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts`:
- Around line 208-228: The API docs mark orgId as required but the handler types
it optional and passes orgId ?? null; update getEcosystems so the orgId
parameter is non-optional and consistent with `@ApiQuery`: remove the optional
marker on the orgId parameter (change orgId?: string to orgId: string), keep the
ParseUUIDPipe validation, and remove the fallback orgId ?? null when calling
this.ecosystemService.getEcosystemOrgs so you pass the validated orgId directly;
ensure any downstream method (getEcosystemOrgs) signature accepts a non-null
string or update that signature if needed.

---

Duplicate comments:
In `@apps/ecosystem/repositories/ecosystem.repository.ts`:
- Around line 1595-1600: The repository query currently filters organization
roles using the authorization enum EcosystemRoles; replace that with the
persisted database enum OrgRoles so the where clause compares ecosystemRole.name
to OrgRoles.ECOSYSTEM_LEAD (or the equivalent member) instead of EcosystemRoles,
updating the filter inside the ecosystemOrgs -> where -> ecosystemRole block to
reference OrgRoles to ensure the DB query uses actual stored role values.
- Around line 1567-1579: The whereClause in getEcosystemOrgs
(Prisma.ecosystem_orgsWhereInput) is missing a filter to exclude soft-deleted
records; update the whereClause (the variable named whereClause used in
getEcosystemOrgs) to include deletedAt: null at the appropriate level so only
non-deleted ecosystem_orgs are returned while preserving the existing orgId and
pageDetail.search ecosystem.name contains filter.

In `@apps/ecosystem/src/ecosystem.service.ts`:
- Around line 892-915: In getEcosystemOrgs, the mapping computes memberCount
using item?.ecosystem?._count.ecosystemOrgs - 1 which yields NaN when _count is
undefined; change it to safely read the nested count (use
item?.ecosystem?._count?.ecosystemOrgs ?? 0), then compute memberCount as
Math.max(0, count - 1) to avoid negative or NaN results. Update the memberCount
computation inside the data.map in getEcosystemOrgs so it references the guarded
count variable before subtracting.

---

Nitpick comments:
In `@apps/api-gateway/src/ecosystem/ecosystem.controller.ts`:
- Around line 117-124: The implicit-arrow-linebreak ESLint warning comes from
the multi-line exceptionFactory arrow in the ParseEnumPipe options; change the
exceptionFactory to a single-line arrow or a named function to remove the line
break. Locate the ParseEnumPipe usage in the decorator for the status parameter
(symbols: ParseEnumPipe, Invitation, exceptionFactory, BadRequestException,
status) and replace the multi-line exceptionFactory with a single-line
expression (or extract a const/function that returns new
BadRequestException(...)) so the arrow body is not split across lines.

In `@apps/ecosystem/interfaces/ecosystem.interfaces.ts`:
- Around line 172-181: Rename the malformed interface IFromattedGetAllOrgs to
IFormattedGetAllOrgs across the codebase: update the declaration in
ecosystem.interfaces.ts and any imports/usages (e.g., type annotations, exports)
that reference IFromattedGetAllOrgs so they use the corrected name
IFormattedGetAllOrgs to maintain consistency and avoid compile/type errors.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d038948 and e0c9be3.

📒 Files selected for processing (6)
  • apps/api-gateway/src/ecosystem/ecosystem.controller.ts
  • apps/api-gateway/src/ecosystem/ecosystem.service.ts
  • apps/ecosystem/interfaces/ecosystem.interfaces.ts
  • apps/ecosystem/repositories/ecosystem.repository.ts
  • apps/ecosystem/src/ecosystem.controller.ts
  • apps/ecosystem/src/ecosystem.service.ts

@sujitaw sujitaw requested a review from shitrerohit March 2, 2026 05:05
@sujitaw sujitaw merged commit 53fb08d into main Mar 2, 2026
8 checks passed
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