diff --git a/CHANGELOG.md b/CHANGELOG.md index cba015a..4af85d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,64 +1,48 @@ # MapTiler Client Changelog -## 2.1.0 - +## 2.2.0 ### New Features +- Exposing ISO languages and non-ISO language separately +### Others +- fixing typos +- languages are now ordered alphabetically -- Added `continental_marine` and `major_landform` to geocoding type +## 2.1.0 +### New Features +- Added `continental_marine` and `major_landform` to geocoding type ### Bug Fixes - - Fixed Czech language geocoding flag - ### Others - - Languages are now listed in the Client library - Improved geocoding types and limit documentation ## 2.0.0 - ### New Features - - Added `matching_text` and `matching_place_name` properties to geocoding feature response - Added `road` to geocoding `types` - -### Bug Fixes - ### Others - - Languages are now listed in the Client library ## 1.8.1 - ### Bug Fixes - - The QuickLRU dependency is not CJS compatible to it is now fully bundled into the CJS bundle - ### Others - - Moved somes wrongly positioned deps into devDep ## 1.8.0 - ### New Features - - Rework of the elevation API to be improve developper experience (new module `elevation`) - Expoing some geo math with the new `math` module - synchronized geocoding types with current geocoding API - added `excludeTypes` option to geocoding API ## 1.7.0 - ### New Features - - DEM elevation API (https://github.com/maptiler/maptiler-client-js/pull/24) - ### Bug Fixes - - `geocoding.byId` can now be used with the apiKey (https://github.com/maptiler/maptiler-client-js/pull/27) - the Typescript types are now properly exported (https://github.com/maptiler/maptiler-client-js/pull/25) - ### Others - - the Typescript `moduleResolution` is now `"Bundler"` (used to be `"Node"`) (https://github.com/maptiler/maptiler-client-js/pull/28) - updated some dev-dependencies (https://github.com/maptiler/maptiler-client-js/pull/28) diff --git a/package-lock.json b/package-lock.json index 407abbb..9610fc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@maptiler/client", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@maptiler/client", - "version": "2.1.0", + "version": "2.2.0", "license": "BSD-3-Clause", "dependencies": { "quick-lru": "^7.0.0" diff --git a/package.json b/package.json index 994caa5..03476a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maptiler/client", - "version": "2.1.0", + "version": "2.2.0", "description": "Javascript & Typescript wrapper to MapTiler Cloud API", "module": "dist/maptiler-client.mjs", "types": "dist/maptiler-client.d.ts", diff --git a/src/language.ts b/src/language.ts index 6625957..422b4ae 100644 --- a/src/language.ts +++ b/src/language.ts @@ -88,12 +88,24 @@ export const NonISOLanguage = { isMode: false, geocoding: false, } as LanguageInfo, -} as const +} as const; /** * List of "country specific" languages. */ export const ISOLanguage = { + /** + * Albanian language + */ + ALBANIAN: { + code: "sq", + flag: "name:sq", + name: "Albanian", + latin: true, + isMode: false, + geocoding: true, + } as LanguageInfo, + /** * Amharic language */ @@ -118,6 +130,18 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, + /** + * Armenian language + */ + ARMENIAN: { + code: "hy", + flag: "name:hy", + name: "Armenian", + latin: false, + isMode: false, + geocoding: true, + } as LanguageInfo, + /** * Azerbaijani language */ @@ -131,24 +155,24 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Belarusian langauge + * Basque language */ - BELARUSIAN: { - code: "be", - flag: "name:be", - name: "Belarusian", - latin: false, + BASQUE: { + code: "eu", + flag: "name:eu", + name: "Basque", + latin: true, isMode: false, - geocoding: true, + geocoding: false, } as LanguageInfo, /** - * Bulgarian language + * Belarusian langauge */ - BULGARIAN: { - code: "bg", - flag: "bg", - name: "Bulgarian", + BELARUSIAN: { + code: "be", + flag: "name:be", + name: "Belarusian", latin: false, isMode: false, geocoding: true, @@ -166,6 +190,18 @@ export const ISOLanguage = { geocoding: false, } as LanguageInfo, + /** + * Bosnian language + */ + BOSNIAN: { + code: "bs", + flag: "name:bs", + name: "Bosnian", + latin: true, + isMode: false, + geocoding: true, + } as LanguageInfo, + /** * Breton language */ @@ -179,13 +215,13 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Bosnian language + * Bulgarian language */ - BOSNIAN: { - code: "bs", - flag: "name:bs", - name: "Bosnian", - latin: true, + BULGARIAN: { + code: "bg", + flag: "bg", + name: "Bulgarian", + latin: false, isMode: false, geocoding: true, } as LanguageInfo, @@ -251,24 +287,24 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Czech language + * Croatian language */ - CZECH: { - code: "cs", - flag: "name:cs", - name: "Czech", + CROATIAN: { + code: "hr", + flag: "name:hr", + name: "Croatian", latin: true, isMode: false, geocoding: true, } as LanguageInfo, /** - * Welsh language + * Czech language */ - WELSH: { - code: "cy", - flag: "name:cy", - name: "WELSH", + CZECH: { + code: "cs", + flag: "name:cs", + name: "Czech", latin: true, isMode: false, geocoding: true, @@ -286,6 +322,18 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, + /** + * Dutch language + */ + DUTCH: { + code: "nl", + flag: "name:nl", + name: "Dutch", + latin: true, + isMode: false, + geocoding: true, + } as LanguageInfo, + /** * German language */ @@ -334,18 +382,6 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, - /** - * Spanish language - */ - SPANISH: { - code: "es", - flag: "name:es", - name: "Spanish", - latin: true, - isMode: false, - geocoding: true, - } as LanguageInfo, - /** * Estonian language */ @@ -358,18 +394,6 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, - /** - * Basque language - */ - BASQUE: { - code: "eu", - flag: "name:eu", - name: "Basque", - latin: true, - isMode: false, - geocoding: false, - } as LanguageInfo, - /** * Finnish language */ @@ -407,25 +431,13 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Irish language - */ - IRISH: { - code: "ga", - flag: "name:ga", - name: "Irish", - latin: true, - isMode: false, - geocoding: true, - } as LanguageInfo, - - /** - * Scottish Gaelic language + * Georgian language */ - SCOTTISH_GAELIC: { - code: "gd", - flag: "name:gd", - name: "Scottish Gaelic", - latin: true, + GEORGIAN: { + code: "ka", + flag: "name:ka", + name: "Georgian", + latin: false, isMode: false, geocoding: true, } as LanguageInfo, @@ -454,18 +466,6 @@ export const ISOLanguage = { geocoding: false, } as LanguageInfo, - /** - * Croatian language - */ - CROATIAN: { - code: "hr", - flag: "name:hr", - name: "Croatian", - latin: true, - isMode: false, - geocoding: true, - } as LanguageInfo, - /** * Hungarian language */ @@ -479,13 +479,13 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Armenian language + * Icelandic language */ - ARMENIAN: { - code: "hy", - flag: "name:hy", - name: "Armenian", - latin: false, + ICELANDIC: { + code: "is", + flag: "name:is", + name: "Icelandic", + latin: true, isMode: false, geocoding: true, } as LanguageInfo, @@ -503,12 +503,12 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Icelandic language + * Irish language */ - ICELANDIC: { - code: "is", - flag: "name:is", - name: "Icelandic", + IRISH: { + code: "ga", + flag: "name:ga", + name: "Irish", latin: true, isMode: false, geocoding: true, @@ -587,13 +587,13 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Georgian language + * Kannada language */ - GEORGIAN: { - code: "ka", - flag: "name:ka", - name: "Georgian", - latin: false, + KANNADA: { + code: "kn", + flag: "name:kn", + name: "Kannada", + latin: true, isMode: false, geocoding: true, } as LanguageInfo, @@ -610,18 +610,6 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, - /** - * Kannada language - */ - KANNADA: { - code: "kn", - flag: "name:kn", - name: "Kannada", - latin: true, - isMode: false, - geocoding: true, - } as LanguageInfo, - /** * Korean language */ @@ -671,12 +659,12 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Luxembourgish language + * Latvian language */ - LUXEMBOURGISH: { - code: "lb", - flag: "name:lb", - name: "Luxembourgish", + LATVIAN: { + code: "lv", + flag: "name:lv", + name: "Latvian", latin: true, isMode: false, geocoding: true, @@ -695,12 +683,12 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Latvian language + * Luxembourgish language */ - LATVIAN: { - code: "lv", - flag: "name:lv", - name: "Latvian", + LUXEMBOURGISH: { + code: "lb", + flag: "name:lb", + name: "Luxembourgish", latin: true, isMode: false, geocoding: true, @@ -742,18 +730,6 @@ export const ISOLanguage = { geocoding: true, } as LanguageInfo, - /** - * Dutch language - */ - DUTCH: { - code: "nl", - flag: "name:nl", - name: "Dutch", - latin: true, - isMode: false, - geocoding: true, - } as LanguageInfo, - /** * Norwegian language */ @@ -778,6 +754,18 @@ export const ISOLanguage = { geocoding: false, } as LanguageInfo, + /** + * Persian language + */ + PERSIAN: { + code: "fa", + flag: "name:fa", + name: "Persian", + latin: false, + isMode: false, + geocoding: false, + } as LanguageInfo, + /** * Polish language */ @@ -791,15 +779,15 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Persian language + * Portuguese language */ - PERSIAN: { - code: "fa", - flag: "name:fa", - name: "Persian", - latin: false, + PORTUGUESE: { + code: "pt", + flag: "name:pt", + name: "Portuguese", + latin: true, isMode: false, - geocoding: false, + geocoding: true, } as LanguageInfo, /** @@ -827,12 +815,12 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Portuguese language + * Romanian language */ - PORTUGUESE: { - code: "pt", - flag: "name:pt", - name: "Portuguese", + ROMANIAN: { + code: "ro", + flag: "name:ro", + name: "Romanian", latin: true, isMode: false, geocoding: true, @@ -851,87 +839,87 @@ export const ISOLanguage = { } as LanguageInfo, /** - * Romanian language + * Russian language */ - ROMANIAN: { - code: "ro", - flag: "name:ro", - name: "Romanian", - latin: true, + RUSSIAN: { + code: "ru", + flag: "name:ru", + name: "Russian", + latin: false, isMode: false, geocoding: true, } as LanguageInfo, /** - * Russian language + * Serbian language (cyrillic script) */ - RUSSIAN: { - code: "ru", - flag: "name:ru", - name: "Russian", + SERBIAN_CYRILLIC: { + code: "sr", + flag: "name:sr", + name: "Serbian (Cyrillic script)", latin: false, isMode: false, geocoding: true, } as LanguageInfo, /** - * Slovak language + * Serbian language (latin script) */ - SLOVAK: { - code: "sk", - flag: "name:sk", - name: "Slovak", + SERBIAN_LATIN: { + code: "sr-Latn", + flag: "name:sr-Latn", + name: "Serbian (Latin script)", latin: true, isMode: false, - geocoding: true, + geocoding: false, } as LanguageInfo, /** - * Slovene language + * Scottish Gaelic language */ - SLOVENE: { - code: "sl", - flag: "name:sl", - name: "Slovene", + SCOTTISH_GAELIC: { + code: "gd", + flag: "name:gd", + name: "Scottish Gaelic", latin: true, isMode: false, geocoding: true, } as LanguageInfo, /** - * Albanian language + * Slovak language */ - ALBANIAN: { - code: "sq", - flag: "name:sq", - name: "Albanian", + SLOVAK: { + code: "sk", + flag: "name:sk", + name: "Slovak", latin: true, isMode: false, geocoding: true, } as LanguageInfo, /** - * Serbian language (cyrillic script) + * Slovene language */ - SERBIAN_CYRILLIC: { - code: "sr", - flag: "name:sr", - name: "Serbian (Cyrillic script)", - latin: false, + SLOVENE: { + code: "sl", + flag: "name:sl", + name: "Slovene", + latin: true, isMode: false, geocoding: true, } as LanguageInfo, /** - * Serbian language (latin script) + * Spanish language */ - SERBIAN_LATIN: { - code: "sr-Latn", - flag: "name:sr-Latn", - name: "Serbian (Latin script)", + SPANISH: { + code: "es", + flag: "name:es", + name: "Spanish", latin: true, isMode: false, - geocoding: false, + geocoding: true, } as LanguageInfo, /** @@ -1017,14 +1005,26 @@ export const ISOLanguage = { isMode: false, geocoding: false, } as LanguageInfo, -} as const + + /** + * Welsh language + */ + WELSH: { + code: "cy", + flag: "name:cy", + name: "Welsh", + latin: true, + isMode: false, + geocoding: true, + } as LanguageInfo, +} as const; /** * The complete list of languages */ export const Language = { ...NonISOLanguage, - ...ISOLanguage + ...ISOLanguage, } as const; /** diff --git a/src/services/geocoding.ts b/src/services/geocoding.ts index f3ac766..5e76857 100644 --- a/src/services/geocoding.ts +++ b/src/services/geocoding.ts @@ -11,6 +11,7 @@ import { Language, getLanguageInfoFromFlag, } from "../language"; + import { ServiceError } from "./ServiceError"; const customMessages = { @@ -266,7 +267,7 @@ export type GeocodingSearchResult = { function addLanguageGeocodingOptions( searchParams: URLSearchParams, - options: LanguageGeocodingOptions + options: LanguageGeocodingOptions, ) { const { language } = options; @@ -285,7 +286,7 @@ function addLanguageGeocodingOptions( } function toValidGeocodingLanguageCode( - lang: string | LanguageInfo + lang: string | LanguageInfo, ): string | null { const langInfo = lang === Language.AUTO.flag @@ -303,7 +304,7 @@ function toValidGeocodingLanguageCode( function addCommonForwardAndReverseGeocodingOptions( searchParams: URLSearchParams, - options: CommonForwardAndReverseGeocodingOptions + options: CommonForwardAndReverseGeocodingOptions, ) { const { apiKey, limit, types, excludeTypes } = options; @@ -326,7 +327,7 @@ function addCommonForwardAndReverseGeocodingOptions( function addForwardGeocodingOptions( searchParams: URLSearchParams, - options: GeocodingOptions + options: GeocodingOptions, ) { addCommonForwardAndReverseGeocodingOptions(searchParams, options); @@ -339,7 +340,7 @@ function addForwardGeocodingOptions( if (proximity !== undefined) { searchParams.set( "proximity", - proximity === "ip" ? proximity : proximity.join(",") + proximity === "ip" ? proximity : proximity.join(","), ); } @@ -369,7 +370,7 @@ function addForwardGeocodingOptions( */ async function forward( query: string, - options: GeocodingOptions = {} + options: GeocodingOptions = {}, ): Promise { if (typeof query !== "string" || query.trim().length === 0) { throw new Error("The query must be a non-empty string"); @@ -377,7 +378,7 @@ async function forward( const endpoint = new URL( `geocoding/${encodeURIComponent(query)}.json`, - defaults.maptilerApiURL + defaults.maptilerApiURL, ); addForwardGeocodingOptions(endpoint.searchParams, options); @@ -403,7 +404,7 @@ async function forward( */ async function reverse( position: Position, - options: ReverseGeocodingOptions = {} + options: ReverseGeocodingOptions = {}, ): Promise { if (!Array.isArray(position) || position.length < 2) { throw new Error("The position must be an array of form [lng, lat]."); @@ -411,7 +412,7 @@ async function reverse( const endpoint = new URL( `geocoding/${position[0]},${position[1]}.json`, - defaults.maptilerApiURL + defaults.maptilerApiURL, ); addCommonForwardAndReverseGeocodingOptions(endpoint.searchParams, options); @@ -438,7 +439,7 @@ async function reverse( */ async function byId( id: string, - options: ByIdGeocodingOptions = {} + options: ByIdGeocodingOptions = {}, ): Promise { const endpoint = new URL(`geocoding/${id}.json`, defaults.maptilerApiURL); @@ -467,7 +468,7 @@ async function byId( */ async function batch( queries: string[], - options: GeocodingOptions = {} + options: GeocodingOptions = {}, ): Promise { if (!queries.length) { return []; @@ -479,7 +480,7 @@ async function batch( const endpoint = new URL( `geocoding/${joinedQuery}.json`, - defaults.maptilerApiURL + defaults.maptilerApiURL, ); addForwardGeocodingOptions(endpoint.searchParams, options);