252 lines
5.6 KiB
TypeScript
252 lines
5.6 KiB
TypeScript
export type User = {
|
|
id: string;
|
|
email: string;
|
|
name: string | null;
|
|
image: string | null;
|
|
};
|
|
|
|
export type WatchlistItem = {
|
|
id: number;
|
|
user_id: string;
|
|
ticker: string;
|
|
company_name: string;
|
|
sector: string | null;
|
|
created_at: string;
|
|
};
|
|
|
|
export type Holding = {
|
|
id: number;
|
|
user_id: string;
|
|
ticker: string;
|
|
shares: string;
|
|
avg_cost: string;
|
|
current_price: string | null;
|
|
market_value: string;
|
|
gain_loss: string;
|
|
gain_loss_pct: string;
|
|
last_price_at: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type PortfolioSummary = {
|
|
positions: number;
|
|
total_value: string;
|
|
total_gain_loss: string;
|
|
total_cost_basis: string;
|
|
avg_return_pct: string;
|
|
};
|
|
|
|
export type FilingExtraction = {
|
|
summary: string;
|
|
keyPoints: string[];
|
|
redFlags: string[];
|
|
followUpQuestions: string[];
|
|
portfolioSignals: string[];
|
|
segmentSpecificData: string[];
|
|
geographicRevenueBreakdown: string[];
|
|
companySpecificData: string[];
|
|
secApiCrossChecks: string[];
|
|
confidence: number;
|
|
};
|
|
|
|
export type FilingExtractionMeta = {
|
|
provider: string;
|
|
model: string;
|
|
source: 'primary_document' | 'metadata_fallback';
|
|
generatedAt: string;
|
|
};
|
|
|
|
export type Filing = {
|
|
id: number;
|
|
ticker: string;
|
|
filing_type: '10-K' | '10-Q' | '8-K';
|
|
filing_date: string;
|
|
accession_number: string;
|
|
cik: string;
|
|
company_name: string;
|
|
filing_url: string | null;
|
|
submission_url?: string | null;
|
|
primary_document?: string | null;
|
|
metrics: {
|
|
revenue: number | null;
|
|
netIncome: number | null;
|
|
totalAssets: number | null;
|
|
cash: number | null;
|
|
debt: number | null;
|
|
} | null;
|
|
analysis: {
|
|
provider?: string;
|
|
model?: string;
|
|
text?: string;
|
|
legacyInsights?: string;
|
|
companyMetrics?: string[];
|
|
extraction?: FilingExtraction;
|
|
extractionMeta?: FilingExtractionMeta;
|
|
} | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
};
|
|
|
|
export type TaskStatus = 'queued' | 'running' | 'completed' | 'failed';
|
|
export type TaskType = 'sync_filings' | 'refresh_prices' | 'analyze_filing' | 'portfolio_insights';
|
|
|
|
export type Task = {
|
|
id: string;
|
|
user_id: string;
|
|
task_type: TaskType;
|
|
status: TaskStatus;
|
|
priority: number;
|
|
payload: Record<string, unknown>;
|
|
result: Record<string, unknown> | null;
|
|
error: string | null;
|
|
attempts: number;
|
|
max_attempts: number;
|
|
workflow_run_id?: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
finished_at: string | null;
|
|
};
|
|
|
|
export type PortfolioInsight = {
|
|
id: number;
|
|
user_id: string;
|
|
provider: string;
|
|
model: string;
|
|
content: string;
|
|
created_at: string;
|
|
};
|
|
|
|
export type CompanyFinancialPoint = {
|
|
filingDate: string;
|
|
filingType: Filing['filing_type'];
|
|
revenue: number | null;
|
|
netIncome: number | null;
|
|
totalAssets: number | null;
|
|
cash: number | null;
|
|
debt: number | null;
|
|
};
|
|
|
|
export type FinancialStatementMode = 'standardized' | 'filing_faithful';
|
|
export type FinancialStatementKind = 'income' | 'balance' | 'cash_flow' | 'equity' | 'comprehensive_income';
|
|
export type FinancialHistoryWindow = '10y' | 'all';
|
|
|
|
export type FinancialStatementPeriod = {
|
|
id: string;
|
|
filingId: number;
|
|
accessionNumber: string;
|
|
filingDate: string;
|
|
periodEnd: string | null;
|
|
filingType: Extract<Filing['filing_type'], '10-K' | '10-Q'>;
|
|
periodLabel: string;
|
|
};
|
|
|
|
export type StandardizedStatementRow = {
|
|
key: string;
|
|
label: string;
|
|
concept: string;
|
|
category: string;
|
|
sourceConcepts: string[];
|
|
values: Record<string, number | null>;
|
|
hasDimensions: boolean;
|
|
};
|
|
|
|
export type FilingFaithfulStatementRow = {
|
|
key: string;
|
|
label: string;
|
|
concept: string | null;
|
|
order: number;
|
|
depth: number;
|
|
isSubtotal: boolean;
|
|
values: Record<string, number | null>;
|
|
hasDimensions: boolean;
|
|
};
|
|
|
|
export type DimensionBreakdownRow = {
|
|
rowKey: string;
|
|
concept: string | null;
|
|
periodId: string;
|
|
axis: string;
|
|
member: string;
|
|
value: number | null;
|
|
unit: string | null;
|
|
};
|
|
|
|
export type CompanyFinancialStatementsResponse = {
|
|
company: {
|
|
ticker: string;
|
|
companyName: string;
|
|
cik: string | null;
|
|
};
|
|
mode: FinancialStatementMode;
|
|
statement: FinancialStatementKind;
|
|
window: FinancialHistoryWindow;
|
|
periods: FinancialStatementPeriod[];
|
|
rows: StandardizedStatementRow[] | FilingFaithfulStatementRow[];
|
|
nextCursor: string | null;
|
|
coverage: {
|
|
filings: number;
|
|
rows: number;
|
|
dimensions: number;
|
|
};
|
|
dataSourceStatus: {
|
|
enabled: boolean;
|
|
hydratedFilings: number;
|
|
partialFilings: number;
|
|
failedFilings: number;
|
|
pendingFilings: number;
|
|
queuedSync: boolean;
|
|
};
|
|
dimensionBreakdown: Record<string, DimensionBreakdownRow[]> | null;
|
|
};
|
|
|
|
export type CompanyAiReport = {
|
|
accessionNumber: string;
|
|
filingDate: string;
|
|
filingType: Filing['filing_type'];
|
|
provider: string;
|
|
model: string;
|
|
summary: string;
|
|
};
|
|
|
|
export type CompanyAiReportDetail = CompanyAiReport & {
|
|
ticker: string;
|
|
companyName: string;
|
|
filingUrl: string | null;
|
|
submissionUrl: string | null;
|
|
primaryDocument: string | null;
|
|
};
|
|
|
|
export type CompanyAnalysis = {
|
|
company: {
|
|
ticker: string;
|
|
companyName: string;
|
|
sector: string | null;
|
|
cik: string | null;
|
|
};
|
|
quote: number;
|
|
position: Holding | null;
|
|
priceHistory: Array<{ date: string; close: number }>;
|
|
financials: CompanyFinancialPoint[];
|
|
filings: Filing[];
|
|
aiReports: CompanyAiReport[];
|
|
};
|
|
|
|
export type NavGroup = 'overview' | 'research' | 'portfolio';
|
|
export type NavMatchMode = 'exact' | 'prefix';
|
|
|
|
export type NavItem = {
|
|
id: string;
|
|
href: string;
|
|
label: string;
|
|
group: NavGroup;
|
|
matchMode: NavMatchMode;
|
|
preserveTicker?: boolean;
|
|
mobilePrimary?: boolean;
|
|
};
|
|
|
|
export type ActiveContext = {
|
|
pathname: string;
|
|
activeTicker: string | null;
|
|
};
|