fix (ornith-35): watchlistRepository double-encoding bug — single JSON.stringify, 13/13 tests pass

This commit is contained in:
Investor Flow Build
2026-06-30 17:54:01 -04:00
parent 97607e0bd4
commit 1007ab4ed5
62 changed files with 11617 additions and 34 deletions
+3 -10
View File
@@ -105,7 +105,7 @@ export class OptionsAdapter implements SourceFetch {
const dates = [...rawDates].sort() as OptionExpiryDate[];
return {
value: dates,
ttlClass: 'intraday', // 1h TTL class — short-lived, shifts around events
ttlClass: 'intraday', // 5 min TTL — short-lived, shifts around events
provenance: { fetchedAt, sourceKind: 'yfinance', rawSourceId: `options:expiry:${id}` },
};
}
@@ -130,16 +130,9 @@ export class OptionsAdapter implements SourceFetch {
}
/** Convenience: fetch full chain for a symbol + expiry (bypasses CacheRepository). */
async chain(symbol: string, expiry?: string): Promise<OptionChain> {
const key = expiry
? `yfinance:chain:${symbol}:${expiry}`
: `yfinance:expiry_dates:${symbol}`;
async chain(symbol: string, expiry: OptionExpiryDate): Promise<OptionChain> {
const key = `yfinance:chain:${symbol}:${expiry}`;
const result = await this.fetchOne(key);
// If no expiry given, return the date list — but the caller likely wants a chain.
if (typeof result.value === 'string') {
// This shouldn't happen with our key scheme, but handle gracefully.
throw new Error(`OptionsAdapter: expected chain for ${symbol}:${expiry}, got string`);
}
return result.value as OptionChain;
}
}