Skip to content

Commit

Permalink
Refactor @app/orchestration to use relative import path
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Feb 8, 2024
1 parent f2c62f3 commit 7b5e3dc
Show file tree
Hide file tree
Showing 79 changed files with 352 additions and 469 deletions.
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions apps/orchestration/src/__test__/fixture/feed.fixture.ts
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
8 changes: 4 additions & 4 deletions apps/orchestration/src/__test__/fixture/price.fixture.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions apps/orchestration/src/__test__/fixture/shared.fixture.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions apps/orchestration/src/data-feed/core/service/feed.service.ts
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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<HistoricalTransfer[]> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Prices> {
Expand Down
3 changes: 2 additions & 1 deletion apps/orchestration/src/data-feed/core/type/data-feed.type.ts
Original file line number Diff line number Diff line change
@@ -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<Data> {
getId(): string
Expand Down
12 changes: 6 additions & 6 deletions apps/orchestration/src/data-feed/data-feed.module.ts
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
6 changes: 3 additions & 3 deletions apps/orchestration/src/main.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions apps/orchestration/src/orchestration.constant.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions apps/orchestration/src/orchestration.module.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
Loading

0 comments on commit 7b5e3dc

Please sign in to comment.