findagrave-client
Version:
TypeScript client for FindAGrave GraphQL and REST APIs
197 lines (195 loc) • 5.83 kB
TypeScript
interface LocationSearchInput {
name: string;
autocomplete: 'name' | 'location';
categories: string[];
returnHighlight?: boolean;
}
interface CemeterySearchInput {
from: number;
size: number;
boundingBox: {
top_left: {
lat: number;
lon: number;
};
bottom_right: {
lat: number;
lon: number;
};
};
}
interface LocationHierarchy {
cemetery?: string;
cemeteryId?: string;
city?: string;
cityId?: string;
county?: string;
countyId?: string;
state?: string;
stateId?: string;
country?: string;
countryId?: string;
continent?: string;
continentId?: string;
}
interface Location {
id: string;
names: Array<{
name: string;
language?: string;
}>;
locations: LocationHierarchy[];
coordinates?: {
lat: number;
lon: number;
};
highlight?: string;
}
interface Cemetery extends Location {
memorialCount?: number;
photographedCount?: number;
photoRequestCount?: number;
gpsCount?: number;
coordinatePrecision?: string;
}
interface Memorial {
id: string;
firstName?: string;
middleName?: string;
lastName?: string;
birthYear?: number;
deathYear?: number;
cemetery?: Cemetery;
coordinates?: {
lat: number;
lon: number;
};
}
interface MemorialSearchParams {
firstname?: string;
middlename?: string;
lastname?: string;
cemeteryName?: string;
location?: string;
birthyear?: string;
birthyearfilter?: string;
deathyear?: string;
deathyearfilter?: string;
bio?: string;
linkedToName?: string;
plot?: string;
memorialid?: string;
mcid?: string;
datefilter?: string;
orderby?: string;
page?: number;
}
declare const PERSISTED_QUERIES: {
locationTypeahead: string;
browse: string;
browseStart: string;
locationCoordinates: string;
getCemeteriesInBbox: string;
};
declare class FindAGraveClient {
private client;
private baseUrl;
constructor();
/**
* Search for cemeteries by name
*/
searchCemeteries(name: string, returnHighlight?: boolean): Promise<{
total: number;
locations: Cemetery[];
}>;
/**
* Search for locations (cities, counties, states, etc.)
*/
searchLocations(name: string, returnHighlight?: boolean): Promise<{
total: number;
locations: Location[];
}>;
/**
* Get cemeteries within a geographic bounding box
*/
getCemeteriesInBoundingBox(searchParams: CemeterySearchInput): Promise<{
cemeteries: Cemetery[];
}>;
/**
* Browse locations hierarchically (continents -> countries -> states -> counties -> cities)
*/
browseLocations(parents: string[], ignoreCemeteries?: boolean, hasCemeteries?: boolean): Promise<Array<{
id: string;
locations: Location[];
}>>;
/**
* Get location details by ID
*/
getLocationById(ids: string[]): Promise<{
locations: Location[];
}>;
/**
* Get coordinates for location IDs
*/
getLocationCoordinates(ids: string[]): Promise<{
locations: Array<{
id: string;
coordinates: {
lat: number;
lon: number;
};
}>;
}>;
/**
* Search for memorials/individuals using the REST endpoint
* This uses the native fetch API since memorial searches use REST, not GraphQL
*/
searchMemorials(cemeteryId: string, params: MemorialSearchParams): Promise<string>;
/**
* Search for memorials/individuals across all cemeteries (general search)
* This uses the main memorial search endpoint without specifying a cemetery
*/
searchMemorialsGeneral(params: MemorialSearchParams): Promise<string>;
/**
* Alternative method using direct URL construction with persisted queries
* This mimics exactly how the browser makes requests
*/
makePersistedQuery(operationName: keyof typeof PERSISTED_QUERIES, variables: Record<string, any>): Promise<any>;
}
/**
* Create a new FindAGrave client instance
*/
declare function createFindAGraveClient(): FindAGraveClient;
/**
* Quick search for cemeteries by name
*/
declare function searchCemeteries(name: string): Promise<Cemetery[]>;
/**
* Quick search for locations by name
*/
declare function searchLocations(name: string): Promise<Location[]>;
/**
* Search for memorials in a specific cemetery
*/
declare function searchMemorials(cemeteryId: string, firstname?: string, lastname?: string, cemeteryName?: string): Promise<string>;
/**
* Search for memorials across all cemeteries (general search)
*/
declare function searchMemorialsGeneral(firstname?: string, lastname?: string, location?: string): Promise<string>;
/**
* Get cemeteries near a location (using bounding box)
*/
declare function getCemeteriesNear(centerLat: number, centerLon: number, radiusDegrees?: number): Promise<Cemetery[]>;
/**
* Browse location hierarchy starting from top level
*/
declare function browseFromTop(): Promise<Location[]>;
/**
* Browse a specific continent's countries
*/
declare function browseContinent(continentId: string): Promise<Location[]>;
/**
* Browse a specific country's states/provinces
*/
declare function browseCountry(continentId: string, countryId: string): Promise<Location[]>;
export { type Cemetery, type CemeterySearchInput, FindAGraveClient, type Location, type LocationHierarchy, type LocationSearchInput, type Memorial, type MemorialSearchParams, browseContinent, browseCountry, browseFromTop, createFindAGraveClient, FindAGraveClient as default, getCemeteriesNear, searchCemeteries, searchLocations, searchMemorials, searchMemorialsGeneral };