diff --git a/apps/api-gateway/src/dtos/create-schema.dto.ts b/apps/api-gateway/src/dtos/create-schema.dto.ts index 9200c30cd..61f45e2b3 100644 --- a/apps/api-gateway/src/dtos/create-schema.dto.ts +++ b/apps/api-gateway/src/dtos/create-schema.dto.ts @@ -32,7 +32,7 @@ import { JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum @IsNotEmpty({ message: 'isRequired property is required' }) isRequired: boolean; - @ApiProperty({ + @ApiPropertyOptional({ description: 'Array of objects with dynamic keys', isArray: true }) diff --git a/apps/issuance/interfaces/issuance.interfaces.ts b/apps/issuance/interfaces/issuance.interfaces.ts index af6752be9..cb30338eb 100644 --- a/apps/issuance/interfaces/issuance.interfaces.ts +++ b/apps/issuance/interfaces/issuance.interfaces.ts @@ -396,3 +396,7 @@ export interface BulkPayloadDetails { height?: string; width?: string; } + +export interface ISchemaId { + schemaLedgerId: string; +} \ No newline at end of file diff --git a/apps/issuance/src/issuance.repository.ts b/apps/issuance/src/issuance.repository.ts index 1f752916e..784b3621e 100644 --- a/apps/issuance/src/issuance.repository.ts +++ b/apps/issuance/src/issuance.repository.ts @@ -108,7 +108,8 @@ export class IssuanceRepository { async getAllIssuedCredentials( user: IUserRequest, orgId: string, - issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams + issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams, + schemaIds?: string[] ): Promise<{ issuedCredentialsCount: number; issuedCredentialsList: { @@ -121,11 +122,12 @@ export class IssuanceRepository { }[]; }> { try { + const issuedCredentialsList = await this.prisma.credentials.findMany({ where: { orgId, OR: [ - { schemaId: { contains: issuedCredentialsSearchCriteria.search, mode: 'insensitive' } }, + { schemaId: { in: schemaIds } }, { connectionId: { contains: issuedCredentialsSearchCriteria.search, mode: 'insensitive' } } ] }, @@ -150,7 +152,7 @@ export class IssuanceRepository { where: { orgId, OR: [ - { schemaId: { contains: issuedCredentialsSearchCriteria.search, mode: 'insensitive' } }, + { schemaId: { in: schemaIds } }, { connectionId: { contains: issuedCredentialsSearchCriteria.search, mode: 'insensitive' } } ] } diff --git a/apps/issuance/src/issuance.service.ts b/apps/issuance/src/issuance.service.ts index cae5369e7..cd0c4c8c5 100644 --- a/apps/issuance/src/issuance.service.ts +++ b/apps/issuance/src/issuance.service.ts @@ -9,7 +9,7 @@ import { CommonConstants } from '@credebl/common/common.constant'; import { ResponseMessages } from '@credebl/common/response-messages'; import { ClientProxy, RpcException } from '@nestjs/microservices'; import { map } from 'rxjs'; -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'; +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'; import { AutoAccept, IssuanceProcessState, OrgAgentType, PromiseResult, SchemaType, TemplateIdentifier, W3CSchemaDataType} from '@credebl/enum/enum'; import * as QRCode from 'qrcode'; import { OutOfBandIssuance } from '../templates/out-of-band-issuance.template'; @@ -457,10 +457,21 @@ export class IssuanceService { issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams ): Promise { try { + + let schemaIds; + if (issuedCredentialsSearchCriteria?.search) { + const schemaDetails = await this._getSchemaDetailsByName(issuedCredentialsSearchCriteria?.search); + + if (schemaDetails && 0 < schemaDetails?.length) { + schemaIds = schemaDetails.map(item => item?.schemaLedgerId); + } + } + const getIssuedCredentialsList = await this.issuanceRepository.getAllIssuedCredentials( user, orgId, - issuedCredentialsSearchCriteria + issuedCredentialsSearchCriteria, + schemaIds ); const getSchemaIds = getIssuedCredentialsList?.issuedCredentialsList?.map((schema) => schema?.schemaId); @@ -508,6 +519,26 @@ export class IssuanceService { } } + async _getSchemaDetailsByName(schemaName: string): Promise { + const pattern = { cmd: 'get-schemas-details-by-name' }; + + const schemaDetails = await this.natsClient + .send(this.issuanceServiceProxy, pattern, schemaName) + + .catch((error) => { + this.logger.error(`catch: ${JSON.stringify(error)}`); + throw new HttpException( + { + status: error.status, + error: error.message + }, + error.status + ); + }); + + return schemaDetails; + } + async getSchemaUrlDetails(schemaUrls: string[]): Promise { const results = []; diff --git a/apps/issuance/templates/out-of-band-issuance.template.ts b/apps/issuance/templates/out-of-band-issuance.template.ts index d8956fbb8..9723ba305 100644 --- a/apps/issuance/templates/out-of-band-issuance.template.ts +++ b/apps/issuance/templates/out-of-band-issuance.template.ts @@ -56,7 +56,7 @@ export class OutOfBandIssuance { iOS App Store. (Skip, if already downloaded)
  • Complete the onboarding process in ${process.env.MOBILE_APP}.
  • -
  • Open the “Accept Credential” link below in this email (This will open the link in the ${process.env.MOBILE_APP} App)
  • +
  • Open the “Accept Credential” link below in this email (This will open the link in the ${process.env.MOBILE_APP})
  • Accept the Credential in ${process.env.MOBILE_APP}.
  • Check "Credentials" tab in ${process.env.MOBILE_APP} to view the issued credential.
  • diff --git a/apps/ledger/src/schema/repositories/schema.repository.ts b/apps/ledger/src/schema/repositories/schema.repository.ts index e4f6ce602..350ce66b3 100644 --- a/apps/ledger/src/schema/repositories/schema.repository.ts +++ b/apps/ledger/src/schema/repositories/schema.repository.ts @@ -7,6 +7,7 @@ import { ResponseMessages } from '@credebl/common/response-messages'; import { AgentDetails, ISchemasWithCount } from '../interfaces/schema.interface'; import { SchemaType, SortValue } from '@credebl/enum/enum'; import { ICredDefWithCount, IPlatformSchemas } from '@credebl/common/interfaces/schema.interface'; +import { ISchemaId } from '../schema.interface'; @Injectable() export class SchemaRepository { @@ -156,6 +157,18 @@ export class SchemaRepository { } } + async getSchemasDetailsBySchemaName(schemaName: string): Promise { + const schemaDetails = await this.prisma.schema.findMany({ + where: { + name: { contains: schemaName, mode: 'insensitive' } + }, + + select: { schemaLedgerId: true } + }); + + return schemaDetails; + } + async getSchemasDetailsBySchemaIds(templateIds: string[]): Promise { try { const schemasResult = await this.prisma.schema.findMany({ diff --git a/apps/ledger/src/schema/schema.controller.ts b/apps/ledger/src/schema/schema.controller.ts index 9409855dd..aa5bae984 100644 --- a/apps/ledger/src/schema/schema.controller.ts +++ b/apps/ledger/src/schema/schema.controller.ts @@ -16,6 +16,7 @@ import { ISchemasWithPagination } from '@credebl/common/interfaces/schema.interface'; import { IschemaPayload } from './interfaces/schema.interface'; +import { ISchemaId } from './schema.interface'; @Controller('schema') export class SchemaController { @@ -33,6 +34,11 @@ export class SchemaController { return this.schemaService.getSchemaDetails(templateIds); } + @MessagePattern({ cmd: 'get-schemas-details-by-name' }) + async getSchemasDetailsBySchemaName(schemaName: string): Promise { + return this.schemaService.getSchemaDetailsBySchemaName(schemaName); + } + @MessagePattern({ cmd: 'get-schema-by-id' }) async getSchemaById(payload: ISchema): Promise { const { schemaId, orgId } = payload; diff --git a/apps/ledger/src/schema/schema.interface.ts b/apps/ledger/src/schema/schema.interface.ts index 9acf33b25..92d0e55d6 100644 --- a/apps/ledger/src/schema/schema.interface.ts +++ b/apps/ledger/src/schema/schema.interface.ts @@ -1,5 +1,8 @@ -import { IUserRequestInterface } from "./interfaces/schema.interface"; +import { IUserRequestInterface } from './interfaces/schema.interface'; +export interface ISchemaId { + schemaLedgerId: string; +} export interface SchemaSearchCriteria { schemaLedgerId: string; credentialDefinitionId: string; diff --git a/apps/ledger/src/schema/schema.service.ts b/apps/ledger/src/schema/schema.service.ts index 524848030..01e195635 100644 --- a/apps/ledger/src/schema/schema.service.ts +++ b/apps/ledger/src/schema/schema.service.ts @@ -13,7 +13,7 @@ import { Prisma, schema } from '@prisma/client'; import { ISaveSchema, ISchema, ISchemaCredDeffSearchInterface, ISchemaExist, ISchemaSearchCriteria, W3CCreateSchema } from './interfaces/schema-payload.interface'; import { ResponseMessages } from '@credebl/common/response-messages'; import { ICreateSchema, ICreateW3CSchema, IGenericSchema, IUserRequestInterface } from './interfaces/schema.interface'; -import { CreateSchemaAgentRedirection, GetSchemaAgentRedirection } from './schema.interface'; +import { CreateSchemaAgentRedirection, GetSchemaAgentRedirection, ISchemaId } from './schema.interface'; import { map } from 'rxjs/operators'; import { JSONSchemaType, LedgerLessConstant, LedgerLessMethods, OrgAgentType, SchemaType, SchemaTypeEnum } from '@credebl/enum/enum'; import { ICredDefWithPagination, ISchemaData, ISchemaDetails, ISchemasWithPagination } from '@credebl/common/interfaces/schema.interface'; @@ -716,6 +716,15 @@ export class SchemaService extends BaseService { } } + async getSchemaDetailsBySchemaName(schemaName: string): Promise { + try { + const getSchemaDetails = await this.schemaRepository.getSchemasDetailsBySchemaName(schemaName); + return getSchemaDetails; + } catch (error) { + throw new RpcException(error.response ? error.response : error); + } + } + async _getSchemaById(payload: GetSchemaAgentRedirection): Promise<{ response: string }> { try { const pattern = { diff --git a/apps/verification/templates/out-of-band-verification.template.ts b/apps/verification/templates/out-of-band-verification.template.ts index df33d0d68..3e236900b 100644 --- a/apps/verification/templates/out-of-band-verification.template.ts +++ b/apps/verification/templates/out-of-band-verification.template.ts @@ -44,7 +44,7 @@ export class OutOfBandVerification { iOS App Store. (Skip, if already downloaded)
  • Complete the onboarding process in ${process.env.MOBILE_APP}.
  • -
  • Open the “Share Credential” link below in this email (This will open the link in the ${process.env.MOBILE_APP} App)
  • +
  • Open the “Share Credential” link below in this email (This will open the link in the ${process.env.MOBILE_APP})
  • Tap the "Send Proof" button in ${process.env.MOBILE_APP} to share you credential data.