Browse Source
Task/improve typings of getAsset() functionality (#5804)
* Improve typings of getAsset() functionality
pull/5805/head
Vansh
4 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
9 additions and
3 deletions
-
apps/api/src/app/asset/asset.controller.ts
-
apps/client/src/app/services/data.service.ts
-
libs/common/src/lib/interfaces/index.ts
-
libs/common/src/lib/interfaces/responses/asset-response.interface.ts
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import { AdminService } from '@ghostfolio/api/app/admin/admin.service'; |
|
|
|
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 type { AdminMarketDataDetails } from '@ghostfolio/common/interfaces'; |
|
|
|
import type { AssetResponse } from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
|
|
import { Controller, Get, Param, UseInterceptors } from '@nestjs/common'; |
|
|
|
import { DataSource } from '@prisma/client'; |
|
|
|
@ -17,7 +17,7 @@ export class AssetController { |
|
|
|
public async getAsset( |
|
|
|
@Param('dataSource') dataSource: DataSource, |
|
|
|
@Param('symbol') symbol: string |
|
|
|
): Promise<AdminMarketDataDetails> { |
|
|
|
): Promise<AssetResponse> { |
|
|
|
const { assetProfile, marketData } = |
|
|
|
await this.adminService.getMarketDataBySymbol({ dataSource, symbol }); |
|
|
|
|
|
|
|
|
|
|
|
@ -30,6 +30,7 @@ import { |
|
|
|
AiPromptResponse, |
|
|
|
ApiKeyResponse, |
|
|
|
AssetProfileIdentifier, |
|
|
|
AssetResponse, |
|
|
|
BenchmarkMarketDataDetailsResponse, |
|
|
|
BenchmarkResponse, |
|
|
|
DataProviderHealthResponse, |
|
|
|
@ -345,7 +346,7 @@ export class DataService { |
|
|
|
public fetchAsset({ |
|
|
|
dataSource, |
|
|
|
symbol |
|
|
|
}: AssetProfileIdentifier): Observable<MarketDataDetailsResponse> { |
|
|
|
}: AssetProfileIdentifier): Observable<AssetResponse> { |
|
|
|
return this.http.get<any>(`/api/v1/asset/${dataSource}/${symbol}`).pipe( |
|
|
|
map((data) => { |
|
|
|
for (const item of data.marketData) { |
|
|
|
|
|
|
|
@ -40,6 +40,7 @@ import type { AccountBalancesResponse } from './responses/account-balances-respo |
|
|
|
import type { AccountsResponse } from './responses/accounts-response.interface'; |
|
|
|
import type { AiPromptResponse } from './responses/ai-prompt-response.interface'; |
|
|
|
import type { ApiKeyResponse } from './responses/api-key-response.interface'; |
|
|
|
import type { AssetResponse } from './responses/asset-response.interface'; |
|
|
|
import type { BenchmarkMarketDataDetailsResponse } from './responses/benchmark-market-data-details-response.interface'; |
|
|
|
import type { BenchmarkResponse } from './responses/benchmark-response.interface'; |
|
|
|
import type { DataEnhancerHealthResponse } from './responses/data-enhancer-health-response.interface'; |
|
|
|
@ -91,6 +92,7 @@ export { |
|
|
|
ApiKeyResponse, |
|
|
|
AssetClassSelectorOption, |
|
|
|
AssetProfileIdentifier, |
|
|
|
AssetResponse, |
|
|
|
Benchmark, |
|
|
|
BenchmarkMarketDataDetailsResponse, |
|
|
|
BenchmarkProperty, |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
import type { AdminMarketDataDetails } from '../admin-market-data-details.interface'; |
|
|
|
|
|
|
|
export interface AssetResponse extends AdminMarketDataDetails {} |