phase-6: typescript introduction

This commit is contained in:
Sai Kiran Vella
2026-06-04 22:16:48 -04:00
parent 96e2840b9b
commit c1b3b26caa
69 changed files with 2323 additions and 1036 deletions
@@ -1,20 +1,24 @@
import fs from 'fs';
import path from 'path';
import type { MarketContext } from '../types.js';
export class FinanceReporter {
// Returns the HTML string — useful for server responses.
render(advice, personalFinance, marketContext) {
render(advice: unknown[], personalFinance: unknown, marketContext: MarketContext): string {
return this._build(advice, personalFinance, marketContext);
}
// Writes to disk and returns the absolute path — used by the CLI.
generate(advice, personalFinance, marketContext, outputPath = './finance-report.html') {
generate(
advice: unknown[],
personalFinance: unknown,
marketContext: MarketContext,
outputPath = './finance-report.html',
): string {
const html = this._build(advice, personalFinance, marketContext);
fs.writeFileSync(outputPath, html, 'utf8');
return path.resolve(outputPath);
}
_build(advice, pf, ctx) {
_build(advice: unknown, pf: unknown, ctx: unknown) {
const date = new Date().toISOString().slice(0, 10);
return `<!DOCTYPE html>
<html lang="en">
@@ -1,17 +1,25 @@
import fs from 'fs';
import path from 'path';
import type { MarketContext } from '../types.js';
// Generates a self-contained HTML report saved to ./screener-report.html
// Console output shows only the signal summary — full breakdown lives here.
export class HtmlReporter {
// Returns the HTML string — useful for server responses.
render(results, marketContext, personalFinance = null) {
render(
results: Record<string, unknown[]>,
marketContext: MarketContext,
personalFinance: unknown = null,
): string {
return this._buildHtml(results, marketContext, personalFinance);
}
// Writes to disk and returns the absolute path — used by the CLI.
generate(results, marketContext, personalFinance = null, outputPath = './screener-report.html') {
generate(
results: Record<string, unknown[]>,
marketContext: MarketContext,
personalFinance: unknown = null,
outputPath = './screener-report.html',
): string {
const html = this._buildHtml(results, marketContext, personalFinance);
fs.writeFileSync(outputPath, html, 'utf8');
return path.resolve(outputPath);