diff --git a/apps/api-gateway/src/dtos/create-schema.dto.ts b/apps/api-gateway/src/dtos/create-schema.dto.ts index 8721a5714..9f9b978f9 100644 --- a/apps/api-gateway/src/dtos/create-schema.dto.ts +++ b/apps/api-gateway/src/dtos/create-schema.dto.ts @@ -17,7 +17,7 @@ import { import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger'; import { plainToClass, Transform, Type } from 'class-transformer'; import { IsNotSQLInjection, trim } from '@credebl/common/cast.helper'; -import { JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum/enum'; +import { IndySchemaDataType, JSONSchemaType, SchemaTypeEnum, W3CSchemaDataType } from '@credebl/enum/enum'; export class W3CAttributeValue { @ApiProperty() @@ -37,7 +37,9 @@ export class W3CAttributeValue { enum: W3CSchemaDataType, example: W3CSchemaDataType.STRING }) - @IsEnum(W3CSchemaDataType, { message: 'Schema data type must be a valid type' }) + @IsEnum(W3CSchemaDataType, { + message: `Schema data type must be one of [${Object.values(W3CSchemaDataType).join(', ')}]` + }) schemaDataType: W3CSchemaDataType; @ApiProperty() @@ -205,11 +207,17 @@ class AttributeValue { @IsNotEmpty({ message: 'attributeName is required' }) attributeName: string; - @ApiProperty() + @ApiProperty({ + description: 'The type of the schema', + enum: IndySchemaDataType, + example: IndySchemaDataType.STRING + }) @IsString() @Transform(({ value }) => trim(value)) - @IsNotEmpty({ message: 'schemaDataType is required' }) - schemaDataType: string; + @IsEnum(IndySchemaDataType, { + message: `Schema data type must be one of [${Object.values(IndySchemaDataType).join(', ')}]` + }) + schemaDataType: IndySchemaDataType; @ApiProperty() @IsString() diff --git a/libs/enum/src/enum.ts b/libs/enum/src/enum.ts index 29dabc308..e0811acbb 100644 --- a/libs/enum/src/enum.ts +++ b/libs/enum/src/enum.ts @@ -1,251 +1,259 @@ export enum NATSReconnects { - maxReconnectAttempts = (10 * 60) / 5, // 10 minutes with a reconnection attempt every 5 seconds - reconnectTimeWait = 5000 // 5 second delay between reconnection attempts + maxReconnectAttempts = (10 * 60) / 5, // 10 minutes with a reconnection attempt every 5 seconds + reconnectTimeWait = 5000 // 5 second delay between reconnection attempts } export enum SortValue { - ASC = 'asc', - DESC = 'desc' + ASC = 'asc', + DESC = 'desc' } export enum SortFields { - ID = 'id', - CREATED_DATE_TIME = 'createDateTime', - NAME = 'name', - VERSION = 'version', - LEDGER_ID = 'schemaLedgerId', - PUBLISHER_DID = 'publisherDid', - ISSUER_ID = 'issuerId' + ID = 'id', + CREATED_DATE_TIME = 'createDateTime', + NAME = 'name', + VERSION = 'version', + LEDGER_ID = 'schemaLedgerId', + PUBLISHER_DID = 'publisherDid', + ISSUER_ID = 'issuerId' } export enum CredDefSortFields { - CREATED_DATE_TIME = 'createDateTime', - TAG = 'tag', - LEDGER_ID = 'schemaLedgerId', - CRED_DEF_ID= 'credentialDefinitionId' + CREATED_DATE_TIME = 'createDateTime', + TAG = 'tag', + LEDGER_ID = 'schemaLedgerId', + CRED_DEF_ID = 'credentialDefinitionId' } export enum AgentType { - // TODO: Change to Credo - AFJ = 'AFJ', - ACAPY = 'ACAPY' + // TODO: Change to Credo + AFJ = 'AFJ', + ACAPY = 'ACAPY' } export enum DevelopmentEnvironment { - PRODUCTION = 'production', - DEVELOPMENT = 'development', - TEST = 'test' + PRODUCTION = 'production', + DEVELOPMENT = 'development', + TEST = 'test' } export declare enum KeyType { - Ed25519 = 'ed25519', - Bls12381g1g2 = 'bls12381g1g2', - Bls12381g1 = 'bls12381g1', - Bls12381g2 = 'bls12381g2', - X25519 = 'x25519', - P256 = 'p256', - P384 = 'p384', - P521 = 'p521', - K256 = 'k256' + Ed25519 = 'ed25519', + Bls12381g1g2 = 'bls12381g1g2', + Bls12381g1 = 'bls12381g1', + Bls12381g2 = 'bls12381g2', + X25519 = 'x25519', + P256 = 'p256', + P384 = 'p384', + P521 = 'p521', + K256 = 'k256' } export enum DidMethod { - INDY = 'indy', - KEY = 'key', - WEB = 'web', - POLYGON = 'polygon' + INDY = 'indy', + KEY = 'key', + WEB = 'web', + POLYGON = 'polygon' } export enum Ledgers { - Bcovrin_Testnet = 'Bcovrin Testnet', - Indicio_Testnet = 'Indicio Testnet', - Indicio_Demonet = 'Indicio Demonet', - Indicio_Mainnet = 'Indicio Mainnet', - Not_Applicable = 'NA' + Bcovrin_Testnet = 'Bcovrin Testnet', + Indicio_Testnet = 'Indicio Testnet', + Indicio_Demonet = 'Indicio Demonet', + Indicio_Mainnet = 'Indicio Mainnet', + Not_Applicable = 'NA' } export enum Invitation { - ACCEPTED = 'accepted', - REJECTED = 'rejected', - PENDING = 'pending' + ACCEPTED = 'accepted', + REJECTED = 'rejected', + PENDING = 'pending' } export enum EndorserTransactionType { - SCHEMA = 'schema', - CREDENTIAL_DEFINITION = 'credential-definition', + SCHEMA = 'schema', + CREDENTIAL_DEFINITION = 'credential-definition' } export enum schemaRequestType { - W3C = 'w3c', - INDY = 'indy' + W3C = 'w3c', + INDY = 'indy' } export enum OrgAgentType { - DEDICATED = 'DEDICATED', - SHARED = 'SHARED' + DEDICATED = 'DEDICATED', + SHARED = 'SHARED' } export enum AgentSpinUpStatus { - PENDING = 0, - PROCESSED = 1, - COMPLETED = 2 + PENDING = 0, + PROCESSED = 1, + COMPLETED = 2 } export enum UserCertificateId { - WINNER = 'Winner', - PARTICIPANT = 'Participant', - ARBITER = 'Arbiter', - WORLD_RECORD = 'WorldRecord' + WINNER = 'Winner', + PARTICIPANT = 'Participant', + ARBITER = 'Arbiter', + WORLD_RECORD = 'WorldRecord' } export enum NodeEnvironment { - DEVELOPMENT='DEV', - PRODUCTION='PROD' + DEVELOPMENT = 'DEV', + PRODUCTION = 'PROD' } export enum AutoAccept { - Always = "always", - ContentApproved = "contentApproved", - Never = "never" + Always = 'always', + ContentApproved = 'contentApproved', + Never = 'never' } export enum SortMembers { - CREATED_DATE_TIME = 'createDateTime', - STATUS = 'status', - ID = 'id', - ORGANIZATION = 'organization' + CREATED_DATE_TIME = 'createDateTime', + STATUS = 'status', + ID = 'id', + ORGANIZATION = 'organization' } const transitionMap: { [key in Invitation]: Invitation[] } = { - [Invitation.PENDING]: [Invitation.ACCEPTED, Invitation.REJECTED], - [Invitation.ACCEPTED]: [], - [Invitation.REJECTED]: [] + [Invitation.PENDING]: [Invitation.ACCEPTED, Invitation.REJECTED], + [Invitation.ACCEPTED]: [], + [Invitation.REJECTED]: [] }; -export const transition = (currentStatus: Invitation, nextStatus: Invitation): boolean => (transitionMap[currentStatus].includes(nextStatus)); +export const transition = (currentStatus: Invitation, nextStatus: Invitation): boolean => + transitionMap[currentStatus].includes(nextStatus); export enum SchemaType { - INDY = 'indy', - W3C_Schema = 'w3c' + INDY = 'indy', + W3C_Schema = 'w3c' } export enum IssueCredentialType { - JSONLD = 'jsonld', - INDY = 'indy' + JSONLD = 'jsonld', + INDY = 'indy' } export enum TemplateIdentifier { - EMAIL_COLUMN = 'email_identifier' + EMAIL_COLUMN = 'email_identifier' } export enum PromiseResult { - REJECTED = 'rejected', - FULFILLED = 'fulfilled' + REJECTED = 'rejected', + FULFILLED = 'fulfilled' } export enum PrismaTables { - PRESENTATIONS = 'presentations', - CREDENTIALS = 'credentials', - ORG_AGENTS = 'org_agents', - ORG_DIDS = 'org_dids', - AGENT_INVITATIONS = 'agent_invitations', - CONNECTIONS = 'connections', - FILE_UPLOAD = 'file_upload', - NOTIFICATION = 'notification', - USER_ACTIVITY = 'user_activity', - USER_ORG_ROLES = 'user_org_roles', - ORG_INVITATIONS = 'org_invitations', - ORGANIZATION = 'organization' + PRESENTATIONS = 'presentations', + CREDENTIALS = 'credentials', + ORG_AGENTS = 'org_agents', + ORG_DIDS = 'org_dids', + AGENT_INVITATIONS = 'agent_invitations', + CONNECTIONS = 'connections', + FILE_UPLOAD = 'file_upload', + NOTIFICATION = 'notification', + USER_ACTIVITY = 'user_activity', + USER_ORG_ROLES = 'user_org_roles', + ORG_INVITATIONS = 'org_invitations', + ORGANIZATION = 'organization' } export enum IssuanceProcessState { - PROPOSAL_SENT = 'proposal-sent', - PROPOSAL_RECEIVED = 'proposal-received', - OFFER_SENT = 'offer-sent', - OFFER_RECEIVED = 'offer-received', - DECLIEND = 'decliend', - REQUEST_SENT = 'request-sent', - REQUEST_RECEIVED = 'request-received', - CREDENTIAL_ISSUED = 'credential-issued', - CREDENTIAL_RECEIVED = 'credential-received', - DONE = 'done', - ABANDONED = 'abandoned' + PROPOSAL_SENT = 'proposal-sent', + PROPOSAL_RECEIVED = 'proposal-received', + OFFER_SENT = 'offer-sent', + OFFER_RECEIVED = 'offer-received', + DECLIEND = 'decliend', + REQUEST_SENT = 'request-sent', + REQUEST_RECEIVED = 'request-received', + CREDENTIAL_ISSUED = 'credential-issued', + CREDENTIAL_RECEIVED = 'credential-received', + DONE = 'done', + ABANDONED = 'abandoned' } export enum VerificationProcessState { - PROPOSAL_SENT = 'proposal-sent', - PROPOSAL_RECEIVED = 'proposal-received', - REQUEST_SENT = 'request-sent', - REQUEST_RECEIVED = 'request-received', - PRESENTATION_SENT = 'presentation-sent', - PRESENTATION_RECEIVED = 'presentation-received', - DECLIEND = 'declined', - ABANDONED = 'abandoned', - DONE = 'done' + PROPOSAL_SENT = 'proposal-sent', + PROPOSAL_RECEIVED = 'proposal-received', + REQUEST_SENT = 'request-sent', + REQUEST_RECEIVED = 'request-received', + PRESENTATION_SENT = 'presentation-sent', + PRESENTATION_RECEIVED = 'presentation-received', + DECLIEND = 'declined', + ABANDONED = 'abandoned', + DONE = 'done' } export enum ConnectionProcessState { - START = 'start', - INVITATION_SENT = 'invitation-sent', - INVITATION_RECEIVED = 'invitation-received', - REQUEST_SENT = 'request-sent', - DECLIEND = 'decliend', - REQUEST_RECEIVED = 'request-received', - RESPONSE_SENT = 'response-sent', - RESPONSE_RECEIVED = 'response-received', - COMPLETE = 'completed', - ABANDONED = 'abandoned' + START = 'start', + INVITATION_SENT = 'invitation-sent', + INVITATION_RECEIVED = 'invitation-received', + REQUEST_SENT = 'request-sent', + DECLIEND = 'decliend', + REQUEST_RECEIVED = 'request-received', + RESPONSE_SENT = 'response-sent', + RESPONSE_RECEIVED = 'response-received', + COMPLETE = 'completed', + ABANDONED = 'abandoned' } export enum SchemaTypeEnum { - JSON = 'json', - INDY = 'indy' - } + JSON = 'json', + INDY = 'indy' +} export enum W3CSchemaDataType { - NUMBER = 'number', - INTEGER = 'integer', - STRING = 'string', - DATE_TIME = 'datetime-local', - ARRAY= 'array', - OBJECT = 'object', - BOOLEAN = 'boolean' - } + NUMBER = 'number', + INTEGER = 'integer', + STRING = 'string', + DATE_TIME = 'datetime-local', + ARRAY = 'array', + OBJECT = 'object', + BOOLEAN = 'boolean' +} + +export enum IndySchemaDataType { + NUMBER = 'number', + STRING = 'string', + DATE_TIME = 'datetime-local', + BOOLEAN = 'boolean' +} export enum JSONSchemaType { - POLYGON_W3C = 'polygon', - LEDGER_LESS = 'no_ledger' + POLYGON_W3C = 'polygon', + LEDGER_LESS = 'no_ledger' } export enum NetworkNamespace { - POLYGON_TESTNET = 'polygon:testnet' + POLYGON_TESTNET = 'polygon:testnet' } export enum LedgerLessMethods { - WEB = 'web', - KEY = 'key' + WEB = 'web', + KEY = 'key' } export enum LedgerLessConstant { - NO_LEDGER = 'no_ledger', + NO_LEDGER = 'no_ledger' } export enum ledgerLessDIDType { - DID_KEY = 'did:key', - DID_WEB = 'did:web' + DID_KEY = 'did:key', + DID_WEB = 'did:web' } export enum CloudWalletType { - BASE_WALLET = 'CLOUD_BASE_WALLET', - SUB_WALLET = 'CLOUD_SUB_WALLET' + BASE_WALLET = 'CLOUD_BASE_WALLET', + SUB_WALLET = 'CLOUD_SUB_WALLET' } export enum UserRole { - DEFAULT_USER = 'DEFAULT_USER', - HOLDER = 'HOLDER' + DEFAULT_USER = 'DEFAULT_USER', + HOLDER = 'HOLDER' } export enum ProofType { - POLYGON_PROOFTYPE = 'EcdsaSecp256k1Signature2019', - NO_LEDGER_PROOFTYPE = 'Ed25519Signature2018' -} \ No newline at end of file + POLYGON_PROOFTYPE = 'EcdsaSecp256k1Signature2019', + NO_LEDGER_PROOFTYPE = 'Ed25519Signature2018' +}