Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: API create tenant #374

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions apps/agent-service/src/agent-service.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
import { AgentServiceService } from './agent-service.service';
import { AgentStatus, GetCredDefAgentRedirection, GetSchemaAgentRedirection, IAgentSpinupDto, IIssuanceCreateOffer, ITenantCredDef, ITenantDto, ITenantSchema, OutOfBandCredentialOffer } from './interface/agent-service.interface';
import { IAgentStatus, IAgentSpinUpSatus, IGetCredDefAgentRedirection, IGetSchemaAgentRedirection, IAgentSpinupDto, IIssuanceCreateOffer, ITenantCredDef, ITenantDto, ITenantSchema, IOutOfBandCredentialOffer } from './interface/agent-service.interface';
import { IConnectionDetails, IUserRequestInterface } from './interface/agent-service.interface';
import { ISendProofRequestPayload } from './interface/agent-service.interface';
import { user } from '@prisma/client';
Expand All @@ -16,9 +16,7 @@ export class AgentServiceController {
}

@MessagePattern({ cmd: 'create-tenant' })
async createTenant(payload: { createTenantDto: ITenantDto, user: IUserRequestInterface }): Promise<{
agentSpinupStatus: number;
}> {
async createTenant(payload: { createTenantDto: ITenantDto, user: IUserRequestInterface }): Promise<IAgentSpinUpSatus> {
return this.agentServiceService.createTenant(payload.createTenantDto, payload.user);
}

Expand All @@ -28,7 +26,7 @@ export class AgentServiceController {
}

@MessagePattern({ cmd: 'agent-get-schema' })
async getSchemaById(payload: GetSchemaAgentRedirection): Promise<object> {
async getSchemaById(payload: IGetSchemaAgentRedirection): Promise<object> {
return this.agentServiceService.getSchemaById(payload);
}

Expand All @@ -39,7 +37,7 @@ export class AgentServiceController {
}

@MessagePattern({ cmd: 'agent-get-credential-definition' })
async getCredentialDefinitionById(payload: GetCredDefAgentRedirection): Promise<object> {
async getCredentialDefinitionById(payload: IGetCredDefAgentRedirection): Promise<object> {
return this.agentServiceService.getCredentialDefinitionById(payload);
}

Expand Down Expand Up @@ -100,7 +98,7 @@ export class AgentServiceController {
* @returns Get agent health
*/
@MessagePattern({ cmd: 'agent-health' })
async getAgentHealth(payload: { user: user, orgId: string }): Promise<AgentStatus> {
async getAgentHealth(payload: { user: user, orgId: string }): Promise<IAgentStatus> {
return this.agentServiceService.getAgentHealthDetails(payload.orgId);
}

Expand Down Expand Up @@ -134,7 +132,7 @@ export class AgentServiceController {
}

@MessagePattern({ cmd: 'agent-out-of-band-credential-offer' })
async outOfBandCredentialOffer(payload: { outOfBandIssuancePayload: OutOfBandCredentialOffer, url: string, apiKey: string }): Promise<object> {
async outOfBandCredentialOffer(payload: { outOfBandIssuancePayload: IOutOfBandCredentialOffer, url: string, apiKey: string }): Promise<object> {
return this.agentServiceService.outOfBandCredentialOffer(payload.outOfBandIssuancePayload, payload.url, payload.apiKey);
}

Expand Down
173 changes: 126 additions & 47 deletions apps/agent-service/src/agent-service.service.ts

Large diffs are not rendered by default.

83 changes: 69 additions & 14 deletions apps/agent-service/src/interface/agent-service.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export interface IAgentSpinupDto {
platformAdminEmail?: string;
}

export interface OutOfBandCredentialOffer {
export interface IOutOfBandCredentialOffer {
emailId: string;
attributes: Attributes[];
attributes: IAttributes[];
credentialDefinitionId: string;
comment: string;
protocolVersion?: string;
Expand Down Expand Up @@ -57,17 +57,17 @@ export interface ITenantSchemaDto {
issuerId: string;
}

export interface GetSchemaAgentRedirection {
export interface IGetSchemaAgentRedirection {
schemaId?: string;
tenantId?: string;
payload?: GetSchemaFromTenantPayload;
payload?: IGetSchemaFromTenantPayload;
apiKey?: string;
agentEndPoint?: string;
agentType?: string;
method?: string;
}

export interface GetSchemaFromTenantPayload {
export interface IGetSchemaFromTenantPayload {
schemaId: string;
}

Expand All @@ -89,17 +89,17 @@ export interface ITenantCredDefDto {
issuerId: string;
}

export interface GetCredDefAgentRedirection {
export interface IGetCredDefAgentRedirection {
credentialDefinitionId?: string;
tenantId?: string;
payload?: GetCredDefFromTenantPayload;
payload?: IGetCredDefFromTenantPayload;
apiKey?: string;
agentEndPoint?: string;
agentType?: string;
method?: string;
}

export interface GetCredDefFromTenantPayload {
export interface IGetCredDefFromTenantPayload {
credentialDefinitionId: string;
}

Expand Down Expand Up @@ -220,17 +220,17 @@ export interface ITenantCredDefDto {
issuerId: string;
}

export interface GetCredDefAgentRedirection {
export interface IGetCredDefAgentRedirection {
credentialDefinitionId?: string;
tenantId?: string;
payload?: GetCredDefFromTenantPayload;
payload?: IGetCredDefFromTenantPayload;
apiKey?: string;
agentEndPoint?: string;
agentType?: string;
method?: string;
}

export interface GetCredDefFromTenantPayload {
export interface IGetCredDefFromTenantPayload {
credentialDefinitionId: string;
}

Expand All @@ -247,10 +247,10 @@ export interface ICredentialFormats {
}

export interface IIndy {
attributes: Attributes[];
attributes: IAttributes[];
}

export interface Attributes {
export interface IAttributes {
name: string;
value: string;
}
Expand All @@ -261,7 +261,7 @@ export interface ISendProofRequestPayload {
autoAcceptProof: string;
}

export interface AgentStatus {
export interface IAgentStatus {
label: string;
endpoints: string[];
isInitialized: boolean;
Expand Down Expand Up @@ -300,3 +300,58 @@ interface IRequestedRestriction {
cred_def_id: string;
}

export interface IAgentSpinUpSatus {
agentSpinupStatus: number;
}

interface IWalletConfig {
id: string;
key: string;
keyDerivationMethod: string;
}

interface IConfig {
label: string;
walletConfig: IWalletConfig;
}

interface ITenantRecord {
_tags: string;
metadata: string;
id: string;
createdAt: string;
config: IConfig;
updatedAt: string;
}

export interface ICreateTenant {
tenantRecord: ITenantRecord;
did: string;
verkey: string;
}

export interface IOrgAgent {
agentSpinUpStatus: number;
}

export interface IOrgLedgers {
id: string;
}

export interface ICreateOrgAgent {
id: string;
}

interface IOrgAgentEndPoint {
agentSpinUpStatus: number;
agentEndPoint: string
}

export interface IOrgAgentsResponse {
org_agents: IOrgAgentEndPoint[];
}


export interface IStoreAgent {
id: string;
}
Loading