From be9d73606542c50e82d3b4e70b71b3e62128deb0 Mon Sep 17 00:00:00 2001 From: bhavanakarwade <137506897+bhavanakarwade@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:01:55 +0530 Subject: [PATCH] refactor: get all schemas API (#813) * feat: get w3c schema details by schema id Signed-off-by: bhavanakarwade * refactor: applied validations Signed-off-by: bhavanakarwade * refactor: get schemas by orgId response Signed-off-by: bhavanakarwade * refactor: optimized logic Signed-off-by: bhavanakarwade * refactor: added query parameter in get all schemas API Signed-off-by: bhavanakarwade * refactor: property type Signed-off-by: bhavanakarwade * refcator: delete ecosystem member template Signed-off-by: bhavanakarwade --------- Signed-off-by: bhavanakarwade Signed-off-by: KulkarniShashank --- .../src/interfaces/ISchemaSearch.interface.ts | 2 ++ .../src/platform/platform.controller.ts | 12 +++++++--- .../src/schema/dtos/get-all-schema.dto.ts | 11 ++++++++- .../DeleteEcosystemMemberTemplate.ts | 2 +- .../interfaces/schema-payload.interface.ts | 3 ++- .../schema/repositories/schema.repository.ts | 24 +++++++++++-------- 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/apps/api-gateway/src/interfaces/ISchemaSearch.interface.ts b/apps/api-gateway/src/interfaces/ISchemaSearch.interface.ts index 062d6272f..36d998e12 100644 --- a/apps/api-gateway/src/interfaces/ISchemaSearch.interface.ts +++ b/apps/api-gateway/src/interfaces/ISchemaSearch.interface.ts @@ -1,3 +1,4 @@ +import { SchemaType } from '@credebl/enum/enum'; import { IUserRequestInterface } from '../schema/interfaces'; export interface ISchemaSearchPayload { @@ -7,6 +8,7 @@ export interface ISchemaSearchPayload { sortField: string; sortBy: string; searchByText?: string; + schemaType?: SchemaType; user?: IUserRequestInterface } diff --git a/apps/api-gateway/src/platform/platform.controller.ts b/apps/api-gateway/src/platform/platform.controller.ts index 1359e1b45..980acfb02 100644 --- a/apps/api-gateway/src/platform/platform.controller.ts +++ b/apps/api-gateway/src/platform/platform.controller.ts @@ -12,7 +12,7 @@ import { ResponseMessages } from '@credebl/common/response-messages'; import { CustomExceptionFilter } from 'apps/api-gateway/common/exception-handler'; import { AuthGuard } from '@nestjs/passport'; import * as QRCode from 'qrcode'; -import { CredDefSortFields, SortFields } from '@credebl/enum/enum'; +import { CredDefSortFields, SchemaType, SortFields } from '@credebl/enum/enum'; import { GetAllPlatformCredDefsDto } from '../credential-definition/dto/get-all-platform-cred-defs.dto'; @Controller('') @@ -32,6 +32,11 @@ export class PlatformController { name: 'sortField', enum: SortFields, required: false + }) + @ApiQuery({ + name: 'schemaType', + enum: SchemaType, + required: false }) @ApiBearerAuth() @UseGuards(AuthGuard('jwt')) @@ -41,14 +46,15 @@ export class PlatformController { @Res() res: Response, @User() user: IUserRequestInterface ): Promise { - const { ledgerId, pageSize, searchByText, pageNumber, sorting, sortByValue } = getAllSchemaDto; + const { ledgerId, pageSize, searchByText, pageNumber, sorting, sortByValue, schemaType } = getAllSchemaDto; const schemaSearchCriteria: ISchemaSearchPayload = { ledgerId, pageNumber, searchByText, pageSize, sortField: sorting, - sortBy: sortByValue + sortBy: sortByValue, + schemaType }; const schemasResponse = await this.platformService.getAllSchema(schemaSearchCriteria, user); const finalResponse: IResponse = { diff --git a/apps/api-gateway/src/schema/dtos/get-all-schema.dto.ts b/apps/api-gateway/src/schema/dtos/get-all-schema.dto.ts index 3af21ac57..797f924cf 100644 --- a/apps/api-gateway/src/schema/dtos/get-all-schema.dto.ts +++ b/apps/api-gateway/src/schema/dtos/get-all-schema.dto.ts @@ -4,7 +4,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsEnum, IsOptional, IsUUID, Min } from 'class-validator'; import { toNumber, trim } from '@credebl/common/cast.helper'; -import { CredDefSortFields, SortFields, SortValue } from '@credebl/enum/enum'; +import { CredDefSortFields, SchemaType, SortFields, SortValue } from '@credebl/enum/enum'; export class GetAllSchemaDto { @ApiProperty({ required: false }) @@ -121,5 +121,14 @@ export class GetAllSchemaByPlatformDto { @ApiProperty({ required: false }) @IsOptional() sortByValue: string = SortValue.DESC; + + @ApiProperty({ + type: SchemaType, + required: false + }) + @Transform(({ value }) => trim(value)) + @IsOptional() + @IsEnum(SchemaType) + schemaType: SchemaType; } \ No newline at end of file diff --git a/apps/ecosystem/templates/DeleteEcosystemMemberTemplate.ts b/apps/ecosystem/templates/DeleteEcosystemMemberTemplate.ts index cfe35fcfc..2cba626dd 100644 --- a/apps/ecosystem/templates/DeleteEcosystemMemberTemplate.ts +++ b/apps/ecosystem/templates/DeleteEcosystemMemberTemplate.ts @@ -27,7 +27,7 @@ export class DeleteEcosystemMemberTemplate { Hello ${email},

- We would like to inform you that the organization“${orgName}”, has removed their participation as a member from the "${ecosystemName}" ecsosystem on CREDEBL. + We would like to inform you that the organization “${orgName}”, has removed their participation as a member from the "${ecosystemName}" on CREDEBL.