From 19b012d625d3220b0a0995312b37f763690abec7 Mon Sep 17 00:00:00 2001 From: mpothier <39810086+mpothier@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:54:21 -0700 Subject: [PATCH 1/3] add sessionId param to geocoding services --- services/__tests__/geocoding-v6.test.js | 12 +++++++++--- services/__tests__/geocoding.test.js | 12 ++++++++---- services/geocoding-v6.js | 10 +++++++--- services/geocoding.js | 12 ++++++++---- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/services/__tests__/geocoding-v6.test.js b/services/__tests__/geocoding-v6.test.js index 32a3752..8ac0cff 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, + sessionId: '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', + sessionId: 'abc123' } }); }); @@ -76,6 +78,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', + sessionId: 'abc123', // structured input parameters will be picked address_line1: '12 main', @@ -99,6 +102,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', + sessionId: 'abc123', address_line1: '12 main', address_number: '12', @@ -140,7 +144,8 @@ describe('reverseGeocode', () => { limit: 3, language: 'de', worldview: 'us', - permanent: true + permanent: true, + sessionId: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -153,7 +158,8 @@ describe('reverseGeocode', () => { limit: 3, language: 'de', worldview: 'us', - permanent: 'true' + permanent: 'true', + sessionId: 'abc123' } }); }); diff --git a/services/__tests__/geocoding.test.js b/services/__tests__/geocoding.test.js index d6d2b55..cbae233 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', + sessionId: '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', + sessionId: 'abc123' } }); }); @@ -89,7 +91,8 @@ describe('reverseGeocode', () => { language: ['de', 'bs'], reverseMode: 'distance', routing: true, - worldview: 'us' + worldview: 'us', + sessionId: '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', + sessionId: 'abc123' } }); }); diff --git a/services/geocoding-v6.js b/services/geocoding-v6.js index c04286b..80ea916 100644 --- a/services/geocoding-v6.js +++ b/services/geocoding-v6.js @@ -129,6 +129,7 @@ GeocodingV6.forwardGeocode = function(config) { worldview: v.string, autocomplete: v.boolean, permanent: v.boolean, + sessionId: v.string, // structured input fields address_line1: v.string, @@ -168,7 +169,8 @@ GeocodingV6.forwardGeocode = function(config) { 'limit', 'worldview', 'autocomplete', - 'permanent' + 'permanent', + 'sessionId' ]) ) ); @@ -220,7 +222,8 @@ GeocodingV6.reverseGeocode = function(config) { limit: v.number, language: v.string, worldview: v.string, - permanent: v.boolean + permanent: v.boolean, + sessionId: v.string })(config); var query = stringifyBooleans( @@ -233,7 +236,8 @@ GeocodingV6.reverseGeocode = function(config) { 'limit', 'language', 'worldview', - 'permanent' + 'permanent', + 'sessionId' ]) ) ); diff --git a/services/geocoding.js b/services/geocoding.js index 02f2814..2100e25 100644 --- a/services/geocoding.js +++ b/services/geocoding.js @@ -104,7 +104,8 @@ Geocoding.forwardGeocode = function(config) { language: v.arrayOf(v.string), routing: v.boolean, fuzzyMatch: v.boolean, - worldview: v.string + worldview: v.string, + sessionId: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -121,7 +122,8 @@ Geocoding.forwardGeocode = function(config) { 'language', 'routing', 'fuzzyMatch', - 'worldview' + 'worldview', + 'sessionId' ]) ) ); @@ -176,7 +178,8 @@ Geocoding.reverseGeocode = function(config) { language: v.arrayOf(v.string), reverseMode: v.oneOf('distance', 'score'), routing: v.boolean, - worldview: v.string + worldview: v.string, + sessionId: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -192,7 +195,8 @@ Geocoding.reverseGeocode = function(config) { 'language', 'reverseMode', 'routing', - 'worldview' + 'worldview', + 'sessionId' ]) ) ); From ae00cc5a16e8a7d1674681e695a263a0b885a107 Mon Sep 17 00:00:00 2001 From: mpothier <39810086+mpothier@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:03:06 -0700 Subject: [PATCH 2/3] change to token --- services/__tests__/geocoding-v6.test.js | 12 ++++++------ services/__tests__/geocoding.test.js | 8 ++++---- services/geocoding-v6.js | 8 ++++---- services/geocoding.js | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/services/__tests__/geocoding-v6.test.js b/services/__tests__/geocoding-v6.test.js index 8ac0cff..d2b0d5e 100644 --- a/services/__tests__/geocoding-v6.test.js +++ b/services/__tests__/geocoding-v6.test.js @@ -34,7 +34,7 @@ describe('forwardGeocode', () => { language: 'de', worldview: 'us', permanent: true, - sessionId: 'abc123', + session_token: 'abc123', // structured input parameters will be ignored in normal mode address_line1: '12 main', @@ -62,7 +62,7 @@ describe('forwardGeocode', () => { language: 'de', worldview: 'us', permanent: 'true', - sessionId: 'abc123' + session_token: 'abc123' } }); }); @@ -78,7 +78,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', - sessionId: 'abc123', + session_token: 'abc123', // structured input parameters will be picked address_line1: '12 main', @@ -102,7 +102,7 @@ describe('forwardGeocode', () => { limit: 3, language: 'de', worldview: 'us', - sessionId: 'abc123', + session_token: 'abc123', address_line1: '12 main', address_number: '12', @@ -145,7 +145,7 @@ describe('reverseGeocode', () => { language: 'de', worldview: 'us', permanent: true, - sessionId: 'abc123' + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -159,7 +159,7 @@ describe('reverseGeocode', () => { language: 'de', worldview: 'us', permanent: 'true', - sessionId: 'abc123' + session_token: 'abc123' } }); }); diff --git a/services/__tests__/geocoding.test.js b/services/__tests__/geocoding.test.js index cbae233..05154a6 100644 --- a/services/__tests__/geocoding.test.js +++ b/services/__tests__/geocoding.test.js @@ -38,7 +38,7 @@ describe('forwardGeocode', () => { routing: true, fuzzyMatch: true, worldview: 'us', - sessionId: 'abc123' + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -58,7 +58,7 @@ describe('forwardGeocode', () => { routing: 'true', fuzzyMatch: 'true', worldview: 'us', - sessionId: 'abc123' + session_token: 'abc123' } }); }); @@ -92,7 +92,7 @@ describe('reverseGeocode', () => { reverseMode: 'distance', routing: true, worldview: 'us', - sessionId: 'abc123' + session_token: 'abc123' }); expect(tu.requestConfig(geocoding)).toEqual({ method: 'GET', @@ -110,7 +110,7 @@ describe('reverseGeocode', () => { reverseMode: 'distance', routing: 'true', worldview: 'us', - sessionId: 'abc123' + session_token: 'abc123' } }); }); diff --git a/services/geocoding-v6.js b/services/geocoding-v6.js index 80ea916..909444b 100644 --- a/services/geocoding-v6.js +++ b/services/geocoding-v6.js @@ -129,7 +129,7 @@ GeocodingV6.forwardGeocode = function(config) { worldview: v.string, autocomplete: v.boolean, permanent: v.boolean, - sessionId: v.string, + session_token: v.string, // structured input fields address_line1: v.string, @@ -170,7 +170,7 @@ GeocodingV6.forwardGeocode = function(config) { 'worldview', 'autocomplete', 'permanent', - 'sessionId' + 'session_token' ]) ) ); @@ -223,7 +223,7 @@ GeocodingV6.reverseGeocode = function(config) { language: v.string, worldview: v.string, permanent: v.boolean, - sessionId: v.string + session_token: v.string })(config); var query = stringifyBooleans( @@ -237,7 +237,7 @@ GeocodingV6.reverseGeocode = function(config) { 'language', 'worldview', 'permanent', - 'sessionId' + 'session_token' ]) ) ); diff --git a/services/geocoding.js b/services/geocoding.js index 2100e25..edeaea7 100644 --- a/services/geocoding.js +++ b/services/geocoding.js @@ -105,7 +105,7 @@ Geocoding.forwardGeocode = function(config) { routing: v.boolean, fuzzyMatch: v.boolean, worldview: v.string, - sessionId: v.string + session_token: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -123,7 +123,7 @@ Geocoding.forwardGeocode = function(config) { 'routing', 'fuzzyMatch', 'worldview', - 'sessionId' + 'session_token' ]) ) ); @@ -179,7 +179,7 @@ Geocoding.reverseGeocode = function(config) { reverseMode: v.oneOf('distance', 'score'), routing: v.boolean, worldview: v.string, - sessionId: v.string + session_token: v.string })(config); config.mode = config.mode || 'mapbox.places'; @@ -196,7 +196,7 @@ Geocoding.reverseGeocode = function(config) { 'reverseMode', 'routing', 'worldview', - 'sessionId' + 'session_token' ]) ) ); From 0e19cc9a7bfb3f9167f2c3c2bd976ace751b7894 Mon Sep 17 00:00:00 2001 From: mpothier <39810086+mpothier@users.noreply.github.com> Date: Fri, 13 Sep 2024 08:21:25 -0700 Subject: [PATCH 3/3] docs, bump package version --- CHANGELOG.md | 4 ++++ docs/services.md | 4 ++++ package.json | 2 +- services/geocoding-v6.js | 2 ++ services/geocoding.js | 2 ++ 5 files changed, 13 insertions(+), 1 deletion(-) 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/geocoding-v6.js b/services/geocoding-v6.js index 909444b..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 @@ -200,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 diff --git a/services/geocoding.js b/services/geocoding.js index edeaea7..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 @@ -155,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