typescript fixin
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 13s

This commit is contained in:
2025-11-12 00:36:00 -08:00
parent db6a133c9d
commit ecdd642fe8
6 changed files with 52 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
import { GoogleGenAI, Type, Modality } from "@google/genai";
import type { FlyerItem, MasterGroceryItem, UnitPrice, Store } from '../types';
import { GoogleGenAI, Type, Modality, GroundingChunk } from "@google/genai";
import type { FlyerItem, MasterGroceryItem, UnitPrice, Store } from "../types";
import { CATEGORIES } from '../types';
import { parsePriceToCents } from '../utils/priceParser';
@@ -304,7 +304,7 @@ export const getDeepDiveAnalysis = async (items: FlyerItem[]): Promise<string> =
return response.text;
};
export const searchWeb = async (items: FlyerItem[]): Promise<{text: string; sources: any[]}> => {
export const searchWeb = async (items: FlyerItem[]): Promise<{text: string; sources: GroundingChunk[]}> => {
const topItems = items.slice(0, 3).map(i => i.item).join(', ');
const prompt = `Find recipes, nutritional information, or price comparisons for these items: ${topItems}. Provide a summary and the sources you used.`;

View File

@@ -10,10 +10,10 @@ type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'DEBUG';
/**
* The core logging function. It uses a generic rest parameter `<T extends any[]>`
* to safely accept any number of arguments of any type, just like the native
* console methods. This avoids using the 'any' or 'unknown' types directly.
* to safely accept any number of arguments of any type, just like the native console
* methods. Using `unknown[]` is more type-safe than `any[]` and satisfies the linter.
*/
const log = <T extends any[]>(level: LogLevel, message: string, ...args: T) => {
const log = <T extends unknown[]>(level: LogLevel, message: string, ...args: T) => {
const timestamp = getTimestamp();
// We construct the log message with a timestamp and level for better context.
const logMessage = `[${timestamp}] [${level}] ${message}`;
@@ -37,8 +37,8 @@ const log = <T extends any[]>(level: LogLevel, message: string, ...args: T) => {
// Export the logger object for use throughout the application.
export const logger = {
info: <T extends any[]>(message: string, ...args: T) => log('INFO', message, ...args),
warn: <T extends any[]>(message: string, ...args: T) => log('WARN', message, ...args),
error: <T extends any[]>(message: string, ...args: T) => log('ERROR', message, ...args),
debug: <T extends any[]>(message: string, ...args: T) => log('DEBUG', message, ...args),
info: <T extends unknown[]>(message: string, ...args: T) => log('INFO', message, ...args),
warn: <T extends unknown[]>(message: string, ...args: T) => log('WARN', message, ...args),
error: <T extends unknown[]>(message: string, ...args: T) => log('ERROR', message, ...args),
debug: <T extends unknown[]>(message: string, ...args: T) => log('DEBUG', message, ...args),
};