feat(financials-v2): add financial statements endpoint and query plumbing
This commit is contained in:
37
lib/api.ts
37
lib/api.ts
@@ -3,8 +3,12 @@ import type { App } from '@/lib/server/api/app';
|
||||
import type {
|
||||
CompanyAiReportDetail,
|
||||
CompanyAnalysis,
|
||||
CompanyFinancialStatementsResponse,
|
||||
Filing,
|
||||
Holding,
|
||||
FinancialHistoryWindow,
|
||||
FinancialStatementKind,
|
||||
FinancialStatementMode,
|
||||
PortfolioInsight,
|
||||
PortfolioSummary,
|
||||
Task,
|
||||
@@ -185,6 +189,39 @@ export async function getCompanyAnalysis(ticker: string) {
|
||||
return await unwrapData<{ analysis: CompanyAnalysis }>(result, 'Unable to fetch company analysis');
|
||||
}
|
||||
|
||||
export async function getCompanyFinancialStatements(input: {
|
||||
ticker: string;
|
||||
mode: FinancialStatementMode;
|
||||
statement: FinancialStatementKind;
|
||||
window: FinancialHistoryWindow;
|
||||
includeDimensions?: boolean;
|
||||
cursor?: string | null;
|
||||
limit?: number;
|
||||
}) {
|
||||
const query = {
|
||||
ticker: input.ticker.trim().toUpperCase(),
|
||||
mode: input.mode,
|
||||
statement: input.statement,
|
||||
window: input.window,
|
||||
includeDimensions: input.includeDimensions ? 'true' : 'false',
|
||||
...(typeof input.cursor === 'string' && input.cursor.trim().length > 0
|
||||
? { cursor: input.cursor.trim() }
|
||||
: {}),
|
||||
...(typeof input.limit === 'number' && Number.isFinite(input.limit)
|
||||
? { limit: input.limit }
|
||||
: {})
|
||||
};
|
||||
|
||||
const result = await client.api.financials.company.get({
|
||||
$query: query
|
||||
});
|
||||
|
||||
return await unwrapData<{ financials: CompanyFinancialStatementsResponse }>(
|
||||
result,
|
||||
'Unable to fetch company financial statements'
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCompanyAiReport(accessionNumber: string) {
|
||||
const normalizedAccession = accessionNumber.trim();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user