diff --git a/apps/orchestration/src/store/entity/http/rest/dto/address-book-account-dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/address-book-account.dto.ts similarity index 70% rename from apps/orchestration/src/store/entity/http/rest/dto/address-book-account-dto.ts rename to apps/orchestration/src/store/entity/http/rest/dto/address-book-account.dto.ts index c272cd5d9..725b73490 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/address-book-account-dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/address-book-account.dto.ts @@ -1,6 +1,6 @@ import { AccountClassification, Address } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsEnum, IsEthereumAddress, IsNotEmpty, IsNumber, IsString } from 'class-validator' +import { IsEnum, IsEthereumAddress, IsNotEmpty, IsNumber, IsString } from 'class-validator' export class AddressBookAccountDataDto { @IsString() @@ -9,9 +9,7 @@ export class AddressBookAccountDataDto { uid: string @IsEnum(AccountClassification) - @ApiProperty({ - enum: Object.values(AccountClassification) - }) + @ApiProperty({ enum: AccountClassification }) classification: AccountClassification @IsEthereumAddress() @@ -22,7 +20,6 @@ export class AddressBookAccountDataDto { address: Address @IsNumber() - @IsDefined() @ApiProperty() chainId: number } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-request.dto.ts index 661745124..71a7c25d3 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-request.dto.ts @@ -1,14 +1,13 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsIn, ValidateNested } from 'class-validator' +import { IsDefined, Matches, ValidateNested } from 'class-validator' import { UserGroupMembershipDto } from './user-group-membership.dto' class AssignUserGroupActionDto extends BaseActionDto { - @IsIn(Object.values(Action)) - @IsDefined() + @Matches(Action.ASSIGN_USER_GROUP) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.ASSIGN_USER_GROUP], default: Action.ASSIGN_USER_GROUP }) action: typeof Action.ASSIGN_USER_GROUP @@ -16,9 +15,7 @@ class AssignUserGroupActionDto extends BaseActionDto { @IsDefined() @Type(() => UserGroupMembershipDto) @ValidateNested() - @ApiProperty({ - type: UserGroupMembershipDto - }) + @ApiProperty() data: UserGroupMembershipDto } @@ -26,8 +23,6 @@ export class AssignUserGroupRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => AssignUserGroupActionDto) @ValidateNested() - @ApiProperty({ - type: AssignUserGroupActionDto - }) + @ApiProperty() request: AssignUserGroupActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-response.dto.ts index c1a475ae0..f6ba30084 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-group-response.dto.ts @@ -7,9 +7,7 @@ export class AssignUserGroupResponseDto { @IsDefined() @Type(() => UserGroupMembershipDto) @ValidateNested() - @ApiProperty({ - type: UserGroupMembershipDto - }) + @ApiProperty() data: UserGroupMembershipDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-request.dto.ts index b8afb2540..13a3c3318 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-request.dto.ts @@ -1,13 +1,13 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, ValidateNested } from 'class-validator' +import { IsDefined, Matches, ValidateNested } from 'class-validator' import { UserWalletDto } from './user-wallet.dto' class AssignUserWalletActionDto extends BaseActionDto { - @IsEnum(Object.values(Action)) + @Matches(Action.ASSIGN_USER_WALLET) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.ASSIGN_USER_WALLET], default: Action.ASSIGN_USER_WALLET }) action: typeof Action.ASSIGN_USER_WALLET @@ -15,9 +15,7 @@ class AssignUserWalletActionDto extends BaseActionDto { @IsDefined() @Type(() => UserWalletDto) @ValidateNested() - @ApiProperty({ - type: UserWalletDto - }) + @ApiProperty() data: UserWalletDto } @@ -25,8 +23,6 @@ export class AssignUserWalletRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => AssignUserWalletActionDto) @ValidateNested() - @ApiProperty({ - type: AssignUserWalletActionDto - }) + @ApiProperty() request: AssignUserWalletActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-response.dto.ts index 0c85d15f4..8843250d3 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-user-wallet-response.dto.ts @@ -7,9 +7,7 @@ export class AssignUserWalletResponseDto { @IsDefined() @Type(() => UserWalletDto) @ValidateNested() - @ApiProperty({ - type: UserWalletDto - }) + @ApiProperty() data: UserWalletDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-request.dto.ts index 786a24a66..4ce28af08 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-request.dto.ts @@ -1,14 +1,13 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, ValidateNested } from 'class-validator' +import { IsDefined, Matches, ValidateNested } from 'class-validator' import { WalletGroupMembershipDto } from './wallet-group-membership.dto' class AssignWalletGroupActionDto extends BaseActionDto { - @IsEnum(Action) - @IsDefined() + @Matches(Action.ASSIGN_WALLET_GROUP) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.ASSIGN_WALLET_GROUP], default: Action.ASSIGN_WALLET_GROUP }) action: typeof Action.ASSIGN_WALLET_GROUP @@ -16,9 +15,7 @@ class AssignWalletGroupActionDto extends BaseActionDto { @IsDefined() @Type(() => WalletGroupMembershipDto) @ValidateNested() - @ApiProperty({ - type: WalletGroupMembershipDto - }) + @ApiProperty() data: WalletGroupMembershipDto } @@ -26,8 +23,6 @@ export class AssignWalletGroupRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => AssignWalletGroupActionDto) @ValidateNested() - @ApiProperty({ - type: AssignWalletGroupActionDto - }) + @ApiProperty() request: AssignWalletGroupActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-response.dto.ts index b2e5988e7..afbcb33ae 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/assign-wallet-group-response.dto.ts @@ -7,9 +7,7 @@ export class AssignWalletGroupResponseDto { @IsDefined() @Type(() => WalletGroupMembershipDto) @ValidateNested() - @ApiProperty({ - type: WalletGroupMembershipDto - }) + @ApiProperty() data: WalletGroupMembershipDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/auth-credential.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/auth-credential.dto.ts index 8ab0e1e6c..fab97a676 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/auth-credential.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/auth-credential.dto.ts @@ -1,25 +1,24 @@ import { Alg } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsIn, IsString } from 'class-validator' +import { IsDefined, IsEnum, IsIn, IsNotEmpty, IsString } from 'class-validator' export class AuthCredentialDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() uid: string @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() pubKey: string - @IsIn(Object.values(Alg)) - @IsDefined() - @ApiProperty({ enum: Object.values(Alg) }) + @IsEnum(Alg) + @ApiProperty({ enum: Alg }) alg: Alg @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() userId: string } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-request.dto.ts index 1d4efe9fa..d5fcc9b84 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-request.dto.ts @@ -1,13 +1,13 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, ValidateNested } from 'class-validator' -import { AddressBookAccountDataDto } from './address-book-account-dto' +import { IsDefined, Matches, ValidateNested } from 'class-validator' +import { AddressBookAccountDataDto } from './address-book-account.dto' class CreateAddressBookAccountActionDto extends BaseActionDto { - @IsEnum(Action) + @Matches(Action.CREATE_ADDRESS_BOOK_ACCOUNT) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.CREATE_ADDRESS_BOOK_ACCOUNT], default: Action.CREATE_ADDRESS_BOOK_ACCOUNT }) action: typeof Action.CREATE_ADDRESS_BOOK_ACCOUNT diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-response.dto.ts index 29b2d6e96..8a1815ced 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-address-book-response.dto.ts @@ -1,15 +1,13 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, ValidateNested } from 'class-validator' -import { AddressBookAccountDataDto } from './address-book-account-dto' +import { AddressBookAccountDataDto } from './address-book-account.dto' export class CreateAddressBookAccountResponseDto { @IsDefined() @Type(() => AddressBookAccountDataDto) @ValidateNested() - @ApiProperty({ - type: AddressBookAccountDataDto - }) + @ApiProperty() account: AddressBookAccountDataDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-credential-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-credential-request.dto.ts index 8a5413e93..c77411aed 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-credential-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-credential-request.dto.ts @@ -1,19 +1,19 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, ValidateNested } from 'class-validator' +import { IsDefined, Matches, ValidateNested } from 'class-validator' import { AuthCredentialDto } from './auth-credential.dto' class CreateCredentialActionDto extends BaseActionDto { - @IsEnum(Action) - @IsDefined() + @Matches(Action.CREATE_CREDENTIAL) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.CREATE_CREDENTIAL], default: Action.CREATE_CREDENTIAL }) action: typeof Action.CREATE_CREDENTIAL @IsDefined() + @Type(() => AuthCredentialDto) @ValidateNested() @ApiProperty() credential: AuthCredentialDto @@ -23,8 +23,6 @@ export class CreateCredentialRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => CreateCredentialActionDto) @ValidateNested() - @ApiProperty({ - type: CreateCredentialActionDto - }) + @ApiProperty() request: CreateCredentialActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-credential-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-credential-response.dto.ts index fddf0e46b..df458e864 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-credential-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-credential-response.dto.ts @@ -7,9 +7,7 @@ export class CreateCredentialResponseDto { @IsDefined() @Type(() => AuthCredentialDto) @ValidateNested() - @ApiProperty({ - type: AuthCredentialDto - }) + @ApiProperty() credential: AuthCredentialDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-organization-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-organization-request.dto.ts index d5d4a55f5..b57da1e68 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-organization-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-organization-request.dto.ts @@ -1,7 +1,7 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, IsNotEmpty, IsString, ValidateNested } from 'class-validator' +import { IsDefined, IsNotEmpty, IsString, Matches, ValidateNested } from 'class-validator' import { AuthCredentialDto } from './auth-credential.dto' class CreateOrganizationDataDto { @@ -13,17 +13,14 @@ class CreateOrganizationDataDto { @IsDefined() @Type(() => AuthCredentialDto) @ValidateNested() - @ApiProperty({ - type: AuthCredentialDto - }) + @ApiProperty() credential: AuthCredentialDto } class CreateOrganizationActionDto extends BaseActionDto { - @IsEnum(Action) - @IsDefined() + @Matches(Action.CREATE_ORGANIZATION) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.CREATE_ORGANIZATION], default: Action.CREATE_ORGANIZATION }) action: typeof Action.CREATE_ORGANIZATION @@ -31,9 +28,7 @@ class CreateOrganizationActionDto extends BaseActionDto { @IsDefined() @Type(() => CreateOrganizationDataDto) @ValidateNested() - @ApiProperty({ - type: CreateOrganizationDataDto - }) + @ApiProperty() organization: CreateOrganizationDataDto } @@ -41,8 +36,6 @@ export class CreateOrganizationRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => CreateOrganizationActionDto) @ValidateNested() - @ApiProperty({ - type: CreateOrganizationActionDto - }) + @ApiProperty() request: CreateOrganizationActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-organization-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-organization-response.dto.ts index e2ade3751..2833e73a0 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-organization-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-organization-response.dto.ts @@ -2,7 +2,7 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, IsNotEmpty, IsString, ValidateNested } from 'class-validator' import { AuthCredentialDto } from './auth-credential.dto' -import { UserDto } from './user-dto' +import { UserDto } from './user.dto' class OrganizationDataDto { @IsString() @@ -15,25 +15,19 @@ export class CreateOrganizationResponseDto { @IsDefined() @Type(() => OrganizationDataDto) @ValidateNested() - @ApiProperty({ - type: OrganizationDataDto - }) + @ApiProperty() organization: OrganizationDataDto @IsDefined() @Type(() => AuthCredentialDto) @ValidateNested() - @ApiProperty({ - type: AuthCredentialDto - }) + @ApiProperty() rootCredential: AuthCredentialDto @IsDefined() @Type(() => UserDto) @ValidateNested() - @ApiProperty({ - type: UserDto - }) + @ApiProperty() rootUser: UserDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-user-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-user-request.dto.ts index 8ebeaa8d5..9e54c3ca7 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-user-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-user-request.dto.ts @@ -1,41 +1,36 @@ import { Action, BaseActionDto, BaseActionRequestDto, UserRole } from '@narval/authz-shared' -import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsIn, IsOptional, IsString, ValidateNested } from 'class-validator' +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' +import { Type } from 'class-transformer' +import { IsDefined, IsEnum, IsNotEmpty, IsOptional, IsString, Matches, ValidateNested } from 'class-validator' import { AuthCredentialDto } from './auth-credential.dto' class CreateUserDataDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() uid: string - @IsIn(Object.values(UserRole)) - @IsDefined() - @ApiProperty({ - enum: Object.values(UserRole) - }) + @IsEnum(UserRole) + @ApiProperty({ enum: UserRole }) role: UserRole - @IsString() @IsOptional() + @Type(() => AuthCredentialDto) @ValidateNested() - @ApiProperty({ - type: () => AuthCredentialDto, - required: false - }) + @ApiPropertyOptional() credential?: AuthCredentialDto } class CreateUserActionDto extends BaseActionDto { - @IsIn(Object.values(Action)) - @IsDefined() + @Matches(Action.CREATE_USER) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.CREATE_USER], default: Action.CREATE_USER }) action: typeof Action.CREATE_USER @IsDefined() + @Type(() => CreateUserDataDto) @ValidateNested() @ApiProperty() user: CreateUserDataDto @@ -43,6 +38,7 @@ class CreateUserActionDto extends BaseActionDto { export class CreateUserRequestDto extends BaseActionRequestDto { @IsDefined() + @Type(() => CreateUserActionDto) @ValidateNested() @ApiProperty() request: CreateUserActionDto diff --git a/apps/orchestration/src/store/entity/http/rest/dto/create-user-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/create-user-response.dto.ts index e8ef1cd68..0cdd74087 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/create-user-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/create-user-response.dto.ts @@ -1,15 +1,13 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, ValidateNested } from 'class-validator' -import { UserDto } from './user-dto' +import { UserDto } from './user.dto' export class CreateUserResponseDto { @IsDefined() @Type(() => UserDto) @ValidateNested() - @ApiProperty({ - type: UserDto - }) + @ApiProperty() user: UserDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-request.dto.ts index e7a418984..955b25ef9 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-request.dto.ts @@ -1,24 +1,21 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsArray, IsDefined, IsEnum, ValidateNested } from 'class-validator' -import { TokenDto } from './token-dto' +import { ArrayNotEmpty, IsDefined, Matches, ValidateNested } from 'class-validator' +import { TokenDto } from './token.dto' class RegisterTokensActionDto extends BaseActionDto { - @IsEnum(Action) + @Matches(Action.REGISTER_TOKENS) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.REGISTER_TOKENS], default: Action.REGISTER_TOKENS }) action: typeof Action.REGISTER_TOKENS - @IsDefined() + @ArrayNotEmpty() @Type(() => TokenDto) - @ValidateNested() - @IsArray() - @ApiProperty({ - type: TokenDto - }) + @ValidateNested({ each: true }) + @ApiProperty({ type: [TokenDto] }) tokens: TokenDto[] } @@ -26,8 +23,6 @@ export class RegisterTokensRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => RegisterTokensActionDto) @ValidateNested() - @ApiProperty({ - type: RegisterTokensActionDto - }) + @ApiProperty() request: RegisterTokensActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-response.dto.ts index 3c0244574..824af5d18 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/register-tokens-response.dto.ts @@ -1,16 +1,13 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsArray, ValidateNested } from 'class-validator' -import { TokenDto } from './token-dto' +import { ArrayNotEmpty, ValidateNested } from 'class-validator' +import { TokenDto } from './token.dto' export class RegisterTokensResponseDto { + @ArrayNotEmpty() @Type(() => TokenDto) @ValidateNested({ each: true }) - @IsArray() - @ApiProperty({ - type: TokenDto, - isArray: true - }) + @ApiProperty({ type: [TokenDto] }) tokens: TokenDto[] constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-request.dto.ts index 3d48a2a5c..f002d643f 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-request.dto.ts @@ -1,13 +1,13 @@ import { Action, BaseActionDto, BaseActionRequestDto } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' -import { IsDefined, IsEnum, ValidateNested } from 'class-validator' -import { WalletDto } from './wallet-dto' +import { IsDefined, Matches, ValidateNested } from 'class-validator' +import { WalletDto } from './wallet.dto' class RegisterWalletActionDto extends BaseActionDto { - @IsEnum(Action) + @Matches(Action.REGISTER_WALLET) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.REGISTER_WALLET], default: Action.REGISTER_WALLET }) action: typeof Action.REGISTER_WALLET @@ -15,9 +15,7 @@ class RegisterWalletActionDto extends BaseActionDto { @IsDefined() @Type(() => WalletDto) @ValidateNested() - @ApiProperty({ - type: WalletDto - }) + @ApiProperty() wallet: WalletDto } @@ -25,8 +23,6 @@ export class RegisterWalletRequestDto extends BaseActionRequestDto { @IsDefined() @Type(() => RegisterWalletActionDto) @ValidateNested() - @ApiProperty({ - type: RegisterWalletActionDto - }) + @ApiProperty() request: RegisterWalletActionDto } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-response.dto.ts index 3feb294da..3fcb24cbe 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/register-wallet-response.dto.ts @@ -1,15 +1,13 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, ValidateNested } from 'class-validator' -import { WalletDto } from './wallet-dto' +import { WalletDto } from './wallet.dto' export class RegisterWalletResponseDto { @IsDefined() @Type(() => WalletDto) @ValidateNested() - @ApiProperty({ - type: WalletDto - }) + @ApiProperty() wallet: WalletDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/request-signature.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/request-signature.dto.ts index 61b7d3865..b72e77678 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/request-signature.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/request-signature.dto.ts @@ -1,20 +1,19 @@ import { Alg } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsIn, IsString } from 'class-validator' +import { IsEnum, IsNotEmpty, IsString } from 'class-validator' export class RequestSignatureDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() sig: string - @IsIn(Object.values(Alg)) - @IsDefined() - @ApiProperty({ enum: Object.values(Alg) }) + @IsEnum(Alg) + @ApiProperty({ enum: Alg }) alg: Alg @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() pubKey: string } diff --git a/apps/orchestration/src/store/entity/http/rest/dto/token-dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/token.dto.ts similarity index 97% rename from apps/orchestration/src/store/entity/http/rest/dto/token-dto.ts rename to apps/orchestration/src/store/entity/http/rest/dto/token.dto.ts index 765b900e8..1adfed3fa 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/token-dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/token.dto.ts @@ -8,7 +8,6 @@ export class TokenDto { @ApiProperty() uid: string - @IsDefined() @IsEthereumAddress() @ApiProperty({ format: 'address', diff --git a/apps/orchestration/src/store/entity/http/rest/dto/update-user-request.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/update-user-request.dto.ts index 11639712c..800e6de66 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/update-user-request.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/update-user-request.dto.ts @@ -1,31 +1,29 @@ import { Action, BaseActionDto, BaseActionRequestDto, UserRole } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsIn, IsString, ValidateNested } from 'class-validator' +import { Type } from 'class-transformer' +import { IsDefined, IsEnum, IsNotEmpty, IsString, Matches, ValidateNested } from 'class-validator' class UpdateUserDataDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() uid: string - @IsIn(Object.values(UserRole)) - @IsDefined() - @ApiProperty({ - enum: Object.values(UserRole) - }) + @IsEnum(UserRole) + @ApiProperty({ enum: UserRole }) role: UserRole } class UpdateUserActionDto extends BaseActionDto { - @IsIn(Object.values(Action)) - @IsDefined() + @Matches(Action.UPDATE_USER) @ApiProperty({ - enum: Object.values(Action), + enum: [Action.UPDATE_USER], default: Action.UPDATE_USER }) action: typeof Action.UPDATE_USER @IsDefined() + @Type(() => UpdateUserDataDto) @ValidateNested() @ApiProperty() user: UpdateUserDataDto @@ -33,6 +31,7 @@ class UpdateUserActionDto extends BaseActionDto { export class UpdateUserRequestDto extends BaseActionRequestDto { @IsDefined() + @Type(() => UpdateUserActionDto) @ValidateNested() @ApiProperty() request: UpdateUserActionDto diff --git a/apps/orchestration/src/store/entity/http/rest/dto/update-user-response.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/update-user-response.dto.ts index 27f1e6cc1..c31a6914f 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/update-user-response.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/update-user-response.dto.ts @@ -1,15 +1,13 @@ import { ApiProperty } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, ValidateNested } from 'class-validator' -import { UserDto } from './user-dto' +import { UserDto } from './user.dto' export class UpdateUserResponseDto { @IsDefined() @Type(() => UserDto) @ValidateNested() - @ApiProperty({ - type: UserDto - }) + @ApiProperty() user: UserDto constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/user-group-membership.dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/user-group-membership.dto.ts index b767162c9..da09da42a 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/user-group-membership.dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/user-group-membership.dto.ts @@ -1,14 +1,14 @@ import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsString } from 'class-validator' +import { IsDefined, IsNotEmpty, IsString } from 'class-validator' export class UserGroupMembershipDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() userId: string @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() groupId: string diff --git a/apps/orchestration/src/store/entity/http/rest/dto/user-dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/user.dto.ts similarity index 59% rename from apps/orchestration/src/store/entity/http/rest/dto/user-dto.ts rename to apps/orchestration/src/store/entity/http/rest/dto/user.dto.ts index 5f19795ec..467321218 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/user-dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/user.dto.ts @@ -1,18 +1,15 @@ import { UserRole } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' -import { IsDefined, IsIn, IsString } from 'class-validator' +import { IsEnum, IsNotEmpty, IsString } from 'class-validator' export class UserDto { @IsString() - @IsDefined() + @IsNotEmpty() @ApiProperty() uid: string - @IsIn(Object.values(UserRole)) - @IsDefined() - @ApiProperty({ - enum: Object.values(UserRole) - }) + @IsEnum(UserRole) + @ApiProperty({ enum: UserRole }) role: UserRole constructor(partial: Partial) { diff --git a/apps/orchestration/src/store/entity/http/rest/dto/wallet-dto.ts b/apps/orchestration/src/store/entity/http/rest/dto/wallet.dto.ts similarity index 89% rename from apps/orchestration/src/store/entity/http/rest/dto/wallet-dto.ts rename to apps/orchestration/src/store/entity/http/rest/dto/wallet.dto.ts index 2d3e48a4b..80f905a77 100644 --- a/apps/orchestration/src/store/entity/http/rest/dto/wallet-dto.ts +++ b/apps/orchestration/src/store/entity/http/rest/dto/wallet.dto.ts @@ -9,13 +9,10 @@ export class WalletDto { uid: string @IsEnum(AccountType) - @ApiProperty({ - enum: Object.values(AccountType) - }) + @ApiProperty({ enum: AccountType }) accountType: AccountType @IsEthereumAddress() - @IsNotEmpty() @ApiProperty({ type: String, format: 'address'