Skip to content
1 change: 0 additions & 1 deletion .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ PROOF_REQ_CONN_LIMIT=10
MAX_ORG_LIMIT=10
FIDO_API_ENDPOINT=http://localhost:8000

IS_ECOSYSTEM_ENABLE=false
CONSOLE_LOG_FLAG=true # Enable or disable console ELK logs
ELK_LOG=false # ELK flag
LOG_LEVEL=debug # ELK log level
Expand Down
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ FILEUPLOAD_CACHE_TTL= //Provide file upload cache ttl
SESSIONS_LIMIT= //Provide limits of sessions
FIELD_UPLOAD_SIZE= //Provide field upload size

IS_ECOSYSTEM_ENABLE= //Set this flag to `true` to enable the ecosystem, or `false` to disable it.
CONSOLE_LOG_FLAG=true // Enable or disable console ELK logs
ELK_LOG=true // ELK flag
LOG_LEVEL=debug // ELK log level
Expand Down
101 changes: 63 additions & 38 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import {
BadRequestException,
Body,
ConflictException,
Controller,
Delete,
Get,
Expand All @@ -29,7 +28,7 @@ import {
import { ApiResponseDto } from '../dtos/apiResponse.dto';
import { Response } from 'express';
import { AuthGuard } from '@nestjs/passport';
import { CustomExceptionFilter } from '@credebl/common/exception-handler';
import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler';
import { EcosystemService } from './ecosystem.service';
import { ForbiddenErrorDto } from '../dtos/forbidden-error.dto';
import { IResponse } from '@credebl/common/interfaces/response.interface';
Expand All @@ -55,6 +54,7 @@ import { CreateIntentTemplateDto, UpdateIntentTemplateDto } from '../utilities/d
import { EcosystemFeatureGuard } from '../authz/guards/ecosystem-feature-guard';
import { EcosystemOrgStatus, Invitation, InvitationViewRole } from '@credebl/enum/enum';
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
import { TrimStringParamPipe } from '@credebl/common/cast.helper';

@UseFilters(CustomExceptionFilter)
@Controller('ecosystem')
Expand Down Expand Up @@ -91,33 +91,17 @@ export class EcosystemController {
if (!reqUser.id) {
throw new Error('Missing request user id');
}
try {
await this.ecosystemService.inviteMemberToEcosystem(
inviteMemberToEcosystem.orgId,
reqUser.id,
inviteMemberToEcosystem.ecosystemId
);

const finalResponse: IResponse = {
statusCode: HttpStatus.CREATED,
message: ResponseMessages.ecosystem.success.memberInviteSucess
};
return res.status(HttpStatus.CREATED).json(finalResponse);
} catch (error) {
if (error instanceof ConflictException || HttpStatus.CONFLICT === error.statusCode) {
return res.status(HttpStatus.CONFLICT).json({
status: HttpStatus.CONFLICT,
message: error.message
});
}

const finalResponse: IResponse = {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message: ResponseMessages.errorMessages.serverError
};
await this.ecosystemService.inviteMemberToEcosystem(
inviteMemberToEcosystem.orgId,
reqUser.id,
inviteMemberToEcosystem.ecosystemId
);

return res.status(HttpStatus.OK).json(finalResponse);
}
const finalResponse: IResponse = {
statusCode: HttpStatus.CREATED,
message: ResponseMessages.ecosystem.success.memberInviteSucess
};
return res.status(HttpStatus.CREATED).json(finalResponse);
Comment thread
pranalidhanavade marked this conversation as resolved.
}

@Post('/update-invitation-status')
Expand Down Expand Up @@ -212,17 +196,32 @@ export class EcosystemController {
@ApiBearerAuth()
@Get('/all-ecosystem')
@ApiOperation({
summary: 'Get ecosystems',
description: 'Fetch ecosystems for Platform Admin or Ecosystem Lead'
summary: 'Get Ecosystems',
description:
'Fetch ecosystems for Platform Admin and Ecosystem Lead, with optional filtering by organization using orgId.'
})
@ApiQuery({
name: 'orgId',
required: false,
type: String
})
@Roles(OrgRoles.PLATFORM_ADMIN, OrgRoles.ECOSYSTEM_LEAD)
async getEcosystems(
@User() reqUser: user,
@Res() res: Response,
@Query() paginationDto: PaginationGetAllEcosystem
@Query() paginationDto: PaginationGetAllEcosystem,
@Query(
'orgId',
new ParseUUIDPipe({
optional: true,
exceptionFactory: (): Error => {
throw new BadRequestException(ResponseMessages.ecosystem.error.invalidOrgId);
}
})
)
orgId?: string
Comment thread
pranalidhanavade marked this conversation as resolved.
): Promise<Response> {
Comment thread
pranalidhanavade marked this conversation as resolved.
const ecosystems = await this.ecosystemService.getEcosystems(reqUser.id, paginationDto);

const ecosystems = await this.ecosystemService.getEcosystems(reqUser.id, paginationDto, orgId);
return res.status(HttpStatus.OK).json({
statusCode: HttpStatus.OK,
message: ResponseMessages.ecosystem.success.fetchAllEcosystems,
Expand Down Expand Up @@ -250,15 +249,33 @@ export class EcosystemController {
@UseGuards(AuthGuard('jwt'), EcosystemRolesGuard)
@ApiBearerAuth()
async getEcosystemDashboard(
@Param('ecosystemId') ecosystemId: string,
@Param('orgId') orgId: string,
@Param(
'ecosystemId',
TrimStringParamPipe,
new ParseUUIDPipe({
exceptionFactory: (): Error => {
throw new BadRequestException(ResponseMessages.ecosystem.error.invalidFormatOfEcosystemId);
}
})
)
ecosystemId: string,
@Param(
'orgId',
TrimStringParamPipe,
new ParseUUIDPipe({
exceptionFactory: (): Error => {
throw new BadRequestException(ResponseMessages.organisation.error.invalidOrgId);
}
})
)
orgId: string,
@Res() res: Response
): Promise<Response> {
const dashboardData = await this.ecosystemService.getEcosystemDashboard(ecosystemId, orgId);

return res.status(HttpStatus.OK).json({
statusCode: HttpStatus.OK,
message: ResponseMessages.ecosystem.success.fetch,
message: ResponseMessages.ecosystem.success.getEcosystemDashboard,
data: dashboardData
});
}
Expand Down Expand Up @@ -676,7 +693,15 @@ export class EcosystemController {
})
async createIntent(
@Body() createIntentDto: CreateIntentDto,
@Param('ecosystemId') ecosystemId: string,
@Param(
'ecosystemId',
new ParseUUIDPipe({
exceptionFactory: (): Error => {
throw new BadRequestException(ResponseMessages.ecosystem.error.invalidFormatOfEcosystemId);
}
})
)
ecosystemId: string,
@User() user: user,
@Res() res: Response
): Promise<Response> {
Expand Down Expand Up @@ -718,7 +743,7 @@ export class EcosystemController {
'ecosystemId',
new ParseUUIDPipe({
exceptionFactory: (): Error => {
throw new BadRequestException('Invalid ecosystem ID format');
throw new BadRequestException(ResponseMessages.ecosystem.error.invalidFormatOfEcosystemId);
}
})
)
Expand Down
4 changes: 2 additions & 2 deletions apps/api-gateway/src/ecosystem/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class EcosystemService {
* @param userId
* @returns All ecosystems from platform
*/
async getEcosystems(userId: string, pageDetail: IPaginationSortingDto): Promise<PaginatedResponse<IEcosystem>> {
return this.natsClient.sendNatsMessage(this.serviceProxy, 'get-ecosystems', { userId, pageDetail });
async getEcosystems(userId: string, pageDetail: IPaginationSortingDto, orgId:string): Promise<PaginatedResponse<IEcosystem>> {
return this.natsClient.sendNatsMessage(this.serviceProxy, 'get-ecosystems', { userId, pageDetail, orgId });
}

/**
Expand Down
49 changes: 24 additions & 25 deletions apps/ecosystem/interfaces/ecosystem.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { EcosystemOrgStatus, InvitationViewRole } from '@credebl/enum/enum';
import { Prisma, PrismaClient } from '@prisma/client';

import { EcosystemOrgStatus, InvitationViewRole } from '@credebl/enum/enum';
import { CommonTableColumns } from '@credebl/common/interfaces/interface';
import { JsonValue } from '@prisma/client/runtime/library';
import { OrgRoles } from 'libs/org-roles/enums';
import { CommonTableColumns } from '@credebl/common/interfaces/interface';

export interface ICreateEcosystem {
name?: string;
description?: string;
name: string;
description: string;
tags?: string;
logoUrl?: string;
userId?: string;
userId: string;
logo?: string;
orgName?: string;
orgDid?: string;
orgId?: string;
orgId: string;
autoEndorsement?: boolean;
lastChangedBy?: string;
}
Expand All @@ -23,10 +23,10 @@ export interface IEcosystem {
id: string;
name: string;
description: string;
tags: string;
tags: string | null;
createDateTime: Date;
createdBy: string;
logoUrl: string;
logoUrl: string | null;
}
export interface IOrganizationData extends CommonTableColumns {
id: string;
Expand Down Expand Up @@ -64,8 +64,8 @@ export interface IEcosystemInvitations {
id: string;
email: string;
status: string;
ecosystemId?: string;
userId?: string;
ecosystemId: string | null;
userId: string | null;
createDateTime: Date;
createdBy: string;
organization?: IEcosystemOrg;
Expand Down Expand Up @@ -103,7 +103,6 @@ export interface IEcosystemDetails extends CommonTableColumns {
deletedAt?: Date;
logoUrl: string;
}

export interface IEcosystemDashboard {
ecosystem: IEcosystemDetails[];
membersCount: number;
Expand Down Expand Up @@ -138,10 +137,10 @@ export interface IEcosystemSummary {

export interface IUserSummary {
id: string;
firstName: string;
lastName: string;
email: string;
username: string;
firstName: string | null;
lastName: string | null;
email: string | null;
username: string | null;
profileImg: string | null;
}

Expand All @@ -161,7 +160,7 @@ export interface IEcosystemInvitation {
export interface IGetAllOrgs {
id: string;
status: string;
userId: string;
userId: string | null;
ecosystem: IGetAllOrgEcosystem;
organisation: IGetAllOrgOrganisation;
user: IGetAllOrgUser;
Expand All @@ -175,10 +174,10 @@ export interface IGetAllOrgEcosystem {
id: string;
name: string;
description: string;
tags: string;
tags: string | null;
createDateTime: Date;
createdBy: string;
logoUrl: string;
logoUrl: string | null;
autoEndorsement: boolean;
ledgers: JsonValue;
}
Expand All @@ -187,19 +186,19 @@ export interface IGetAllOrgOrganisation {
id: string;
createDateTime: Date;
createdBy: string;
name: string;
description: string;
orgSlug: string;
name: string | null;
description: string | null;
orgSlug: string | null;
}

export interface IGetAllOrgUser {
id: string;
createDateTime: Date;
lastChangedDateTime: Date;
firstName: string;
lastName: string;
email: string;
username: string;
firstName: string | null;
lastName: string | null;
email: string | null;
username: string | null;
}

export type EcosystemInvitationRoles = OrgRoles.ECOSYSTEM_LEAD | OrgRoles.ECOSYSTEM_MEMBER;
Expand Down
Loading