From 2ab45d486ebe4ded7aaadb69ed90d17ab5a45e5f Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Wed, 11 Sep 2019 10:32:33 -0400 Subject: [PATCH] [node-geocoder] Allow for discrimination on options for specific geocoder providers (#38133) * Allow for discrimination on options for specific geocoder providers This allows for clearer identification of which options are required for which provider, including which parameters are mandatory. I only covered the most distinct providers (here, ism, odf, agol, smartystreets, google) as the others are more generic This also adds the `production` option used in HERE * Remove patch from version --- types/node-geocoder/index.d.ts | 88 ++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 24 deletions(-) diff --git a/types/node-geocoder/index.d.ts b/types/node-geocoder/index.d.ts index 750e78342c..851863f8b9 100644 --- a/types/node-geocoder/index.d.ts +++ b/types/node-geocoder/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-geocoder 3.19 +// Type definitions for node-geocoder 3.24 // Project: https://github.com/nchaulet/node-geocoder#readme // Definitions by: Krzysztof Rosinski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,37 +7,77 @@ declare namespace node_geocoder { type Providers = - 'google' | 'here' | 'freegeoip' | - 'datasciencetoolkit' | 'openstreetmap' | + 'freegeoip' | 'datasciencetoolkit' | 'locationiq' | 'mapquest' | 'openmapquest' | - 'agol' | 'tomtom' | 'nominatimmapquest' | - 'opencage' | 'smartyStreet' | 'geocodio' | - 'yandex' | 'teleport' | 'opendatafrance' | - 'pickpoint'; + 'tomtom' | 'nominatimmapquest' | + 'opencage' | 'geocodio' | + 'yandex' | 'teleport' | 'pickpoint'; - interface Options { - provider: Providers; + interface BaseOptions { + provider: string; httpAdapter?: 'https' | 'http' | 'request'; - clientId?: string; - apiKey?: string; - language?: string; - region?: string; - appId?: string; - appCode?: string; - politicalView?: string; - country?: string; - state?: string; - host?: string; - email?: string; - client_id?: string; - client_secret?: string; - auth_id?: string; - auth_token?: string; timeout?: number; formatterPattern?: string; formatter?: any; } + interface HereOptions { + provider: 'here'; + appId: string; + appCode: string; + language?: string; + politicalView?: string; + country?: string; + state?: string; + production?: boolean; + } + + interface OpenStreetMapOptions { + provider: 'openstreetmap'; + language?: string; + email?: string; + apiKey?: string; + osmServer?: string; + } + + interface OpenDataFranceOptions { + provider: 'opendatafrance'; + language?: string; + email?: string; + apiKey?: string; + } + + interface AgolOptions { + provider: 'agol'; + client_id?: string; + client_secret?: string; + } + + interface SmartyStreetsOptions { + provider: 'smartyStreet'; + auth_id: string; + auth_token: string; + } + + interface GoogleOptions { + provider: 'google'; + clientId?: string; + apiKey?: string; + language?: string; + region?: string; + excludePartialMatches?: boolean; + channel?: string; + } + + interface GenericOptions { + provider: Providers; + apiKey?: string; + language?: string; + host?: string; + } + + type Options = BaseOptions & (GenericOptions | HereOptions | OpenStreetMapOptions | OpenDataFranceOptions | AgolOptions | SmartyStreetsOptions | GoogleOptions); + interface Location { lat: number; lon: number;