Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bugs fixes #606

Merged
merged 9 commits into from
Mar 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ export class AgentController {
@Res() res: Response
): Promise<Response> {

validateDid(createDidDto);
await validateDid(createDidDto);

if (seedLength !== createDidDto.seed.length) {
if (createDidDto.seed && seedLength !== createDidDto.seed.length) {
this.logger.error(`seed must be at most 32 characters.`);
throw new BadRequestException(
ResponseMessages.agent.error.seedChar,
Expand Down
4 changes: 2 additions & 2 deletions apps/api-gateway/src/agent-service/dto/create-did.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class CreateDidDto {
keyType: string;

@ApiProperty({ example: 'indy'})
@IsNotEmpty({ message: 'seed is required' })
@IsString({ message: 'did must be in string format.' })
@IsNotEmpty({ message: 'method is required' })
@IsString({ message: 'method must be in string format.' })
method: string;

@ApiProperty({example: 'bcovrin:testnet'})
Expand Down
8 changes: 4 additions & 4 deletions apps/api-gateway/src/ecosystem/dtos/create-ecosystem-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export class CreateEcosystemDto {

@ApiProperty()
@Transform(({ value }) => trim(value))
@IsNotEmpty({ message: 'ecosystem name is required.' })
@MinLength(2, { message: 'ecosystem name must be at least 2 characters.' })
@MaxLength(50, { message: 'ecosystem name must be at most 50 characters.' })
@IsString({ message: 'ecosystem name must be in string format.' })
@IsNotEmpty({ message: 'Ecosystem name is required.' })
@MinLength(2, { message: 'Ecosystem name must be at least 2 characters.' })
@MaxLength(50, { message: 'Ecosystem name must be at most 50 characters.' })
@IsString({ message: 'Ecosystem name must be in string format.' })
name: string;

@ApiProperty()
Expand Down
20 changes: 18 additions & 2 deletions apps/api-gateway/src/ecosystem/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class EcosystemController {
const finalResponse: IResponse = {
statusCode: 200,
message: ResponseMessages.ecosystem.success.allschema,
data: schemaList.response
data: schemaList
};
return res.status(200).json(finalResponse);
}
Expand All @@ -124,11 +124,27 @@ export class EcosystemController {
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER)
@ApiBearerAuth()
@ApiQuery({
name: 'pageNumber',
type: Number,
required: false
})
@ApiQuery({
name: 'pageSize',
type: Number,
required: false
})
@ApiQuery({
name: 'search',
type: String,
required: false
})
async getEcosystem(
@Query() paginationDto: PaginationDto,
@Param('orgId') orgId: string,
@Res() res: Response
): Promise<Response> {
const ecosystemList = await this.ecosystemService.getAllEcosystem(orgId);
const ecosystemList = await this.ecosystemService.getAllEcosystem(orgId, paginationDto);
const finalResponse: IResponse = {
statusCode: 200,
message: ResponseMessages.ecosystem.success.fetch,
Expand Down
9 changes: 5 additions & 4 deletions apps/api-gateway/src/ecosystem/ecosystem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { GetAllEndorsementsDto } from './dtos/get-all-endorsements.dto';
import { RequestSchemaDto, RequestCredDefDto } from './dtos/request-schema.dto';
import { CreateEcosystemDto } from './dtos/create-ecosystem-dto';
import { EditEcosystemDto } from './dtos/edit-ecosystem-dto';
import { IEcosystemDashboard, EcosystemDetailsResult, IEcosystemInvitation, IEcosystemInvitations, IEcosystem, IEditEcosystem, IEndorsementTransaction } from 'apps/ecosystem/interfaces/ecosystem.interfaces';
import { IEcosystemDashboard, IEcosystemInvitation, IEcosystemInvitations, IEcosystem, IEditEcosystem, IEndorsementTransaction, ISchemaResponse } from 'apps/ecosystem/interfaces/ecosystem.interfaces';
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
import { IEcosystemDetails } from '@credebl/common/interfaces/ecosystem.interface';

@Injectable()
export class EcosystemService extends BaseService {
Expand Down Expand Up @@ -45,8 +46,8 @@ export class EcosystemService extends BaseService {
*
* @returns Get all ecosystems
*/
async getAllEcosystem(orgId: string): Promise<EcosystemDetailsResult> {
const payload = { orgId };
async getAllEcosystem(orgId: string, payload: PaginationDto): Promise<IEcosystemDetails> {
payload['orgId'] = orgId;
return this.sendNatsMessage(this.serviceProxy, 'get-all-ecosystem', payload);
}

Expand Down Expand Up @@ -144,7 +145,7 @@ export class EcosystemService extends BaseService {
ecosystemId: string,
orgId: string,
paginationDto: PaginationDto
): Promise<{ response: object }> {
): Promise<ISchemaResponse> {
const { pageNumber, pageSize, search } = paginationDto;
const payload = { ecosystemId, orgId, pageNumber, pageSize, search };
return this.sendNatsMessage(this.serviceProxy, 'get-all-ecosystem-schemas', payload);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform, Type } from 'class-transformer';
import { IsEnum, IsInt, IsOptional, IsString } from 'class-validator';
import { Transform } from 'class-transformer';
import { IsEnum, IsOptional } from 'class-validator';
import { SortValue } from '../../enum';
import { trim } from '@credebl/common/cast.helper';
import { SortFields } from 'apps/issuance/enum/issuance.enum';
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';

export class IGetAllIssuedCredentialsDto {
@ApiProperty({ required: false, default: 1 })
@IsOptional()
@Type(() => Number)
@IsInt({ message: 'Page Number should be a number' })
pageNumber: number = 1;

@ApiProperty({ required: false, default: 10 })
@IsOptional()
@Type(() => Number)
@IsInt({ message: 'Page size should be a number' })
pageSize: number;

@ApiProperty({ required: false })
@IsOptional()
@Type(() => String)
@IsString({ message: 'Search text should be a string' })
@Transform(({ value }) => trim(value))
searchByText: string;
export class IGetAllIssuedCredentialsDto extends PaginationDto {

@ApiProperty({ required: false, enum: SortFields })
@Transform(({ value }) => trim(value))
Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/issuance/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface IIssuedCredentialSearchParams {
pageSize: number;
sortField: string;
sortBy: string;
searchByText: string;
search: string;
}

export enum IssueCredentialType {
Expand Down
19 changes: 17 additions & 2 deletions apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ export class IssuanceController {
summary: `Get all issued credentials for a specific organization`,
description: `Get all issued credentials for a specific organization`
})
@ApiQuery({
name: 'pageNumber',
type: Number,
required: false
})
@ApiQuery({
name: 'pageSize',
type: Number,
required: false
})
@ApiQuery({
name: 'search',
type: String,
required: false
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiBearerAuth()
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
Expand All @@ -98,10 +113,10 @@ export class IssuanceController {
@Param('orgId') orgId: string,
@Res() res: Response
): Promise<Response> {
const { pageSize, searchByText, pageNumber, sortField, sortBy } = getAllIssuedCredentials;
const { pageSize, search, pageNumber, sortField, sortBy } = getAllIssuedCredentials;
const issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams = {
pageNumber,
searchByText,
search,
pageSize,
sortField,
sortBy
Expand Down
3 changes: 0 additions & 3 deletions apps/api-gateway/src/organization/dtos/send-invitation.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,5 @@ export class BulkSendInvitationDto {
@Type(() => SendInvitationDto)
invitations: SendInvitationDto[];

@ApiProperty()
@IsString({ message: 'orgId should be a string' })
@IsNotEmpty({ message: 'orgId is required' })
orgId: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class OrganizationController {
@Post('/:orgId/invitations')
@ApiOperation({
summary: 'Create organization invitation',
description: 'Create send invitation'
description: 'Create organization invitation'
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@Roles(OrgRoles.OWNER, OrgRoles.SUPER_ADMIN, OrgRoles.ADMIN)
Expand Down
77 changes: 41 additions & 36 deletions apps/ecosystem/interfaces/ecosystem.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,41 +220,6 @@ export interface LedgerDetails {
networkUrl: string;
}

interface EcosystemRole {
id: string;
name: string;
description: string;
createDateTime: Date;
lastChangedDateTime: Date;
deletedAt: Date;
}

interface EcosystemDetail {
id: string;
name: string;
description: string;
logoUrl: string;
createDateTime: Date;
lastChangedDateTime: Date;
createdBy: string;
autoEndorsement: boolean;
ecosystemOrgs: {
id: string;
orgId: string;
status: string;
createDateTime: Date;
lastChangedDateTime: Date;
ecosystemId: string;
ecosystemRoleId: string;
ecosystemRole: EcosystemRole;
}[];
}

export interface EcosystemDetailsResult {
totalCount: number;
ecosystemDetails: EcosystemDetail[];
}

export interface EcosystemInvitationDetails {
name: string;
id: string;
Expand Down Expand Up @@ -363,4 +328,44 @@ export interface IEcosystemInvitations {
ecosystem: EcosystemInvitationDetails;
createDateTime: Date;
createdBy: string;
}
}

interface IAttributes {
isRequired: boolean;
displayName: string;
attributeName: string;
schemaDataType: string;
}

interface ISChemaItems {
id: string;
createDateTime: string;
createdBy: string;
lastChangedDateTime: string;
lastChangedBy: string;
name: string;
version: string;
attributes: IAttributes[];
schemaLedgerId: string;
publisherDid: string;
issuerId: string;
orgId: string;
ledgerId: string;
}

export interface ISchemaResponse {
totalItems: number;
hasNextPage: boolean;
hasPreviousPage: boolean;
nextPage: number;
previousPage: number;
lastPage: number;
data: ISChemaItems[];
}

export interface IEcosystemList {
orgId: string,
pageNumber: number;
pageSize: number;
search: string;
}
20 changes: 19 additions & 1 deletion apps/ecosystem/interfaces/endorsements.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,22 @@ export interface GetEndorsementsPayload {
pageNumber: number;
pageSize: number;
search: string;
}
}

interface ISchemaResult {
createDateTime: Date;
createdBy: string;
name: string;
version: string;
attributes: string;
schemaLedgerId: string;
publisherDid: string;
issuerId: string;
orgId: string;
}

export interface ISchemasResponse {
schemasCount: number;
schemasResult: ISchemaResult[];
}

9 changes: 5 additions & 4 deletions apps/ecosystem/src/ecosystem.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { BulkSendInvitationDto } from '../dtos/send-invitation.dto';
import { AcceptRejectEcosystemInvitationDto } from '../dtos/accept-reject-ecosysteminvitation.dto';
import { FetchInvitationsPayload } from '../interfaces/invitations.interface';
import { EcosystemMembersPayload } from '../interfaces/ecosystemMembers.interface';
import { GetEndorsementsPayload } from '../interfaces/endorsements.interface';
import { IEcosystemDashboard, RequestCredDeffEndorsement, RequestSchemaEndorsement, IEcosystem, EcosystemDetailsResult, IEcosystemInvitation, IEcosystemInvitations, IEditEcosystem, IEndorsementTransaction } from '../interfaces/ecosystem.interfaces';
import { GetEndorsementsPayload, ISchemasResponse } from '../interfaces/endorsements.interface';
import { IEcosystemDashboard, RequestCredDeffEndorsement, RequestSchemaEndorsement, IEcosystem, IEcosystemInvitation, IEcosystemInvitations, IEditEcosystem, IEndorsementTransaction, IEcosystemList } from '../interfaces/ecosystem.interfaces';
import { IEcosystemDetails } from '@credebl/common/interfaces/ecosystem.interface';

@Controller()
export class EcosystemController {
Expand Down Expand Up @@ -42,7 +43,7 @@ export class EcosystemController {
* @returns Get all ecosystem details
*/
@MessagePattern({ cmd: 'get-all-ecosystem' })
async getAllEcosystems(@Body() payload: { orgId: string }): Promise<EcosystemDetailsResult> {
async getAllEcosystems(@Body() payload: IEcosystemList): Promise<IEcosystemDetails> {
return this.ecosystemService.getAllEcosystem(payload);
}

Expand Down Expand Up @@ -121,7 +122,7 @@ export class EcosystemController {
}

@MessagePattern({ cmd: 'get-all-ecosystem-schemas' })
async getAllEcosystemSchemas(@Body() payload: GetEndorsementsPayload): Promise<object> {
async getAllEcosystemSchemas(@Body() payload: GetEndorsementsPayload): Promise<ISchemasResponse> {
return this.ecosystemService.getAllEcosystemSchemas(payload);
}

Expand Down
Loading