pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
80 lines (79 loc) • 2.01 kB
TypeScript
export interface Location {
lat: number;
lng: number;
area_id?: string;
confidence?: number;
accuracy?: number;
city?: string;
}
export interface LocationWithRelevance extends Location {
relevance: number;
}
export interface ContentWithLocation {
id: string;
title: string;
description?: string;
type: string;
primary_area: string;
locations?: LocationWithRelevance[];
primary_location?: Location;
geohash?: string;
location_names?: string[];
[key: string]: any;
}
export declare class LocationService {
private areaCache;
/**
* Get location coordinates from area ID
*/
getLocationFromArea(areaInput: string): Promise<Location | null>;
/**
* Extract locations from content text and metadata
*/
extractLocationsFromContent(content: {
title: string;
description?: string;
primary_area: string;
[key: string]: any;
}): Promise<LocationWithRelevance[]>;
/**
* Get user location from IP address
*/
getUserLocationFromIP(ip: string): Promise<Location>;
/**
* Parse browser geolocation position
*/
parseGeolocationPosition(position: any): Location;
/**
* Find nearest known area to coordinates
*/
findNearestKnownArea(lat: number, lng: number): {
area_id: string;
distance: number;
location: Location;
};
/**
* Generate geohash for coordinates
*/
generateGeohash(lat: number, lng: number, precision?: number): string;
/**
* Enrich content with location data
*/
enrichContentWithLocation(content: any): Promise<ContentWithLocation>;
/**
* Normalize area name for matching
*/
private normalizeAreaName;
/**
* Check if two area names match
*/
private areaNamesMatch;
/**
* Get variations of area name for matching
*/
private getAreaVariations;
/**
* Clear cache
*/
clearCache(): void;
}