/** * InMemoryGoogleMapsClient — deterministic in-memory GoogleMapsClient for dev. * * Returns a fixed set of FAKE vendor PlaceResults, lightly filtered by a * case-insensitive substring match against textQuery and capped at * maxResultCount. No network, no API key. * * This is for build-plan §4 "in-memory dev clients (tools return real data * locally)". */ import type { GoogleMapsClient, PlaceResult, SearchTextParams } from './client.js'; const SEED_PLACES: PlaceResult[] = [ { displayName: 'Harbor Electric Co.', formattedAddress: '142 Dock St, Sea Haven, NY 11790', nationalPhoneNumber: '(631) 555-0142', types: ['electrician', 'point_of_interest', 'establishment'], rating: 4.6, googleMapsUri: 'https://maps.google.com/?cid=10000000000000000001', }, { displayName: 'Coastal Supply & Hardware', formattedAddress: '88 Marina Way, Sea Haven, NY 11790', nationalPhoneNumber: '(631) 555-0188', types: ['hardware_store', 'point_of_interest', 'establishment'], rating: 4.2, googleMapsUri: 'https://maps.google.com/?cid=10000000000000000002', }, { displayName: 'Tidewater Plumbing LLC', formattedAddress: '23 Bayfront Rd, Sea Haven, NY 11790', nationalPhoneNumber: '(631) 555-0123', types: ['plumber', 'point_of_interest', 'establishment'], rating: 4.8, googleMapsUri: 'https://maps.google.com/?cid=10000000000000000003', }, ]; /** In-memory GoogleMapsClient returning seeded vendor places. */ export class InMemoryGoogleMapsClient implements GoogleMapsClient { async searchText(params: SearchTextParams): Promise { const q = params.textQuery.trim().toLowerCase(); const filtered = q.length === 0 ? SEED_PLACES : SEED_PLACES.filter( (p) => p.displayName.toLowerCase().includes(q) || p.types.some((t) => t.toLowerCase().includes(q)), ); const results = filtered.length > 0 ? filtered : SEED_PLACES; const limit = params.maxResultCount ?? 10; return results.slice(0, limit); } }