feat(financials-v2): add financial statements endpoint and query plumbing
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
export const queryKeys = {
|
||||
companyAnalysis: (ticker: string) => ['analysis', ticker] as const,
|
||||
companyFinancialStatements: (
|
||||
ticker: string,
|
||||
mode: string,
|
||||
statement: string,
|
||||
window: string,
|
||||
includeDimensions: boolean,
|
||||
cursor: string | null,
|
||||
limit: number
|
||||
) => ['financials-v2', ticker, mode, statement, window, includeDimensions ? 'dims' : 'no-dims', cursor ?? '', limit] as const,
|
||||
filings: (ticker: string | null, limit: number) => ['filings', ticker ?? '', limit] as const,
|
||||
report: (accessionNumber: string) => ['report', accessionNumber] as const,
|
||||
watchlist: () => ['watchlist'] as const,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { queryOptions } from '@tanstack/react-query';
|
||||
import {
|
||||
getCompanyAiReport,
|
||||
getCompanyAnalysis,
|
||||
getCompanyFinancialStatements,
|
||||
getLatestPortfolioInsight,
|
||||
getPortfolioSummary,
|
||||
getTask,
|
||||
@@ -11,6 +12,11 @@ import {
|
||||
listWatchlist
|
||||
} from '@/lib/api';
|
||||
import { queryKeys } from '@/lib/query/keys';
|
||||
import type {
|
||||
FinancialHistoryWindow,
|
||||
FinancialStatementKind,
|
||||
FinancialStatementMode
|
||||
} from '@/lib/types';
|
||||
|
||||
export function companyAnalysisQueryOptions(ticker: string) {
|
||||
const normalizedTicker = ticker.trim().toUpperCase();
|
||||
@@ -22,6 +28,43 @@ export function companyAnalysisQueryOptions(ticker: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function companyFinancialStatementsQueryOptions(input: {
|
||||
ticker: string;
|
||||
mode: FinancialStatementMode;
|
||||
statement: FinancialStatementKind;
|
||||
window: FinancialHistoryWindow;
|
||||
includeDimensions?: boolean;
|
||||
cursor?: string | null;
|
||||
limit?: number;
|
||||
}) {
|
||||
const normalizedTicker = input.ticker.trim().toUpperCase();
|
||||
const includeDimensions = input.includeDimensions ?? false;
|
||||
const cursor = input.cursor ?? null;
|
||||
const limit = input.limit ?? 40;
|
||||
|
||||
return queryOptions({
|
||||
queryKey: queryKeys.companyFinancialStatements(
|
||||
normalizedTicker,
|
||||
input.mode,
|
||||
input.statement,
|
||||
input.window,
|
||||
includeDimensions,
|
||||
cursor,
|
||||
limit
|
||||
),
|
||||
queryFn: () => getCompanyFinancialStatements({
|
||||
ticker: normalizedTicker,
|
||||
mode: input.mode,
|
||||
statement: input.statement,
|
||||
window: input.window,
|
||||
includeDimensions,
|
||||
cursor,
|
||||
limit
|
||||
}),
|
||||
staleTime: 60_000
|
||||
});
|
||||
}
|
||||
|
||||
export function filingsQueryOptions(input: { ticker?: string; limit?: number } = {}) {
|
||||
const normalizedTicker = input.ticker?.trim().toUpperCase() ?? null;
|
||||
const limit = input.limit ?? 120;
|
||||
|
||||
Reference in New Issue
Block a user