Skip to content
2 changes: 1 addition & 1 deletion apps/api-gateway/src/dtos/create-schema.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 4 additions & 0 deletions apps/issuance/interfaces/issuance.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,7 @@ export interface BulkPayloadDetails {
height?: string;
width?: string;
}

export interface ISchemaId {
schemaLedgerId: string;
}
8 changes: 5 additions & 3 deletions apps/issuance/src/issuance.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export class IssuanceRepository {
async getAllIssuedCredentials(
user: IUserRequest,
orgId: string,
issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams
issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams,
schemaIds?: string[]
): Promise<{
issuedCredentialsCount: number;
issuedCredentialsList: {
Expand All @@ -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' } }
]
},
Expand All @@ -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' } }
]
}
Expand Down
35 changes: 33 additions & 2 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -457,10 +457,21 @@ export class IssuanceService {
issuedCredentialsSearchCriteria: IIssuedCredentialSearchParams
): Promise<IIssuedCredential> {
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);
Expand Down Expand Up @@ -508,6 +519,26 @@ export class IssuanceService {
}
}

async _getSchemaDetailsByName(schemaName: string): Promise<ISchemaId[]> {
const pattern = { cmd: 'get-schemas-details-by-name' };

const schemaDetails = await this.natsClient
.send<ISchemaId[]>(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<ISchemaObject[]> {
const results = [];

Expand Down
2 changes: 1 addition & 1 deletion apps/issuance/templates/out-of-band-issuance.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class OutOfBandIssuance {
<a href="${process.env.IOS_DOWNLOAD_LINK}" target="_blank">iOS App Store.</a> (Skip, if already downloaded)
</li>
<li>Complete the onboarding process in ${process.env.MOBILE_APP}.</li>
<li>Open the “Accept Credential” link below in this email <i>(This will open the link in the ${process.env.MOBILE_APP} App)</i></li>
<li>Open the “Accept Credential” link below in this email <i>(This will open the link in the ${process.env.MOBILE_APP})</i></li>
<li><b>Accept</b> the Credential in ${process.env.MOBILE_APP}.</li>
<li>Check <b>"Credentials"</b> tab in ${process.env.MOBILE_APP} to view the issued credential.</li>
</ul>
Expand Down
13 changes: 13 additions & 0 deletions apps/ledger/src/schema/repositories/schema.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -156,6 +157,18 @@ export class SchemaRepository {
}
}

async getSchemasDetailsBySchemaName(schemaName: string): Promise<ISchemaId[]> {
const schemaDetails = await this.prisma.schema.findMany({
where: {
name: { contains: schemaName, mode: 'insensitive' }
},

select: { schemaLedgerId: true }
});

return schemaDetails;
}

async getSchemasDetailsBySchemaIds(templateIds: string[]): Promise<schema[]> {
try {
const schemasResult = await this.prisma.schema.findMany({
Expand Down
6 changes: 6 additions & 0 deletions apps/ledger/src/schema/schema.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,6 +34,11 @@ export class SchemaController {
return this.schemaService.getSchemaDetails(templateIds);
}

@MessagePattern({ cmd: 'get-schemas-details-by-name' })
async getSchemasDetailsBySchemaName(schemaName: string): Promise<ISchemaId[]> {
return this.schemaService.getSchemaDetailsBySchemaName(schemaName);
}

@MessagePattern({ cmd: 'get-schema-by-id' })
async getSchemaById(payload: ISchema): Promise<schema> {
const { schemaId, orgId } = payload;
Expand Down
5 changes: 4 additions & 1 deletion apps/ledger/src/schema/schema.interface.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 10 additions & 1 deletion apps/ledger/src/schema/schema.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -716,6 +716,15 @@ export class SchemaService extends BaseService {
}
}

async getSchemaDetailsBySchemaName(schemaName: string): Promise<ISchemaId[]> {
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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class OutOfBandVerification {
<a href="${process.env.IOS_DOWNLOAD_LINK}" target="_blank">iOS App Store.</a> (Skip, if already downloaded)
</li>
<li>Complete the onboarding process in ${process.env.MOBILE_APP}.</li>
<li>Open the “Share Credential” link below in this email <i>(This will open the link in the ${process.env.MOBILE_APP} App)</i></li>
<li>Open the “Share Credential” link below in this email <i>(This will open the link in the ${process.env.MOBILE_APP})</i></li>
<li>Tap the <b>"Send Proof"</b> button in ${process.env.MOBILE_APP} to share you credential data.</li>
</ul>
<div style="text-align: center; padding-bottom: 20px;">
Expand Down