@@ -37,7 +37,6 @@ import { ResponseMessages } from '@credebl/common/response-messages';
3737import { Roles } from '../authz/decorators/roles.decorator' ;
3838import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto' ;
3939import { InviteMemberToEcosystemDto , UpdateEcosystemInvitationDto } from './dtos/send-ecosystem-invitation' ;
40- import { OrgRolesGuard } from '../authz/guards/org-roles.guard' ;
4140import { EcosystemRolesGuard } from '../authz/guards/ecosystem-roles.guard' ;
4241import { user } from '@prisma/client' ;
4342import { User } from '../authz/decorators/user.decorator' ;
@@ -52,10 +51,12 @@ import { GetAllIntentTemplatesResponseDto } from '../utilities/dtos/get-all-inte
5251import { GetAllIntentTemplatesDto } from '../utilities/dtos/get-all-intent-templates.dto' ;
5352import { GetIntentTemplateByIntentAndOrgDto } from '../utilities/dtos/get-intent-template-by-intent-and-org.dto' ;
5453import { CreateIntentTemplateDto , UpdateIntentTemplateDto } from '../utilities/dtos/intent-template.dto' ;
54+ import { EcosystemFeatureGuard } from '../authz/guards/ecosystem-feature-guard' ;
5555
5656@UseFilters ( CustomExceptionFilter )
5757@Controller ( 'ecosystem' )
5858@ApiTags ( 'ecosystem' )
59+ @UseGuards ( EcosystemFeatureGuard )
5960@ApiUnauthorizedResponse ( {
6061 description : 'Unauthorized' ,
6162 type : UnauthorizedErrorDto
@@ -198,20 +199,16 @@ export class EcosystemController {
198199 * Get all ecosystems (platform admin)
199200 * @returns All ecosystems from platform
200201 */
201- @Get ( )
202+ @UseGuards ( AuthGuard ( 'jwt' ) , EcosystemRolesGuard )
203+ @ApiBearerAuth ( )
204+ @Get ( '/all-ecosystem' )
202205 @ApiOperation ( {
203- summary : 'Get all ecosystems (platform admin)' ,
204- description : 'Fetch all ecosystems available on the platform'
205- } )
206- @ApiResponse ( {
207- status : HttpStatus . OK ,
208- description : 'Ecosystems fetched successfully'
206+ summary : 'Get ecosystems' ,
207+ description : 'Fetch ecosystems for Platform Admin or Ecosystem Lead'
209208 } )
210- @Roles ( OrgRoles . PLATFORM_ADMIN )
211- @UseGuards ( AuthGuard ( 'jwt' ) , OrgRolesGuard )
212- @ApiBearerAuth ( )
213- async getAllEcosystems ( @User ( ) reqUser : user , @Res ( ) res : Response ) : Promise < Response > {
214- const ecosystems = await this . ecosystemService . getAllEcosystems ( ) ;
209+ @Roles ( OrgRoles . PLATFORM_ADMIN , OrgRoles . ECOSYSTEM_LEAD )
210+ async getEcosystems ( @User ( ) reqUser : user , @Res ( ) res : Response ) : Promise < Response > {
211+ const ecosystems = await this . ecosystemService . getEcosystems ( reqUser . id ) ;
215212
216213 return res . status ( HttpStatus . OK ) . json ( {
217214 statusCode : HttpStatus . OK ,
@@ -800,7 +797,6 @@ export class EcosystemController {
800797
801798 return res . status ( HttpStatus . OK ) . json ( finalResponse ) ;
802799 }
803-
804800 /**
805801 * Delete intent
806802 * @param id Intent ID
@@ -820,12 +816,29 @@ export class EcosystemController {
820816 type : ApiResponseDto
821817 } )
822818 async deleteIntent (
823- @Param ( 'ecosystemId' ) ecosystemId : string ,
824- @Param ( 'intentId' ) intentId : string ,
825- @User ( ) user : IUserRequest ,
819+ @Param (
820+ 'ecosystemId' ,
821+ new ParseUUIDPipe ( {
822+ exceptionFactory : ( ) : Error => {
823+ throw new BadRequestException ( ResponseMessages . ecosystem . error . invalidFormatOfEcosystemId ) ;
824+ }
825+ } )
826+ )
827+ ecosystemId : string ,
828+ @Param (
829+ 'intentId' ,
830+ new ParseUUIDPipe ( {
831+ exceptionFactory : ( ) : Error => {
832+ throw new BadRequestException ( ResponseMessages . ecosystem . error . invalidFormatOfIntentId ) ;
833+ }
834+ } )
835+ )
836+ intentId : string ,
837+
838+ @User ( ) user : user ,
826839 @Res ( ) res : Response
827840 ) : Promise < Response > {
828- const intent = await this . ecosystemService . deleteIntent ( ecosystemId , intentId , user ) ;
841+ const intent = await this . ecosystemService . deleteIntent ( ecosystemId , intentId , user . id ) ;
829842
830843 return res . status ( HttpStatus . OK ) . json ( {
831844 statusCode : HttpStatus . OK ,
0 commit comments