Run playwright UI tests
This commit is contained in:
@@ -4,7 +4,6 @@ import type {
|
||||
Filing,
|
||||
FinancialHistoryWindow,
|
||||
FinancialStatementKind,
|
||||
FinancialStatementMode,
|
||||
TaskStatus
|
||||
} from '@/lib/types';
|
||||
import { auth } from '@/lib/auth';
|
||||
@@ -13,8 +12,8 @@ import { asErrorMessage, jsonError } from '@/lib/server/http';
|
||||
import { buildPortfolioSummary } from '@/lib/server/portfolio';
|
||||
import {
|
||||
defaultFinancialSyncLimit,
|
||||
getCompanyFinancialStatements
|
||||
} from '@/lib/server/financial-statements';
|
||||
getCompanyFinancialTaxonomy
|
||||
} from '@/lib/server/financial-taxonomy';
|
||||
import { redactInternalFilingAnalysisFields } from '@/lib/server/api/filing-redaction';
|
||||
import { getFilingByAccession, listFilingsRecords } from '@/lib/server/repos/filings';
|
||||
import {
|
||||
@@ -44,8 +43,7 @@ import {
|
||||
const ALLOWED_STATUSES: TaskStatus[] = ['queued', 'running', 'completed', 'failed'];
|
||||
const FINANCIAL_FORMS: ReadonlySet<Filing['filing_type']> = new Set(['10-K', '10-Q']);
|
||||
const AUTO_FILING_SYNC_LIMIT = 20;
|
||||
const FINANCIALS_V2_ENABLED = process.env.FINANCIALS_V2?.trim().toLowerCase() !== 'false';
|
||||
const FINANCIAL_STATEMENT_MODES: FinancialStatementMode[] = ['standardized', 'filing_faithful'];
|
||||
const FINANCIALS_V3_ENABLED = process.env.FINANCIALS_V3?.trim().toLowerCase() !== 'false';
|
||||
const FINANCIAL_STATEMENT_KINDS: FinancialStatementKind[] = [
|
||||
'income',
|
||||
'balance',
|
||||
@@ -120,12 +118,6 @@ function asTags(value: unknown) {
|
||||
return [...unique];
|
||||
}
|
||||
|
||||
function asStatementMode(value: unknown): FinancialStatementMode {
|
||||
return FINANCIAL_STATEMENT_MODES.includes(value as FinancialStatementMode)
|
||||
? value as FinancialStatementMode
|
||||
: 'standardized';
|
||||
}
|
||||
|
||||
function asStatementKind(value: unknown): FinancialStatementKind {
|
||||
return FINANCIAL_STATEMENT_KINDS.includes(value as FinancialStatementKind)
|
||||
? value as FinancialStatementKind
|
||||
@@ -613,8 +605,8 @@ export const app = new Elysia({ prefix: '/api' })
|
||||
return response;
|
||||
}
|
||||
|
||||
if (!FINANCIALS_V2_ENABLED) {
|
||||
return jsonError('Financial statements v2 is disabled', 404);
|
||||
if (!FINANCIALS_V3_ENABLED) {
|
||||
return jsonError('Financial statements v3 is disabled', 404);
|
||||
}
|
||||
|
||||
const ticker = typeof query.ticker === 'string'
|
||||
@@ -624,26 +616,34 @@ export const app = new Elysia({ prefix: '/api' })
|
||||
return jsonError('ticker is required');
|
||||
}
|
||||
|
||||
const mode = asStatementMode(query.mode);
|
||||
const statement = asStatementKind(query.statement);
|
||||
const window = asHistoryWindow(query.window);
|
||||
const includeDimensions = asBoolean(query.includeDimensions, false);
|
||||
const includeFacts = asBoolean(query.includeFacts, false);
|
||||
const cursor = typeof query.cursor === 'string' && query.cursor.trim().length > 0
|
||||
? query.cursor.trim()
|
||||
: null;
|
||||
const limit = Number.isFinite(Number(query.limit))
|
||||
? Number(query.limit)
|
||||
: undefined;
|
||||
const factsCursor = typeof query.factsCursor === 'string' && query.factsCursor.trim().length > 0
|
||||
? query.factsCursor.trim()
|
||||
: null;
|
||||
const factsLimit = Number.isFinite(Number(query.factsLimit))
|
||||
? Number(query.factsLimit)
|
||||
: undefined;
|
||||
|
||||
let payload = await getCompanyFinancialStatements({
|
||||
let payload = await getCompanyFinancialTaxonomy({
|
||||
ticker,
|
||||
mode,
|
||||
statement,
|
||||
window,
|
||||
includeDimensions,
|
||||
includeFacts,
|
||||
factsCursor,
|
||||
factsLimit,
|
||||
cursor,
|
||||
limit,
|
||||
v2Enabled: FINANCIALS_V2_ENABLED,
|
||||
v3Enabled: FINANCIALS_V3_ENABLED,
|
||||
queuedSync: false
|
||||
});
|
||||
|
||||
@@ -671,7 +671,7 @@ export const app = new Elysia({ prefix: '/api' })
|
||||
});
|
||||
queuedSync = true;
|
||||
} catch (error) {
|
||||
console.error(`[financials-v2-sync] failed for ${ticker}:`, error);
|
||||
console.error(`[financials-v3-sync] failed for ${ticker}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +689,6 @@ export const app = new Elysia({ prefix: '/api' })
|
||||
}, {
|
||||
query: t.Object({
|
||||
ticker: t.String({ minLength: 1 }),
|
||||
mode: t.Optional(t.Union([t.Literal('standardized'), t.Literal('filing_faithful')])),
|
||||
statement: t.Optional(t.Union([
|
||||
t.Literal('income'),
|
||||
t.Literal('balance'),
|
||||
@@ -699,8 +698,11 @@ export const app = new Elysia({ prefix: '/api' })
|
||||
])),
|
||||
window: t.Optional(t.Union([t.Literal('10y'), t.Literal('all')])),
|
||||
includeDimensions: t.Optional(t.Union([t.String(), t.Boolean()])),
|
||||
includeFacts: t.Optional(t.Union([t.String(), t.Boolean()])),
|
||||
cursor: t.Optional(t.String()),
|
||||
limit: t.Optional(t.Numeric())
|
||||
limit: t.Optional(t.Numeric()),
|
||||
factsCursor: t.Optional(t.String()),
|
||||
factsLimit: t.Optional(t.Numeric())
|
||||
})
|
||||
})
|
||||
.get('/analysis/reports/:accessionNumber', async ({ params }) => {
|
||||
|
||||
Reference in New Issue
Block a user