Skip to content

Commit

Permalink
DTOs CR
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 14, 2024
1 parent 98ec08c commit 6ecd25f
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 180 deletions.
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -9,9 +9,7 @@ export class AddressBookAccountDataDto {
uid: string

@IsEnum(AccountClassification)
@ApiProperty({
enum: Object.values(AccountClassification)
})
@ApiProperty({ enum: AccountClassification })
classification: AccountClassification

@IsEthereumAddress()
Expand All @@ -22,7 +20,6 @@ export class AddressBookAccountDataDto {
address: Address

@IsNumber()
@IsDefined()
@ApiProperty()
chainId: number
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
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

@IsDefined()
@Type(() => UserGroupMembershipDto)
@ValidateNested()
@ApiProperty({
type: UserGroupMembershipDto
})
@ApiProperty()
data: UserGroupMembershipDto
}

export class AssignUserGroupRequestDto extends BaseActionRequestDto {
@IsDefined()
@Type(() => AssignUserGroupActionDto)
@ValidateNested()
@ApiProperty({
type: AssignUserGroupActionDto
})
@ApiProperty()
request: AssignUserGroupActionDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export class AssignUserGroupResponseDto {
@IsDefined()
@Type(() => UserGroupMembershipDto)
@ValidateNested()
@ApiProperty({
type: UserGroupMembershipDto
})
@ApiProperty()
data: UserGroupMembershipDto

constructor(partial: Partial<AssignUserGroupResponseDto>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
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

@IsDefined()
@Type(() => UserWalletDto)
@ValidateNested()
@ApiProperty({
type: UserWalletDto
})
@ApiProperty()
data: UserWalletDto
}

export class AssignUserWalletRequestDto extends BaseActionRequestDto {
@IsDefined()
@Type(() => AssignUserWalletActionDto)
@ValidateNested()
@ApiProperty({
type: AssignUserWalletActionDto
})
@ApiProperty()
request: AssignUserWalletActionDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export class AssignUserWalletResponseDto {
@IsDefined()
@Type(() => UserWalletDto)
@ValidateNested()
@ApiProperty({
type: UserWalletDto
})
@ApiProperty()
data: UserWalletDto

constructor(partial: Partial<AssignUserWalletResponseDto>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
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

@IsDefined()
@Type(() => WalletGroupMembershipDto)
@ValidateNested()
@ApiProperty({
type: WalletGroupMembershipDto
})
@ApiProperty()
data: WalletGroupMembershipDto
}

export class AssignWalletGroupRequestDto extends BaseActionRequestDto {
@IsDefined()
@Type(() => AssignWalletGroupActionDto)
@ValidateNested()
@ApiProperty({
type: AssignWalletGroupActionDto
})
@ApiProperty()
request: AssignWalletGroupActionDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export class AssignWalletGroupResponseDto {
@IsDefined()
@Type(() => WalletGroupMembershipDto)
@ValidateNested()
@ApiProperty({
type: WalletGroupMembershipDto
})
@ApiProperty()
data: WalletGroupMembershipDto

constructor(partial: Partial<AssignWalletGroupResponseDto>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CreateAddressBookAccountResponseDto>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,8 +23,6 @@ export class CreateCredentialRequestDto extends BaseActionRequestDto {
@IsDefined()
@Type(() => CreateCredentialActionDto)
@ValidateNested()
@ApiProperty({
type: CreateCredentialActionDto
})
@ApiProperty()
request: CreateCredentialActionDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export class CreateCredentialResponseDto {
@IsDefined()
@Type(() => AuthCredentialDto)
@ValidateNested()
@ApiProperty({
type: AuthCredentialDto
})
@ApiProperty()
credential: AuthCredentialDto

constructor(partial: Partial<CreateCredentialResponseDto>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -13,36 +13,29 @@ 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

@IsDefined()
@Type(() => CreateOrganizationDataDto)
@ValidateNested()
@ApiProperty({
type: CreateOrganizationDataDto
})
@ApiProperty()
organization: CreateOrganizationDataDto
}

export class CreateOrganizationRequestDto extends BaseActionRequestDto {
@IsDefined()
@Type(() => CreateOrganizationActionDto)
@ValidateNested()
@ApiProperty({
type: CreateOrganizationActionDto
})
@ApiProperty()
request: CreateOrganizationActionDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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<CreateOrganizationResponseDto>) {
Expand Down
Loading

0 comments on commit 6ecd25f

Please sign in to comment.