diff --git a/apps/api/src/app/symbol/symbol.controller.ts b/apps/api/src/app/symbol/symbol.controller.ts index b3b9dc109..89cdd416c 100644 --- a/apps/api/src/app/symbol/symbol.controller.ts +++ b/apps/api/src/app/symbol/symbol.controller.ts @@ -2,6 +2,7 @@ import { HasPermissionGuard } from '@ghostfolio/api/guards/has-permission.guard' import { TransformDataSourceInRequestInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-request/transform-data-source-in-request.interceptor'; import { TransformDataSourceInResponseInterceptor } from '@ghostfolio/api/interceptors/transform-data-source-in-response/transform-data-source-in-response.interceptor'; import { IDataProviderHistoricalResponse } from '@ghostfolio/api/services/interfaces/interfaces'; +import { LookupResponse } from '@ghostfolio/common/interfaces'; import type { RequestWithUser } from '@ghostfolio/common/types'; import { @@ -21,7 +22,6 @@ import { parseISO } from 'date-fns'; import { StatusCodes, getReasonPhrase } from 'http-status-codes'; import { isDate, isEmpty } from 'lodash'; -import { LookupItem } from './interfaces/lookup-item.interface'; import { SymbolItem } from './interfaces/symbol-item.interface'; import { SymbolService } from './symbol.service'; @@ -41,7 +41,7 @@ export class SymbolController { public async lookupSymbol( @Query('includeIndices') includeIndicesParam = 'false', @Query('query') query = '' - ): Promise<{ items: LookupItem[] }> { + ): Promise { const includeIndices = includeIndicesParam === 'true'; try { diff --git a/apps/api/src/app/symbol/symbol.service.ts b/apps/api/src/app/symbol/symbol.service.ts index 2baca18dd..ae864e2fc 100644 --- a/apps/api/src/app/symbol/symbol.service.ts +++ b/apps/api/src/app/symbol/symbol.service.ts @@ -5,13 +5,15 @@ import { } from '@ghostfolio/api/services/interfaces/interfaces'; import { MarketDataService } from '@ghostfolio/api/services/market-data/market-data.service'; import { DATE_FORMAT } from '@ghostfolio/common/helper'; -import { HistoricalDataItem } from '@ghostfolio/common/interfaces'; +import { + HistoricalDataItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { UserWithSettings } from '@ghostfolio/common/types'; import { Injectable, Logger } from '@nestjs/common'; import { format, subDays } from 'date-fns'; -import { LookupItem } from './interfaces/lookup-item.interface'; import { SymbolItem } from './interfaces/symbol-item.interface'; @Injectable() @@ -104,8 +106,8 @@ export class SymbolService { includeIndices?: boolean; query: string; user: UserWithSettings; - }): Promise<{ items: LookupItem[] }> { - const results: { items: LookupItem[] } = { items: [] }; + }): Promise { + const results: LookupResponse = { items: [] }; if (!query) { return results; diff --git a/apps/api/src/services/data-provider/alpha-vantage/alpha-vantage.service.ts b/apps/api/src/services/data-provider/alpha-vantage/alpha-vantage.service.ts index 016584949..5c9eee127 100644 --- a/apps/api/src/services/data-provider/alpha-vantage/alpha-vantage.service.ts +++ b/apps/api/src/services/data-provider/alpha-vantage/alpha-vantage.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -12,7 +11,10 @@ import { IDataProviderResponse } from '@ghostfolio/api/services/interfaces/interfaces'; import { DATE_FORMAT } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -119,9 +121,7 @@ export class AlphaVantageService implements DataProviderInterface { return undefined; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { const result = await this.alphaVantage.data.search(query); return { diff --git a/apps/api/src/services/data-provider/coingecko/coingecko.service.ts b/apps/api/src/services/data-provider/coingecko/coingecko.service.ts index d420c51fd..7d6f22c60 100644 --- a/apps/api/src/services/data-provider/coingecko/coingecko.service.ts +++ b/apps/api/src/services/data-provider/coingecko/coingecko.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -13,7 +12,11 @@ import { } from '@ghostfolio/api/services/interfaces/interfaces'; import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; import { DATE_FORMAT } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable, Logger } from '@nestjs/common'; import { @@ -221,9 +224,7 @@ export class CoinGeckoService implements DataProviderInterface { return 'bitcoin'; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { let items: LookupItem[] = []; try { diff --git a/apps/api/src/services/data-provider/data-provider.service.ts b/apps/api/src/services/data-provider/data-provider.service.ts index 385c7b078..c4670bc3b 100644 --- a/apps/api/src/services/data-provider/data-provider.service.ts +++ b/apps/api/src/services/data-provider/data-provider.service.ts @@ -1,5 +1,4 @@ import { RedisCacheService } from '@ghostfolio/api/app/redis-cache/redis-cache.service'; -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-provider.interface'; import { @@ -20,7 +19,11 @@ import { getStartOfUtcDate, isDerivedCurrency } from '@ghostfolio/common/helper'; -import { AssetProfileIdentifier } from '@ghostfolio/common/interfaces'; +import { + AssetProfileIdentifier, + LookupItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import type { Granularity, UserWithSettings } from '@ghostfolio/common/types'; import { Inject, Injectable, Logger } from '@nestjs/common'; @@ -571,8 +574,8 @@ export class DataProviderService { includeIndices?: boolean; query: string; user: UserWithSettings; - }): Promise<{ items: LookupItem[] }> { - const promises: Promise<{ items: LookupItem[] }>[] = []; + }): Promise { + const promises: Promise[] = []; let lookupItems: LookupItem[] = []; if (query?.length < 2) { diff --git a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts index c3c948b47..7329b821b 100644 --- a/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts +++ b/apps/api/src/services/data-provider/eod-historical-data/eod-historical-data.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -17,7 +16,11 @@ import { REPLACE_NAME_PARTS } from '@ghostfolio/common/config'; import { DATE_FORMAT, isCurrency } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { MarketState } from '@ghostfolio/common/types'; import { Injectable, Logger } from '@nestjs/common'; @@ -317,9 +320,7 @@ export class EodHistoricalDataService implements DataProviderInterface { return 'AAPL.US'; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { const searchResult = await this.getSearchResult(query); return { diff --git a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts b/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts index 7d5b38479..9334fc4cd 100644 --- a/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts +++ b/apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -13,7 +12,11 @@ import { } from '@ghostfolio/api/services/interfaces/interfaces'; import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -169,9 +172,7 @@ export class FinancialModelingPrepService implements DataProviderInterface { return 'AAPL'; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { let items: LookupItem[] = []; try { diff --git a/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts b/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts index 9f2344233..f18d670d1 100644 --- a/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts +++ b/apps/api/src/services/data-provider/google-sheets/google-sheets.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -14,7 +13,10 @@ import { import { PrismaService } from '@ghostfolio/api/services/prisma/prisma.service'; import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile/symbol-profile.service'; import { DATE_FORMAT, parseDate } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -157,9 +159,7 @@ export class GoogleSheetsService implements DataProviderInterface { return 'INDEXSP:.INX'; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { const items = await this.prismaService.symbolProfile.findMany({ select: { assetClass: true, diff --git a/apps/api/src/services/data-provider/interfaces/data-provider.interface.ts b/apps/api/src/services/data-provider/interfaces/data-provider.interface.ts index 3b3644473..7352ce78a 100644 --- a/apps/api/src/services/data-provider/interfaces/data-provider.interface.ts +++ b/apps/api/src/services/data-provider/interfaces/data-provider.interface.ts @@ -1,9 +1,11 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { IDataProviderHistoricalResponse, IDataProviderResponse } from '@ghostfolio/api/services/interfaces/interfaces'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Granularity } from '@ghostfolio/common/types'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -44,10 +46,7 @@ export interface DataProviderInterface { getTestSymbol(): string; - search({ - includeIndices, - query - }: GetSearchParams): Promise<{ items: LookupItem[] }>; + search({ includeIndices, query }: GetSearchParams): Promise; } export interface GetDividendsParams { diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.ts index 030ab8ea2..30c7efa6a 100644 --- a/apps/api/src/services/data-provider/manual/manual.service.ts +++ b/apps/api/src/services/data-provider/manual/manual.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -20,6 +19,7 @@ import { } from '@ghostfolio/common/helper'; import { DataProviderInfo, + LookupResponse, ScraperConfiguration } from '@ghostfolio/common/interfaces'; @@ -219,9 +219,7 @@ export class ManualService implements DataProviderInterface { return undefined; } - public async search({ - query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({ query }: GetSearchParams): Promise { let items = await this.prismaService.symbolProfile.findMany({ select: { assetClass: true, diff --git a/apps/api/src/services/data-provider/rapid-api/rapid-api.service.ts b/apps/api/src/services/data-provider/rapid-api/rapid-api.service.ts index e47e96d88..29e7f4ee9 100644 --- a/apps/api/src/services/data-provider/rapid-api/rapid-api.service.ts +++ b/apps/api/src/services/data-provider/rapid-api/rapid-api.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; import { DataProviderInterface, @@ -13,7 +12,10 @@ import { } from '@ghostfolio/api/services/interfaces/interfaces'; import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config'; import { DATE_FORMAT, getYesterday } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -121,7 +123,7 @@ export class RapidApiService implements DataProviderInterface { return undefined; } - public async search({}: GetSearchParams): Promise<{ items: LookupItem[] }> { + public async search({}: GetSearchParams): Promise { return { items: [] }; } diff --git a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts index 2d67c646c..27da18ab0 100644 --- a/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts +++ b/apps/api/src/services/data-provider/yahoo-finance/yahoo-finance.service.ts @@ -1,4 +1,3 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { CryptocurrencyService } from '@ghostfolio/api/services/cryptocurrency/cryptocurrency.service'; import { YahooFinanceDataEnhancerService } from '@ghostfolio/api/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service'; import { @@ -14,7 +13,11 @@ import { } from '@ghostfolio/api/services/interfaces/interfaces'; import { DEFAULT_CURRENCY } from '@ghostfolio/common/config'; import { DATE_FORMAT } from '@ghostfolio/common/helper'; -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; +import { + DataProviderInfo, + LookupItem, + LookupResponse +} from '@ghostfolio/common/interfaces'; import { Injectable, Logger } from '@nestjs/common'; import { DataSource, SymbolProfile } from '@prisma/client'; @@ -224,7 +227,7 @@ export class YahooFinanceService implements DataProviderInterface { public async search({ includeIndices = false, query - }: GetSearchParams): Promise<{ items: LookupItem[] }> { + }: GetSearchParams): Promise { const items: LookupItem[] = []; try { diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts index abf4b21a0..1d40de69c 100644 --- a/apps/client/src/app/services/data.service.ts +++ b/apps/client/src/app/services/data.service.ts @@ -10,7 +10,6 @@ import { } from '@ghostfolio/api/app/order/interfaces/activities.interface'; import { UpdateOrderDto } from '@ghostfolio/api/app/order/update-order.dto'; import { PortfolioHoldingDetail } from '@ghostfolio/api/app/portfolio/interfaces/portfolio-holding-detail.interface'; -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { SymbolItem } from '@ghostfolio/api/app/symbol/interfaces/symbol-item.interface'; import { DeleteOwnUserDto } from '@ghostfolio/api/app/user/delete-own-user.dto'; import { UserItem } from '@ghostfolio/api/app/user/interfaces/user-item.interface'; @@ -30,6 +29,7 @@ import { Filter, ImportResponse, InfoItem, + LookupResponse, OAuthResponse, PortfolioDetails, PortfolioDividends, @@ -464,7 +464,7 @@ export class DataService { } return this.http - .get<{ items: LookupItem[] }>('/api/v1/symbol/lookup', { params }) + .get('/api/v1/symbol/lookup', { params }) .pipe( map((respose) => { return respose.items; diff --git a/libs/common/src/lib/interfaces/index.ts b/libs/common/src/lib/interfaces/index.ts index becc872dd..eca147066 100644 --- a/libs/common/src/lib/interfaces/index.ts +++ b/libs/common/src/lib/interfaces/index.ts @@ -23,6 +23,7 @@ import type { Holding } from './holding.interface'; import type { InfoItem } from './info-item.interface'; import type { InvestmentItem } from './investment-item.interface'; import type { LineChartItem } from './line-chart-item.interface'; +import type { LookupItem } from './lookup-item.interface'; import type { PortfolioChart } from './portfolio-chart.interface'; import type { PortfolioDetails } from './portfolio-details.interface'; import type { PortfolioDividends } from './portfolio-dividends.interface'; @@ -40,6 +41,7 @@ import type { AccountBalancesResponse } from './responses/account-balances-respo import type { BenchmarkResponse } from './responses/benchmark-response.interface'; import type { ResponseError } from './responses/errors.interface'; import type { ImportResponse } from './responses/import-response.interface'; +import type { LookupResponse } from './responses/lookup-response.interface'; import type { OAuthResponse } from './responses/oauth-response.interface'; import type { PortfolioHoldingsResponse } from './responses/portfolio-holdings-response.interface'; import type { PortfolioPerformanceResponse } from './responses/portfolio-performance-response.interface'; @@ -82,6 +84,8 @@ export { InfoItem, InvestmentItem, LineChartItem, + LookupItem, + LookupResponse, OAuthResponse, PortfolioChart, PortfolioDetails, diff --git a/apps/api/src/app/symbol/interfaces/lookup-item.interface.ts b/libs/common/src/lib/interfaces/lookup-item.interface.ts similarity index 80% rename from apps/api/src/app/symbol/interfaces/lookup-item.interface.ts rename to libs/common/src/lib/interfaces/lookup-item.interface.ts index 89b476397..fa91ed690 100644 --- a/apps/api/src/app/symbol/interfaces/lookup-item.interface.ts +++ b/libs/common/src/lib/interfaces/lookup-item.interface.ts @@ -1,7 +1,7 @@ -import { DataProviderInfo } from '@ghostfolio/common/interfaces'; - import { AssetClass, AssetSubClass, DataSource } from '@prisma/client'; +import { DataProviderInfo } from './data-provider-info.interface'; + export interface LookupItem { assetClass: AssetClass; assetSubClass: AssetSubClass; diff --git a/libs/common/src/lib/interfaces/responses/lookup-response.interface.ts b/libs/common/src/lib/interfaces/responses/lookup-response.interface.ts new file mode 100644 index 000000000..579be9d01 --- /dev/null +++ b/libs/common/src/lib/interfaces/responses/lookup-response.interface.ts @@ -0,0 +1,5 @@ +import { LookupItem } from '../lookup-item.interface'; + +export interface LookupResponse { + items: LookupItem[]; +} diff --git a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts index da97aac05..a537c50a7 100644 --- a/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts +++ b/libs/ui/src/lib/symbol-autocomplete/symbol-autocomplete.component.ts @@ -1,6 +1,6 @@ -import { LookupItem } from '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface'; import { GfSymbolModule } from '@ghostfolio/client/pipes/symbol/symbol.module'; import { DataService } from '@ghostfolio/client/services/data.service'; +import { LookupItem } from '@ghostfolio/common/interfaces'; import { translate } from '@ghostfolio/ui/i18n'; import { AbstractMatFormField } from '@ghostfolio/ui/shared/abstract-mat-form-field';