@@ -9,7 +9,7 @@ import { CommonConstants } from '@credebl/common/common.constant';
9
9
import { ResponseMessages } from '@credebl/common/response-messages' ;
10
10
import { ClientProxy , RpcException } from '@nestjs/microservices' ;
11
11
import { map } from 'rxjs' ;
12
- import { BulkPayloadDetails , CredentialOffer , FileUpload , FileUploadData , IAttributes , IBulkPayloadObject , IClientDetails , ICreateOfferResponse , ICredentialPayload , IIssuance , IIssueData , IPattern , IQueuePayload , ISchemaAttributes , ISendOfferNatsPayload , ImportFileDetails , IssueCredentialWebhookPayload , OutOfBandCredentialOfferPayload , PreviewRequest , SchemaDetails , SendEmailCredentialOffer , TemplateDetailsInterface } from '../interfaces/issuance.interfaces' ;
12
+ import { BulkPayloadDetails , CredentialOffer , FileUpload , FileUploadData , IAttributes , IBulkPayloadObject , IClientDetails , ICreateOfferResponse , ICredentialPayload , IIssuance , IIssueData , IPattern , IQueuePayload , ISchemaAttributes , ISchemaId , ISendOfferNatsPayload , ImportFileDetails , IssueCredentialWebhookPayload , OutOfBandCredentialOfferPayload , PreviewRequest , SchemaDetails , SendEmailCredentialOffer , TemplateDetailsInterface } from '../interfaces/issuance.interfaces' ;
13
13
import { AutoAccept , IssuanceProcessState , OrgAgentType , PromiseResult , SchemaType , TemplateIdentifier , W3CSchemaDataType } from '@credebl/enum/enum' ;
14
14
import * as QRCode from 'qrcode' ;
15
15
import { OutOfBandIssuance } from '../templates/out-of-band-issuance.template' ;
@@ -457,10 +457,21 @@ export class IssuanceService {
457
457
issuedCredentialsSearchCriteria : IIssuedCredentialSearchParams
458
458
) : Promise < IIssuedCredential > {
459
459
try {
460
+
461
+ let schemaIds ;
462
+ if ( issuedCredentialsSearchCriteria ?. search ) {
463
+ const schemaDetails = await this . _getSchemaDetailsByName ( issuedCredentialsSearchCriteria ?. search ) ;
464
+
465
+ if ( schemaDetails && 0 < schemaDetails ?. length ) {
466
+ schemaIds = schemaDetails . map ( item => item ?. schemaLedgerId ) ;
467
+ }
468
+ }
469
+
460
470
const getIssuedCredentialsList = await this . issuanceRepository . getAllIssuedCredentials (
461
471
user ,
462
472
orgId ,
463
- issuedCredentialsSearchCriteria
473
+ issuedCredentialsSearchCriteria ,
474
+ schemaIds
464
475
) ;
465
476
466
477
const getSchemaIds = getIssuedCredentialsList ?. issuedCredentialsList ?. map ( ( schema ) => schema ?. schemaId ) ;
@@ -508,6 +519,26 @@ export class IssuanceService {
508
519
}
509
520
}
510
521
522
+ async _getSchemaDetailsByName ( schemaName : string ) : Promise < ISchemaId [ ] > {
523
+ const pattern = { cmd : 'get-schemas-details-by-name' } ;
524
+
525
+ const schemaDetails = await this . natsClient
526
+ . send < ISchemaId [ ] > ( this . issuanceServiceProxy , pattern , schemaName )
527
+
528
+ . catch ( ( error ) => {
529
+ this . logger . error ( `catch: ${ JSON . stringify ( error ) } ` ) ;
530
+ throw new HttpException (
531
+ {
532
+ status : error . status ,
533
+ error : error . message
534
+ } ,
535
+ error . status
536
+ ) ;
537
+ } ) ;
538
+
539
+ return schemaDetails ;
540
+ }
541
+
511
542
async getSchemaUrlDetails ( schemaUrls : string [ ] ) : Promise < ISchemaObject [ ] > {
512
543
const results = [ ] ;
513
544
0 commit comments