Skip to content

Commit af1973b

Browse files
feat: add array data type in schema payload (#1110)
* fix:added array data type in schema payload Signed-off-by: pallavicoder <[email protected]> * fix:added nested attributes in schema paylaod Signed-off-by: pallavicoder <[email protected]> * feat: add array data type while creating schema Signed-off-by: bhavanakarwade <[email protected]> * replace hardcoded value with dynamic Signed-off-by: bhavanakarwade <[email protected]> * fix: removed commented code Signed-off-by: bhavanakarwade <[email protected]> --------- Signed-off-by: pallavicoder <[email protected]> Signed-off-by: bhavanakarwade <[email protected]> Co-authored-by: bhavanakarwade <[email protected]> Signed-off-by: bhavanakarwade <[email protected]>
1 parent 880a715 commit af1973b

File tree

9 files changed

+113
-33
lines changed

9 files changed

+113
-33
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Transform, Type } from 'class-transformer';
55
import { IsNotSQLInjection, trim } from '@credebl/common/cast.helper';
66
import { JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum/enum';
77

8+
89
class W3CAttributeValue {
910
@ApiProperty()
1011
@IsString()
@@ -30,6 +31,14 @@ import { JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum
3031
@IsBoolean()
3132
@IsNotEmpty({ message: 'isRequired property is required' })
3233
isRequired: boolean;
34+
35+
@ApiProperty({
36+
description: 'Array of objects with dynamic keys',
37+
isArray: true
38+
})
39+
@IsArray()
40+
@IsOptional()
41+
nestedAttributes: Record<string, Record<string, string> | string>[];
3342
}
3443
class AttributeValue {
3544

apps/api-gateway/src/issuance/dtos/issuance.dto.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ export class CredentialsIssuanceDto {
249249
reuseConnection?: boolean;
250250

251251
orgId: string;
252+
253+
isValidateSchema?: boolean;
252254
}
253255

254256
export class OOBIssueCredentialDto extends CredentialsIssuanceDto {

apps/api-gateway/src/issuance/interfaces/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export interface UploadedFileDetails {
7070
templateId: string;
7171
fileKey: string;
7272
fileName: string;
73-
type: SchemaType
73+
type: SchemaType;
74+
isValidateSchema?: boolean;
7475
}
7576
export interface IIssuedCredentialSearchParams {
7677
pageNumber: number;

apps/api-gateway/src/issuance/issuance.controller.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,20 @@ async downloadBulkIssuanceCSVTemplate(
278278
required: true,
279279
description: 'The type of schema to be used'
280280
})
281+
@ApiQuery({
282+
name: 'isValidateSchema',
283+
type: Boolean,
284+
required: false
285+
})
281286
@UseInterceptors(FileInterceptor('file'))
282287
async uploadCSVTemplate(
283288
@Param('orgId', new ParseUUIDPipe({exceptionFactory: (): Error => { throw new BadRequestException(ResponseMessages.organisation.error.invalidOrgId); }})) orgId: string,
284289
@Query(new ValidationPipe({ transform: true })) query: TemplateQuery,
285290
@UploadedFile() file: Express.Multer.File,
286291
@Body() fileDetails: object,
287292
@Res() res: Response,
288-
@Query('schemaType') schemaType: SchemaType = SchemaType.INDY
293+
@Query('schemaType') schemaType: SchemaType = SchemaType.INDY,
294+
@Query('isValidateSchema') isValidateSchema: boolean = true
289295
): Promise<object> {
290296
const { templateId } = query;
291297

@@ -301,7 +307,8 @@ async downloadBulkIssuanceCSVTemplate(
301307
type: schemaType,
302308
templateId,
303309
fileKey,
304-
fileName: fileDetails['fileName'] || file?.filename || file?.originalname
310+
fileName: fileDetails['fileName'] || file?.filename || file?.originalname,
311+
isValidateSchema
305312
};
306313

307314
const importCsvDetails = await this.issueCredentialService.uploadCSVTemplate(uploadedfileDetails);
@@ -384,6 +391,11 @@ async downloadBulkIssuanceCSVTemplate(
384391
summary: 'bulk issue credential',
385392
description: 'bulk issue credential'
386393
})
394+
@ApiQuery({
395+
name: 'isValidateSchema',
396+
type: Boolean,
397+
required: false
398+
})
387399
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
388400
@ApiConsumes('multipart/form-data')
389401
@ApiBody({
@@ -409,6 +421,7 @@ async downloadBulkIssuanceCSVTemplate(
409421
@Param('orgId') orgId: string,
410422
@User() user: user,
411423
@Query(new ValidationPipe({ transform: true })) query: CredentialQuery,
424+
@Query('isValidateSchema') isValidateSchema: boolean = true,
412425
@Res() res: Response,
413426
@Body() fileDetails?: object,
414427
@UploadedFile() file?: Express.Multer.File
@@ -432,7 +445,7 @@ async downloadBulkIssuanceCSVTemplate(
432445
type: fileDetails?.['type']
433446
};
434447
}
435-
const bulkIssuanceDetails = await this.issueCredentialService.issueBulkCredential(requestId, orgId, clientDetails, reqPayload);
448+
const bulkIssuanceDetails = await this.issueCredentialService.issueBulkCredential(requestId, orgId, clientDetails, reqPayload, isValidateSchema);
436449

437450
const finalResponse: IResponse = {
438451
statusCode: HttpStatus.CREATED,
@@ -562,16 +575,23 @@ async downloadBulkIssuanceCSVTemplate(
562575
summary: 'Retry bulk issue credential',
563576
description: 'Retry bulk issue credential'
564577
})
578+
@ApiQuery({
579+
name: 'isValidateSchema',
580+
type: Boolean,
581+
required: false
582+
})
565583
async retryBulkCredentials(
566584
@Param('fileId') fileId: string,
567585
@Param('orgId') orgId: string,
586+
@Query('isValidateSchema') isValidateSchema: boolean = true,
568587
@Res() res: Response,
569588
@Body() clientDetails: ClientDetails
570589
): Promise<Response> {
571590
const bulkIssuanceDetails = await this.issueCredentialService.retryBulkCredential(
572591
fileId,
573592
orgId,
574-
clientDetails
593+
clientDetails,
594+
isValidateSchema
575595
);
576596
const finalResponse: IResponseType = {
577597
statusCode: HttpStatus.CREATED,
@@ -713,17 +733,24 @@ async downloadBulkIssuanceCSVTemplate(
713733
name:'credentialType',
714734
enum: IssueCredentialType
715735
})
736+
@ApiQuery({
737+
name: 'isValidateSchema',
738+
type: Boolean,
739+
required: false
740+
})
716741
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
717742
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER)
718743
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
719744
async createOOBCredentialOffer(
720745
@Query('credentialType') credentialType: IssueCredentialType = IssueCredentialType.INDY,
746+
@Query('isValidateSchema') isValidateSchema: boolean = true,
721747
@Param('orgId') orgId: string,
722748
@Body() issueCredentialDto: OOBIssueCredentialDto,
723749
@Res() res: Response
724750
): Promise<Response> {
725751
issueCredentialDto.orgId = orgId;
726752
issueCredentialDto.credentialType = credentialType;
753+
issueCredentialDto.isValidateSchema = isValidateSchema;
727754
const getCredentialDetails = await this.issueCredentialService.sendCredentialOutOfBand(issueCredentialDto);
728755
const finalResponse: IResponseType = {
729756
statusCode: HttpStatus.CREATED,

apps/api-gateway/src/issuance/issuance.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ export class IssuanceService extends BaseService {
121121
return this.natsClient.sendNats(this.issuanceProxy, 'issued-file-data', payload);
122122
}
123123

124-
async issueBulkCredential(requestId: string, orgId: string, clientDetails: ClientDetails, reqPayload: IReqPayload): Promise<object> {
125-
const payload = { requestId, orgId, clientDetails, reqPayload };
124+
async issueBulkCredential(requestId: string, orgId: string, clientDetails: ClientDetails, reqPayload: IReqPayload, isValidateSchema: boolean): Promise<object> {
125+
const payload = { requestId, orgId, clientDetails, reqPayload, isValidateSchema };
126+
126127
return this.natsClient.sendNatsMessage(this.issuanceProxy, 'issue-bulk-credentials', payload);
127128
}
128129

129-
async retryBulkCredential(fileId: string, orgId: string, clientDetails: ClientDetails): Promise<object> {
130-
const payload = { fileId, orgId, clientDetails };
130+
async retryBulkCredential(fileId: string, orgId: string, clientDetails: ClientDetails, isValidateSchema?: boolean): Promise<object> {
131+
const payload = { fileId, orgId, clientDetails, isValidateSchema };
131132
return this.natsClient.sendNatsMessage(this.issuanceProxy, 'retry-bulk-credentials', payload);
132133
}
133134

apps/issuance/interfaces/issuance.interfaces.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ export interface ImportFileDetails {
195195
templateId: string;
196196
fileKey: string;
197197
fileName: string;
198-
type: string
198+
type: string;
199+
isValidateSchema?: boolean;
199200
}
200201
export interface ICredentialPayload {
201202
schemaLedgerId: string,
@@ -298,6 +299,7 @@ export interface SendEmailCredentialOffer {
298299
platformName?: string,
299300
organizationLogoUrl?: string;
300301
prettyVc?: IPrettyVc;
302+
isValidateSchema?: boolean;
301303
}
302304

303305
export interface TemplateDetailsInterface {
@@ -328,6 +330,7 @@ export interface IQueuePayload{
328330
id: string;
329331
jobId: string;
330332
cacheId?: string;
333+
isValidateSchema?: boolean;
331334
clientId: string;
332335
referenceId: string;
333336
fileUploadId: string;
@@ -383,6 +386,7 @@ export interface BulkPayloadDetails {
383386
clientId: string;
384387
orgId: string;
385388
requestId?: string;
389+
isValidateSchema?: boolean;
386390
isRetry: boolean;
387391
organizationLogoUrl?: string;
388392
platformName?: string;

apps/issuance/src/issuance.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ export class IssuanceController {
9090

9191

9292
@MessagePattern({ cmd: 'issue-bulk-credentials' })
93-
async issueBulkCredentials(payload: { requestId: string, orgId: string, clientDetails: IClientDetails, reqPayload: ImportFileDetails }): Promise<string> {
94-
return this.issuanceService.issueBulkCredential(payload.requestId, payload.orgId, payload.clientDetails, payload.reqPayload);
93+
async issueBulkCredentials(payload: { requestId: string, orgId: string, clientDetails: IClientDetails, reqPayload: ImportFileDetails, isValidateSchema: boolean }): Promise<string> {
94+
return this.issuanceService.issueBulkCredential(payload.requestId, payload.orgId, payload.clientDetails, payload.reqPayload, payload.isValidateSchema);
9595
}
9696

9797
@MessagePattern({ cmd: 'retry-bulk-credentials' })
98-
async retryeBulkCredentials(payload: { fileId: string, orgId: string, clientDetails: IClientDetails }): Promise<string> {
99-
return this.issuanceService.retryBulkCredential(payload.fileId, payload.orgId, payload.clientDetails);
98+
async retryeBulkCredentials(payload: { fileId: string, orgId: string, clientDetails: IClientDetails, isValidateSchema?: boolean }): Promise<string> {
99+
return this.issuanceService.retryBulkCredential(payload.fileId, payload.orgId, payload.clientDetails, payload.isValidateSchema);
100100
}
101101

102102
@MessagePattern({ cmd: 'delete-issuance-records' })

0 commit comments

Comments
 (0)