From 3920b3c19b1bba98f757c412eb10fff853cd0af6 Mon Sep 17 00:00:00 2001 From: kirti763 Date: Tue, 13 May 2025 17:34:57 +0530 Subject: [PATCH 1/2] fix: handle invalid orgID with proper 400 error Signed-off-by: kirti763 --- apps/api-gateway/src/webhook/dtos/get-webhoook-dto.ts | 6 +++--- platform | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) create mode 160000 platform diff --git a/apps/api-gateway/src/webhook/dtos/get-webhoook-dto.ts b/apps/api-gateway/src/webhook/dtos/get-webhoook-dto.ts index 846225df0..54e98c6c1 100644 --- a/apps/api-gateway/src/webhook/dtos/get-webhoook-dto.ts +++ b/apps/api-gateway/src/webhook/dtos/get-webhoook-dto.ts @@ -6,11 +6,11 @@ import { trim } from '@credebl/common/cast.helper'; @ApiExtraModels() export class GetWebhookDto { - @ApiPropertyOptional({example: '2a041d6e-d24c-4ed9-b011-1cfc371a8b8e'}) - @IsOptional() + @ApiProperty({example: '2a041d6e-d24c-4ed9-b011-1cfc371a8b8e'}) @Transform(({ value }) => trim(value)) + @IsNotEmpty({ message: 'Please provide the valid orgID' }) @IsString({ message: 'Organization id must be in string format.' }) - orgId?: string; + orgId: string; @ApiPropertyOptional({example: '3a041d6e-d24c-4ed9-b011-1cfc371a8b8e'}) @IsOptional() diff --git a/platform b/platform new file mode 160000 index 000000000..ea4d5f56a --- /dev/null +++ b/platform @@ -0,0 +1 @@ +Subproject commit ea4d5f56abc1e7aff64ab7e9d643d2fa19beac6e From 5f19ecc3bc0cd5e5907ebabe3a551e898b9a82b9 Mon Sep 17 00:00:00 2001 From: kirti763 Date: Sun, 18 May 2025 00:01:38 +0530 Subject: [PATCH 2/2] refactor: replace searchbyText with search in relevant files Signed-off-by: kirti763 --- .../dto/get-all-cred-defs.dto.ts | 44 +++++++------------ .../interfaces/IConnectionSearch.interface.ts | 2 +- .../src/issuance/dtos/issuance.dto.ts | 39 +++------------- .../src/schema/schema.controller.ts | 4 +- .../src/interfaces/connection.interfaces.ts | 2 +- 5 files changed, 28 insertions(+), 63 deletions(-) diff --git a/apps/api-gateway/src/credential-definition/dto/get-all-cred-defs.dto.ts b/apps/api-gateway/src/credential-definition/dto/get-all-cred-defs.dto.ts index 475519e93..70ab4372f 100644 --- a/apps/api-gateway/src/credential-definition/dto/get-all-cred-defs.dto.ts +++ b/apps/api-gateway/src/credential-definition/dto/get-all-cred-defs.dto.ts @@ -5,35 +5,25 @@ import { SortValue } from '../../enum'; import { Transform, Type } from 'class-transformer'; import { IsOptional, Max, Min } from 'class-validator'; import { toNumber } from '@credebl/common/cast.helper'; +import { PaginationDto } from '@credebl/common/dtos/pagination.dto'; -export class GetAllCredDefsDto { - @ApiProperty({ required: false, default: 1 }) - @IsOptional() - @Transform(({ value }) => toNumber(value)) - pageNumber: number = 1; +export class GetAllCredDefsDto extends PaginationDto{ + + @ApiProperty({ required: false, example: 'id' }) + @IsOptional() + sorting: string = 'id'; - @ApiProperty({ required: false }) - @IsOptional() - @Type(() => String) - searchByText: string = ''; + @ApiProperty({ + enum: [SortValue.DESC, SortValue.ASC], + required: false, + example: SortValue.DESC, + }) + @IsOptional() + @IsEnum(SortValue) + sortByValue: string = SortValue.DESC; - @ApiProperty({ required: false, default: 10 }) - @IsOptional() - @Transform(({ value }) => toNumber(value)) - @Min(1, { message: 'Page size must be greater than 0' }) - @Max(100, { message: 'Page size must be less than 100' }) - pageSize: number = 10; - - @ApiProperty({ required: false }) - @IsOptional() - sorting: string = 'id'; - - @ApiProperty({ required: false }) - @IsOptional() - sortByValue: string = SortValue.DESC; - - @ApiProperty({ required: false }) - @IsOptional() - revocable: boolean = true; + @ApiProperty({ required: false, example: true }) + @IsOptional() + revocable: boolean = true; } diff --git a/apps/api-gateway/src/interfaces/IConnectionSearch.interface.ts b/apps/api-gateway/src/interfaces/IConnectionSearch.interface.ts index a228ae636..838445ea4 100644 --- a/apps/api-gateway/src/interfaces/IConnectionSearch.interface.ts +++ b/apps/api-gateway/src/interfaces/IConnectionSearch.interface.ts @@ -5,7 +5,7 @@ export interface IConnectionSearchCriteria { pageSize: number; sortField: string; sortBy: string; - searchByText: string; + search: string; user?: IUserRequestInterface; } diff --git a/apps/api-gateway/src/issuance/dtos/issuance.dto.ts b/apps/api-gateway/src/issuance/dtos/issuance.dto.ts index 26b5e5ca4..26deb44e1 100644 --- a/apps/api-gateway/src/issuance/dtos/issuance.dto.ts +++ b/apps/api-gateway/src/issuance/dtos/issuance.dto.ts @@ -30,6 +30,7 @@ import { Transform, Type } from 'class-transformer'; import { SortFields } from 'apps/connection/src/enum/connection.enum'; import { trim } from '@credebl/common/cast.helper'; +import { PaginationDto } from '@credebl/common/dtos/pagination.dto'; class Issuer { @ApiProperty() @@ -492,33 +493,13 @@ export class OOBCredentialDtoWithEmail { orgId: string; } -export class PreviewFileDetails { - @ApiProperty({ required: false, example: '1' }) - @IsOptional() - pageNumber: number = 1; - - @ApiProperty({ required: false, example: '10' }) - @IsOptional() - pageSize: number = 10; - - @ApiProperty({ required: false }) - @IsOptional() - @Transform(({ value }) => trim(value)) - @Type(() => String) - searchByText: string = ''; +export class PreviewFileDetails extends PaginationDto { + } -export class FileParameter { - @ApiProperty({ required: false, example: '10' }) - @IsOptional() - pageSize: number = 10; - - @ApiProperty({ required: false, example: '1' }) - @IsOptional() - pageNumber: number = 1; - - @ApiProperty({ - required: false +export class FileParameter extends PaginationDto { + @ApiProperty({ + required: false, }) @Transform(({ value }) => trim(value)) @IsOptional() @@ -527,18 +508,12 @@ export class FileParameter { @ApiProperty({ enum: [SortValue.DESC, SortValue.ASC], - required: false + required: false, }) @Transform(({ value }) => trim(value)) @IsOptional() @IsEnum(SortValue) sortBy: string = SortValue.DESC; - - @ApiProperty({ required: false }) - @IsOptional() - @Transform(({ value }) => trim(value)) - @Type(() => String) - searchByText: string = ''; } export class ClientDetails { diff --git a/apps/api-gateway/src/schema/schema.controller.ts b/apps/api-gateway/src/schema/schema.controller.ts index 93682107f..595ac3e4d 100644 --- a/apps/api-gateway/src/schema/schema.controller.ts +++ b/apps/api-gateway/src/schema/schema.controller.ts @@ -143,10 +143,10 @@ export class SchemaController { @User() user: IUserRequestInterface ): Promise { - const { pageSize, searchByText, pageNumber, sortField, sortBy } = getAllSchemaDto; + const { pageSize, search, pageNumber, sortField, sortBy } = getAllSchemaDto; const schemaSearchCriteria: ISchemaSearchPayload = { pageNumber, - searchByText, + search, pageSize, sortField, sortBy diff --git a/apps/connection/src/interfaces/connection.interfaces.ts b/apps/connection/src/interfaces/connection.interfaces.ts index 020e4821d..9e7771600 100644 --- a/apps/connection/src/interfaces/connection.interfaces.ts +++ b/apps/connection/src/interfaces/connection.interfaces.ts @@ -129,7 +129,7 @@ export interface IConnectionSearchCriteria { pageSize: number; sortField: string; sortBy: string; - searchByText: string; + search: string; user: IUserRequestInterface }