Skip to content

Commit 931f578

Browse files
ajile-inpranalidhanavadepallavighulebhavanakarwade
authored andcommitted
merge: Qa to main (#1134)
* added compass.yml file Signed-off-by: pranalidhanavade <[email protected]> * feat: update schema details and add alias in schema table (#1129) * API for update schema details Signed-off-by: pallavighule <[email protected]> * refactored query Signed-off-by: pallavighule <[email protected]> * chore: added alias in response Signed-off-by: bhavanakarwade <[email protected]> --------- Signed-off-by: pallavighule <[email protected]> Signed-off-by: bhavanakarwade <[email protected]> Co-authored-by: bhavanakarwade <[email protected]> --------- Signed-off-by: pranalidhanavade <[email protected]> Signed-off-by: pallavighule <[email protected]> Signed-off-by: bhavanakarwade <[email protected]> Co-authored-by: pranalidhanavade <[email protected]> Co-authored-by: pallavighule <[email protected]> Co-authored-by: bhavanakarwade <[email protected]>
1 parent 1821026 commit 931f578

File tree

5 files changed

+48
-56
lines changed

5 files changed

+48
-56
lines changed

apps/api-gateway/src/dtos/create-schema.dto.ts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -315,33 +315,38 @@ export class CreateW3CSchemaDto {
315315

316316
@ApiExtraModels(CreateSchemaDto, CreateW3CSchemaDto)
317317
export class GenericSchemaDTO {
318-
@ApiProperty({
319-
description: 'The type of the schema',
320-
enum: SchemaTypeEnum,
321-
example: SchemaTypeEnum.INDY
322-
})
323-
@IsEnum(SchemaTypeEnum, { message: 'Type must be a valid schema type' })
324-
@IsNotEmpty({ message: 'Type is required' })
325-
type: SchemaTypeEnum;
326-
327-
@ApiPropertyOptional()
328-
@Transform(({ value }) => trim(value))
329-
@IsOptional()
330-
@IsString({ message: 'alias must be a string' })
331-
@IsNotEmpty({ message: 'alias is required' })
332-
alias: string;
333-
334-
@ApiProperty({
335-
type: Object,
336-
oneOf: [{ $ref: getSchemaPath(CreateSchemaDto) }, { $ref: getSchemaPath(CreateW3CSchemaDto) }]
337-
})
338-
@ValidateNested()
339-
@Type(({ object }) => {
340-
if (object.type === SchemaTypeEnum.INDY) {
341-
return CreateSchemaDto;
342-
} else if (object.type === SchemaTypeEnum.JSON) {
343-
return CreateW3CSchemaDto;
344-
}
345-
})
346-
schemaPayload: CreateSchemaDto | CreateW3CSchemaDto;
318+
@ApiProperty({
319+
description: 'The type of the schema',
320+
enum: SchemaTypeEnum,
321+
example: SchemaTypeEnum.INDY
322+
})
323+
@IsEnum(SchemaTypeEnum, { message: 'Type must be a valid schema type' })
324+
@IsNotEmpty({ message: 'Type is required' })
325+
type: SchemaTypeEnum;
326+
327+
@ApiPropertyOptional()
328+
@Transform(({ value }) => trim(value))
329+
@IsOptional()
330+
@IsString({ message: 'alias must be a string' })
331+
@IsNotEmpty({ message: 'alias is required' })
332+
alias: string;
333+
334+
@ApiProperty({
335+
type: Object,
336+
oneOf: [
337+
{ $ref: getSchemaPath(CreateSchemaDto) },
338+
{ $ref: getSchemaPath(CreateW3CSchemaDto) }
339+
]
340+
})
341+
@ValidateNested()
342+
@Type(({ object }) => {
343+
if (object.type === SchemaTypeEnum.INDY) {
344+
return CreateSchemaDto;
345+
} else if (object.type === SchemaTypeEnum.JSON) {
346+
return CreateW3CSchemaDto;
347+
}
348+
})
349+
schemaPayload:CreateSchemaDto | CreateW3CSchemaDto;
350+
351+
347352
}

apps/ledger/src/schema/interfaces/schema.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ export interface ISchemasList {
129129
export interface IUpdateSchema {
130130
alias: string;
131131
schemaLedgerId: string;
132-
orgId?: string;
132+
orgId?: string;
133133
}
134134

135135
export interface UpdateSchemaResponse {
136-
count: number;
136+
count: number;
137137
}

apps/ledger/src/schema/repositories/schema.repository.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { ConflictException, Injectable, InternalServerErrorException, Logger } f
44
import { ICredDefWithCount, IPlatformSchemasWithOrg } from '@credebl/common/interfaces/schema.interface';
55
import { ISaveSchema, ISchema, ISchemaExist, ISchemaSearchCriteria } from '../interfaces/schema-payload.interface';
66
import { Prisma, ledgers, org_agents, org_agents_type, organisation, schema } from '@prisma/client';
7+
import { PrismaService } from '@credebl/prisma-service';
8+
import { ResponseMessages } from '@credebl/common/response-messages';
79
import { SchemaType, SortValue } from '@credebl/enum/enum';
810

911
import { ISchemaId } from '../schema.interface';
10-
import { PrismaService } from '@credebl/prisma-service';
11-
import { ResponseMessages } from '@credebl/common/response-messages';
1212

1313
@Injectable()
1414
export class SchemaRepository {
@@ -479,10 +479,10 @@ export class SchemaRepository {
479479
const { alias, schemaLedgerId, orgId } = schemaDetails;
480480

481481
try {
482-
return await this.prisma.schema.updateMany({
483-
where: orgId ? { schemaLedgerId, orgId } : { schemaLedgerId },
484-
data: { alias }
485-
});
482+
return await this.prisma.schema.updateMany({
483+
where: orgId ? { schemaLedgerId, orgId } : { schemaLedgerId },
484+
data: { alias }
485+
});
486486
} catch (error) {
487487
this.logger.error(`Error in updating schema details: ${error}`);
488488
throw error;

apps/ledger/src/schema/schema.service.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ import {
2121
W3CCreateSchema
2222
} from './interfaces/schema-payload.interface';
2323
import { ResponseMessages } from '@credebl/common/response-messages';
24-
import {
25-
ICreateSchema,
26-
ICreateW3CSchema,
27-
IGenericSchema,
28-
IUpdateSchema,
29-
IUserRequestInterface,
30-
UpdateSchemaResponse
31-
} from './interfaces/schema.interface';
24+
import { ICreateSchema, ICreateW3CSchema, IGenericSchema, IUpdateSchema, IUserRequestInterface, UpdateSchemaResponse } from './interfaces/schema.interface';
3225
import { CreateSchemaAgentRedirection, GetSchemaAgentRedirection, ISchemaId } from './schema.interface';
3326
import { map } from 'rxjs/operators';
3427
import {
@@ -123,8 +116,7 @@ export class SchemaService extends BaseService {
123116
});
124117
}
125118

126-
const attributeDisplayNamesLowerCase = trimmedAttributes.map((attribute) =>
127-
attribute.displayName.toLocaleLowerCase()
119+
const attributeDisplayNamesLowerCase = trimmedAttributes.map((attribute) => attribute.displayName.toLocaleLowerCase()
128120
);
129121
const duplicateAttributeDisplayNames = attributeDisplayNamesLowerCase.filter(
130122
(value, index, element) => element.indexOf(value) !== index
@@ -260,8 +252,8 @@ export class SchemaService extends BaseService {
260252
});
261253
}
262254
} else if (type === SchemaTypeEnum.JSON) {
263-
const josnSchemaDetails = schemaPayload as unknown as ICreateW3CSchema;
264-
const createW3CSchema = await this.createW3CSchema(orgId, josnSchemaDetails, user.id, alias);
255+
const jsonSchemaDetails = schemaPayload as unknown as ICreateW3CSchema;
256+
const createW3CSchema = await this.createW3CSchema(orgId, jsonSchemaDetails, user.id, alias);
265257
return createW3CSchema;
266258
}
267259
} catch (error) {
@@ -271,12 +263,7 @@ export class SchemaService extends BaseService {
271263
}
272264
}
273265

274-
async createW3CSchema(
275-
orgId: string,
276-
schemaPayload: ICreateW3CSchema,
277-
user: string,
278-
alias: string
279-
): Promise<ISchemaData> {
266+
async createW3CSchema(orgId:string, schemaPayload: ICreateW3CSchema, user: string, alias: string): Promise<ISchemaData> {
280267
try {
281268
let createSchema;
282269

libs/common/src/response-messages/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const ResponseMessages = {
159159
success: {
160160
fetch: 'Schema retrieved successfully.',
161161
create: 'Schema created successfully.',
162-
update: 'Schema updated successfully'
162+
update:'Schema updated successfully'
163163
},
164164
error: {
165165
invalidSchemaId: 'Please provide valid schema Id',

0 commit comments

Comments
 (0)