Skip to content

Commit

Permalink
Move types for reports so they're excluded from coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn committed Dec 5, 2024
1 parent 4325f44 commit e21eaa6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 120 deletions.
2 changes: 1 addition & 1 deletion src/Reports/Processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
AssetTransactionReportFilter,
ProfitAndLossReportPrivateCredit,
ProfitAndLossReportPublicCredit,
} from './types.js'
} from './reports.js'
import { InvestorTransaction } from '../queries/investorTransactions.js'

describe('Processor', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
TokenPriceReport,
TokenPriceReportFilter,
TokenPriceData,
} from './types.js'
} from './reports.js'

Check failure on line 25 in src/Reports/Processor.ts

View workflow job for this annotation

GitHub Actions / build-n-test

Cannot find module './reports.js' or its corresponding type declarations.

export class Processor {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai'
import { Centrifuge } from '../Centrifuge.js'
import { spy } from 'sinon'
import { Reports } from '../Reports/index.js'
import { ReportFilter } from './types.js'
import { ReportFilter } from './reports.js'
import { processor } from './Processor.js'

describe('Reports', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
AssetTransactionReportFilter,
TokenPriceReport,
TokenPriceReportFilter,
} from './types.js'
} from './reports.js'
import { Query } from '../types/query.js'
import {
PoolFeeSnapshotFilter,
Expand Down
118 changes: 2 additions & 116 deletions src/Reports/types.ts → src/types/reports.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { AssetTransaction, AssetTransactionType } from '../queries/assetTransactions.js'
import { InvestorTransaction, SubqueryInvestorTransactionType } from '../queries/investorTransactions.js'
import { PoolFeeSnapshotsByDate } from '../queries/poolFeeSnapshots.js'
import { PoolFeeTransaction } from '../queries/poolFeeTransactions.js'
import { PoolSnapshot } from '../queries/poolSnapshots.js'
import { TrancheSnapshotsByDate } from '../queries/trancheSnapshots.js'
import { PoolMetadata } from '../types/poolMetadata.js'
import { Price, Token } from '../utils/BigInt.js'
import { PoolMetadata } from './poolMetadata.js'
import { Price } from '../utils/BigInt.js'
import { Currency } from '../utils/BigInt.js'
import { GroupBy } from '../utils/date.js'

Expand All @@ -15,17 +12,6 @@ export interface ReportFilter {
groupBy?: GroupBy
}

export type DataReportFilter = {
to?: string
from?: string
}

export type Report = 'balanceSheet' | 'cashflow' | 'profitAndLoss'
export type DataReport = 'investorTransactions' | 'assetTransactions' | 'feeTransactions' | 'tokenPrice'

/**
* Balance sheet type
*/
export type BalanceSheetReport = {
type: 'balanceSheet'
timestamp: string
Expand All @@ -50,9 +36,6 @@ export type BalanceSheetData = {
trancheSnapshots: TrancheSnapshotsByDate
}

/**
* Cashflow types
*/
type CashflowReportBase = {
type: 'cashflow'
timestamp: string
Expand Down Expand Up @@ -87,9 +70,6 @@ export type CashflowData = {
metadata: PoolMetadata | undefined
}

/**
* Profit and loss types
*/
export type ProfitAndLossReportBase = {
type: 'profitAndLoss'
timestamp: string
Expand Down Expand Up @@ -119,97 +99,3 @@ export type ProfitAndLossData = {
poolFeeSnapshots: PoolFeeSnapshotsByDate
metadata: PoolMetadata | undefined
}

/**
* Investor transactions types
*/
export type InvestorTransactionsData = {
investorTransactions: InvestorTransaction[]
}

export type InvestorTransactionsReport = {
type: 'investorTransactions'
timestamp: string
chainId: number
account: string
epoch: string
transactionType: SubqueryInvestorTransactionType
currencyAmount: Currency
// TODO: probably needs to be an array of tranches
trancheTokenId: string
trancheTokenAmount: Currency
price: Price
transactionHash: string
}

export type InvestorTransactionsReportFilter = {
tokenId?: string
transactionType?: 'orders' | 'executions' | 'transfers' | 'all'
network?: number | 'centrifuge' | 'all'
address?: string
to?: string
from?: string
}

/**
* Asset transactions types
*/
export type AssetTransactionsData = {
assetTransactions: AssetTransaction[]
}

export type AssetTransactionReport = {
type: 'assetTransactions'
timestamp: string
assetId: string
epoch: string
transactionType: AssetTransactionType
amount: Currency
transactionHash: string
}

export type AssetTransactionReportFilter = {
from?: string
to?: string
assetId?: string
transactionType?: 'created' | 'financed' | 'repaid' | 'priced' | 'closed' | 'cashTransfer' | 'all'
}

/**
* Fee transactions types
*/
export type FeeTransactionsData = {
poolFeeTransactions: PoolFeeTransaction[]
}

export type FeeTransactionReport = {
type: 'feeTransactions'
timestamp: string
feeId: string
amount: Currency
}

export type FeeTransactionReportFilter = {
from?: string
to?: string
transactionType?: 'directChargeMade' | 'directChargeCanceled' | 'accrued' | 'paid' | 'all'
}

/**
* Token price types
*/
export type TokenPriceData = {
trancheSnapshots: TrancheSnapshotsByDate
}

export type TokenPriceReport = {
type: 'tokenPrice'
timestamp: string
tranches: { name: string; price: Price; supply: Token; timestamp: string }[]
}

export type TokenPriceReportFilter = {
from?: string
to?: string
groupBy?: GroupBy
}

0 comments on commit e21eaa6

Please sign in to comment.