Skip to content

Commit

Permalink
Refactor @app/authz to use relative import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Feb 8, 2024
1 parent 117609b commit f2c62f3
Show file tree
Hide file tree
Showing 52 changed files with 145 additions and 162 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx", "no-relative-import-paths"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand All @@ -10,7 +10,6 @@
"error",
{
"enforceBuildableLibDependency": true,
"allow": ["@app/**", "@narval/**"],
"depConstraints": [
{
"sourceTag": "*",
Expand Down
11 changes: 1 addition & 10 deletions apps/authz/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"rules": {
"no-relative-import-paths/no-relative-import-paths": [
"error",
{
"allowSameFolder": true,
"rootDir": "apps",
"prefix": "@app"
}
]
}
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
Expand Down
2 changes: 0 additions & 2 deletions apps/authz/jest.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-relative-import-paths/no-relative-import-paths */

import type { Config } from 'jest'
import sharedConfig from './jest.config'

Expand Down
2 changes: 0 additions & 2 deletions apps/authz/jest.integration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-relative-import-paths/no-relative-import-paths */

import type { Config } from 'jest'
import sharedConfig from './jest.config'

Expand Down
2 changes: 0 additions & 2 deletions apps/authz/jest.unit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-relative-import-paths/no-relative-import-paths */

import type { Config } from 'jest'
import sharedConfig from './jest.config'

Expand Down
12 changes: 6 additions & 6 deletions apps/authz/src/app/__test__/e2e/admin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { load } from '@app/authz/app/app.config'
import { AppModule } from '@app/authz/app/app.module'
import { AAUser, AAUser_Credential_1 } from '@app/authz/app/persistence/repository/mock_data'
import { PersistenceModule } from '@app/authz/shared/module/persistence/persistence.module'
import { TestPrismaService } from '@app/authz/shared/module/persistence/service/test-prisma.service'
import { Organization } from '@app/authz/shared/types/entities.types'
import { AccountClassification, AccountType, Action, Alg, Signature, UserRole } from '@narval/authz-shared'
import { HttpStatus, INestApplication } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { Test, TestingModule } from '@nestjs/testing'
import request from 'supertest'
import { AppModule } from '../../../app/app.module'
import { AAUser, AAUser_Credential_1 } from '../../../app/persistence/repository/mock_data'
import { PersistenceModule } from '../../../shared/module/persistence/persistence.module'
import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service'
import { Organization } from '../../../shared/types/entities.types'
import { load } from '../../app.config'

const REQUEST_HEADER_ORG_ID = 'x-org-id'
describe('Admin Endpoints', () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/authz/src/app/__test__/unit/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { finalizeDecision } from '@app/authz/app/app.service'
import { OpaResult } from '@app/authz/shared/types/rego'
import { Decision, EntityType } from '@narval/authz-shared'
import { OpaResult } from '../../../shared/types/rego'
import { finalizeDecision } from '../../app.service'

describe('finalizeDecision', () => {
it('returns Forbid if any of the reasons is Forbid', () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/authz/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EvaluationRequestDto } from '@app/authz/app/evaluation-request.dto'
import { generateInboundRequest } from '@app/authz/app/persistence/repository/mock_data'
import { EvaluationRequest } from '@narval/authz-shared'
import { Body, Controller, Get, Logger, Post } from '@nestjs/common'
import { generateInboundRequest } from '../app/persistence/repository/mock_data'
import { AppService } from './app.service'
import { EvaluationRequestDto } from './evaluation-request.dto'

@Controller()
export class AppController {
Expand Down
8 changes: 4 additions & 4 deletions apps/authz/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AdminService } from '@app/authz/app/core/admin.service'
import { AdminController } from '@app/authz/app/http/rest/controller/admin.controller'
import { AdminRepository } from '@app/authz/app/persistence/repository/admin.repository'
import { PersistenceModule } from '@app/authz/shared/module/persistence/persistence.module'
import { Module, ValidationPipe } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { APP_PIPE } from '@nestjs/core'
import { PersistenceModule } from '../shared/module/persistence/persistence.module'
import { load } from './app.config'
import { AppController } from './app.controller'
import { AppService } from './app.service'
import { AdminService } from './core/admin.service'
import { AdminController } from './http/rest/controller/admin.controller'
import { OpaService } from './opa/opa.service'
import { AdminRepository } from './persistence/repository/admin.repository'

@Module({
imports: [
Expand Down
6 changes: 3 additions & 3 deletions apps/authz/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { AdminRepository } from '@app/authz/app/persistence/repository/admin.repository'
import { OpaResult, RegoInput } from '@app/authz/shared/types/domain.type'
import {
Action,
Alg,
Expand All @@ -18,6 +16,8 @@ import { InputType } from 'packages/transaction-request-intent/src/lib/domain'
import { Intent } from 'packages/transaction-request-intent/src/lib/intent.types'
import { Hex, verifyMessage } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { AdminRepository } from '../app/persistence/repository/admin.repository'
import { OpaResult, RegoInput } from '../shared/types/domain.type'
import { OpaService } from './opa/opa.service'

const ENGINE_PRIVATE_KEY = '0x7cfef3303797cbc7515d9ce22ffe849c701b0f2812f999b0847229c47951fca5'
Expand Down Expand Up @@ -189,7 +189,7 @@ export class AppService {
const authzResponse: EvaluationResponse = {
decision: finalDecision.decision,
request,
transactionRequestIntent: intent,
// transactionRequestIntent: intent,
approvals: finalDecision.totalApprovalsRequired?.length
? {
required: finalDecision.totalApprovalsRequired,
Expand Down
4 changes: 2 additions & 2 deletions apps/authz/src/app/core/admin.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { AdminRepository } from '@app/authz/app/persistence/repository/admin.repository'
import { AddressBookAccount, Organization, Token, User, Wallet } from '@app/authz/shared/types/entities.types'
import {
AssignUserGroupRequest,
AssignUserWalletRequest,
Expand All @@ -17,6 +15,8 @@ import {
WalletGroupMembership
} from '@narval/authz-shared'
import { Injectable } from '@nestjs/common'
import { AddressBookAccount, Organization, Token, User, Wallet } from '../../shared/types/entities.types'
import { AdminRepository } from '../persistence/repository/admin.repository'

@Injectable()
export class AdminService {
Expand Down
4 changes: 2 additions & 2 deletions apps/authz/src/app/evaluation-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { RequestSignatureDto } from '@app/authz/app/http/rest/dto/request-signature.dto'
import { AccessList, AccountId, Action, Address, FiatCurrency, Hex } 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
42 changes: 21 additions & 21 deletions apps/authz/src/app/http/rest/controller/admin.controller.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
import { AdminService } from '@app/authz/app/core/admin.service'
import { AssignUserGroupRequestDto } from '@app/authz/app/http/rest/dto/assign-user-group-request.dto'
import { AssignUserGroupResponseDto } from '@app/authz/app/http/rest/dto/assign-user-group-response.dto'
import { AssignUserWalletRequestDto } from '@app/authz/app/http/rest/dto/assign-user-wallet-request.dto'
import { AssignUserWalletResponseDto } from '@app/authz/app/http/rest/dto/assign-user-wallet-response.dto'
import { AssignWalletGroupRequestDto } from '@app/authz/app/http/rest/dto/assign-wallet-group-request.dto'
import { AssignWalletGroupResponseDto } from '@app/authz/app/http/rest/dto/assign-wallet-group-response.dto'
import { CreateAddressBookAccountRequestDto } from '@app/authz/app/http/rest/dto/create-address-book-request.dto'
import { CreateAddressBookAccountResponseDto } from '@app/authz/app/http/rest/dto/create-address-book-response.dto'
import { CreateCredentialRequestDto } from '@app/authz/app/http/rest/dto/create-credential-request.dto'
import { CreateCredentialResponseDto } from '@app/authz/app/http/rest/dto/create-credential-response.dto'
import { CreateOrganizationRequestDto } from '@app/authz/app/http/rest/dto/create-organization-request.dto'
import { CreateOrganizationResponseDto } from '@app/authz/app/http/rest/dto/create-organization-response.dto'
import { CreateUserRequestDto } from '@app/authz/app/http/rest/dto/create-user-request.dto'
import { CreateUserResponseDto } from '@app/authz/app/http/rest/dto/create-user-response.dto'
import { RegisterTokensRequestDto } from '@app/authz/app/http/rest/dto/register-tokens-request.dto'
import { RegisterTokensResponseDto } from '@app/authz/app/http/rest/dto/register-tokens-response.dto'
import { RegisterWalletRequestDto } from '@app/authz/app/http/rest/dto/register-wallet-request.dto'
import { RegisterWalletResponseDto } from '@app/authz/app/http/rest/dto/register-wallet-response.dto'
import { UpdateUserRequestDto } from '@app/authz/app/http/rest/dto/update-user-request.dto'
import { UpdateUserResponseDto } from '@app/authz/app/http/rest/dto/update-user-response.dto'
import {
AssignUserGroupRequest,
AssignUserWalletRequest,
Expand All @@ -32,6 +11,27 @@ import {
UpdateUserRequest
} from '@narval/authz-shared'
import { Body, Controller, Logger, Patch, Post } from '@nestjs/common'
import { AdminService } from '../../../core/admin.service'
import { AssignUserGroupRequestDto } from '../dto/assign-user-group-request.dto'
import { AssignUserGroupResponseDto } from '../dto/assign-user-group-response.dto'
import { AssignUserWalletRequestDto } from '../dto/assign-user-wallet-request.dto'
import { AssignUserWalletResponseDto } from '../dto/assign-user-wallet-response.dto'
import { AssignWalletGroupRequestDto } from '../dto/assign-wallet-group-request.dto'
import { AssignWalletGroupResponseDto } from '../dto/assign-wallet-group-response.dto'
import { CreateAddressBookAccountRequestDto } from '../dto/create-address-book-request.dto'
import { CreateAddressBookAccountResponseDto } from '../dto/create-address-book-response.dto'
import { CreateCredentialRequestDto } from '../dto/create-credential-request.dto'
import { CreateCredentialResponseDto } from '../dto/create-credential-response.dto'
import { CreateOrganizationRequestDto } from '../dto/create-organization-request.dto'
import { CreateOrganizationResponseDto } from '../dto/create-organization-response.dto'
import { CreateUserRequestDto } from '../dto/create-user-request.dto'
import { CreateUserResponseDto } from '../dto/create-user-response.dto'
import { RegisterTokensRequestDto } from '../dto/register-tokens-request.dto'
import { RegisterTokensResponseDto } from '../dto/register-tokens-response.dto'
import { RegisterWalletRequestDto } from '../dto/register-wallet-request.dto'
import { RegisterWalletResponseDto } from '../dto/register-wallet-response.dto'
import { UpdateUserRequestDto } from '../dto/update-user-request.dto'
import { UpdateUserResponseDto } from '../dto/update-user-response.dto'

@Controller('/admin')
export class AdminController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AddressBookAccount } from '@app/authz/shared/types/entities.types'
import { AccountClassification, Address } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, IsNumber, IsString } from 'class-validator'
import { AddressBookAccount } from '../../../../shared/types/entities.types'

export class AddressBookAccountDataDto {
constructor(addressBookAccount: AddressBookAccount) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action, 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,7 +1,7 @@
import { UserGroupMembershipDto } from '@app/authz/app/http/rest/dto/user-group-membership.dto'
import { UserGroupMembership } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { UserGroupMembershipDto } from './user-group-membership.dto'

export class AssignUserGroupResponseDto {
constructor(userGroup: UserGroupMembership) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action, 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,7 +1,7 @@
import { UserWalletDto } from '@app/authz/app/http/rest/dto/user-wallet.dto'
import { UserWallet } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { UserWalletDto } from './user-wallet.dto'

export class AssignUserWalletResponseDto {
constructor(userWallet: UserWallet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action, 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WalletGroupMembershipDto } from '@app/authz/app/http/rest/dto/wallet-group-membership.dto'
import { WalletGroupMembership } from '@narval/authz-shared'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { WalletGroupMembershipDto } from './wallet-group-membership.dto'

export class AssignWalletGroupResponseDto {
constructor(walletGroup: WalletGroupMembership) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestSignatureDto } from '@app/authz/app/http/rest/dto/request-signature.dto'
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger'
import { ArrayNotEmpty, IsDefined, ValidateNested } from 'class-validator'
import { RequestSignatureDto } from './request-signature.dto'

@ApiExtraModels(RequestSignatureDto)
export class BaseAdminRequestPayloadDto {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AddressBookAccountDataDto } from '@app/authz/app/http/rest/dto/address-book-account-dto'
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action } 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,7 +1,7 @@
import { AddressBookAccountDataDto } from '@app/authz/app/http/rest/dto/address-book-account-dto'
import { AddressBookAccount } from '@app/authz/shared/types/entities.types'
import { ApiProperty } from '@nestjs/swagger'
import { IsDefined, ValidateNested } from 'class-validator'
import { AddressBookAccount } from '../../../../shared/types/entities.types'
import { AddressBookAccountDataDto } from './address-book-account-dto'

export class CreateAddressBookAccountResponseDto {
constructor(account: AddressBookAccount) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action } 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,7 +1,7 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { AuthCredential } 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action } 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,9 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { UserDto } from '@app/authz/app/http/rest/dto/user-dto'
import { Organization, User } from '@app/authz/shared/types/entities.types'
import { AuthCredential } from '@narval/authz-shared'
import { ApiExtraModels, 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 Down
6 changes: 3 additions & 3 deletions apps/authz/src/app/http/rest/dto/create-user-request.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { BaseActionDto } from '@app/authz/app/http/rest/dto/base-action.dto'
import { BaseAdminRequestPayloadDto } from '@app/authz/app/http/rest/dto/base-admin-request-payload.dto'
import { Action, UserRole } from '@narval/authz-shared'
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsIn, IsOptional, 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 CreateUserDataDto {
@IsString()
Expand Down
6 changes: 3 additions & 3 deletions apps/authz/src/app/http/rest/dto/create-user-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AuthCredentialDto } from '@app/authz/app/http/rest/dto/auth-credential.dto'
import { UserDto } from '@app/authz/app/http/rest/dto/user-dto'
import { User } from '@app/authz/shared/types/entities.types'
import { ApiExtraModels, ApiProperty } from '@nestjs/swagger'
import { IsDefined, IsString, ValidateNested } from 'class-validator'
import { User } from '../../../../shared/types/entities.types'
import { AuthCredentialDto } from './auth-credential.dto'
import { UserDto } from './user-dto'

class OrganizationDataDto {
@IsString()
Expand Down
Loading

0 comments on commit f2c62f3

Please sign in to comment.