Skip to content

Commit

Permalink
chore: get rid of TS paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed May 9, 2024
1 parent 654e330 commit e89b15b
Show file tree
Hide file tree
Showing 70 changed files with 85 additions and 156 deletions.
11 changes: 1 addition & 10 deletions packages/backtesting-playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#backtesting-playground/*": ["./src/*"],

// imported modules
"#backtesting/*": ["../backtesting/src/*"],
"#bot-processor/*": ["../bot-processor/src/*"],
"#bot-templates/*": ["../bot-templates/src/*"],
"#db/*": ["../db/src/*"],
"#exchanges/*": ["../exchanges/src/*"]
}
"paths": {}
}
}
2 changes: 1 addition & 1 deletion packages/backtesting/src/report/buyOrder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTrade } from "@opentrader/bot-processor";
import { OrderSideEnum } from "@opentrader/types";
import type { ActiveOrder } from "#backtesting/types";
import type { ActiveOrder } from "../types";

export function buyOrder(smartTrade: SmartTrade): ActiveOrder {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/backtesting/src/report/buyTransaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTrade } from "@opentrader/bot-processor";
import { OrderSideEnum } from "@opentrader/types";
import type { BuyTransaction } from "#backtesting/types";
import type { BuyTransaction } from "../types";

export function buyTransaction(smartTrade: SmartTrade): BuyTransaction {
const { buy, sell, quantity, id } = smartTrade;
Expand Down
2 changes: 1 addition & 1 deletion packages/backtesting/src/report/sellOrder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTrade } from "@opentrader/bot-processor";
import { OrderSideEnum } from "@opentrader/types";
import type { ActiveOrder } from "#backtesting/types";
import type { ActiveOrder } from "../types";

export function sellOrder(smartTrade: SmartTrade): ActiveOrder {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/backtesting/src/types/report/report-result.type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ActiveOrder } from "#backtesting/types/report/active-order.type";
import type { Transaction } from "#backtesting/types/report/transaction.type";
import type { ActiveOrder } from "./active-order.type";
import type { Transaction } from "./transaction.type";

export type ReportResult = {
transactions: Transaction[];
Expand Down
10 changes: 1 addition & 9 deletions packages/backtesting/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#backtesting/*": ["./src/*"],

// imported modules
"#bot-processor/*": ["../bot-processor/src/*"],
"#exchanges/*": ["../exchanges/src/*"],
"#db/*": ["../db/src/*"],
"#logger/*": ["../logger/src/*"]
}
"paths": {}
}
}
2 changes: 1 addition & 1 deletion packages/bot-processor/src/bot-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IExchange } from "@opentrader/exchanges";
import { computeIndicators } from "@opentrader/indicators";
import type { IndicatorBarSize } from "@opentrader/types";
import { lastClosedCandleDate } from "@opentrader/tools";
import type { TBotContext } from "#bot-processor/types/bot/bot-context.type";
import type { TBotContext } from "./types/bot/bot-context.type";
import { createContext } from "./utils/createContext";
import { SmartTradeService } from "./smart-trade.service";
import type { IBotConfiguration, BotTemplate, IBotControl } from "./types";
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-processor/src/types/bot/bot-context.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IBotControl } from "#bot-processor/types/bot/bot-control.interface";
import type { IBotControl } from "./bot-control.interface";
import type { IBotConfiguration } from "./bot-configuration.interface";

export type TBotContext<T extends IBotConfiguration> = {
Expand Down
8 changes: 1 addition & 7 deletions packages/bot-processor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#bot-processor/*": ["./src/*"],

// imported modules
"#exchanges/*": ["../exchanges/src/*"],
"#db/*": ["../db/src/*"]
}
"paths": {}
}
}
8 changes: 1 addition & 7 deletions packages/bot-templates/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#bot-templates/*": ["./src/*"],
// imported modules
"#exchanges/*": ["../exchanges/src/*"],
"#bot-processor/*": ["../bot-processor/src/*"],
"#db/*": ["../db/src/*"],
}
"paths": {}
}
}
5 changes: 1 addition & 4 deletions packages/bot/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#bot/*": ["./src/*"]
// imported modules
}
"paths": {}
}
}
11 changes: 1 addition & 10 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#cli/*": ["./src/*"],
// imported modules
"#bot-processor/*": ["../bot-processor/src/*"],
"#bot-template/*": ["../bot-template/src/*"],
"#backtesting/*": ["../backtesting/src/*"],
"#exchanges/*": ["../exchanges/src/*"],
"#db/*": ["../db/src/*"],
"#logger/*": ["../logger/src/*"]
}
"paths": {}
}
}
2 changes: 1 addition & 1 deletion packages/db/src/asserts/assertHasExchangeOrderId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OrderEntity } from "#db/entities";
import type { OrderEntity } from "../entities";

