Consolidate server utilities into shared module

- Add lib/server/utils/normalize.ts with normalizeTicker, normalizeTagsOrNull, nowIso, todayIso
- Add lib/server/utils/validation.ts with asRecord, asBoolean, asStringArray, asEnum
- Add lib/server/utils/index.ts re-exporting all utilities
- Remove duplicate lib/server/utils.ts (old file)
- Update all repos and files to use shared utilities
- Remove redundant ?? '' from normalizeTicker calls
- Update watchlist.ts to use normalizeTagsOrNull for null-return tags
This commit is contained in:
2026-03-15 15:56:16 -04:00
parent edf1cfb421
commit 5f0abbb007
14 changed files with 193 additions and 127 deletions

View File

@@ -39,6 +39,7 @@ import {
} from '@/lib/server/sec';
import { enqueueTask } from '@/lib/server/tasks';
import { hydrateFilingTaxonomySnapshot } from '@/lib/server/taxonomy/engine';
import { nowIso } from '@/lib/server/utils';
const EXTRACTION_REQUIRED_KEYS = [
'summary',
@@ -762,7 +763,7 @@ async function processSyncFilings(task: Task) {
await deleteCompanyFinancialBundlesForTicker(filing.ticker);
taxonomySnapshotsHydrated += 1;
} catch (error) {
const now = new Date().toISOString();
const now = nowIso();
await upsertFilingTaxonomySnapshot({
filing_id: filing.id,
ticker: filing.ticker,
@@ -961,7 +962,7 @@ async function processRefreshPrices(task: Task) {
}
}
);
const updatedCount = await applyRefreshedPrices(userId, quotes, new Date().toISOString());
const updatedCount = await applyRefreshedPrices(userId, quotes, nowIso());
const result = {
updatedCount,