diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d68fe..f48891d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.16.1 + +- **Add:** Add `session_token` as optional parameter in the geocoding services + ## 0.16.0 - **Add:** Add `depart_at` as optional parameter in the isochrone service diff --git a/docs/services.md b/docs/services.md index ffc8a43..35313d5 100644 --- a/docs/services.md +++ b/docs/services.md @@ -1687,6 +1687,7 @@ See the [public documentation][241]. * `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`) * `config.fuzzyMatch` **[boolean][209]** Specify whether the Geocoding API should attempt approximate, as well as exact, matching. (optional, default `true`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) + * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples @@ -1758,6 +1759,7 @@ See the [public documentation][245]. * `config.reverseMode` **(`"distance"` | `"score"`)** Set the factors that are used to sort nearby results. (optional, default `'distance'`) * `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) + * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples @@ -2380,6 +2382,7 @@ See the [public documentation][264]. * `config.autocomplete` **[boolean][209]** Return autocomplete results or not. (optional, default `true`) * `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) + * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples @@ -2463,6 +2466,7 @@ See the [public documentation][265]. [ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script. * `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`) * `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`) + * `config.session_token` **[String][208]?** A unique session identifier generated by the client. #### Examples diff --git a/package.json b/package.json index def5f7e..09492e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapbox/mapbox-sdk", - "version": "0.16.0", + "version": "0.16.1", "description": "JS SDK for accessing Mapbox APIs", "main": "index.js", "files": [ diff --git a/services/__tests__/geocoding-v6.test.js b/services/__tests__/geocoding-v6.test.js index 32a3752..d2b0d5e 100644 --- a/services/__tests__/geocoding-v6.test.js +++ b/services/__tests__/geocoding-v6.test.js @@ -34,6 +34,7 @@ describe('forwardGeocode', () => { language: 'de', worldview: 'us', permanent: true, + session_token: 'abc123', // structured input parameters will be ignored in normal mode address_line1: '12 main', @@ -60,7 +61,8 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', - permanent: 'true' + permanent: 'true', + session_token: 'abc123' } }); }); @@ -76,6 +78,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', + session_token: 'abc123', // structured input parameters will be picked address_line1: '12 main', @@ -99,6 +102,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', + session_token: 'abc123', address_line1: '12 main', address_number: '12', @@ -140,7 +144,8 @@ describe('reverseGeocode', () => { limit: 3, language: 'de', worldview: 'us', - permanent: true + permanent: true, + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -153,7 +158,8 @@ describe('reverseGeocode', () => { limit: 3, language: 'de', worldview: 'us', - permanent: 'true' + permanent: 'true', + session_token: 'abc123' } }); }); diff --git a/services/__tests__/geocoding.test.js b/services/__tests__/geocoding.test.js index d6d2b55..05154a6 100644 --- a/services/__tests__/geocoding.test.js +++ b/services/__tests__/geocoding.test.js @@ -37,7 +37,8 @@ describe('forwardGeocode', () => { language: ['de', 'bs'], routing: true, fuzzyMatch: true, - worldview: 'us' + worldview: 'us', + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -56,7 +57,8 @@ describe('forwardGeocode', () => { language: ['de', 'bs'], routing: 'true', fuzzyMatch: 'true', - worldview: 'us' + worldview: 'us', + session_token: 'abc123' } }); }); @@ -89,7 +91,8 @@ describe('reverseGeocode', () => { language: ['de', 'bs'], reverseMode: 'distance', routing: true, - worldview: 'us' + worldview: 'us', + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -106,7 +109,8 @@ describe('reverseGeocode', () => { language: ['de', 'bs'], reverseMode: 'distance', routing: 'true', - worldview: 'us' + worldview: 'us', + session_token: 'abc123' } }); }); diff --git a/services/geocoding-v6.js b/services/geocoding-v6.js index c04286b..16e6d90 100644 --- a/services/geocoding-v6.js +++ b/services/geocoding-v6.js @@ -58,6 +58,7 @@ var featureTypes = [ * @param {boolean} [config.autocomplete=true] - Return autocomplete results or not. * @param {boolean} [config.permanent=false] - Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. * @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. + * @param {String} [config.session_token] - A unique session identifier generated by the client. * @return {MapiRequest} * * @example @@ -129,6 +130,7 @@ GeocodingV6.forwardGeocode = function(config) { worldview: v.string, autocomplete: v.boolean, permanent: v.boolean, + session_token: v.string, // structured input fields address_line1: v.string, @@ -168,7 +170,8 @@ GeocodingV6.forwardGeocode = function(config) { 'limit', 'worldview', 'autocomplete', - 'permanent' + 'permanent', + 'session_token' ]) ) ); @@ -198,6 +201,7 @@ GeocodingV6.forwardGeocode = function(config) { * [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script. * @param {boolean} [config.permanent=false] - Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. * @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. + * @param {String} [config.session_token] - A unique session identifier generated by the client. * @return {MapiRequest} * * @example @@ -220,7 +224,8 @@ GeocodingV6.reverseGeocode = function(config) { limit: v.number, language: v.string, worldview: v.string, - permanent: v.boolean + permanent: v.boolean, + session_token: v.string })(config); var query = stringifyBooleans( @@ -233,7 +238,8 @@ GeocodingV6.reverseGeocode = function(config) { 'limit', 'language', 'worldview', - 'permanent' + 'permanent', + 'session_token' ]) ) ); diff --git a/services/geocoding.js b/services/geocoding.js index 02f2814..fcf9b8c 100644 --- a/services/geocoding.js +++ b/services/geocoding.js @@ -48,6 +48,7 @@ var featureTypes = [ * @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. * @param {boolean} [config.fuzzyMatch=true] - Specify whether the Geocoding API should attempt approximate, as well as exact, matching. * @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. + * @param {String} [config.session_token] - A unique session identifier generated by the client. * @return {MapiRequest} * * @example @@ -104,7 +105,8 @@ Geocoding.forwardGeocode = function(config) { language: v.arrayOf(v.string), routing: v.boolean, fuzzyMatch: v.boolean, - worldview: v.string + worldview: v.string, + session_token: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -121,7 +123,8 @@ Geocoding.forwardGeocode = function(config) { 'language', 'routing', 'fuzzyMatch', - 'worldview' + 'worldview', + 'session_token' ]) ) ); @@ -153,6 +156,7 @@ Geocoding.forwardGeocode = function(config) { * @param {'distance'|'score'} [config.reverseMode='distance'] - Set the factors that are used to sort nearby results. * @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. * @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. + * @param {String} [config.session_token] - A unique session identifier generated by the client. * @return {MapiRequest} * * @example @@ -176,7 +180,8 @@ Geocoding.reverseGeocode = function(config) { language: v.arrayOf(v.string), reverseMode: v.oneOf('distance', 'score'), routing: v.boolean, - worldview: v.string + worldview: v.string, + session_token: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -192,7 +197,8 @@ Geocoding.reverseGeocode = function(config) { 'language', 'reverseMode', 'routing', - 'worldview' + 'worldview', + 'session_token' ]) ) );