type RequiredNotNull<T, K extends keyof T> = T & {
[P in K]: NonNullable<T[P]>;
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/asserts/assertIsOrderBased.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
SmartTradeEntity,
SmartTradeEntity_Order_Order,
} from "#db/entities";
} from "../entities";

/**
* Asserts that SmartTrade uses orders for entry and exit
Expand Down
2 changes: 1 addition & 1 deletion packages/db/src/entities/smart-trade.entity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { $Enums } from "@prisma/client";
import type { SmartTradeWithOrders } from "#db/types/smart-trade";
import type { SmartTradeWithOrders } from "../types/smart-trade";
import type { OrderEntity } from "./order.entity";
import { toOrderEntity } from "./order.entity";

Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/extension/models/custom-bot.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Prisma, PrismaClient } from "@prisma/client";
import type { TBotSettings } from "#db/types";
import { ZBotSettings } from "#db/types";
import type { TBotSettings } from "../../types";
import { ZBotSettings } from "../../types";

export const customBotModel = (prisma: PrismaClient) => ({
async findUnique<T extends Prisma.BotFindUniqueArgs>(
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/extension/models/grid-bot.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Prisma, PrismaClient } from "@prisma/client";
import type { TGridBotSettings } from "#db/types/grid-bot";
import { ZGridBotSettings } from "#db/types/grid-bot";
import type { TGridBotSettings } from "../../types/grid-bot";
import { ZGridBotSettings } from "../../types/grid-bot";

export const gridBotModel = (prisma: PrismaClient) => ({
async findUnique<T extends Prisma.BotFindUniqueArgs>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Prisma } from "@prisma/client";
import type { xprisma } from "#db/xprisma";
import type { xprisma } from "../../xprisma";

export type ExchangeAccountWithCredentials = Prisma.PromiseReturnType<
typeof xprisma.exchangeAccount.findUniqueOrThrow
Expand Down
4 changes: 1 addition & 3 deletions packages/db/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#db/*": ["./src/*"]
}
"paths": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Dictionary, Exchange, Market } from "ccxt";
import type { ExchangeCode } from "@opentrader/types";
import type { ICacheProvider } from "#exchanges/types/cache/cache-provider.interface";
import type { ICacheProvider } from "../../../types/cache/cache-provider.interface";

export class MemoryCacheProvider implements ICacheProvider {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/exchanges/src/exchanges/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExchangeCode } from "@opentrader/types";
import type { IExchangeCredentials } from "#exchanges/types/exchange-credentials.interface";
import type { IExchangeCredentials } from "../types/exchange-credentials.interface";
import { OkxExchange } from "./okx/exchange";

export const exchanges = {
Expand Down
3 changes: 1 addition & 2 deletions packages/exchanges/src/exchanges/okx/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import type {
import { ExchangeCode } from "@opentrader/types";
import type { Dictionary, Market, okex5 } from "ccxt";
import { pro } from "ccxt";
import type { IExchangeCredentials } from "#exchanges/types/exchange-credentials.interface";
import type { IExchange } from "#exchanges/types/exchange.interface";
import type { IExchange, IExchangeCredentials } from "../../types";
import { cache } from "../../cache";
import { fetcher } from "../../utils/next/fetcher";
import { normalize } from "./normalize";
Expand Down
4 changes: 2 additions & 2 deletions packages/exchanges/src/exchanges/okx/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExchangeCode } from "@opentrader/types";
import { composeSymbolIdFromPair } from "@opentrader/tools";
import type { Normalize } from "#exchanges/types/normalize.interface";
import { normalizeOrderStatus } from "#exchanges/utils/normalizeOrderStatus";
import type { Normalize } from "../../types/normalize.interface";
import { normalizeOrderStatus } from "../../utils/normalizeOrderStatus";

const accountAssets: Normalize["accountAssets"] = {
response: (data) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Dictionary, Exchange, Market } from "ccxt";
import type { ExchangeCode } from "@opentrader/types";
import type { Prisma } from "@opentrader/db";
import { xprisma } from "@opentrader/db";
import type { ICacheProvider } from "#exchanges/types/cache/cache-provider.interface";
import type { ICacheProvider } from "../../../types/cache/cache-provider.interface";

export class PrismaCacheProvider implements ICacheProvider {
async getMarkets(exchangeCode: ExchangeCode, ccxtExchange: Exchange) {
Expand Down
6 changes: 1 addition & 5 deletions packages/exchanges/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#exchanges/*": ["./src/*"],
// imported modules
"#db/*": ["../db/src/*"]
}
"paths": {}
}
}
6 changes: 1 addition & 5 deletions packages/indicators/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#indicators/*": ["./src/*"],
// imported modules
"#db/*": ["../db/src/*"]
}
"paths": {}
}
}
4 changes: 1 addition & 3 deletions packages/logger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#logger/*": ["./src/*"]
}
"paths": {}
}
}
2 changes: 1 addition & 1 deletion packages/processing/src/bot/bot-store-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
UseSmartTradePayload,
} from "@opentrader/bot-processor";
import { xprisma, toSmartTradeEntity } from "@opentrader/db";
import { SmartTradeProcessor } from "#processing/smart-trade";
import { SmartTradeProcessor } from "../smart-trade";
import { toPrismaSmartTrade, toSmartTradeIteratorResult } from "./utils";

export class BotStoreAdapter implements IStore {
Expand Down
2 changes: 1 addition & 1 deletion packages/processing/src/bot/bot.processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { findTemplate } from "@opentrader/bot-templates";
import { exchangeProvider } from "@opentrader/exchanges";
import type { TBot } from "@opentrader/db";
import { xprisma } from "@opentrader/db";
import { SmartTradeProcessor } from "#processing/smart-trade";
import { SmartTradeProcessor } from "../smart-trade";
import { BotStoreAdapter } from "./bot-store-adapter";

export class BotProcessing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
import { xprisma } from "@opentrader/db";
import { exchangeProvider, type IExchange } from "@opentrader/exchanges";
import type { IGetLimitOrderResponse } from "@opentrader/types";
import { toDbStatus } from "#processing/utils";
import { toDbStatus } from "../utils";

type SymbolId = string;

Expand Down
10 changes: 1 addition & 9 deletions packages/processing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"#processing/*": ["./src/*"],

// imported modules
"#bot-processor/*": ["../bot-processor/src/*"],
"#bot-templates/*": ["../bot-templates/src/*"],
"#db/*": ["../db/src/*"],
"#exchanges/*": ["../exchanges/src/*"]
}
"paths": {}
}
}
2 changes: 1 addition & 1 deletion packages/trpc/src/common/middlewares/isLoggedIn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TRPCError } from "@trpc/server";
import { middleware } from "#trpc/trpc";
import { middleware } from "../../trpc";

export const isLoggedIn = middleware(({ next, ctx }) => {
if (!ctx.user) {
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc/src/routers/appRouter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { trpc } from "#trpc/trpc"; // @todo relative path
import { trpc } from "../trpc"; // @todo relative path
import {
botRouter,
cronRouter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TRPCError } from "@trpc/server";
import { xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TCreateBotInputSchema } from "./schema";

type Options = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { xprisma } from "@opentrader/db";
import { SmartTradeProcessor } from "@opentrader/processing";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TCronPlacePendingOrdersInputSchema } from "./schema";

type Options = {
Expand Down
4 changes: 2 additions & 2 deletions packages/trpc/src/routers/private/bot/delete-bot/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { xprisma } from "@opentrader/db";
import { BotService } from "#trpc/services/bot.service";
import type { Context } from "#trpc/utils/context";
import { BotService } from "../../../../services/bot.service";
import type { Context } from "../../../../utils/context";
import type { TDeleteBotInputSchema } from "./schema";

type Options = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTradeEntity_Order_Order } from "@opentrader/db";
import { toSmartTradeEntity, xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TGetActiveSmartTradesInputSchema } from "./schema";

type Options = {
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc/src/routers/private/bot/get-bot/handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TGetBotInputSchema } from "./schema";

type Options = {
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc/src/routers/private/bot/get-bots/handler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";

type Options = {
ctx: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTradeEntity_Order_Order } from "@opentrader/db";
import { toSmartTradeEntity, xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TGetCompletedSmartTradesInputSchema } from "./schema";

type Options = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TGetGridBotOrdersInputSchema } from "./schema";

type Options = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SmartTradeEntity_Order_Order } from "@opentrader/db";
import { toSmartTradeEntity, xprisma } from "@opentrader/db";
import type { Context } from "#trpc/utils/context";
import type { Context } from "../../../../utils/context";
import type { TGetPendingSmartTradesInputSchema } from "./schema";

type Options = {
Expand Down
Loading

0 comments on commit e89b15b

Please sign in to comment.