Skip to content

Commit

Permalink
Move DTOs to create user to authz-shared
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Feb 9, 2024
1 parent bf9560d commit d81fdef
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 235 deletions.
7 changes: 6 additions & 1 deletion apps/authz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ authz/test/integration:
authz/test/e2e:
npx nx test:e2e ${AUTHZ_PROJECT_NAME} -- ${ARGS}

authz/test:
make authz/test/unit
make authz/test/integration
make authz/test/e2e

# === Open Policy Agent & Rego ===

authz/rego/compile:
Expand All @@ -123,7 +128,7 @@ authz/rego/template:
make authz/rego/compile

make authz/rego/wasm

authz/rego/bundle:
rm -rf ${AUTHZ_PROJECT_DIR}/src/opa/build

Expand Down
13 changes: 10 additions & 3 deletions apps/authz/src/app/evaluation-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { AccessList, AccountId, Action, Address, FiatCurrency, Hex } from '@narval/authz-shared'
import {
AccessList,
AccountId,
Action,
Address,
BaseActionDto,
FiatCurrency,
Hex,
RequestSignatureDto
} from '@narval/authz-shared'
import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger'
import { Transform, Type } from 'class-transformer'
import { IsDefined, IsEthereumAddress, IsIn, IsOptional, IsString, ValidateNested } from 'class-validator'
import { BaseActionDto } from './http/rest/dto/base-action.dto'
import { RequestSignatureDto } from './http/rest/dto/request-signature.dto'

export class TransactionRequestDto {
@IsString()
Expand Down
9 changes: 3 additions & 6 deletions apps/authz/src/app/http/rest/controller/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RegisterWalletRequest,
UpdateUserRequest
} from '@narval/authz-shared'
import { Body, Controller, HttpStatus, Logger, Patch, Post } from '@nestjs/common'
import { Body, Controller, HttpStatus, Patch, Post } from '@nestjs/common'
import { ApiOperation, ApiResponse } from '@nestjs/swagger'
import { AdminService } from '../../../core/admin.service'
import { AssignUserGroupRequestDto } from '../dto/assign-user-group-request.dto'
Expand All @@ -36,8 +36,6 @@ import { UpdateUserResponseDto } from '../dto/update-user-response.dto'

@Controller('/admin')
export class AdminController {
private logger = new Logger(AdminController.name)

constructor(private readonly adminService: AdminService) {}

@Post('/organizations')
Expand Down Expand Up @@ -83,10 +81,9 @@ export class AdminController {
async createCredential(@Body() body: CreateCredentialRequestDto) {
const payload: CreateCredentialRequest = body

const authCredential = await this.adminService.createCredential(payload)
const credential = await this.adminService.createCredential(payload)

const response = new CreateCredentialResponseDto(authCredential)
return response
return new CreateCredentialResponseDto({ credential })
}

@Post('/user-groups')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action, UserGroupMembership } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto, UserGroupMembership } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class AssignUserGroupActionDto extends BaseActionDto {
@IsIn(Object.values(Action))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action, UserWallet } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto, UserWallet } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class AssignUserWalletActionDto extends BaseActionDto {
@IsIn(Object.values(Action))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action, WalletGroupMembership } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto, WalletGroupMembership } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class AssignWalletGroupActionDto extends BaseActionDto {
@IsIn(Object.values(Action))
Expand Down
32 changes: 0 additions & 32 deletions apps/authz/src/app/http/rest/dto/auth-credential.dto.ts

This file was deleted.

17 changes: 0 additions & 17 deletions apps/authz/src/app/http/rest/dto/base-action.dto.ts

This file was deleted.

19 changes: 0 additions & 19 deletions apps/authz/src/app/http/rest/dto/base-admin-request-payload.dto.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Action } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { AddressBookAccountDataDto } from './address-book-account-dto'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class CreateAddressBookAccountActionDto extends BaseActionDto {
@IsIn(Object.values(Action))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Action } from '@narval/authz-shared'
import { Action, AuthCredentialDto, BaseActionDto, BaseAdminRequestPayloadDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { AuthCredentialDto } from './auth-credential.dto'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class CreateCredentialActionDto extends BaseActionDto {
@IsIn(Object.values(Action))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { AuthCredential } from '@narval/authz-shared'
import { AuthCredentialDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { AuthCredentialDto } from './auth-credential.dto'

export class CreateCredentialResponseDto {
constructor(authCredential: AuthCredential) {
this.credential = new AuthCredentialDto(authCredential)
}

@IsDefined()
@ValidateNested()
@ApiProperty()
credential: AuthCredentialDto

constructor(partial: Partial<CreateCredentialResponseDto>) {
Object.assign(this, partial)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Action } from '@narval/authz-shared'
import { Action, AuthCredentialDto, BaseActionDto, BaseAdminRequestPayloadDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, IsString, ValidateNested } from 'class-validator'
import { AuthCredentialDto } from './auth-credential.dto'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class CreateOrganizationDataDto {
@IsString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { AuthCredential } from '@narval/authz-shared'
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger'
import { AuthCredential, AuthCredentialDto, UserDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsString, ValidateNested } from 'class-validator'
import { Organization, User } from '../../../../shared/types/entities.types'
import { AuthCredentialDto } from './auth-credential.dto'
import { UserDto } from './user-dto'

class OrganizationDataDto {
@IsString()
Expand All @@ -12,7 +10,6 @@ class OrganizationDataDto {
uid: string
}

@ApiExtraModels(OrganizationDataDto, AuthCredentialDto)
export class CreateOrganizationResponseDto {
constructor(organization: Organization, rootCredential: AuthCredential, rootUser: User) {
this.organization = organization
Expand Down
49 changes: 0 additions & 49 deletions apps/authz/src/app/http/rest/dto/create-user-request.dto.ts

This file was deleted.

24 changes: 0 additions & 24 deletions apps/authz/src/app/http/rest/dto/create-user-response.dto.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsArray, IsDefined, IsIn, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'
import { TokenDataDto } from './register-token-dto'

class RegisterTokensActionDto extends BaseActionDto {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'
import { WalletDataDto } from './wallet-dto'

class RegisterWalletActionDto extends BaseActionDto {
Expand Down
20 changes: 0 additions & 20 deletions apps/authz/src/app/http/rest/dto/request-signature.dto.ts

This file was deleted.

4 changes: 1 addition & 3 deletions apps/authz/src/app/http/rest/dto/update-user-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Action, UserRole } from '@narval/authz-shared'
import { Action, BaseActionDto, BaseAdminRequestPayloadDto, UserRole } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, IsString, ValidateNested } from 'class-validator'
import { BaseActionDto } from './base-action.dto'
import { BaseAdminRequestPayloadDto } from './base-admin-request-payload.dto'

class UpdateUserDataDto {
@IsString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UserDto } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { User } from '../../../../shared/types/entities.types'
import { UserDto } from './user-dto'

export class UpdateUserResponseDto {
constructor(user: User) {
Expand Down
Loading

0 comments on commit d81fdef

Please sign in to comment.