diff --git a/.eslintrc.json b/.eslintrc.json index aa35e0b5d..5f6a588ce 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "ignorePatterns": ["**/*"], - "plugins": ["@nx", "no-relative-import-paths"], + "plugins": ["@nx"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], @@ -10,7 +10,6 @@ "error", { "enforceBuildableLibDependency": true, - "allow": ["@app/**", "@narval/**"], "depConstraints": [ { "sourceTag": "*", diff --git a/apps/authz/.eslintrc.json b/apps/authz/.eslintrc.json index 360c3953c..9d9c0db55 100644 --- a/apps/authz/.eslintrc.json +++ b/apps/authz/.eslintrc.json @@ -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"], diff --git a/apps/authz/jest.e2e.ts b/apps/authz/jest.e2e.ts index 5e65d6150..b7d56d62b 100644 --- a/apps/authz/jest.e2e.ts +++ b/apps/authz/jest.e2e.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/authz/jest.integration.ts b/apps/authz/jest.integration.ts index 3bd1b8e63..533d40428 100644 --- a/apps/authz/jest.integration.ts +++ b/apps/authz/jest.integration.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/authz/jest.unit.ts b/apps/authz/jest.unit.ts index f41a2117d..9376919b3 100644 --- a/apps/authz/jest.unit.ts +++ b/apps/authz/jest.unit.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/authz/src/app/__test__/e2e/admin.spec.ts b/apps/authz/src/app/__test__/e2e/admin.spec.ts index b39b24fab..30962d3be 100644 --- a/apps/authz/src/app/__test__/e2e/admin.spec.ts +++ b/apps/authz/src/app/__test__/e2e/admin.spec.ts @@ -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', () => { diff --git a/apps/authz/src/app/__test__/unit/app.service.spec.ts b/apps/authz/src/app/__test__/unit/app.service.spec.ts index 6bf6a70a4..82d2051bb 100644 --- a/apps/authz/src/app/__test__/unit/app.service.spec.ts +++ b/apps/authz/src/app/__test__/unit/app.service.spec.ts @@ -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', () => { diff --git a/apps/authz/src/app/app.controller.ts b/apps/authz/src/app/app.controller.ts index bf22c55bb..ebe2ba492 100644 --- a/apps/authz/src/app/app.controller.ts +++ b/apps/authz/src/app/app.controller.ts @@ -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 { diff --git a/apps/authz/src/app/app.module.ts b/apps/authz/src/app/app.module.ts index 5c9ef0bdb..e16e91047 100644 --- a/apps/authz/src/app/app.module.ts +++ b/apps/authz/src/app/app.module.ts @@ -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: [ diff --git a/apps/authz/src/app/app.service.ts b/apps/authz/src/app/app.service.ts index da11ef8e3..62e3123d1 100644 --- a/apps/authz/src/app/app.service.ts +++ b/apps/authz/src/app/app.service.ts @@ -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, @@ -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' @@ -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, diff --git a/apps/authz/src/app/core/admin.service.ts b/apps/authz/src/app/core/admin.service.ts index e26546a27..64ee35758 100644 --- a/apps/authz/src/app/core/admin.service.ts +++ b/apps/authz/src/app/core/admin.service.ts @@ -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, @@ -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 { diff --git a/apps/authz/src/app/evaluation-request.dto.ts b/apps/authz/src/app/evaluation-request.dto.ts index e349cff9d..171442e28 100644 --- a/apps/authz/src/app/evaluation-request.dto.ts +++ b/apps/authz/src/app/evaluation-request.dto.ts @@ -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() diff --git a/apps/authz/src/app/http/rest/controller/admin.controller.ts b/apps/authz/src/app/http/rest/controller/admin.controller.ts index 75d974e23..f4f3154ae 100644 --- a/apps/authz/src/app/http/rest/controller/admin.controller.ts +++ b/apps/authz/src/app/http/rest/controller/admin.controller.ts @@ -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, @@ -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 { diff --git a/apps/authz/src/app/http/rest/dto/address-book-account-dto.ts b/apps/authz/src/app/http/rest/dto/address-book-account-dto.ts index 7b7f79e17..446c4038d 100644 --- a/apps/authz/src/app/http/rest/dto/address-book-account-dto.ts +++ b/apps/authz/src/app/http/rest/dto/address-book-account-dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/assign-user-group-request.dto.ts b/apps/authz/src/app/http/rest/dto/assign-user-group-request.dto.ts index d8e0cc497..61e6ec9d5 100644 --- a/apps/authz/src/app/http/rest/dto/assign-user-group-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-user-group-request.dto.ts @@ -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)) diff --git a/apps/authz/src/app/http/rest/dto/assign-user-group-response.dto.ts b/apps/authz/src/app/http/rest/dto/assign-user-group-response.dto.ts index a37f3466f..55191078a 100644 --- a/apps/authz/src/app/http/rest/dto/assign-user-group-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-user-group-response.dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/assign-user-wallet-request.dto.ts b/apps/authz/src/app/http/rest/dto/assign-user-wallet-request.dto.ts index ddcd29017..6394b3d78 100644 --- a/apps/authz/src/app/http/rest/dto/assign-user-wallet-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-user-wallet-request.dto.ts @@ -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)) diff --git a/apps/authz/src/app/http/rest/dto/assign-user-wallet-response.dto.ts b/apps/authz/src/app/http/rest/dto/assign-user-wallet-response.dto.ts index d2823d171..134296da3 100644 --- a/apps/authz/src/app/http/rest/dto/assign-user-wallet-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-user-wallet-response.dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/assign-wallet-group-request.dto.ts b/apps/authz/src/app/http/rest/dto/assign-wallet-group-request.dto.ts index cc8bbc6b5..3697a133d 100644 --- a/apps/authz/src/app/http/rest/dto/assign-wallet-group-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-wallet-group-request.dto.ts @@ -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)) diff --git a/apps/authz/src/app/http/rest/dto/assign-wallet-group-response.dto.ts b/apps/authz/src/app/http/rest/dto/assign-wallet-group-response.dto.ts index 1024e9581..6b91e564a 100644 --- a/apps/authz/src/app/http/rest/dto/assign-wallet-group-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/assign-wallet-group-response.dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/base-admin-request-payload.dto.ts b/apps/authz/src/app/http/rest/dto/base-admin-request-payload.dto.ts index ece3f613f..bd91342d6 100644 --- a/apps/authz/src/app/http/rest/dto/base-admin-request-payload.dto.ts +++ b/apps/authz/src/app/http/rest/dto/base-admin-request-payload.dto.ts @@ -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 { diff --git a/apps/authz/src/app/http/rest/dto/create-address-book-request.dto.ts b/apps/authz/src/app/http/rest/dto/create-address-book-request.dto.ts index 29965bc95..daf4ee6a5 100644 --- a/apps/authz/src/app/http/rest/dto/create-address-book-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-address-book-request.dto.ts @@ -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)) diff --git a/apps/authz/src/app/http/rest/dto/create-address-book-response.dto.ts b/apps/authz/src/app/http/rest/dto/create-address-book-response.dto.ts index b50fed536..a72cbb2f6 100644 --- a/apps/authz/src/app/http/rest/dto/create-address-book-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-address-book-response.dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/create-credential-request.dto.ts b/apps/authz/src/app/http/rest/dto/create-credential-request.dto.ts index d71efebf9..7ea96ecb0 100644 --- a/apps/authz/src/app/http/rest/dto/create-credential-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-credential-request.dto.ts @@ -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)) diff --git a/apps/authz/src/app/http/rest/dto/create-credential-response.dto.ts b/apps/authz/src/app/http/rest/dto/create-credential-response.dto.ts index c355be2b0..50913a550 100644 --- a/apps/authz/src/app/http/rest/dto/create-credential-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-credential-response.dto.ts @@ -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) { diff --git a/apps/authz/src/app/http/rest/dto/create-organization-request.dto.ts b/apps/authz/src/app/http/rest/dto/create-organization-request.dto.ts index b51ac21fc..bea8a45af 100644 --- a/apps/authz/src/app/http/rest/dto/create-organization-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-organization-request.dto.ts @@ -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() diff --git a/apps/authz/src/app/http/rest/dto/create-organization-response.dto.ts b/apps/authz/src/app/http/rest/dto/create-organization-response.dto.ts index 4d98e7f65..cfc6b8f79 100644 --- a/apps/authz/src/app/http/rest/dto/create-organization-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-organization-response.dto.ts @@ -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() diff --git a/apps/authz/src/app/http/rest/dto/create-user-request.dto.ts b/apps/authz/src/app/http/rest/dto/create-user-request.dto.ts index 7d95298bd..a6230b8b3 100644 --- a/apps/authz/src/app/http/rest/dto/create-user-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-user-request.dto.ts @@ -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() diff --git a/apps/authz/src/app/http/rest/dto/create-user-response.dto.ts b/apps/authz/src/app/http/rest/dto/create-user-response.dto.ts index eeb8097a2..960b1b9a3 100644 --- a/apps/authz/src/app/http/rest/dto/create-user-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/create-user-response.dto.ts @@ -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() diff --git a/apps/authz/src/app/http/rest/dto/register-token-dto.ts b/apps/authz/src/app/http/rest/dto/register-token-dto.ts index f814ba431..c8b42e418 100644 --- a/apps/authz/src/app/http/rest/dto/register-token-dto.ts +++ b/apps/authz/src/app/http/rest/dto/register-token-dto.ts @@ -1,7 +1,7 @@ -import { Token } from '@app/authz/shared/types/entities.types' import { Address } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { IsDefined, IsNumber, IsString } from 'class-validator' +import { Token } from '../../../../shared/types/entities.types' export class TokenDataDto { constructor(token: Token) { diff --git a/apps/authz/src/app/http/rest/dto/register-tokens-request.dto.ts b/apps/authz/src/app/http/rest/dto/register-tokens-request.dto.ts index 7ec91e4ec..0f4c999c6 100644 --- a/apps/authz/src/app/http/rest/dto/register-tokens-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/register-tokens-request.dto.ts @@ -1,9 +1,9 @@ -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 { TokenDataDto } from '@app/authz/app/http/rest/dto/register-token-dto' import { Action } 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 { @IsIn(Object.values(Action)) diff --git a/apps/authz/src/app/http/rest/dto/register-tokens-response.dto.ts b/apps/authz/src/app/http/rest/dto/register-tokens-response.dto.ts index 8467cf09b..016863d69 100644 --- a/apps/authz/src/app/http/rest/dto/register-tokens-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/register-tokens-response.dto.ts @@ -1,7 +1,7 @@ -import { TokenDataDto } from '@app/authz/app/http/rest/dto/register-token-dto' -import { Token } from '@app/authz/shared/types/entities.types' import { ApiProperty } from '@nestjs/swagger' import { IsArray, IsDefined, ValidateNested } from 'class-validator' +import { Token } from '../../../../shared/types/entities.types' +import { TokenDataDto } from './register-token-dto' export class RegisterTokensResponseDto { constructor(tokens: Token[]) { diff --git a/apps/authz/src/app/http/rest/dto/register-wallet-request.dto.ts b/apps/authz/src/app/http/rest/dto/register-wallet-request.dto.ts index c41d52b41..255d66ba7 100644 --- a/apps/authz/src/app/http/rest/dto/register-wallet-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/register-wallet-request.dto.ts @@ -1,9 +1,9 @@ -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 { WalletDataDto } from '@app/authz/app/http/rest/dto/wallet-dto' import { Action } 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 { @IsIn(Object.values(Action)) diff --git a/apps/authz/src/app/http/rest/dto/register-wallet-response.dto.ts b/apps/authz/src/app/http/rest/dto/register-wallet-response.dto.ts index 173b7510a..fba910197 100644 --- a/apps/authz/src/app/http/rest/dto/register-wallet-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/register-wallet-response.dto.ts @@ -1,7 +1,7 @@ -import { WalletDataDto } from '@app/authz/app/http/rest/dto/wallet-dto' -import { Wallet } from '@app/authz/shared/types/entities.types' import { ApiProperty } from '@nestjs/swagger' import { IsDefined, ValidateNested } from 'class-validator' +import { Wallet } from '../../../../shared/types/entities.types' +import { WalletDataDto } from './wallet-dto' export class RegisterWalletResponseDto { constructor(wallet: Wallet) { diff --git a/apps/authz/src/app/http/rest/dto/update-user-request.dto.ts b/apps/authz/src/app/http/rest/dto/update-user-request.dto.ts index 373a2abc2..7b17d9809 100644 --- a/apps/authz/src/app/http/rest/dto/update-user-request.dto.ts +++ b/apps/authz/src/app/http/rest/dto/update-user-request.dto.ts @@ -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, 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() diff --git a/apps/authz/src/app/http/rest/dto/update-user-response.dto.ts b/apps/authz/src/app/http/rest/dto/update-user-response.dto.ts index 31e6543ff..aeb4559c6 100644 --- a/apps/authz/src/app/http/rest/dto/update-user-response.dto.ts +++ b/apps/authz/src/app/http/rest/dto/update-user-response.dto.ts @@ -1,7 +1,7 @@ -import { UserDto } from '@app/authz/app/http/rest/dto/user-dto' -import { User } from '@app/authz/shared/types/entities.types' 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) { diff --git a/apps/authz/src/app/http/rest/dto/user-dto.ts b/apps/authz/src/app/http/rest/dto/user-dto.ts index b9cc987a4..6f9fdf497 100644 --- a/apps/authz/src/app/http/rest/dto/user-dto.ts +++ b/apps/authz/src/app/http/rest/dto/user-dto.ts @@ -1,7 +1,7 @@ -import { User } from '@app/authz/shared/types/entities.types' import { UserRole } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { IsDefined, IsIn, IsString } from 'class-validator' +import { User } from '../../../../shared/types/entities.types' export class UserDto { constructor(user: User) { diff --git a/apps/authz/src/app/http/rest/dto/wallet-dto.ts b/apps/authz/src/app/http/rest/dto/wallet-dto.ts index 2a6d6d26d..32bfb6cb2 100644 --- a/apps/authz/src/app/http/rest/dto/wallet-dto.ts +++ b/apps/authz/src/app/http/rest/dto/wallet-dto.ts @@ -1,7 +1,7 @@ -import { Wallet } from '@app/authz/shared/types/entities.types' import { AccountType, Address } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { IsDefined, IsIn, IsNumber, IsOptional, IsString } from 'class-validator' +import { Wallet } from '../../../../shared/types/entities.types' export class WalletDataDto { constructor(wallet: Wallet) { diff --git a/apps/authz/src/app/opa/opa.service.ts b/apps/authz/src/app/opa/opa.service.ts index de8cae313..a7a50ffe9 100644 --- a/apps/authz/src/app/opa/opa.service.ts +++ b/apps/authz/src/app/opa/opa.service.ts @@ -1,11 +1,11 @@ -import { AdminRepository } from '@app/authz/app/persistence/repository/admin.repository' -import { RegoData, User, UserGroup, WalletGroup } from '@app/authz/shared/types/entities.types' -import { OpaResult, RegoInput } from '@app/authz/shared/types/rego' import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common' import { loadPolicy } from '@open-policy-agent/opa-wasm' import { readFileSync } from 'fs' import path from 'path' import * as R from 'remeda' +import { RegoData, User, UserGroup, WalletGroup } from '../../shared/types/entities.types' +import { OpaResult, RegoInput } from '../../shared/types/rego' +import { AdminRepository } from '../persistence/repository/admin.repository' type PromiseType> = T extends Promise ? U : never type OpaEngine = PromiseType> diff --git a/apps/authz/src/app/persistence/repository/__test__/integration/admin.repository.spec.ts b/apps/authz/src/app/persistence/repository/__test__/integration/admin.repository.spec.ts index 9174679e0..c39405a6b 100644 --- a/apps/authz/src/app/persistence/repository/__test__/integration/admin.repository.spec.ts +++ b/apps/authz/src/app/persistence/repository/__test__/integration/admin.repository.spec.ts @@ -1,10 +1,10 @@ -import { load } from '@app/authz/app/app.config' -import { AdminRepository } from '@app/authz/app/persistence/repository/admin.repository' -import { PersistenceModule } from '@app/authz/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/authz/shared/module/persistence/service/test-prisma.service' import { Alg, UserRole } from '@narval/authz-shared' import { ConfigModule, ConfigService } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' +import { load } from '../../../../../app/app.config' +import { AdminRepository } from '../../../../../app/persistence/repository/admin.repository' +import { PersistenceModule } from '../../../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../../../shared/module/persistence/service/test-prisma.service' describe(AdminRepository.name, () => { let module: TestingModule diff --git a/apps/authz/src/app/persistence/repository/admin.repository.ts b/apps/authz/src/app/persistence/repository/admin.repository.ts index 4a049f62d..3e5d7038c 100644 --- a/apps/authz/src/app/persistence/repository/admin.repository.ts +++ b/apps/authz/src/app/persistence/repository/admin.repository.ts @@ -1,8 +1,8 @@ -import { PrismaService } from '@app/authz/shared/module/persistence/service/prisma.service' -import { AddressBookAccount, Organization, RegoData, Token, User, Wallet } from '@app/authz/shared/types/entities.types' import { AccountClassification, AccountType, Address, Alg, AuthCredential, UserRole } from '@narval/authz-shared' import { Injectable, Logger, OnModuleInit } from '@nestjs/common' import { castArray } from 'lodash/fp' +import { PrismaService } from '../../../shared/module/persistence/service/prisma.service' +import { AddressBookAccount, Organization, RegoData, Token, User, Wallet } from '../../../shared/types/entities.types' import { mockEntityData, userAddressStore, userCredentialStore } from './mock_data' function convertResponse( diff --git a/apps/authz/src/app/persistence/repository/mock_data.ts b/apps/authz/src/app/persistence/repository/mock_data.ts index 2ba7f87b3..c376fdef7 100644 --- a/apps/authz/src/app/persistence/repository/mock_data.ts +++ b/apps/authz/src/app/persistence/repository/mock_data.ts @@ -1,12 +1,3 @@ -import { RegoInput } from '@app/authz/shared/types/domain.type' -import { - AddressBookAccount, - RegoData, - User, - UserGroup, - Wallet, - WalletGroup -} from '@app/authz/shared/types/entities.types' import { AccountClassification, AccountId, @@ -25,6 +16,15 @@ import { Intents } from 'packages/transaction-request-intent/src/lib/domain' import { TransferNative } from 'packages/transaction-request-intent/src/lib/intent.types' import { Address, sha256, toHex } from 'viem' import { privateKeyToAccount } from 'viem/accounts' +import { RegoInput } from '../../../shared/types/domain.type' +import { + AddressBookAccount, + RegoData, + User, + UserGroup, + Wallet, + WalletGroup +} from '../../../shared/types/entities.types' export const ONE_ETH = BigInt('1000000000000000000') diff --git a/apps/authz/src/opa/template/mockData.ts b/apps/authz/src/opa/template/mockData.ts index 8a679871a..cd2e2b728 100644 --- a/apps/authz/src/opa/template/mockData.ts +++ b/apps/authz/src/opa/template/mockData.ts @@ -1,6 +1,6 @@ -import { Criterion, PolicyCriterionBuilder, Then } from '@app/authz/shared/types/policy-builder.type' import { Action } from '@narval/authz-shared' import { Intents } from '@narval/transaction-request-intent' +import { Criterion, PolicyCriterionBuilder, Then } from '../../shared/types/policy-builder.type' export const examplePermitPolicy: PolicyCriterionBuilder = { then: Then.PERMIT, diff --git a/apps/authz/src/opa/template/script.ts b/apps/authz/src/opa/template/script.ts index 3ee5b953c..1fb7884d4 100644 --- a/apps/authz/src/opa/template/script.ts +++ b/apps/authz/src/opa/template/script.ts @@ -1,7 +1,7 @@ -import { Criterion, Then } from '@app/authz/shared/types/policy-builder.type' import { readFileSync, writeFileSync } from 'fs' import Handlebars from 'handlebars' import { isEmpty } from 'lodash' +import { Criterion, Then } from '../../shared/types/policy-builder.type' import { policies } from './mockData' Handlebars.registerHelper('criterion', function (item) { diff --git a/apps/authz/src/shared/module/persistence/persistence.module.ts b/apps/authz/src/shared/module/persistence/persistence.module.ts index 6fdf19ecf..95d5dcd4c 100644 --- a/apps/authz/src/shared/module/persistence/persistence.module.ts +++ b/apps/authz/src/shared/module/persistence/persistence.module.ts @@ -1,6 +1,6 @@ -import { PrismaService } from '@app/authz/shared/module/persistence/service/prisma.service' -import { TestPrismaService } from '@app/authz/shared/module/persistence/service/test-prisma.service' import { Module } from '@nestjs/common' +import { PrismaService } from './service/prisma.service' +import { TestPrismaService } from './service/test-prisma.service' @Module({ exports: [PrismaService, TestPrismaService], diff --git a/apps/authz/src/shared/module/persistence/seed.ts b/apps/authz/src/shared/module/persistence/seed.ts index 1bb961ea1..ebd0fb76d 100644 --- a/apps/authz/src/shared/module/persistence/seed.ts +++ b/apps/authz/src/shared/module/persistence/seed.ts @@ -1,7 +1,7 @@ -import { mockEntityData } from '@app/authz/app/persistence/repository/mock_data' -import { User } from '@app/authz/shared/types/entities.types' import { Logger } from '@nestjs/common' import { Organization, PrismaClient } from '@prisma/client/authz' +import { mockEntityData } from '../../../app/persistence/repository/mock_data' +import { User } from '../../../shared/types/entities.types' const prisma = new PrismaClient() diff --git a/apps/authz/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts b/apps/authz/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts index c5f079084..7524813da 100644 --- a/apps/authz/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts +++ b/apps/authz/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts @@ -1,6 +1,6 @@ -import { PrismaService } from '@app/authz/shared/module/persistence/service/prisma.service' import { ConfigService } from '@nestjs/config' import { mock } from 'jest-mock-extended' +import { PrismaService } from '../../prisma.service' describe(PrismaService.name, () => { describe('constructor', () => { diff --git a/apps/authz/src/shared/module/persistence/service/prisma.service.ts b/apps/authz/src/shared/module/persistence/service/prisma.service.ts index d830e73a1..db1c6a955 100644 --- a/apps/authz/src/shared/module/persistence/service/prisma.service.ts +++ b/apps/authz/src/shared/module/persistence/service/prisma.service.ts @@ -1,7 +1,7 @@ -import { Config } from '@app/authz/app/app.config' import { Inject, Injectable, Logger, OnApplicationShutdown, OnModuleDestroy, OnModuleInit } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { PrismaClient } from '@prisma/client/authz' +import { Config } from '../../../../app/app.config' @Injectable() export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy, OnApplicationShutdown { diff --git a/apps/orchestration/.eslintrc.json b/apps/orchestration/.eslintrc.json index 360c3953c..9d9c0db55 100644 --- a/apps/orchestration/.eslintrc.json +++ b/apps/orchestration/.eslintrc.json @@ -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"], diff --git a/apps/orchestration/jest.e2e.ts b/apps/orchestration/jest.e2e.ts index 5e65d6150..b7d56d62b 100644 --- a/apps/orchestration/jest.e2e.ts +++ b/apps/orchestration/jest.e2e.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/orchestration/jest.integration.ts b/apps/orchestration/jest.integration.ts index 3bd1b8e63..533d40428 100644 --- a/apps/orchestration/jest.integration.ts +++ b/apps/orchestration/jest.integration.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/orchestration/jest.unit.ts b/apps/orchestration/jest.unit.ts index f41a2117d..9376919b3 100644 --- a/apps/orchestration/jest.unit.ts +++ b/apps/orchestration/jest.unit.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-relative-import-paths/no-relative-import-paths */ - import type { Config } from 'jest' import sharedConfig from './jest.config' diff --git a/apps/orchestration/src/__test__/fixture/authorization-request.fixture.ts b/apps/orchestration/src/__test__/fixture/authorization-request.fixture.ts index 547ff1ed2..cf8535b16 100644 --- a/apps/orchestration/src/__test__/fixture/authorization-request.fixture.ts +++ b/apps/orchestration/src/__test__/fixture/authorization-request.fixture.ts @@ -1,13 +1,13 @@ -import { addressGenerator, chainIdGenerator, hexGenerator } from '@app/orchestration/__test__/fixture/shared.fixture' -import { Approval, AuthorizationRequest, SignTransaction } from '@app/orchestration/policy-engine/core/type/domain.type' -import { readRequestSchema } from '@app/orchestration/policy-engine/persistence/schema/request.schema' -import { readSignTransactionSchema } from '@app/orchestration/policy-engine/persistence/schema/sign-transaction.schema' -import { signatureSchema } from '@app/orchestration/policy-engine/persistence/schema/signature.schema' -import { readTransactionRequestSchema } from '@app/orchestration/policy-engine/persistence/schema/transaction-request.schema' import { Decision, Signature, TransactionRequest } from '@narval/authz-shared' import { AuthorizationRequestStatus } from '@prisma/client/orchestration' import { z } from 'zod' import { Fixture } from 'zod-fixture' +import { Approval, AuthorizationRequest, SignTransaction } from '../../policy-engine/core/type/domain.type' +import { readRequestSchema } from '../../policy-engine/persistence/schema/request.schema' +import { readSignTransactionSchema } from '../../policy-engine/persistence/schema/sign-transaction.schema' +import { signatureSchema } from '../../policy-engine/persistence/schema/signature.schema' +import { readTransactionRequestSchema } from '../../policy-engine/persistence/schema/transaction-request.schema' +import { addressGenerator, chainIdGenerator, hexGenerator } from './shared.fixture' const approvalSchema = signatureSchema.extend({ id: z.string().uuid(), diff --git a/apps/orchestration/src/__test__/fixture/feed.fixture.ts b/apps/orchestration/src/__test__/fixture/feed.fixture.ts index 444106d88..80df14452 100644 --- a/apps/orchestration/src/__test__/fixture/feed.fixture.ts +++ b/apps/orchestration/src/__test__/fixture/feed.fixture.ts @@ -1,11 +1,11 @@ -import { hexGenerator } from '@app/orchestration/__test__/fixture/shared.fixture' -import { generateTransfer } from '@app/orchestration/__test__/fixture/transfer-tracking.fixture' -import { HistoricalTransferFeedService } from '@app/orchestration/data-feed/core/service/historical-transfer-feed.service' -import { signatureSchema } from '@app/orchestration/policy-engine/persistence/schema/signature.schema' import { Feed, HistoricalTransfer } from '@narval/authz-shared' import { times } from 'lodash/fp' import { z } from 'zod' import { Fixture } from 'zod-fixture' +import { HistoricalTransferFeedService } from '../../data-feed/core/service/historical-transfer-feed.service' +import { signatureSchema } from '../../policy-engine/persistence/schema/signature.schema' +import { hexGenerator } from './shared.fixture' +import { generateTransfer } from './transfer-tracking.fixture' const feedSchema = z.object({ source: z.string().min(1).max(42), diff --git a/apps/orchestration/src/__test__/fixture/price.fixture.ts b/apps/orchestration/src/__test__/fixture/price.fixture.ts index 37f0590cb..e74114ad7 100644 --- a/apps/orchestration/src/__test__/fixture/price.fixture.ts +++ b/apps/orchestration/src/__test__/fixture/price.fixture.ts @@ -1,12 +1,12 @@ -import { generateAddress, generateSupportedChainId } from '@app/orchestration/__test__/fixture/shared.fixture' -import { CHAINS, FIAT_ID_USD } from '@app/orchestration/orchestration.constant' -import { Price } from '@app/orchestration/shared/core/type/price.type' -import { assetIdSchema } from '@app/orchestration/shared/schema/caip.schema' import { AssetType, Namespace, Prices } from '@narval/authz-shared' import { sample } from 'lodash' import { times } from 'lodash/fp' import { z } from 'zod' import { Fixture, Generator } from 'zod-fixture' +import { CHAINS, FIAT_ID_USD } from '../../orchestration.constant' +import { Price } from '../../shared/core/type/price.type' +import { assetIdSchema } from '../../shared/schema/caip.schema' +import { generateAddress, generateSupportedChainId } from './shared.fixture' export const fiatIdSchema = z.custom<`fiat:${string}`>((value) => { const parse = z.string().safeParse(value) diff --git a/apps/orchestration/src/__test__/fixture/shared.fixture.ts b/apps/orchestration/src/__test__/fixture/shared.fixture.ts index 8f8505fcf..c3e6fe66a 100644 --- a/apps/orchestration/src/__test__/fixture/shared.fixture.ts +++ b/apps/orchestration/src/__test__/fixture/shared.fixture.ts @@ -1,12 +1,12 @@ -import { CHAINS } from '@app/orchestration/orchestration.constant' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { addressSchema } from '@app/orchestration/shared/schema/address.schema' -import { chainIdSchema } from '@app/orchestration/shared/schema/chain-id.schema' -import { hexSchema } from '@app/orchestration/shared/schema/hex.schema' import { faker } from '@faker-js/faker' import { Address, getAddress } from '@narval/authz-shared' import { sample } from 'lodash/fp' import { Generator } from 'zod-fixture' +import { CHAINS } from '../../orchestration.constant' +import { ChainId } from '../../shared/core/lib/chains.lib' +import { addressSchema } from '../../shared/schema/address.schema' +import { chainIdSchema } from '../../shared/schema/chain-id.schema' +import { hexSchema } from '../../shared/schema/hex.schema' export const hexGenerator = Generator({ schema: hexSchema, diff --git a/apps/orchestration/src/__test__/fixture/transfer-tracking.fixture.ts b/apps/orchestration/src/__test__/fixture/transfer-tracking.fixture.ts index b71d12fa8..a4d5bcef9 100644 --- a/apps/orchestration/src/__test__/fixture/transfer-tracking.fixture.ts +++ b/apps/orchestration/src/__test__/fixture/transfer-tracking.fixture.ts @@ -1,10 +1,10 @@ -import { generatePrice } from '@app/orchestration/__test__/fixture/price.fixture' -import { addressGenerator, chainIdGenerator } from '@app/orchestration/__test__/fixture/shared.fixture' -import { Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { addressSchema } from '@app/orchestration/shared/schema/address.schema' -import { chainIdSchema } from '@app/orchestration/shared/schema/chain-id.schema' import { z } from 'zod' import { Fixture } from 'zod-fixture' +import { generatePrice } from '../../__test__/fixture/price.fixture' +import { Transfer } from '../../shared/core/type/transfer-tracking.type' +import { addressSchema } from '../../shared/schema/address.schema' +import { chainIdSchema } from '../../shared/schema/chain-id.schema' +import { addressGenerator, chainIdGenerator } from './shared.fixture' const transferFeedSchema = z.object({ id: z.string().uuid(), diff --git a/apps/orchestration/src/data-feed/core/service/__test__/unit/feed.service.spec.ts b/apps/orchestration/src/data-feed/core/service/__test__/unit/feed.service.spec.ts index e3af0f26e..ee9b7fcaf 100644 --- a/apps/orchestration/src/data-feed/core/service/__test__/unit/feed.service.spec.ts +++ b/apps/orchestration/src/data-feed/core/service/__test__/unit/feed.service.spec.ts @@ -1,20 +1,20 @@ +import { Feed, HistoricalTransfer, Prices } from '@narval/authz-shared' +import { Test, TestingModule } from '@nestjs/testing' +import { MockProxy, mock, mockDeep } from 'jest-mock-extended' import { generateAuthorizationRequest, generateSignTransactionRequest, generateSignature, generateTransactionRequest -} from '@app/orchestration/__test__/fixture/authorization-request.fixture' -import { generateHistoricalTransfers } from '@app/orchestration/__test__/fixture/feed.fixture' -import { generatePrices } from '@app/orchestration/__test__/fixture/price.fixture' -import { FeedService } from '@app/orchestration/data-feed/core/service/feed.service' -import { HistoricalTransferFeedService } from '@app/orchestration/data-feed/core/service/historical-transfer-feed.service' -import { PriceFeedService } from '@app/orchestration/data-feed/core/service/price-feed.service' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' -import { Feed, HistoricalTransfer, Prices } from '@narval/authz-shared' -import { Test, TestingModule } from '@nestjs/testing' -import { MockProxy, mock, mockDeep } from 'jest-mock-extended' +} from '../../../../../__test__/fixture/authorization-request.fixture' +import { generateHistoricalTransfers } from '../../../../../__test__/fixture/feed.fixture' +import { generatePrices } from '../../../../../__test__/fixture/price.fixture' +import { AuthorizationRequest } from '../../../../../policy-engine/core/type/domain.type' +import { ChainId } from '../../../../../shared/core/lib/chains.lib' +import { PrismaService } from '../../../../../shared/module/persistence/service/prisma.service' +import { FeedService } from '../../feed.service' +import { HistoricalTransferFeedService } from '../../historical-transfer-feed.service' +import { PriceFeedService } from '../../price-feed.service' describe(FeedService.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/data-feed/core/service/__test__/unit/historical-transfer-feed.service.spec.ts b/apps/orchestration/src/data-feed/core/service/__test__/unit/historical-transfer-feed.service.spec.ts index edbe24cb1..a510e40f9 100644 --- a/apps/orchestration/src/data-feed/core/service/__test__/unit/historical-transfer-feed.service.spec.ts +++ b/apps/orchestration/src/data-feed/core/service/__test__/unit/historical-transfer-feed.service.spec.ts @@ -1,20 +1,20 @@ -import { - generateAuthorizationRequest, - generateSignTransactionRequest, - generateTransactionRequest -} from '@app/orchestration/__test__/fixture/authorization-request.fixture' -import { generateTransfer } from '@app/orchestration/__test__/fixture/transfer-tracking.fixture' -import { HistoricalTransferFeedService } from '@app/orchestration/data-feed/core/service/historical-transfer-feed.service' -import { load } from '@app/orchestration/orchestration.config' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' import { Alg } from '@narval/authz-shared' import { ConfigModule } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' import { MockProxy, mock } from 'jest-mock-extended' import { times } from 'lodash/fp' +import { + generateAuthorizationRequest, + generateSignTransactionRequest, + generateTransactionRequest +} from '../../../../../__test__/fixture/authorization-request.fixture' +import { generateTransfer } from '../../../../../__test__/fixture/transfer-tracking.fixture' +import { load } from '../../../../../orchestration.config' +import { AuthorizationRequest } from '../../../../../policy-engine/core/type/domain.type' +import { ChainId } from '../../../../../shared/core/lib/chains.lib' +import { Transfer } from '../../../../../shared/core/type/transfer-tracking.type' +import { TransferTrackingService } from '../../../../../transfer-tracking/core/service/transfer-tracking.service' +import { HistoricalTransferFeedService } from '../../../../core/service/historical-transfer-feed.service' describe(HistoricalTransferFeedService.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/data-feed/core/service/__test__/unit/price-feed.service.spec.ts b/apps/orchestration/src/data-feed/core/service/__test__/unit/price-feed.service.spec.ts index cded139b4..3991456f5 100644 --- a/apps/orchestration/src/data-feed/core/service/__test__/unit/price-feed.service.spec.ts +++ b/apps/orchestration/src/data-feed/core/service/__test__/unit/price-feed.service.spec.ts @@ -1,18 +1,18 @@ -import { - generateAuthorizationRequest, - generateSignTransactionRequest, - generateTransactionRequest -} from '@app/orchestration/__test__/fixture/authorization-request.fixture' -import { PriceFeedService } from '@app/orchestration/data-feed/core/service/price-feed.service' -import { load } from '@app/orchestration/orchestration.config' -import { FIAT_ID_USD, POLYGON } from '@app/orchestration/orchestration.constant' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' import { Alg, Prices } from '@narval/authz-shared' import { ConfigModule } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' import { MockProxy, mock } from 'jest-mock-extended' +import { + generateAuthorizationRequest, + generateSignTransactionRequest, + generateTransactionRequest +} from '../../../../../__test__/fixture/authorization-request.fixture' +import { load } from '../../../../../orchestration.config' +import { FIAT_ID_USD, POLYGON } from '../../../../../orchestration.constant' +import { AuthorizationRequest } from '../../../../../policy-engine/core/type/domain.type' +import { PriceService } from '../../../../../price/core/service/price.service' +import { ChainId } from '../../../../../shared/core/lib/chains.lib' +import { PriceFeedService } from '../../../../core/service/price-feed.service' describe(PriceFeedService.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/data-feed/core/service/feed.service.ts b/apps/orchestration/src/data-feed/core/service/feed.service.ts index 993c0c5dc..8ff7f1248 100644 --- a/apps/orchestration/src/data-feed/core/service/feed.service.ts +++ b/apps/orchestration/src/data-feed/core/service/feed.service.ts @@ -1,12 +1,12 @@ -import { HistoricalTransferFeedService } from '@app/orchestration/data-feed/core/service/historical-transfer-feed.service' -import { PriceFeedService } from '@app/orchestration/data-feed/core/service/price-feed.service' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { DataFeedException } from '@app/orchestration/shared/core/exception/data-feed.exception' -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' import { Feed } from '@narval/authz-shared' import { HttpStatus, Injectable } from '@nestjs/common' import { Prisma } from '@prisma/client/orchestration' import { v4 as uuid } from 'uuid' +import { HistoricalTransferFeedService } from '../../../data-feed/core/service/historical-transfer-feed.service' +import { PriceFeedService } from '../../../data-feed/core/service/price-feed.service' +import { AuthorizationRequest } from '../../../policy-engine/core/type/domain.type' +import { DataFeedException } from '../../../shared/core/exception/data-feed.exception' +import { PrismaService } from '../../../shared/module/persistence/service/prisma.service' const isJsonObject = (value: unknown): boolean => typeof value === 'object' && value !== null && !Array.isArray(value) diff --git a/apps/orchestration/src/data-feed/core/service/historical-transfer-feed.service.ts b/apps/orchestration/src/data-feed/core/service/historical-transfer-feed.service.ts index f2c58a44f..f0528359e 100644 --- a/apps/orchestration/src/data-feed/core/service/historical-transfer-feed.service.ts +++ b/apps/orchestration/src/data-feed/core/service/historical-transfer-feed.service.ts @@ -1,13 +1,13 @@ -import { DataFeed } from '@app/orchestration/data-feed/core/type/data-feed.type' -import { Config } from '@app/orchestration/orchestration.config' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' import { Alg, Feed, HistoricalTransfer, Signature, hashRequest } from '@narval/authz-shared' import { Injectable } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { mapValues, omit } from 'lodash/fp' import { privateKeyToAccount } from 'viem/accounts' +import { DataFeed } from '../../../data-feed/core/type/data-feed.type' +import { Config } from '../../../orchestration.config' +import { AuthorizationRequest } from '../../../policy-engine/core/type/domain.type' +import { Transfer } from '../../../shared/core/type/transfer-tracking.type' +import { TransferTrackingService } from '../../../transfer-tracking/core/service/transfer-tracking.service' @Injectable() export class HistoricalTransferFeedService implements DataFeed { diff --git a/apps/orchestration/src/data-feed/core/service/price-feed.service.ts b/apps/orchestration/src/data-feed/core/service/price-feed.service.ts index b48d3adf4..82e6ada5f 100644 --- a/apps/orchestration/src/data-feed/core/service/price-feed.service.ts +++ b/apps/orchestration/src/data-feed/core/service/price-feed.service.ts @@ -1,16 +1,16 @@ -import { DataFeed } from '@app/orchestration/data-feed/core/type/data-feed.type' -import { Config } from '@app/orchestration/orchestration.config' -import { FIAT_ID_USD } from '@app/orchestration/orchestration.constant' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { getChain } from '@app/orchestration/shared/core/lib/chains.lib' -import { Prices } from '@app/orchestration/shared/core/type/price.type' import { Action, Alg, AssetId, Feed, Signature, hashRequest } from '@narval/authz-shared' import { InputType, Intents, safeDecode } from '@narval/transaction-request-intent' import { Injectable } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { uniq } from 'lodash/fp' import { privateKeyToAccount } from 'viem/accounts' +import { Config } from '../../../orchestration.config' +import { FIAT_ID_USD } from '../../../orchestration.constant' +import { AuthorizationRequest } from '../../../policy-engine/core/type/domain.type' +import { PriceService } from '../../../price/core/service/price.service' +import { getChain } from '../../../shared/core/lib/chains.lib' +import { Prices } from '../../../shared/core/type/price.type' +import { DataFeed } from '../type/data-feed.type' @Injectable() export class PriceFeedService implements DataFeed { diff --git a/apps/orchestration/src/data-feed/core/type/data-feed.type.ts b/apps/orchestration/src/data-feed/core/type/data-feed.type.ts index 3f842485e..8d78f37ab 100644 --- a/apps/orchestration/src/data-feed/core/type/data-feed.type.ts +++ b/apps/orchestration/src/data-feed/core/type/data-feed.type.ts @@ -1,5 +1,6 @@ -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' import { Feed, Signature } from '@narval/authz-shared' +// TODO (@wcalderipe, 06/02/24): Move the AuthorizationRequest type to shared +import { AuthorizationRequest } from '../../../policy-engine/core/type/domain.type' export interface DataFeed { getId(): string diff --git a/apps/orchestration/src/data-feed/data-feed.module.ts b/apps/orchestration/src/data-feed/data-feed.module.ts index bdfdf590c..a3b8ec118 100644 --- a/apps/orchestration/src/data-feed/data-feed.module.ts +++ b/apps/orchestration/src/data-feed/data-feed.module.ts @@ -1,10 +1,10 @@ -import { FeedService } from '@app/orchestration/data-feed/core/service/feed.service' -import { HistoricalTransferFeedService } from '@app/orchestration/data-feed/core/service/historical-transfer-feed.service' -import { PriceFeedService } from '@app/orchestration/data-feed/core/service/price-feed.service' -import { PriceModule } from '@app/orchestration/price/price.module' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TransferTrackingModule } from '@app/orchestration/transfer-tracking/transfer-tracking.module' import { Module } from '@nestjs/common' +import { PriceModule } from '../price/price.module' +import { PersistenceModule } from '../shared/module/persistence/persistence.module' +import { TransferTrackingModule } from '../transfer-tracking/transfer-tracking.module' +import { FeedService } from './/core/service/feed.service' +import { HistoricalTransferFeedService } from './/core/service/historical-transfer-feed.service' +import { PriceFeedService } from './/core/service/price-feed.service' @Module({ imports: [PersistenceModule, PriceModule, TransferTrackingModule], diff --git a/apps/orchestration/src/main.ts b/apps/orchestration/src/main.ts index 93b90e6e6..c9fdacc53 100644 --- a/apps/orchestration/src/main.ts +++ b/apps/orchestration/src/main.ts @@ -1,12 +1,12 @@ -import { OrchestrationModule } from '@app/orchestration/orchestration.module' -import { ApplicationExceptionFilter } from '@app/orchestration/shared/filter/application-exception.filter' -import { ZodExceptionFilter } from '@app/orchestration/shared/filter/zod-exception.filter' import { ClassSerializerInterceptor, INestApplication, Logger, ValidationPipe } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { NestFactory, Reflector } from '@nestjs/core' import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger' import { lastValueFrom, map, of, switchMap } from 'rxjs' import { Config } from './orchestration.config' +import { OrchestrationModule } from './orchestration.module' +import { ApplicationExceptionFilter } from './shared/filter/application-exception.filter' +import { ZodExceptionFilter } from './shared/filter/zod-exception.filter' /** * Adds Swagger documentation to the application. diff --git a/apps/orchestration/src/orchestration.constant.ts b/apps/orchestration/src/orchestration.constant.ts index 331a054fd..1e8f7cc89 100644 --- a/apps/orchestration/src/orchestration.constant.ts +++ b/apps/orchestration/src/orchestration.constant.ts @@ -1,7 +1,7 @@ -import { Chain, ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { FiatId } from '@app/orchestration/shared/core/type/price.type' import { AssetId } from '@narval/authz-shared' import { BackoffOptions } from 'bull' +import { Chain, ChainId } from './shared/core/lib/chains.lib' +import { FiatId } from './shared/core/type/price.type' export const REQUEST_HEADER_ORG_ID = 'x-org-id' diff --git a/apps/orchestration/src/orchestration.module.ts b/apps/orchestration/src/orchestration.module.ts index 92e9b00a8..be19ab2b9 100644 --- a/apps/orchestration/src/orchestration.module.ts +++ b/apps/orchestration/src/orchestration.module.ts @@ -1,10 +1,10 @@ -import { PolicyEngineModule } from '@app/orchestration/policy-engine/policy-engine.module' -import { TransferTrackingModule } from '@app/orchestration/transfer-tracking/transfer-tracking.module' import { ClassSerializerInterceptor, Module } from '@nestjs/common' import { ConfigModule } from '@nestjs/config' import { APP_INTERCEPTOR } from '@nestjs/core' import { load } from './orchestration.config' +import { PolicyEngineModule } from './policy-engine/policy-engine.module' import { QueueModule } from './shared/module/queue/queue.module' +import { TransferTrackingModule } from './transfer-tracking/transfer-tracking.module' @Module({ imports: [ diff --git a/apps/orchestration/src/policy-engine/__test__/e2e/authorization-request.spec.ts b/apps/orchestration/src/policy-engine/__test__/e2e/authorization-request.spec.ts index 75a28eaca..57e4aeb4f 100644 --- a/apps/orchestration/src/policy-engine/__test__/e2e/authorization-request.spec.ts +++ b/apps/orchestration/src/policy-engine/__test__/e2e/authorization-request.spec.ts @@ -1,15 +1,3 @@ -import { load } from '@app/orchestration/orchestration.config' -import { - AUTHORIZATION_REQUEST_PROCESSING_QUEUE, - REQUEST_HEADER_ORG_ID -} from '@app/orchestration/orchestration.constant' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { SignatureDto } from '@app/orchestration/policy-engine/http/rest/dto/signature.dto' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { PolicyEngineModule } from '@app/orchestration/policy-engine/policy-engine.module' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' -import { QueueModule } from '@app/orchestration/shared/module/queue/queue.module' import { Action, Alg } from '@narval/authz-shared' import { getQueueToken } from '@nestjs/bull' import { HttpStatus, INestApplication } from '@nestjs/common' @@ -19,6 +7,15 @@ import { AuthorizationRequestStatus, Organization } from '@prisma/client/orchest import { Queue } from 'bull' import request from 'supertest' import { stringToHex } from 'viem' +import { load } from '../../../orchestration.config' +import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE, REQUEST_HEADER_ORG_ID } from '../../../orchestration.constant' +import { AuthorizationRequest } from '../../../policy-engine/core/type/domain.type' +import { SignatureDto } from '../../../policy-engine/http/rest/dto/signature.dto' +import { AuthorizationRequestRepository } from '../../../policy-engine/persistence/repository/authorization-request.repository' +import { PolicyEngineModule } from '../../../policy-engine/policy-engine.module' +import { PersistenceModule } from '../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service' +import { QueueModule } from '../../../shared/module/queue/queue.module' const ENDPOINT_PREFIX = '/authorization-requests' diff --git a/apps/orchestration/src/policy-engine/core/exception/authorization-request-already-processing.exception.ts b/apps/orchestration/src/policy-engine/core/exception/authorization-request-already-processing.exception.ts index e4ed89c52..9aac9e212 100644 --- a/apps/orchestration/src/policy-engine/core/exception/authorization-request-already-processing.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/authorization-request-already-processing.exception.ts @@ -1,6 +1,6 @@ -import { PolicyEngineException } from '@app/orchestration/policy-engine/core/exception/policy-engine.exception' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' import { HttpStatus } from '@nestjs/common' +import { AuthorizationRequest } from '../type/domain.type' +import { PolicyEngineException } from './policy-engine.exception' export class AuthorizationRequestAlreadyProcessingException extends PolicyEngineException { constructor(authzRequest: AuthorizationRequest) { diff --git a/apps/orchestration/src/policy-engine/core/exception/cluster-not-found.exception.ts b/apps/orchestration/src/policy-engine/core/exception/cluster-not-found.exception.ts index aa22e9d67..e93906f1e 100644 --- a/apps/orchestration/src/policy-engine/core/exception/cluster-not-found.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/cluster-not-found.exception.ts @@ -1,5 +1,5 @@ -import { PolicyEngineException } from '@app/orchestration/policy-engine/core/exception/policy-engine.exception' import { HttpStatus } from '@nestjs/common' +import { PolicyEngineException } from './policy-engine.exception' export class ClusterNotFoundException extends PolicyEngineException { constructor(orgId: string) { diff --git a/apps/orchestration/src/policy-engine/core/exception/evaluation-consensus.exception.ts b/apps/orchestration/src/policy-engine/core/exception/evaluation-consensus.exception.ts index cb9d43f21..6c37f84fa 100644 --- a/apps/orchestration/src/policy-engine/core/exception/evaluation-consensus.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/evaluation-consensus.exception.ts @@ -1,7 +1,7 @@ -import { PolicyEngineException } from '@app/orchestration/policy-engine/core/exception/policy-engine.exception' -import { Node } from '@app/orchestration/policy-engine/core/type/clustering.type' import { EvaluationResponse } from '@narval/authz-shared' import { HttpStatus } from '@nestjs/common' +import { Node } from '../type/clustering.type' +import { PolicyEngineException } from './policy-engine.exception' export class EvaluationConsensusException extends PolicyEngineException { constructor(responses: EvaluationResponse[], nodes: Node[]) { diff --git a/apps/orchestration/src/policy-engine/core/exception/invalid-attestation-signature.exception.ts b/apps/orchestration/src/policy-engine/core/exception/invalid-attestation-signature.exception.ts index 056629864..dfa250df5 100644 --- a/apps/orchestration/src/policy-engine/core/exception/invalid-attestation-signature.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/invalid-attestation-signature.exception.ts @@ -1,5 +1,5 @@ -import { PolicyEngineException } from '@app/orchestration/policy-engine/core/exception/policy-engine.exception' import { HttpStatus } from '@nestjs/common' +import { PolicyEngineException } from './policy-engine.exception' export class InvalidAttestationSignatureException extends PolicyEngineException { constructor(nodePubKey: string, recoveredPubKey: string) { diff --git a/apps/orchestration/src/policy-engine/core/exception/policy-engine.exception.ts b/apps/orchestration/src/policy-engine/core/exception/policy-engine.exception.ts index 8dec28fbf..e835e3dad 100644 --- a/apps/orchestration/src/policy-engine/core/exception/policy-engine.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/policy-engine.exception.ts @@ -1,3 +1,3 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' +import { ApplicationException } from '../../../shared/exception/application.exception' export class PolicyEngineException extends ApplicationException {} diff --git a/apps/orchestration/src/policy-engine/core/exception/unreachable-cluster.exception.ts b/apps/orchestration/src/policy-engine/core/exception/unreachable-cluster.exception.ts index 90d1a6ecf..08294acd6 100644 --- a/apps/orchestration/src/policy-engine/core/exception/unreachable-cluster.exception.ts +++ b/apps/orchestration/src/policy-engine/core/exception/unreachable-cluster.exception.ts @@ -1,6 +1,6 @@ -import { PolicyEngineException } from '@app/orchestration/policy-engine/core/exception/policy-engine.exception' -import { Cluster } from '@app/orchestration/policy-engine/core/type/clustering.type' import { HttpStatus } from '@nestjs/common' +import { PolicyEngineException } from '../exception/policy-engine.exception' +import { Cluster } from '../type/clustering.type' export class UnreachableClusterException extends PolicyEngineException { constructor(cluster: Cluster) { diff --git a/apps/orchestration/src/policy-engine/core/service/__test__/unit/authorization-request.service.spec.ts b/apps/orchestration/src/policy-engine/core/service/__test__/unit/authorization-request.service.spec.ts index 9874857f7..b603da6cd 100644 --- a/apps/orchestration/src/policy-engine/core/service/__test__/unit/authorization-request.service.spec.ts +++ b/apps/orchestration/src/policy-engine/core/service/__test__/unit/authorization-request.service.spec.ts @@ -1,33 +1,33 @@ +import { Action, Decision, EvaluationResponse, getAccountId } from '@narval/authz-shared' +import { Intents, TransferNative } from '@narval/transaction-request-intent' +import { Test, TestingModule } from '@nestjs/testing' +import { MockProxy, mock } from 'jest-mock-extended' +import { times } from 'lodash/fp' import { generateApproval, generateAuthorizationRequest, generateSignTransactionRequest, generateSignature, generateTransactionRequest -} from '@app/orchestration/__test__/fixture/authorization-request.fixture' -import { generateTransfer } from '@app/orchestration/__test__/fixture/transfer-tracking.fixture' -import { FeedService } from '@app/orchestration/data-feed/core/service/feed.service' -import { FIAT_ID_USD, POLYGON } from '@app/orchestration/orchestration.constant' -import { AuthorizationRequestAlreadyProcessingException } from '@app/orchestration/policy-engine/core/exception/authorization-request-already-processing.exception' -import { AuthorizationRequestService } from '@app/orchestration/policy-engine/core/service/authorization-request.service' -import { ClusterService } from '@app/orchestration/policy-engine/core/service/cluster.service' +} from '../../../../../__test__/fixture/authorization-request.fixture' +import { generateTransfer } from '../../../../../__test__/fixture/transfer-tracking.fixture' +import { FeedService } from '../../../../../data-feed/core/service/feed.service' +import { FIAT_ID_USD, POLYGON } from '../../../../../orchestration.constant' +import { PriceService } from '../../../../../price/core/service/price.service' +import { ChainId } from '../../../../../shared/core/lib/chains.lib' +import { Transfer } from '../../../../../shared/core/type/transfer-tracking.type' +import { TransferTrackingService } from '../../../../../transfer-tracking/core/service/transfer-tracking.service' +import { AuthorizationRequestAlreadyProcessingException } from '../../../../core/exception/authorization-request-already-processing.exception' +import { AuthorizationRequestService } from '../../../../core/service/authorization-request.service' +import { ClusterService } from '../../../../core/service/cluster.service' import { Approval, AuthorizationRequest, AuthorizationRequestStatus, SignTransaction -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { AuthorizationRequestProcessingProducer } from '@app/orchestration/policy-engine/queue/producer/authorization-request-processing.producer' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' -import { Action, Decision, EvaluationResponse, getAccountId } from '@narval/authz-shared' -import { Intents, TransferNative } from '@narval/transaction-request-intent' -import { Test, TestingModule } from '@nestjs/testing' -import { MockProxy, mock } from 'jest-mock-extended' -import { times } from 'lodash/fp' +} from '../../../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../../../persistence/repository/authorization-request.repository' +import { AuthorizationRequestProcessingProducer } from '../../../../queue/producer/authorization-request-processing.producer' describe(AuthorizationRequestService.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/policy-engine/core/service/__test__/unit/cluster.service.spec.ts b/apps/orchestration/src/policy-engine/core/service/__test__/unit/cluster.service.spec.ts index 1f9d1fa7b..75ef0d7d2 100644 --- a/apps/orchestration/src/policy-engine/core/service/__test__/unit/cluster.service.spec.ts +++ b/apps/orchestration/src/policy-engine/core/service/__test__/unit/cluster.service.spec.ts @@ -1,23 +1,23 @@ +import { Alg, Decision, EvaluationResponse, Feed, Prices, hashRequest } from '@narval/authz-shared' +import { Test } from '@nestjs/testing' +import { MockProxy, mock } from 'jest-mock-extended' +import { PrivateKeyAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts' import { generateAuthorizationRequest, generateSignTransactionRequest, generateSignature, generateTransactionRequest -} from '@app/orchestration/__test__/fixture/authorization-request.fixture' -import { generatePrices } from '@app/orchestration/__test__/fixture/price.fixture' -import { PriceFeedService } from '@app/orchestration/data-feed/core/service/price-feed.service' -import { ClusterNotFoundException } from '@app/orchestration/policy-engine/core/exception/cluster-not-found.exception' -import { EvaluationConsensusException } from '@app/orchestration/policy-engine/core/exception/evaluation-consensus.exception' -import { InvalidAttestationSignatureException } from '@app/orchestration/policy-engine/core/exception/invalid-attestation-signature.exception' -import { ClusterService } from '@app/orchestration/policy-engine/core/service/cluster.service' -import { Cluster, Node } from '@app/orchestration/policy-engine/core/type/clustering.type' -import { AuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthzApplicationClient } from '@app/orchestration/policy-engine/http/client/authz-application.client' -import { ChainId } from '@app/orchestration/shared/core/lib/chains.lib' -import { Alg, Decision, EvaluationResponse, Feed, Prices, hashRequest } from '@narval/authz-shared' -import { Test } from '@nestjs/testing' -import { MockProxy, mock } from 'jest-mock-extended' -import { PrivateKeyAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts' +} from '../../../../../__test__/fixture/authorization-request.fixture' +import { generatePrices } from '../../../../../__test__/fixture/price.fixture' +import { PriceFeedService } from '../../../../../data-feed/core/service/price-feed.service' +import { ChainId } from '../../../../../shared/core/lib/chains.lib' +import { ClusterNotFoundException } from '../../../../core/exception/cluster-not-found.exception' +import { EvaluationConsensusException } from '../../../../core/exception/evaluation-consensus.exception' +import { InvalidAttestationSignatureException } from '../../../../core/exception/invalid-attestation-signature.exception' +import { ClusterService } from '../../../../core/service/cluster.service' +import { Cluster, Node } from '../../../../core/type/clustering.type' +import { AuthorizationRequest } from '../../../../core/type/domain.type' +import { AuthzApplicationClient } from '../../../../http/client/authz-application.client' describe(ClusterService.name, () => { let service: ClusterService diff --git a/apps/orchestration/src/policy-engine/core/service/authorization-request.service.ts b/apps/orchestration/src/policy-engine/core/service/authorization-request.service.ts index e7cd43863..2c94f9f61 100644 --- a/apps/orchestration/src/policy-engine/core/service/authorization-request.service.ts +++ b/apps/orchestration/src/policy-engine/core/service/authorization-request.service.ts @@ -1,22 +1,22 @@ -import { FeedService } from '@app/orchestration/data-feed/core/service/feed.service' -import { FIAT_ID_USD } from '@app/orchestration/orchestration.constant' -import { AuthorizationRequestAlreadyProcessingException } from '@app/orchestration/policy-engine/core/exception/authorization-request-already-processing.exception' -import { ClusterService } from '@app/orchestration/policy-engine/core/service/cluster.service' +import { Action, Decision } from '@narval/authz-shared' +import { Intent, Intents } from '@narval/transaction-request-intent' +import { Injectable, Logger } from '@nestjs/common' +import { SetOptional } from 'type-fest' +import { v4 as uuid } from 'uuid' +import { FeedService } from '../../../data-feed/core/service/feed.service' +import { FIAT_ID_USD } from '../../../orchestration.constant' +import { PriceService } from '../../../price/core/service/price.service' +import { TransferTrackingService } from '../../../transfer-tracking/core/service/transfer-tracking.service' import { Approval, AuthorizationRequest, AuthorizationRequestStatus, CreateAuthorizationRequest -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { AuthorizationRequestProcessingProducer } from '@app/orchestration/policy-engine/queue/producer/authorization-request-processing.producer' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' -import { Action, Decision } from '@narval/authz-shared' -import { Intents } from '@narval/transaction-request-intent' -import { Injectable, Logger } from '@nestjs/common' -import { SetOptional } from 'type-fest' -import { v4 as uuid } from 'uuid' +} from '../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../persistence/repository/authorization-request.repository' +import { AuthorizationRequestProcessingProducer } from '../../queue/producer/authorization-request-processing.producer' +import { AuthorizationRequestAlreadyProcessingException } from '../exception/authorization-request-already-processing.exception' +import { ClusterService } from './cluster.service' const getStatus = (decision: string): AuthorizationRequestStatus => { const statuses: Map = new Map([ @@ -146,7 +146,8 @@ export class AuthorizationRequestService { // TODO (@wcalderipe, 01/02/24): Move to the TransferTrackingService. if (authzRequest.request.action === Action.SIGN_TRANSACTION && status === AuthorizationRequestStatus.PERMITTED) { - const intent = evaluation.transactionRequestIntent + // TODO (@wcalderipe, 08/02/24): Remove the cast `as Intent`. + const intent = evaluation.transactionRequestIntent as Intent if (intent && intent.type === Intents.TRANSFER_NATIVE) { const transferPrices = await this.priceService.getPrices({ from: [intent.token], diff --git a/apps/orchestration/src/policy-engine/core/service/cluster.service.ts b/apps/orchestration/src/policy-engine/core/service/cluster.service.ts index 560348799..d268e9cd1 100644 --- a/apps/orchestration/src/policy-engine/core/service/cluster.service.ts +++ b/apps/orchestration/src/policy-engine/core/service/cluster.service.ts @@ -1,12 +1,12 @@ -import { ClusterNotFoundException } from '@app/orchestration/policy-engine/core/exception/cluster-not-found.exception' -import { EvaluationConsensusException } from '@app/orchestration/policy-engine/core/exception/evaluation-consensus.exception' -import { InvalidAttestationSignatureException } from '@app/orchestration/policy-engine/core/exception/invalid-attestation-signature.exception' -import { UnreachableClusterException } from '@app/orchestration/policy-engine/core/exception/unreachable-cluster.exception' -import { Cluster, Node } from '@app/orchestration/policy-engine/core/type/clustering.type' -import { AuthzApplicationClient } from '@app/orchestration/policy-engine/http/client/authz-application.client' import { Decision, EvaluationRequest, EvaluationResponse, hashRequest } from '@narval/authz-shared' import { Injectable, Logger } from '@nestjs/common' import { zip } from 'lodash/fp' +import { ClusterNotFoundException } from '../../core/exception/cluster-not-found.exception' +import { EvaluationConsensusException } from '../../core/exception/evaluation-consensus.exception' +import { InvalidAttestationSignatureException } from '../../core/exception/invalid-attestation-signature.exception' +import { UnreachableClusterException } from '../../core/exception/unreachable-cluster.exception' +import { Cluster, Node } from '../../core/type/clustering.type' +import { AuthzApplicationClient } from '../../http/client/authz-application.client' // eslint-disable-next-line no-restricted-imports import { getAddress, isAddressEqual, recoverMessageAddress } from 'viem' diff --git a/apps/orchestration/src/policy-engine/http/client/authz-application.client.ts b/apps/orchestration/src/policy-engine/http/client/authz-application.client.ts index 196dfc52b..a1a20df75 100644 --- a/apps/orchestration/src/policy-engine/http/client/authz-application.client.ts +++ b/apps/orchestration/src/policy-engine/http/client/authz-application.client.ts @@ -1,8 +1,8 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' import { EvaluationRequest, EvaluationResponse } from '@narval/authz-shared' import { HttpService } from '@nestjs/axios' import { HttpStatus, Injectable, Logger } from '@nestjs/common' import { catchError, lastValueFrom, map, tap } from 'rxjs' +import { ApplicationException } from '../../../shared/exception/application.exception' @Injectable() export class AuthzApplicationClient { diff --git a/apps/orchestration/src/policy-engine/http/rest/controller/authorization-request.controller.ts b/apps/orchestration/src/policy-engine/http/rest/controller/authorization-request.controller.ts index 2e0828f19..2e7a517f0 100644 --- a/apps/orchestration/src/policy-engine/http/rest/controller/authorization-request.controller.ts +++ b/apps/orchestration/src/policy-engine/http/rest/controller/authorization-request.controller.ts @@ -1,13 +1,13 @@ -import { REQUEST_HEADER_ORG_ID } from '@app/orchestration/orchestration.constant' -import { AuthorizationRequestService } from '@app/orchestration/policy-engine/core/service/authorization-request.service' -import { AuthorizationRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/authorization-request.dto' -import { AuthorizationResponseDto } from '@app/orchestration/policy-engine/http/rest/dto/authorization-response.dto' -import { SignatureDto } from '@app/orchestration/policy-engine/http/rest/dto/signature.dto' -import { toCreateAuthorizationRequest } from '@app/orchestration/policy-engine/http/rest/util' -import { OrgId } from '@app/orchestration/shared/decorator/org-id.decorator' -import { ErrorResponseDto } from '@app/orchestration/shared/dto/error-response.dto' import { Body, Controller, Get, HttpStatus, NotFoundException, Param, Post } from '@nestjs/common' import { ApiHeader, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger' +import { REQUEST_HEADER_ORG_ID } from '../../../../orchestration.constant' +import { OrgId } from '../../../../shared/decorator/org-id.decorator' +import { ErrorResponseDto } from '../../../../shared/dto/error-response.dto' +import { AuthorizationRequestService } from '../../../core/service/authorization-request.service' +import { AuthorizationRequestDto } from '../../../http/rest/dto/authorization-request.dto' +import { AuthorizationResponseDto } from '../../../http/rest/dto/authorization-response.dto' +import { SignatureDto } from '../../../http/rest/dto/signature.dto' +import { toCreateAuthorizationRequest } from '../../../http/rest/util' @Controller('/authorization-requests') @ApiTags('Authorization Request') diff --git a/apps/orchestration/src/policy-engine/http/rest/dto/authorization-request.dto.ts b/apps/orchestration/src/policy-engine/http/rest/dto/authorization-request.dto.ts index 3667ec55a..d46bb8eca 100644 --- a/apps/orchestration/src/policy-engine/http/rest/dto/authorization-request.dto.ts +++ b/apps/orchestration/src/policy-engine/http/rest/dto/authorization-request.dto.ts @@ -1,10 +1,10 @@ -import { SignMessageRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/sign-message-request.dto' -import { SignTransactionRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/sign-transaction-request.dto' -import { SignatureDto } from '@app/orchestration/policy-engine/http/rest/dto/signature.dto' import { Action } from '@narval/authz-shared' import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, ValidateNested } from 'class-validator' +import { SignMessageRequestDto } from '../../../http/rest/dto/sign-message-request.dto' +import { SignTransactionRequestDto } from '../../../http/rest/dto/sign-transaction-request.dto' +import { SignatureDto } from '../../../http/rest/dto/signature.dto' @ApiExtraModels(SignTransactionRequestDto, SignMessageRequestDto) export class AuthorizationRequestDto { diff --git a/apps/orchestration/src/policy-engine/http/rest/dto/authorization-response.dto.ts b/apps/orchestration/src/policy-engine/http/rest/dto/authorization-response.dto.ts index beafb30f5..26160a175 100644 --- a/apps/orchestration/src/policy-engine/http/rest/dto/authorization-response.dto.ts +++ b/apps/orchestration/src/policy-engine/http/rest/dto/authorization-response.dto.ts @@ -1,13 +1,13 @@ -import { AuthorizationRequestStatus } from '@app/orchestration/policy-engine/core/type/domain.type' -import { EvaluationDto } from '@app/orchestration/policy-engine/http/rest/dto/evaluation.dto' -import { SignMessageRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/sign-message-request.dto' -import { SignTransactionRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/sign-transaction-request.dto' -import { SignatureDto } from '@app/orchestration/policy-engine/http/rest/dto/signature.dto' -import { TransactionResponseDto } from '@app/orchestration/policy-engine/http/rest/dto/transaction-request.dto' import { Action } from '@narval/authz-shared' import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger' import { Type } from 'class-transformer' import { IsDefined, IsString, ValidateNested } from 'class-validator' +import { AuthorizationRequestStatus } from '../../../core/type/domain.type' +import { EvaluationDto } from '../../../http/rest/dto/evaluation.dto' +import { SignMessageRequestDto } from '../../../http/rest/dto/sign-message-request.dto' +import { SignTransactionRequestDto } from '../../../http/rest/dto/sign-transaction-request.dto' +import { SignatureDto } from '../../../http/rest/dto/signature.dto' +import { TransactionResponseDto } from '../../../http/rest/dto/transaction-request.dto' class SignTransactionResponseDto extends SignTransactionRequestDto { // Use a different DTO for the response to ensure the conversion of attributes diff --git a/apps/orchestration/src/policy-engine/http/rest/dto/sign-transaction-request.dto.ts b/apps/orchestration/src/policy-engine/http/rest/dto/sign-transaction-request.dto.ts index 87e6bbe73..664a0b38b 100644 --- a/apps/orchestration/src/policy-engine/http/rest/dto/sign-transaction-request.dto.ts +++ b/apps/orchestration/src/policy-engine/http/rest/dto/sign-transaction-request.dto.ts @@ -1,7 +1,7 @@ -import { TransactionRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/transaction-request.dto' import { Action } from '@narval/authz-shared' import { ApiProperty } from '@nestjs/swagger' import { IsDefined, IsIn, IsString, ValidateNested } from 'class-validator' +import { TransactionRequestDto } from '../../../http/rest/dto/transaction-request.dto' export class SignTransactionRequestDto { @IsIn(Object.values(Action)) diff --git a/apps/orchestration/src/policy-engine/http/rest/dto/validator/__test__/unit/request-hash.validator.spec.ts b/apps/orchestration/src/policy-engine/http/rest/dto/validator/__test__/unit/request-hash.validator.spec.ts deleted file mode 100644 index eada9b8d6..000000000 --- a/apps/orchestration/src/policy-engine/http/rest/dto/validator/__test__/unit/request-hash.validator.spec.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { RequestHash } from '@app/orchestration/policy-engine/http/rest/dto/validator/request-hash.validator' -import { hashRequest } from '@narval/authz-shared' -import { ValidationArguments } from 'class-validator' - -describe(RequestHash.name, () => { - let validator: RequestHash - - beforeEach(() => { - validator = new RequestHash() - }) - - describe('validate', () => { - it('returns true if the given hash matches the hash of the request object', () => { - const request = { foo: 'bar' } - const hash = hashRequest(request) - const args: ValidationArguments = { - targetName: 'AuthorizationRequestDto', - object: { request }, - property: 'hash', - constraints: [], - value: hash - } - - const result = validator.validate(hash, args) - - expect(result).toEqual(true) - }) - - it('returns false if the given hash does not match the hash of the request object', () => { - const hash = '123456' - const request = { foo: 'baz' } - const args: ValidationArguments = { - targetName: 'AuthorizationRequestDto', - object: { request }, - property: 'hash', - constraints: [], - value: hash - } - - const result = validator.validate(hash, args) - - expect(result).toEqual(false) - }) - - it('returns false if the request object is not present in the arguments', () => { - const hash = '123456' - const args: ValidationArguments = { - targetName: 'AuthorizationRequestDto', - object: {}, - property: 'hash', - constraints: [], - value: hash - } - - const result = validator.validate(hash, args) - - expect(result).toEqual(false) - }) - }) - - describe('defaultMessage', () => { - it('returns error message for the given property', () => { - const property = 'hash' - const args: ValidationArguments = { - targetName: 'AuthorizationRequestDto', - object: {}, - property, - constraints: [], - value: '' - } - - const message = validator.defaultMessage(args) - - expect(message).toEqual(`${property} is not a valid hexadecimal SHA256 hash`) - }) - }) -}) diff --git a/apps/orchestration/src/policy-engine/http/rest/dto/validator/request-hash.validator.ts b/apps/orchestration/src/policy-engine/http/rest/dto/validator/request-hash.validator.ts deleted file mode 100644 index 37a428a4e..000000000 --- a/apps/orchestration/src/policy-engine/http/rest/dto/validator/request-hash.validator.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { hashRequest } from '@narval/authz-shared' -import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator' - -@ValidatorConstraint({ async: false }) -export class RequestHash implements ValidatorConstraintInterface { - validate(givenHash: string, args: ValidationArguments) { - if ('request' in args.object) { - const hash = hashRequest(args.object.request) - - return givenHash === hash - } - - return false - } - - defaultMessage(args: ValidationArguments) { - return `${args.property} is not a valid hexadecimal SHA256 hash` - } -} diff --git a/apps/orchestration/src/policy-engine/http/rest/util.ts b/apps/orchestration/src/policy-engine/http/rest/util.ts index 2b3b11b3f..0db597196 100644 --- a/apps/orchestration/src/policy-engine/http/rest/util.ts +++ b/apps/orchestration/src/policy-engine/http/rest/util.ts @@ -1,7 +1,7 @@ -import { CreateApproval, CreateAuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/authorization-request.dto' import { Signature } from '@narval/authz-shared' import { plainToInstance } from 'class-transformer' +import { CreateApproval, CreateAuthorizationRequest } from '../../core/type/domain.type' +import { AuthorizationRequestDto } from '../../http/rest/dto/authorization-request.dto' // Not in love with the gymnastics required to bend a DTO to a domain object. // Most of the complexity came from the discriminated union type. diff --git a/apps/orchestration/src/policy-engine/persistence/decode/__test__/unit/authorization-request.decode.spec.ts b/apps/orchestration/src/policy-engine/persistence/decode/__test__/unit/authorization-request.decode.spec.ts index 9f9515eec..27d0ca317 100644 --- a/apps/orchestration/src/policy-engine/persistence/decode/__test__/unit/authorization-request.decode.spec.ts +++ b/apps/orchestration/src/policy-engine/persistence/decode/__test__/unit/authorization-request.decode.spec.ts @@ -1,8 +1,8 @@ -import { decodeAuthorizationRequest } from '@app/orchestration/policy-engine/persistence/decode/authorization-request.decode' -import { DecodeAuthorizationRequestException } from '@app/orchestration/policy-engine/persistence/exception/decode-authorization-request.exception' -import { AuthorizationRequestModel } from '@app/orchestration/policy-engine/persistence/type/model.type' import { Action } from '@narval/authz-shared' import { AuthorizationRequestStatus } from '@prisma/client/orchestration' +import { decodeAuthorizationRequest } from '../../../../persistence/decode/authorization-request.decode' +import { DecodeAuthorizationRequestException } from '../../../../persistence/exception/decode-authorization-request.exception' +import { AuthorizationRequestModel } from '../../../../persistence/type/model.type' describe('decodeAuthorizationRequest', () => { const sharedModel: Omit = { diff --git a/apps/orchestration/src/policy-engine/persistence/decode/authorization-request.decode.ts b/apps/orchestration/src/policy-engine/persistence/decode/authorization-request.decode.ts index cd3102231..f69d6a5e6 100644 --- a/apps/orchestration/src/policy-engine/persistence/decode/authorization-request.decode.ts +++ b/apps/orchestration/src/policy-engine/persistence/decode/authorization-request.decode.ts @@ -1,12 +1,12 @@ -import { AuthorizationRequest, Evaluation } from '@app/orchestration/policy-engine/core/type/domain.type' -import { DecodeAuthorizationRequestException } from '@app/orchestration/policy-engine/persistence/exception/decode-authorization-request.exception' -import { signatureSchema } from '@app/orchestration/policy-engine/persistence/schema/signature.schema' -import { AuthorizationRequestModel } from '@app/orchestration/policy-engine/persistence/type/model.type' -import { ACTION_REQUEST } from '@app/orchestration/policy-engine/policy-engine.constant' import { Action } from '@narval/authz-shared' import { EvaluationLog } from '@prisma/client/orchestration' import { SetOptional } from 'type-fest' import { ZodIssueCode, ZodSchema, z } from 'zod' +import { AuthorizationRequest, Evaluation } from '../../core/type/domain.type' +import { DecodeAuthorizationRequestException } from '../../persistence/exception/decode-authorization-request.exception' +import { signatureSchema } from '../../persistence/schema/signature.schema' +import { AuthorizationRequestModel } from '../../persistence/type/model.type' +import { ACTION_REQUEST } from '../../policy-engine.constant' type Model = SetOptional diff --git a/apps/orchestration/src/policy-engine/persistence/exception/decode-authorization-request.exception.ts b/apps/orchestration/src/policy-engine/persistence/exception/decode-authorization-request.exception.ts index 4e2bba111..4103f7f23 100644 --- a/apps/orchestration/src/policy-engine/persistence/exception/decode-authorization-request.exception.ts +++ b/apps/orchestration/src/policy-engine/persistence/exception/decode-authorization-request.exception.ts @@ -1,6 +1,6 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' import { HttpStatus } from '@nestjs/common' import { ZodIssue } from 'zod' +import { ApplicationException } from '../../../shared/exception/application.exception' export class DecodeAuthorizationRequestException extends ApplicationException { constructor(reasons: ZodIssue[]) { diff --git a/apps/orchestration/src/policy-engine/persistence/repository/__test__/integration/authorization-request.repository.spec.ts b/apps/orchestration/src/policy-engine/persistence/repository/__test__/integration/authorization-request.repository.spec.ts index 517df674b..afbfa0913 100644 --- a/apps/orchestration/src/policy-engine/persistence/repository/__test__/integration/authorization-request.repository.spec.ts +++ b/apps/orchestration/src/policy-engine/persistence/repository/__test__/integration/authorization-request.repository.spec.ts @@ -1,18 +1,13 @@ -import { load } from '@app/orchestration/orchestration.config' -import { - Approval, - AuthorizationRequest, - Evaluation, - SignTransaction -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' import { Action, Alg, Signature } from '@narval/authz-shared' import { ConfigModule } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' import { AuthorizationRequestStatus, Organization } from '@prisma/client/orchestration' import { omit } from 'lodash/fp' +import { load } from '../../../../../orchestration.config' +import { PersistenceModule } from '../../../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../../../shared/module/persistence/service/test-prisma.service' +import { Approval, AuthorizationRequest, Evaluation, SignTransaction } from '../../../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../../repository/authorization-request.repository' describe(AuthorizationRequestRepository.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/policy-engine/persistence/repository/authorization-request.repository.ts b/apps/orchestration/src/policy-engine/persistence/repository/authorization-request.repository.ts index 486a5c809..53440fbdb 100644 --- a/apps/orchestration/src/policy-engine/persistence/repository/authorization-request.repository.ts +++ b/apps/orchestration/src/policy-engine/persistence/repository/authorization-request.repository.ts @@ -1,15 +1,15 @@ +import { Injectable } from '@nestjs/common' +import { EvaluationLog } from '@prisma/client/orchestration' +import { v4 as uuid } from 'uuid' +import { PrismaService } from '../../../shared/module/persistence/service/prisma.service' import { AuthorizationRequest, AuthorizationRequestStatus, CreateAuthorizationRequest, Evaluation -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { decodeAuthorizationRequest } from '@app/orchestration/policy-engine/persistence/decode/authorization-request.decode' -import { createRequestSchema } from '@app/orchestration/policy-engine/persistence/schema/request.schema' -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' -import { Injectable } from '@nestjs/common' -import { EvaluationLog } from '@prisma/client/orchestration' -import { v4 as uuid } from 'uuid' +} from '../../core/type/domain.type' +import { decodeAuthorizationRequest } from '../decode/authorization-request.decode' +import { createRequestSchema } from '../schema/request.schema' @Injectable() export class AuthorizationRequestRepository { diff --git a/apps/orchestration/src/policy-engine/persistence/schema/request.schema.ts b/apps/orchestration/src/policy-engine/persistence/schema/request.schema.ts index b84a64fb5..e4df5085f 100644 --- a/apps/orchestration/src/policy-engine/persistence/schema/request.schema.ts +++ b/apps/orchestration/src/policy-engine/persistence/schema/request.schema.ts @@ -1,12 +1,9 @@ -import { - createSignMessageSchema, - readSignMessageSchema -} from '@app/orchestration/policy-engine/persistence/schema/sign-message.schema' +import { z } from 'zod' +import { createSignMessageSchema, readSignMessageSchema } from '../../persistence/schema/sign-message.schema' import { createSignTransactionSchema, readSignTransactionSchema -} from '@app/orchestration/policy-engine/persistence/schema/sign-transaction.schema' -import { z } from 'zod' +} from '../../persistence/schema/sign-transaction.schema' export const readRequestSchema = z.discriminatedUnion('action', [readSignTransactionSchema, readSignMessageSchema]) diff --git a/apps/orchestration/src/policy-engine/persistence/schema/sign-transaction.schema.ts b/apps/orchestration/src/policy-engine/persistence/schema/sign-transaction.schema.ts index 8d4fe8d08..6ab78cfe1 100644 --- a/apps/orchestration/src/policy-engine/persistence/schema/sign-transaction.schema.ts +++ b/apps/orchestration/src/policy-engine/persistence/schema/sign-transaction.schema.ts @@ -1,9 +1,9 @@ +import { Action } from '@narval/authz-shared' +import { z } from 'zod' import { createTransactionRequestSchema, readTransactionRequestSchema -} from '@app/orchestration/policy-engine/persistence/schema/transaction-request.schema' -import { Action } from '@narval/authz-shared' -import { z } from 'zod' +} from '../../persistence/schema/transaction-request.schema' export const readSignTransactionSchema = z.object({ action: z.literal(Action.SIGN_TRANSACTION), diff --git a/apps/orchestration/src/policy-engine/persistence/schema/transaction-request.schema.ts b/apps/orchestration/src/policy-engine/persistence/schema/transaction-request.schema.ts index be6ab5f2c..5456d5f4f 100644 --- a/apps/orchestration/src/policy-engine/persistence/schema/transaction-request.schema.ts +++ b/apps/orchestration/src/policy-engine/persistence/schema/transaction-request.schema.ts @@ -1,7 +1,7 @@ -import { addressSchema } from '@app/orchestration/shared/schema/address.schema' -import { chainIdSchema } from '@app/orchestration/shared/schema/chain-id.schema' -import { hexSchema } from '@app/orchestration/shared/schema/hex.schema' import { z } from 'zod' +import { addressSchema } from '../../../shared/schema/address.schema' +import { chainIdSchema } from '../../../shared/schema/chain-id.schema' +import { hexSchema } from '../../../shared/schema/hex.schema' export const accessListSchema = z.object({ address: addressSchema, diff --git a/apps/orchestration/src/policy-engine/policy-engine.constant.ts b/apps/orchestration/src/policy-engine/policy-engine.constant.ts index d6a866d73..c5013bfb8 100644 --- a/apps/orchestration/src/policy-engine/policy-engine.constant.ts +++ b/apps/orchestration/src/policy-engine/policy-engine.constant.ts @@ -1,14 +1,8 @@ -import { SupportedAction } from '@app/orchestration/policy-engine/core/type/domain.type' -import { - createSignMessageSchema, - readSignMessageSchema -} from '@app/orchestration/policy-engine/persistence/schema/sign-message.schema' -import { - createSignTransactionSchema, - readSignTransactionSchema -} from '@app/orchestration/policy-engine/persistence/schema/sign-transaction.schema' import { Action } from '@narval/authz-shared' import { ZodType } from 'zod' +import { SupportedAction } from './core/type/domain.type' +import { createSignMessageSchema, readSignMessageSchema } from './persistence/schema/sign-message.schema' +import { createSignTransactionSchema, readSignTransactionSchema } from './persistence/schema/sign-transaction.schema' type ActionRequestConfig = { action: SupportedAction diff --git a/apps/orchestration/src/policy-engine/policy-engine.module.ts b/apps/orchestration/src/policy-engine/policy-engine.module.ts index 340fa5abf..806bd3db2 100644 --- a/apps/orchestration/src/policy-engine/policy-engine.module.ts +++ b/apps/orchestration/src/policy-engine/policy-engine.module.ts @@ -1,13 +1,3 @@ -import { DataFeedModule } from '@app/orchestration/data-feed/data-feed.module' -import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE } from '@app/orchestration/orchestration.constant' -import { ClusterService } from '@app/orchestration/policy-engine/core/service/cluster.service' -import { AuthzApplicationClient } from '@app/orchestration/policy-engine/http/client/authz-application.client' -import { AuthorizationRequestController } from '@app/orchestration/policy-engine/http/rest/controller/authorization-request.controller' -import { PriceModule } from '@app/orchestration/price/price.module' -import { ApplicationExceptionFilter } from '@app/orchestration/shared/filter/application-exception.filter' -import { ZodExceptionFilter } from '@app/orchestration/shared/filter/zod-exception.filter' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TransferTrackingModule } from '@app/orchestration/transfer-tracking/transfer-tracking.module' import { BullAdapter } from '@bull-board/api/bullAdapter' import { BullBoardModule } from '@bull-board/nestjs' import { HttpModule } from '@nestjs/axios' @@ -15,7 +5,17 @@ import { BullModule } from '@nestjs/bull' import { ClassSerializerInterceptor, Module, ValidationPipe } from '@nestjs/common' import { ConfigModule } from '@nestjs/config' import { APP_FILTER, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core' +import { DataFeedModule } from '../data-feed/data-feed.module' +import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE } from '../orchestration.constant' +import { PriceModule } from '../price/price.module' +import { ApplicationExceptionFilter } from '../shared/filter/application-exception.filter' +import { ZodExceptionFilter } from '../shared/filter/zod-exception.filter' +import { PersistenceModule } from '../shared/module/persistence/persistence.module' +import { TransferTrackingModule } from '../transfer-tracking/transfer-tracking.module' import { AuthorizationRequestService } from './core/service/authorization-request.service' +import { ClusterService } from './core/service/cluster.service' +import { AuthzApplicationClient } from './http/client/authz-application.client' +import { AuthorizationRequestController } from './http/rest/controller/authorization-request.controller' import { AuthorizationRequestRepository } from './persistence/repository/authorization-request.repository' import { AuthorizationRequestProcessingConsumer } from './queue/consumer/authorization-request-processing.consumer' import { AuthorizationRequestProcessingProducer } from './queue/producer/authorization-request-processing.producer' diff --git a/apps/orchestration/src/policy-engine/queue/consumer/__test__/integration/authorization-request-processing.consumer.spec.ts b/apps/orchestration/src/policy-engine/queue/consumer/__test__/integration/authorization-request-processing.consumer.spec.ts index 11ec121ee..08dab9d29 100644 --- a/apps/orchestration/src/policy-engine/queue/consumer/__test__/integration/authorization-request-processing.consumer.spec.ts +++ b/apps/orchestration/src/policy-engine/queue/consumer/__test__/integration/authorization-request-processing.consumer.spec.ts @@ -1,30 +1,3 @@ -import { FeedService } from '@app/orchestration/data-feed/core/service/feed.service' -import { load } from '@app/orchestration/orchestration.config' -import { - AUTHORIZATION_REQUEST_PROCESSING_QUEUE, - AUTHORIZATION_REQUEST_PROCESSING_QUEUE_ATTEMPTS -} from '@app/orchestration/orchestration.constant' -import { AuthorizationRequestAlreadyProcessingException } from '@app/orchestration/policy-engine/core/exception/authorization-request-already-processing.exception' -import { ClusterNotFoundException } from '@app/orchestration/policy-engine/core/exception/cluster-not-found.exception' -import { EvaluationConsensusException } from '@app/orchestration/policy-engine/core/exception/evaluation-consensus.exception' -import { InvalidAttestationSignatureException } from '@app/orchestration/policy-engine/core/exception/invalid-attestation-signature.exception' -import { UnreachableClusterException } from '@app/orchestration/policy-engine/core/exception/unreachable-cluster.exception' -import { AuthorizationRequestService } from '@app/orchestration/policy-engine/core/service/authorization-request.service' -import { ClusterService } from '@app/orchestration/policy-engine/core/service/cluster.service' -import { Cluster } from '@app/orchestration/policy-engine/core/type/clustering.type' -import { - AuthorizationRequest, - AuthorizationRequestProcessingJob, - AuthorizationRequestStatus -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { AuthorizationRequestProcessingConsumer } from '@app/orchestration/policy-engine/queue/consumer/authorization-request-processing.consumer' -import { AuthorizationRequestProcessingProducer } from '@app/orchestration/policy-engine/queue/producer/authorization-request-processing.producer' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' -import { QueueModule } from '@app/orchestration/shared/module/queue/queue.module' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' import { Action, Alg, Signature } from '@narval/authz-shared' import { HttpModule } from '@nestjs/axios' import { BullModule, getQueueToken } from '@nestjs/bull' @@ -33,6 +6,33 @@ import { Test, TestingModule } from '@nestjs/testing' import { Organization } from '@prisma/client/orchestration' import { Job, Queue } from 'bull' import { mock } from 'jest-mock-extended' +import { FeedService } from '../../../../../data-feed/core/service/feed.service' +import { load } from '../../../../../orchestration.config' +import { + AUTHORIZATION_REQUEST_PROCESSING_QUEUE, + AUTHORIZATION_REQUEST_PROCESSING_QUEUE_ATTEMPTS +} from '../../../../../orchestration.constant' +import { PriceService } from '../../../../../price/core/service/price.service' +import { PersistenceModule } from '../../../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../../../shared/module/persistence/service/test-prisma.service' +import { QueueModule } from '../../../../../shared/module/queue/queue.module' +import { TransferTrackingService } from '../../../../../transfer-tracking/core/service/transfer-tracking.service' +import { AuthorizationRequestAlreadyProcessingException } from '../../../../core/exception/authorization-request-already-processing.exception' +import { ClusterNotFoundException } from '../../../../core/exception/cluster-not-found.exception' +import { EvaluationConsensusException } from '../../../../core/exception/evaluation-consensus.exception' +import { InvalidAttestationSignatureException } from '../../../../core/exception/invalid-attestation-signature.exception' +import { UnreachableClusterException } from '../../../../core/exception/unreachable-cluster.exception' +import { AuthorizationRequestService } from '../../../../core/service/authorization-request.service' +import { ClusterService } from '../../../../core/service/cluster.service' +import { Cluster } from '../../../../core/type/clustering.type' +import { + AuthorizationRequest, + AuthorizationRequestProcessingJob, + AuthorizationRequestStatus +} from '../../../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../../../persistence/repository/authorization-request.repository' +import { AuthorizationRequestProcessingConsumer } from '../../../../queue/consumer/authorization-request-processing.consumer' +import { AuthorizationRequestProcessingProducer } from '../../../../queue/producer/authorization-request-processing.producer' describe(AuthorizationRequestProcessingConsumer.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/policy-engine/queue/consumer/authorization-request-processing.consumer.ts b/apps/orchestration/src/policy-engine/queue/consumer/authorization-request-processing.consumer.ts index 40e9bd964..92f619ec5 100644 --- a/apps/orchestration/src/policy-engine/queue/consumer/authorization-request-processing.consumer.ts +++ b/apps/orchestration/src/policy-engine/queue/consumer/authorization-request-processing.consumer.ts @@ -1,20 +1,17 @@ -import { - AUTHORIZATION_REQUEST_PROCESSING_QUEUE, - AUTHORIZATION_REQUEST_PROCESSING_QUEUE_ATTEMPTS -} from '@app/orchestration/orchestration.constant' -import { AuthorizationRequestAlreadyProcessingException } from '@app/orchestration/policy-engine/core/exception/authorization-request-already-processing.exception' -import { ClusterNotFoundException } from '@app/orchestration/policy-engine/core/exception/cluster-not-found.exception' -import { EvaluationConsensusException } from '@app/orchestration/policy-engine/core/exception/evaluation-consensus.exception' -import { InvalidAttestationSignatureException } from '@app/orchestration/policy-engine/core/exception/invalid-attestation-signature.exception' -import { UnreachableClusterException } from '@app/orchestration/policy-engine/core/exception/unreachable-cluster.exception' -import { AuthorizationRequestService } from '@app/orchestration/policy-engine/core/service/authorization-request.service' -import { - AuthorizationRequestProcessingJob, - AuthorizationRequestStatus -} from '@app/orchestration/policy-engine/core/type/domain.type' import { OnQueueActive, OnQueueCompleted, OnQueueFailed, Process, Processor } from '@nestjs/bull' import { Logger } from '@nestjs/common' import { Job } from 'bull' +import { + AUTHORIZATION_REQUEST_PROCESSING_QUEUE, + AUTHORIZATION_REQUEST_PROCESSING_QUEUE_ATTEMPTS +} from '../../../orchestration.constant' +import { AuthorizationRequestAlreadyProcessingException } from '../../core/exception/authorization-request-already-processing.exception' +import { ClusterNotFoundException } from '../../core/exception/cluster-not-found.exception' +import { EvaluationConsensusException } from '../../core/exception/evaluation-consensus.exception' +import { InvalidAttestationSignatureException } from '../../core/exception/invalid-attestation-signature.exception' +import { UnreachableClusterException } from '../../core/exception/unreachable-cluster.exception' +import { AuthorizationRequestService } from '../../core/service/authorization-request.service' +import { AuthorizationRequestProcessingJob, AuthorizationRequestStatus } from '../../core/type/domain.type' @Processor(AUTHORIZATION_REQUEST_PROCESSING_QUEUE) export class AuthorizationRequestProcessingConsumer { diff --git a/apps/orchestration/src/policy-engine/queue/producer/__test__/integration/authorization-request-processing.producer.spec.ts b/apps/orchestration/src/policy-engine/queue/producer/__test__/integration/authorization-request-processing.producer.spec.ts index 197e2b257..d1411462e 100644 --- a/apps/orchestration/src/policy-engine/queue/producer/__test__/integration/authorization-request-processing.producer.spec.ts +++ b/apps/orchestration/src/policy-engine/queue/producer/__test__/integration/authorization-request-processing.producer.spec.ts @@ -1,23 +1,23 @@ -import { load } from '@app/orchestration/orchestration.config' -import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE } from '@app/orchestration/orchestration.constant' +import { Action, Alg, Signature } from '@narval/authz-shared' +import { BullModule, getQueueToken } from '@nestjs/bull' +import { ConfigModule } from '@nestjs/config' +import { Test, TestingModule } from '@nestjs/testing' +import { Queue } from 'bull' +import { load } from '../../../../../orchestration.config' +import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE } from '../../../../../orchestration.constant' +import { PersistenceModule } from '../../../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../../../shared/module/persistence/service/test-prisma.service' +import { QueueModule } from '../../../../../shared/module/queue/queue.module' import { AuthorizationRequest, AuthorizationRequestProcessingJob, AuthorizationRequestStatus -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' +} from '../../../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../../../persistence/repository/authorization-request.repository' import { AuthorizationRequestProcessingProducer, DEFAULT_JOB_OPTIONS -} from '@app/orchestration/policy-engine/queue/producer/authorization-request-processing.producer' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' -import { QueueModule } from '@app/orchestration/shared/module/queue/queue.module' -import { Action, Alg, Signature } from '@narval/authz-shared' -import { BullModule, getQueueToken } from '@nestjs/bull' -import { ConfigModule } from '@nestjs/config' -import { Test, TestingModule } from '@nestjs/testing' -import { Queue } from 'bull' +} from '../../../../queue/producer/authorization-request-processing.producer' describe(AuthorizationRequestProcessingProducer.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/policy-engine/queue/producer/authorization-request-processing.producer.ts b/apps/orchestration/src/policy-engine/queue/producer/authorization-request-processing.producer.ts index 781d6cf7b..4a706b835 100644 --- a/apps/orchestration/src/policy-engine/queue/producer/authorization-request-processing.producer.ts +++ b/apps/orchestration/src/policy-engine/queue/producer/authorization-request-processing.producer.ts @@ -1,17 +1,17 @@ +import { InjectQueue } from '@nestjs/bull' +import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common' +import { BackoffOptions, Job, Queue } from 'bull' import { AUTHORIZATION_REQUEST_PROCESSING_QUEUE, AUTHORIZATION_REQUEST_PROCESSING_QUEUE_ATTEMPTS, AUTHORIZATION_REQUEST_PROCESSING_QUEUE_BACKOFF -} from '@app/orchestration/orchestration.constant' +} from '../../../orchestration.constant' import { AuthorizationRequest, AuthorizationRequestProcessingJob, AuthorizationRequestStatus -} from '@app/orchestration/policy-engine/core/type/domain.type' -import { AuthorizationRequestRepository } from '@app/orchestration/policy-engine/persistence/repository/authorization-request.repository' -import { InjectQueue } from '@nestjs/bull' -import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common' -import { BackoffOptions, Job, Queue } from 'bull' +} from '../../core/type/domain.type' +import { AuthorizationRequestRepository } from '../../persistence/repository/authorization-request.repository' type JobOption = { attempts: number diff --git a/apps/orchestration/src/price/core/exception/price.exception.ts b/apps/orchestration/src/price/core/exception/price.exception.ts index ed066487a..44b160c0d 100644 --- a/apps/orchestration/src/price/core/exception/price.exception.ts +++ b/apps/orchestration/src/price/core/exception/price.exception.ts @@ -1,3 +1,3 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' +import { ApplicationException } from '../../../shared/exception/application.exception' export class PriceException extends ApplicationException {} diff --git a/apps/orchestration/src/price/core/service/__test__/unit/price.service.spec.ts b/apps/orchestration/src/price/core/service/__test__/unit/price.service.spec.ts index adb4bb6b1..c57bb00c5 100644 --- a/apps/orchestration/src/price/core/service/__test__/unit/price.service.spec.ts +++ b/apps/orchestration/src/price/core/service/__test__/unit/price.service.spec.ts @@ -1,11 +1,11 @@ -import { ASSET_ID_MAINNET_USDC, ETHEREUM, FIAT_ID_USD, POLYGON } from '@app/orchestration/orchestration.constant' -import { PriceException } from '@app/orchestration/price/core/exception/price.exception' -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { CoinGeckoClient } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.client' -import { CoinGeckoAssetRepository } from '@app/orchestration/price/persistence/repository/coin-gecko-asset.repository' import { AssetType, getAddress, getAssetId, toAssetId } from '@narval/authz-shared' import { Test, TestingModule } from '@nestjs/testing' import { mock } from 'jest-mock-extended' +import { ASSET_ID_MAINNET_USDC, ETHEREUM, FIAT_ID_USD, POLYGON } from '../../../../../orchestration.constant' +import { PriceException } from '../../../../core/exception/price.exception' +import { PriceService } from '../../../../core/service/price.service' +import { CoinGeckoClient } from '../../../../http/client/coin-gecko/coin-gecko.client' +import { CoinGeckoAssetRepository } from '../../../../persistence/repository/coin-gecko-asset.repository' describe(PriceService.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/price/core/service/price.service.ts b/apps/orchestration/src/price/core/service/price.service.ts index 3098ad7a1..e053ec0af 100644 --- a/apps/orchestration/src/price/core/service/price.service.ts +++ b/apps/orchestration/src/price/core/service/price.service.ts @@ -1,11 +1,11 @@ -import { PriceException } from '@app/orchestration/price/core/exception/price.exception' -import { CoinGeckoClient } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.client' -import { SimplePrice } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.type' -import { CoinGeckoAssetRepository } from '@app/orchestration/price/persistence/repository/coin-gecko-asset.repository' -import { FiatId, Prices } from '@app/orchestration/shared/core/type/price.type' import { AssetId } from '@narval/authz-shared' import { HttpStatus, Injectable, Logger } from '@nestjs/common' import { compact } from 'lodash/fp' +import { FiatId, Prices } from '../../../shared/core/type/price.type' +import { CoinGeckoClient } from '../../http/client/coin-gecko/coin-gecko.client' +import { SimplePrice } from '../../http/client/coin-gecko/coin-gecko.type' +import { CoinGeckoAssetRepository } from '../../persistence/repository/coin-gecko-asset.repository' +import { PriceException } from '../exception/price.exception' type GetPricesOption = { from: AssetId[] diff --git a/apps/orchestration/src/price/http/client/coin-gecko/__test__/fixture/coin-gecko.fixture.ts b/apps/orchestration/src/price/http/client/coin-gecko/__test__/fixture/coin-gecko.fixture.ts index e7a2f2146..a02f0b11e 100644 --- a/apps/orchestration/src/price/http/client/coin-gecko/__test__/fixture/coin-gecko.fixture.ts +++ b/apps/orchestration/src/price/http/client/coin-gecko/__test__/fixture/coin-gecko.fixture.ts @@ -1,4 +1,4 @@ -import { SimplePrice } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.type' +import { SimplePrice } from '../../coin-gecko.type' export const generateSimplePrice = (): SimplePrice => { return { diff --git a/apps/orchestration/src/price/http/client/coin-gecko/__test__/integration/coin-gecko.client.spec.ts b/apps/orchestration/src/price/http/client/coin-gecko/__test__/integration/coin-gecko.client.spec.ts index aa114b70b..bf0af80ed 100644 --- a/apps/orchestration/src/price/http/client/coin-gecko/__test__/integration/coin-gecko.client.spec.ts +++ b/apps/orchestration/src/price/http/client/coin-gecko/__test__/integration/coin-gecko.client.spec.ts @@ -1,11 +1,11 @@ -import { generateSimplePrice } from '@app/orchestration/price/http/client/coin-gecko/__test__/fixture/coin-gecko.fixture' -import { CoinGeckoClient } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.client' -import { CoinGeckoException } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.exception' import { HttpModule } from '@nestjs/axios' import { HttpStatus } from '@nestjs/common' import { Test, TestingModule } from '@nestjs/testing' import { lowerCase } from 'lodash/fp' import nock from 'nock' +import { generateSimplePrice } from '../../__test__/fixture/coin-gecko.fixture' +import { CoinGeckoClient } from '../../coin-gecko.client' +import { CoinGeckoException } from '../../coin-gecko.exception' describe(CoinGeckoClient.name, () => { let module: TestingModule diff --git a/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.client.ts b/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.client.ts index f06b9415b..35db93979 100644 --- a/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.client.ts +++ b/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.client.ts @@ -1,14 +1,10 @@ -import { CoinGeckoException } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.exception' -import { - CoinList, - SimplePrice, - SimplePriceOption -} from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.type' import { HttpService } from '@nestjs/axios' import { HttpStatus, Injectable, Logger } from '@nestjs/common' import { AxiosError, AxiosRequestConfig } from 'axios' import { omit } from 'lodash/fp' import { catchError, lastValueFrom, map, tap, throwError } from 'rxjs' +import { CoinGeckoException } from './coin-gecko.exception' +import { CoinList, SimplePrice, SimplePriceOption } from './coin-gecko.type' @Injectable() export class CoinGeckoClient { diff --git a/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.exception.ts b/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.exception.ts index ce4269984..aaacd61cf 100644 --- a/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.exception.ts +++ b/apps/orchestration/src/price/http/client/coin-gecko/coin-gecko.exception.ts @@ -1,3 +1,3 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' +import { ApplicationException } from '../../../../shared/exception/application.exception' export class CoinGeckoException extends ApplicationException {} diff --git a/apps/orchestration/src/price/persistence/repository/coin-gecko-asset.repository.ts b/apps/orchestration/src/price/persistence/repository/coin-gecko-asset.repository.ts index f7525267c..9f22aa594 100644 --- a/apps/orchestration/src/price/persistence/repository/coin-gecko-asset.repository.ts +++ b/apps/orchestration/src/price/persistence/repository/coin-gecko-asset.repository.ts @@ -1,8 +1,8 @@ -import CoinGeckoAssetIdIndex from '@app/orchestration/price/resource/coin-gecko-asset-id-index.json' -import { findChain, safeGetChain } from '@app/orchestration/shared/core/lib/chains.lib' -import { FiatId } from '@app/orchestration/shared/core/type/price.type' import { AssetId, getAssetId, isCoin, parseAsset } from '@narval/authz-shared' import { Injectable } from '@nestjs/common' +import { findChain, safeGetChain } from '../../../shared/core/lib/chains.lib' +import { FiatId } from '../../../shared/core/type/price.type' +import CoinGeckoAssetIdIndex from '../../resource/coin-gecko-asset-id-index.json' @Injectable() export class CoinGeckoAssetRepository { diff --git a/apps/orchestration/src/price/price.module.ts b/apps/orchestration/src/price/price.module.ts index 98c12f57c..a1347037d 100644 --- a/apps/orchestration/src/price/price.module.ts +++ b/apps/orchestration/src/price/price.module.ts @@ -1,8 +1,8 @@ -import { PriceService } from '@app/orchestration/price/core/service/price.service' -import { CoinGeckoClient } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.client' -import { CoinGeckoAssetRepository } from '@app/orchestration/price/persistence/repository/coin-gecko-asset.repository' import { HttpModule } from '@nestjs/axios' import { Module } from '@nestjs/common' +import { PriceService } from './core/service/price.service' +import { CoinGeckoClient } from './http/client/coin-gecko/coin-gecko.client' +import { CoinGeckoAssetRepository } from './persistence/repository/coin-gecko-asset.repository' @Module({ imports: [HttpModule], diff --git a/apps/orchestration/src/price/script/generate-coin-gecko-asset-id-index.script.ts b/apps/orchestration/src/price/script/generate-coin-gecko-asset-id-index.script.ts index b1b6076ac..7e209db07 100644 --- a/apps/orchestration/src/price/script/generate-coin-gecko-asset-id-index.script.ts +++ b/apps/orchestration/src/price/script/generate-coin-gecko-asset-id-index.script.ts @@ -2,10 +2,6 @@ * Generates an CAIP Asset ID to coin ID index using CoinGecko API to make price * queries faster and easier. */ -import { CHAINS } from '@app/orchestration/orchestration.constant' -import { CoinGeckoClient } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.client' -import { Coin } from '@app/orchestration/price/http/client/coin-gecko/coin-gecko.type' -import { Chain, findChain } from '@app/orchestration/shared/core/lib/chains.lib' import { AssetId, AssetType, getAddress, isAddress, toAssetId } from '@narval/authz-shared' import { HttpService } from '@nestjs/axios' import { Logger } from '@nestjs/common' @@ -13,6 +9,10 @@ import File from 'fs' import { compact, flatten, pick } from 'lodash/fp' import { concatMap, filter, from, lastValueFrom, map, mergeMap, reduce, tap } from 'rxjs' import { Address } from 'viem' +import { CHAINS } from '../../orchestration.constant' +import { Chain, findChain } from '../../shared/core/lib/chains.lib' +import { CoinGeckoClient } from '../http/client/coin-gecko/coin-gecko.client' +import { Coin } from '../http/client/coin-gecko/coin-gecko.type' const logger = new Logger('CoinGeckoCoinDictionaryScript') diff --git a/apps/orchestration/src/repl.ts b/apps/orchestration/src/repl.ts index 4d4248cb1..360cd0568 100644 --- a/apps/orchestration/src/repl.ts +++ b/apps/orchestration/src/repl.ts @@ -1,5 +1,5 @@ -import { OrchestrationModule } from '@app/orchestration/orchestration.module' import { repl } from '@nestjs/core' +import { OrchestrationModule } from './orchestration.module' async function bootstrap() { try { diff --git a/apps/orchestration/src/shared/core/exception/data-feed.exception.ts b/apps/orchestration/src/shared/core/exception/data-feed.exception.ts index 2656a1e97..95a0954a6 100644 --- a/apps/orchestration/src/shared/core/exception/data-feed.exception.ts +++ b/apps/orchestration/src/shared/core/exception/data-feed.exception.ts @@ -1,3 +1,3 @@ -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' +import { ApplicationException } from '../../../shared/exception/application.exception' export class DataFeedException extends ApplicationException {} diff --git a/apps/orchestration/src/shared/core/lib/chains.lib.ts b/apps/orchestration/src/shared/core/lib/chains.lib.ts index be19d2d39..9bc6817e0 100644 --- a/apps/orchestration/src/shared/core/lib/chains.lib.ts +++ b/apps/orchestration/src/shared/core/lib/chains.lib.ts @@ -1,7 +1,7 @@ -import { CHAINS } from '@app/orchestration/orchestration.constant' -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' import { AssetId } from '@narval/authz-shared' import { HttpStatus } from '@nestjs/common' +import { CHAINS } from '../../../orchestration.constant' +import { ApplicationException } from '../../../shared/exception/application.exception' export enum ChainId { ETHEREUM = 1, diff --git a/apps/orchestration/src/shared/core/type/transfer-tracking.type.ts b/apps/orchestration/src/shared/core/type/transfer-tracking.type.ts index cd4f92883..ab2da1303 100644 --- a/apps/orchestration/src/shared/core/type/transfer-tracking.type.ts +++ b/apps/orchestration/src/shared/core/type/transfer-tracking.type.ts @@ -1,5 +1,5 @@ -import { Price } from '@app/orchestration/shared/core/type/price.type' import { SetOptional } from 'type-fest' +import { Price } from './price.type' export type Transfer = { id: string diff --git a/apps/orchestration/src/shared/decorator/__test__/unit/org-id.decorator.spec.ts b/apps/orchestration/src/shared/decorator/__test__/unit/org-id.decorator.spec.ts index d719efc8d..45f947543 100644 --- a/apps/orchestration/src/shared/decorator/__test__/unit/org-id.decorator.spec.ts +++ b/apps/orchestration/src/shared/decorator/__test__/unit/org-id.decorator.spec.ts @@ -1,6 +1,6 @@ -import { REQUEST_HEADER_ORG_ID } from '@app/orchestration/orchestration.constant' -import { factory } from '@app/orchestration/shared/decorator/org-id.decorator' import { ExecutionContext } from '@nestjs/common' +import { REQUEST_HEADER_ORG_ID } from '../../../../orchestration.constant' +import { factory } from '../../../decorator/org-id.decorator' describe('OrgId Decorator', () => { it(`returns ${REQUEST_HEADER_ORG_ID} if it exists in the headers`, () => { diff --git a/apps/orchestration/src/shared/decorator/org-id.decorator.ts b/apps/orchestration/src/shared/decorator/org-id.decorator.ts index 7a1e38a2c..0c9c406ef 100644 --- a/apps/orchestration/src/shared/decorator/org-id.decorator.ts +++ b/apps/orchestration/src/shared/decorator/org-id.decorator.ts @@ -1,5 +1,5 @@ -import { REQUEST_HEADER_ORG_ID } from '@app/orchestration/orchestration.constant' import { BadRequestException, ExecutionContext, createParamDecorator } from '@nestjs/common' +import { REQUEST_HEADER_ORG_ID } from '../../orchestration.constant' // eslint-disable-next-line @typescript-eslint/no-explicit-any export const factory = (value: any, ctx: ExecutionContext) => { diff --git a/apps/orchestration/src/shared/filter/__test__/unit/application-exception.filter.spec.ts b/apps/orchestration/src/shared/filter/__test__/unit/application-exception.filter.spec.ts index e6207a6e8..76a5ebe8c 100644 --- a/apps/orchestration/src/shared/filter/__test__/unit/application-exception.filter.spec.ts +++ b/apps/orchestration/src/shared/filter/__test__/unit/application-exception.filter.spec.ts @@ -1,11 +1,11 @@ -import { Config, Env } from '@app/orchestration/orchestration.config' -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' -import { ApplicationExceptionFilter } from '@app/orchestration/shared/filter/application-exception.filter' import { ArgumentsHost, HttpStatus } from '@nestjs/common' import { HttpArgumentsHost } from '@nestjs/common/interfaces' import { ConfigService } from '@nestjs/config' import { Response } from 'express' import { mock } from 'jest-mock-extended' +import { Config, Env } from '../../../../orchestration.config' +import { ApplicationException } from '../../../../shared/exception/application.exception' +import { ApplicationExceptionFilter } from '../../../../shared/filter/application-exception.filter' describe(ApplicationExceptionFilter.name, () => { const exception = new ApplicationException({ diff --git a/apps/orchestration/src/shared/filter/application-exception.filter.ts b/apps/orchestration/src/shared/filter/application-exception.filter.ts index 6fb3b478d..a7664c113 100644 --- a/apps/orchestration/src/shared/filter/application-exception.filter.ts +++ b/apps/orchestration/src/shared/filter/application-exception.filter.ts @@ -1,8 +1,8 @@ -import { Config, Env } from '@app/orchestration/orchestration.config' -import { ApplicationException } from '@app/orchestration/shared/exception/application.exception' import { ArgumentsHost, Catch, ExceptionFilter, LogLevel, Logger } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { Response } from 'express' +import { Config, Env } from '../../orchestration.config' +import { ApplicationException } from '../../shared/exception/application.exception' @Catch(ApplicationException) export class ApplicationExceptionFilter implements ExceptionFilter { diff --git a/apps/orchestration/src/shared/filter/zod-exception.filter.ts b/apps/orchestration/src/shared/filter/zod-exception.filter.ts index 8d84a5fd6..e387b6297 100644 --- a/apps/orchestration/src/shared/filter/zod-exception.filter.ts +++ b/apps/orchestration/src/shared/filter/zod-exception.filter.ts @@ -1,8 +1,8 @@ -import { Config, Env } from '@app/orchestration/orchestration.config' import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus, Logger } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { Response } from 'express' import { ZodError } from 'zod' +import { Config, Env } from '../../orchestration.config' @Catch(ZodError) export class ZodExceptionFilter implements ExceptionFilter { diff --git a/apps/orchestration/src/shared/module/persistence/persistence.module.ts b/apps/orchestration/src/shared/module/persistence/persistence.module.ts index bd34e89f7..c21f85213 100644 --- a/apps/orchestration/src/shared/module/persistence/persistence.module.ts +++ b/apps/orchestration/src/shared/module/persistence/persistence.module.ts @@ -1,6 +1,6 @@ -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' import { Module } from '@nestjs/common' +import { PrismaService } from '../../..//shared/module/persistence/service/prisma.service' +import { TestPrismaService } from '../../../shared/module/persistence/service/test-prisma.service' @Module({ exports: [PrismaService, TestPrismaService], diff --git a/apps/orchestration/src/shared/module/persistence/seed.ts b/apps/orchestration/src/shared/module/persistence/seed.ts index e394ab0f7..573a14139 100644 --- a/apps/orchestration/src/shared/module/persistence/seed.ts +++ b/apps/orchestration/src/shared/module/persistence/seed.ts @@ -1,6 +1,6 @@ -import { germinate as germinateTransferTrackingModule } from '@app/orchestration/transfer-tracking/persistence/transfer.seed' import { Logger } from '@nestjs/common' import { Organization, PrismaClient } from '@prisma/client/orchestration' +import { germinate as germinateTransferTrackingModule } from '../../../transfer-tracking/persistence/transfer.seed' const now = new Date() const prisma = new PrismaClient() diff --git a/apps/orchestration/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts b/apps/orchestration/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts index d379bb7a9..9455d631d 100644 --- a/apps/orchestration/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts +++ b/apps/orchestration/src/shared/module/persistence/service/__test__/unit/prisma.service.spec.ts @@ -1,6 +1,6 @@ -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' import { ConfigService } from '@nestjs/config' import { mock } from 'jest-mock-extended' +import { PrismaService } from '../../../../../../shared/module/persistence/service/prisma.service' describe(PrismaService.name, () => { describe('constructor', () => { diff --git a/apps/orchestration/src/shared/module/persistence/service/prisma.service.ts b/apps/orchestration/src/shared/module/persistence/service/prisma.service.ts index 7fa22e894..5f4f64370 100644 --- a/apps/orchestration/src/shared/module/persistence/service/prisma.service.ts +++ b/apps/orchestration/src/shared/module/persistence/service/prisma.service.ts @@ -1,7 +1,7 @@ -import { Config } from '@app/orchestration/orchestration.config' import { Inject, Injectable, Logger, OnApplicationShutdown, OnModuleDestroy, OnModuleInit } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { PrismaClient } from '@prisma/client/orchestration' +import { Config } from '../../../../orchestration.config' @Injectable() export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy, OnApplicationShutdown { diff --git a/apps/orchestration/src/shared/module/queue/queue.module.ts b/apps/orchestration/src/shared/module/queue/queue.module.ts index 82f315b34..51bd723aa 100644 --- a/apps/orchestration/src/shared/module/queue/queue.module.ts +++ b/apps/orchestration/src/shared/module/queue/queue.module.ts @@ -1,10 +1,10 @@ -import { Config, Env } from '@app/orchestration/orchestration.config' -import { QUEUE_PREFIX } from '@app/orchestration/orchestration.constant' import { ExpressAdapter } from '@bull-board/express' import { BullBoardModule } from '@bull-board/nestjs' import { BullModule } from '@nestjs/bull' import { DynamicModule } from '@nestjs/common' import { ConfigService } from '@nestjs/config' +import { Config, Env } from '../../../orchestration.config' +import { QUEUE_PREFIX } from '../../../orchestration.constant' export type RegisterQueueOption = { name: string diff --git a/apps/orchestration/src/transfer-tracking/core/service/__test__/e2e/transfer-tracking.service.spec.ts b/apps/orchestration/src/transfer-tracking/core/service/__test__/e2e/transfer-tracking.service.spec.ts index 5cbde2434..021c5dc9d 100644 --- a/apps/orchestration/src/transfer-tracking/core/service/__test__/e2e/transfer-tracking.service.spec.ts +++ b/apps/orchestration/src/transfer-tracking/core/service/__test__/e2e/transfer-tracking.service.spec.ts @@ -1,15 +1,15 @@ -import { generateTransfer } from '@app/orchestration/__test__/fixture/transfer-tracking.fixture' -import { load } from '@app/orchestration/orchestration.config' -import { Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TestPrismaService } from '@app/orchestration/shared/module/persistence/service/test-prisma.service' -import { QueueModule } from '@app/orchestration/shared/module/queue/queue.module' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' -import { TransferTrackingModule } from '@app/orchestration/transfer-tracking/transfer-tracking.module' import { INestApplication } from '@nestjs/common' import { ConfigModule } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' import { first, map, mapValues, omit, uniq } from 'lodash/fp' +import { generateTransfer } from '../../../../../__test__/fixture/transfer-tracking.fixture' +import { load } from '../../../../../orchestration.config' +import { Transfer } from '../../../../../shared/core/type/transfer-tracking.type' +import { PersistenceModule } from '../../../../../shared/module/persistence/persistence.module' +import { TestPrismaService } from '../../../../../shared/module/persistence/service/test-prisma.service' +import { QueueModule } from '../../../../../shared/module/queue/queue.module' +import { TransferTrackingService } from '../../../../core/service/transfer-tracking.service' +import { TransferTrackingModule } from '../../../../transfer-tracking.module' describe(TransferTrackingService.name, () => { let app: INestApplication diff --git a/apps/orchestration/src/transfer-tracking/core/service/transfer-tracking.service.ts b/apps/orchestration/src/transfer-tracking/core/service/transfer-tracking.service.ts index 45148e094..1071c3064 100644 --- a/apps/orchestration/src/transfer-tracking/core/service/transfer-tracking.service.ts +++ b/apps/orchestration/src/transfer-tracking/core/service/transfer-tracking.service.ts @@ -1,6 +1,6 @@ -import { CreateTransfer, Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { TransferRepository } from '@app/orchestration/transfer-tracking/persistence/repository/transfer.repository' import { Injectable, Logger } from '@nestjs/common' +import { CreateTransfer, Transfer } from '../../../shared/core/type/transfer-tracking.type' +import { TransferRepository } from '../../../transfer-tracking/persistence/repository/transfer.repository' @Injectable() export class TransferTrackingService { diff --git a/apps/orchestration/src/transfer-tracking/persistence/repository/transfer.repository.ts b/apps/orchestration/src/transfer-tracking/persistence/repository/transfer.repository.ts index 2fddd70ae..785334dfb 100644 --- a/apps/orchestration/src/transfer-tracking/persistence/repository/transfer.repository.ts +++ b/apps/orchestration/src/transfer-tracking/persistence/repository/transfer.repository.ts @@ -1,9 +1,9 @@ -import { CreateTransfer, Transfer } from '@app/orchestration/shared/core/type/transfer-tracking.type' -import { PrismaService } from '@app/orchestration/shared/module/persistence/service/prisma.service' import { Injectable } from '@nestjs/common' import { ApprovedTransfer } from '@prisma/client/orchestration' import { v4 as uuid } from 'uuid' import { z } from 'zod' +import { CreateTransfer, Transfer } from '../../../shared/core/type/transfer-tracking.type' +import { PrismaService } from '../../../shared/module/persistence/service/prisma.service' const decodeRatesSchema = z.record(z.string(), z.coerce.number()) const encodeRatesSchema = z.record(z.string(), z.coerce.string()) diff --git a/apps/orchestration/src/transfer-tracking/persistence/transfer.seed.ts b/apps/orchestration/src/transfer-tracking/persistence/transfer.seed.ts index 2d3fa4a60..23cab0265 100644 --- a/apps/orchestration/src/transfer-tracking/persistence/transfer.seed.ts +++ b/apps/orchestration/src/transfer-tracking/persistence/transfer.seed.ts @@ -1,7 +1,7 @@ -import { POLYGON } from '@app/orchestration/orchestration.constant' import { Logger } from '@nestjs/common' import { PrismaClient } from '@prisma/client/orchestration' import { getTime, subHours } from 'date-fns' +import { POLYGON } from '../../orchestration.constant' export const germinate = async (prisma: PrismaClient): Promise => { const logger = new Logger('TransferFeedSeed') diff --git a/apps/orchestration/src/transfer-tracking/transfer-tracking.module.ts b/apps/orchestration/src/transfer-tracking/transfer-tracking.module.ts index 8b6258c83..b60e09724 100644 --- a/apps/orchestration/src/transfer-tracking/transfer-tracking.module.ts +++ b/apps/orchestration/src/transfer-tracking/transfer-tracking.module.ts @@ -1,7 +1,7 @@ -import { PersistenceModule } from '@app/orchestration/shared/module/persistence/persistence.module' -import { TransferTrackingService } from '@app/orchestration/transfer-tracking/core/service/transfer-tracking.service' -import { TransferRepository } from '@app/orchestration/transfer-tracking/persistence/repository/transfer.repository' import { Module } from '@nestjs/common' +import { PersistenceModule } from '../shared/module/persistence/persistence.module' +import { TransferTrackingService } from './core/service/transfer-tracking.service' +import { TransferRepository } from './persistence/repository/transfer.repository' @Module({ imports: [PersistenceModule], diff --git a/package-lock.json b/package-lock.json index 240ebe73d..c6d5d9e1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,7 +88,6 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "2.27.5", "eslint-plugin-jsx-a11y": "6.8.0", - "eslint-plugin-no-relative-import-paths": "^1.5.3", "eslint-plugin-playwright": "^0.22.2", "eslint-plugin-react": "7.32.2", "eslint-plugin-react-hooks": "4.6.0", @@ -15284,12 +15283,6 @@ "node": "*" } }, - "node_modules/eslint-plugin-no-relative-import-paths": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-no-relative-import-paths/-/eslint-plugin-no-relative-import-paths-1.5.3.tgz", - "integrity": "sha512-z7c7Km1U0zdLyPziWeRKSsN2mPaGaBHDjfXn98B8XjRIhFi2bPqduRYcxWih1kI5al5tQtiChXVmspLkB0wNsQ==", - "dev": true - }, "node_modules/eslint-plugin-playwright": { "version": "0.22.2", "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-0.22.2.tgz", diff --git a/package.json b/package.json index c60d35cb5..bbb34de78 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "2.27.5", "eslint-plugin-jsx-a11y": "6.8.0", - "eslint-plugin-no-relative-import-paths": "^1.5.3", "eslint-plugin-playwright": "^0.22.2", "eslint-plugin-react": "7.32.2", "eslint-plugin-react-hooks": "4.6.0", diff --git a/packages/authz-shared/src/lib/type/domain.type.ts b/packages/authz-shared/src/lib/type/domain.type.ts index 0f9bdbee1..6c0e7c7f9 100644 --- a/packages/authz-shared/src/lib/type/domain.type.ts +++ b/packages/authz-shared/src/lib/type/domain.type.ts @@ -1,11 +1,5 @@ -import { - AssetId, - CreateOrganizationAction, - SignMessageAction, - SignTransactionAction, - Signature -} from '@narval/authz-shared' -import { Intent } from '@narval/transaction-request-intent' +import { AssetId } from '../util/caip.util' +import { CreateOrganizationAction, SignMessageAction, SignTransactionAction, Signature } from './action.type' export enum Decision { PERMIT = 'Permit', @@ -34,14 +28,30 @@ export enum FiatCurrency { } export type HistoricalTransfer = { - amount: string // Amount in the smallest unit of the token (eg. wei for ETH) + /** + * Amount in the smallest unit of the token (eg. wei for ETH). + */ + amount: string from: string - to: string // In case we want spending limit per destination address + /** + * In case we want spending limit per destination address + */ + to: string chainId: number token: string - rates: Record // eg. { fiat:usd: '0.01', fiat:eur: '0.02' } - initiatedBy: string // uid of the user who initiated the spending - timestamp: number // unix timestamp in ms + /** + * @example + * { fiat:usd: '0.01', fiat:eur: '0.02' } + */ + rates: Record + /** + * UID of the user who initiated the transfer. + */ + initiatedBy: string + /** + * Unix timestamp in milliseconds. + */ + timestamp: number } /** @@ -137,5 +147,5 @@ export type EvaluationResponse = { satisfied: ApprovalRequirement[] } attestation?: Signature - transactionRequestIntent?: Intent + transactionRequestIntent?: unknown } diff --git a/packages/signature-verifier/project.json b/packages/signature-verifier/project.json index 7b23a4e22..64e8d1776 100644 --- a/packages/signature-verifier/project.json +++ b/packages/signature-verifier/project.json @@ -20,5 +20,5 @@ } } }, - "tags": [] + "tags": ["package"] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 0a5f1fd91..b18c3ba51 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -13,8 +13,7 @@ "noImplicitAny": true, "noImplicitThis": true, "paths": { - "@app/authz/*": ["apps/authz/src/*"], - "@app/orchestration/*": ["apps/orchestration/src/*"], + "@app/*": ["apps/*"], "@narval/authz-shared": ["packages/authz-shared/src/index.ts"], "@narval/signature-verifier": ["packages/signature-verifier/src/index.ts"], "@narval/transaction-engine-module": ["packages/transaction-engine-module/src/index.ts"],