From 34c2bceb2fd2f8786a8c5d877d9c0b680478c991 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Tue, 5 Dec 2023 15:41:08 -0500 Subject: [PATCH 01/16] Prelim session work for sdk --- src/api/search.ts | 2 ++ src/types.ts | 1 + src/ui/autocomplete.ts | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/api/search.ts b/src/api/search.ts index 86c2bdcc..ff7d82da 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -22,6 +22,7 @@ class SearchAPI { layers, countryCode, expandUnits, + session, } = params; // near can be provided as a string or Location object @@ -42,6 +43,7 @@ class SearchAPI { layers, countryCode, expandUnits, + session, }, }); diff --git a/src/types.ts b/src/types.ts index 41cf76d0..df23ac88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -342,6 +342,7 @@ export interface RadarAutocompleteParams { layers?: RadarGeocodeLayer[]; countryCode?: string; expandUnits?: boolean; + session?: string; } export interface RadarAutocompleteResponse extends RadarResponse { diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 506cff24..1dd12d85 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -4,6 +4,8 @@ import SearchAPI from '../api/search'; import { RadarAutocompleteContainerNotFound } from '../errors'; import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location } from '../types'; +import crypto from 'crypto'; + const CLASSNAMES = { WRAPPER: 'radar-autocomplete-wrapper', INPUT: 'radar-autocomplete-input', @@ -86,6 +88,7 @@ class AutocompleteUI { resultsList: HTMLElement; wrapper: HTMLElement; poweredByLink?: HTMLElement; + session?: string; // create a new AutocompleteUI instance public static createAutocomplete(autocompleteOptions: RadarAutocompleteUIOptions): AutocompleteUI { @@ -237,6 +240,10 @@ class AutocompleteUI { public async fetchResults(query: string) { const { limit, layers, countryCode, expandUnits, onRequest } = this.config; + if (!this.session) { + this.session = this.generateUUID(); + } + const session = this.session; const params: RadarAutocompleteParams = { query, @@ -244,6 +251,7 @@ class AutocompleteUI { layers, countryCode, expandUnits, + session, } if (this.near) { @@ -442,6 +450,9 @@ class AutocompleteUI { onSelection(result); } + // Close out session + this.session = undefined; + // clear results list this.close(); } @@ -511,6 +522,10 @@ class AutocompleteUI { return this; } + public generateUUID = (): string => { + return crypto.randomUUID(); + } + public setShowMarkers(showMarkers: boolean) { this.config.showMarkers = showMarkers; if (showMarkers) { From 38a7e4ab8b62947371ea972529e7f7c28e7c6942 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 6 Dec 2023 11:17:23 -0500 Subject: [PATCH 02/16] autocomplete/session/selection endpoint --- src/api/search.ts | 17 +++++++++++++++++ src/types.ts | 5 +++++ src/ui/autocomplete.ts | 11 ++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/api/search.ts b/src/api/search.ts index ff7d82da..7ae87c2b 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -9,6 +9,7 @@ import type { RadarSearchPlacesResponse, RadarSearchGeofencesParams, RadarSearchGeofencesResponse, + RadarAutocompleteSessionParams, } from '../types'; class SearchAPI { @@ -58,6 +59,22 @@ class SearchAPI { return autocompleteRes; } + static async autocompleteSelect(params: RadarAutocompleteSessionParams) { + let { + session, + selection, + } = params; + + await Http.request({ + method: 'GET', + path: 'search/autocomplete/session', + data: { + session, + selection, + }, + }); + } + static async searchGeofences(params: RadarSearchGeofencesParams): Promise { const options = Config.get(); diff --git a/src/types.ts b/src/types.ts index df23ac88..c9d68daa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -345,6 +345,11 @@ export interface RadarAutocompleteParams { session?: string; } +export interface RadarAutocompleteSessionParams { + session: string; + selection: number; +} + export interface RadarAutocompleteResponse extends RadarResponse { addresses: RadarAutocompleteAddress[]; } diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 1dd12d85..3969f34a 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -2,7 +2,7 @@ import Logger from '../logger'; import SearchAPI from '../api/search'; import { RadarAutocompleteContainerNotFound } from '../errors'; -import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location } from '../types'; +import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionParams } from '../types'; import crypto from 'crypto'; @@ -450,6 +450,15 @@ class AutocompleteUI { onSelection(result); } + // Session work + if (this.session) { + const params: RadarAutocompleteSessionParams = { + session: this.session, + selection: index, + } + SearchAPI.autocompleteSelect(params); + } + // Close out session this.session = undefined; From a60303afc4d8cdf09920728e0762ac1ce44852a7 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 6 Dec 2023 13:30:35 -0500 Subject: [PATCH 03/16] change endpoint --- src/api/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/search.ts b/src/api/search.ts index 7ae87c2b..7b20e8aa 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -67,7 +67,7 @@ class SearchAPI { await Http.request({ method: 'GET', - path: 'search/autocomplete/session', + path: 'search/autocomplete/selection', data: { session, selection, From e012ebb88d815ffd9a009043ba90161bf4d752b4 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Thu, 7 Dec 2023 12:10:44 -0500 Subject: [PATCH 04/16] device session info --- src/api/search.ts | 8 +------- src/config.ts | 3 ++- src/types.ts | 4 ++++ src/ui/autocomplete.ts | 13 ++++++++++++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/api/search.ts b/src/api/search.ts index 7b20e8aa..941dc0c3 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -60,17 +60,11 @@ class SearchAPI { } static async autocompleteSelect(params: RadarAutocompleteSessionParams) { - let { - session, - selection, - } = params; - await Http.request({ method: 'GET', path: 'search/autocomplete/selection', data: { - session, - selection, + ...params }, }); } diff --git a/src/config.ts b/src/config.ts index 89a599f2..b8d08528 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,7 +6,8 @@ class Config { static defaultOptions = { live: false, logLevel: 'error', - host: 'https://api.radar.io', + // host: 'https://api.radar-staging.com', + host: 'http://localhost:8081', version: 'v1', debug: false, }; diff --git a/src/types.ts b/src/types.ts index c9d68daa..27ddad42 100644 --- a/src/types.ts +++ b/src/types.ts @@ -348,6 +348,10 @@ export interface RadarAutocompleteParams { export interface RadarAutocompleteSessionParams { session: string; selection: number; + radarSessionId?: string; + userId?: string; + deviceId?: string; + installId?: string; } export interface RadarAutocompleteResponse extends RadarResponse { diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 3969f34a..8c320031 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -1,5 +1,8 @@ import Logger from '../logger'; import SearchAPI from '../api/search'; +import Device from '../device'; +import Session from '../session'; +import Storage from '../storage'; import { RadarAutocompleteContainerNotFound } from '../errors'; import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionParams } from '../types'; @@ -450,11 +453,19 @@ class AutocompleteUI { onSelection(result); } - // Session work + // Radar Autocomplete Session if (this.session) { + const userId = Storage.getItem(Storage.USER_ID) || undefined; + const deviceId = Device.getDeviceId() || undefined; + const installId = Device.getInstallId() || undefined; + const radarSessionId = Session.getSessionId() || undefined; const params: RadarAutocompleteSessionParams = { session: this.session, selection: index, + userId, + deviceId, + installId, + radarSessionId, } SearchAPI.autocompleteSelect(params); } From efadaef3cfef4faca84e82ae393b5b13fc365eed Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Mon, 11 Dec 2023 13:53:37 -0500 Subject: [PATCH 05/16] Adding previous query into parameters --- src/types.ts | 7 +++++++ src/ui/autocomplete.ts | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/types.ts b/src/types.ts index 27ddad42..4bdffd7b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -352,6 +352,13 @@ export interface RadarAutocompleteSessionParams { userId?: string; deviceId?: string; installId?: string; + + query?: string; + near?: Location | string; + limit?: number; + layers?: RadarGeocodeLayer[]; + countryCode?: string; + expandUnits?: boolean; } export interface RadarAutocompleteResponse extends RadarResponse { diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 8c320031..6e4b5744 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -92,6 +92,7 @@ class AutocompleteUI { wrapper: HTMLElement; poweredByLink?: HTMLElement; session?: string; + autocompleteParams?: RadarAutocompleteParams; // create a new AutocompleteUI instance public static createAutocomplete(autocompleteOptions: RadarAutocompleteUIOptions): AutocompleteUI { @@ -243,6 +244,7 @@ class AutocompleteUI { public async fetchResults(query: string) { const { limit, layers, countryCode, expandUnits, onRequest } = this.config; + if (!this.session) { this.session = this.generateUUID(); } @@ -265,6 +267,8 @@ class AutocompleteUI { onRequest(params); } + this.autocompleteParams = params; // set previous params for autocomplete session selections + const { addresses } = await SearchAPI.autocomplete(params); return addresses; } @@ -466,12 +470,14 @@ class AutocompleteUI { deviceId, installId, radarSessionId, + ...this.autocompleteParams } SearchAPI.autocompleteSelect(params); } // Close out session this.session = undefined; + this.autocompleteParams = undefined; // clear results list this.close(); From 8f12951affe4c57fb85b7b0b825b447e6e9f1710 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 10:16:53 -0500 Subject: [PATCH 06/16] formatting --- src/api/search.ts | 4 ++-- src/config.ts | 3 +-- src/types.ts | 2 +- src/ui/autocomplete.ts | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/api/search.ts b/src/api/search.ts index 941dc0c3..8c714281 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -9,7 +9,7 @@ import type { RadarSearchPlacesResponse, RadarSearchGeofencesParams, RadarSearchGeofencesResponse, - RadarAutocompleteSessionParams, + RadarAutocompleteSessionSelectionParams, } from '../types'; class SearchAPI { @@ -59,7 +59,7 @@ class SearchAPI { return autocompleteRes; } - static async autocompleteSelect(params: RadarAutocompleteSessionParams) { + static async autocompleteSelect(params: RadarAutocompleteSessionSelectionParams) { await Http.request({ method: 'GET', path: 'search/autocomplete/selection', diff --git a/src/config.ts b/src/config.ts index b8d08528..89a599f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,8 +6,7 @@ class Config { static defaultOptions = { live: false, logLevel: 'error', - // host: 'https://api.radar-staging.com', - host: 'http://localhost:8081', + host: 'https://api.radar.io', version: 'v1', debug: false, }; diff --git a/src/types.ts b/src/types.ts index 4bdffd7b..0574d62b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -345,7 +345,7 @@ export interface RadarAutocompleteParams { session?: string; } -export interface RadarAutocompleteSessionParams { +export interface RadarAutocompleteSessionSelectionParams { session: string; selection: number; radarSessionId?: string; diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 6e4b5744..0cc79eeb 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -5,7 +5,7 @@ import Session from '../session'; import Storage from '../storage'; import { RadarAutocompleteContainerNotFound } from '../errors'; -import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionParams } from '../types'; +import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionSelectionParams } from '../types'; import crypto from 'crypto'; @@ -463,7 +463,7 @@ class AutocompleteUI { const deviceId = Device.getDeviceId() || undefined; const installId = Device.getInstallId() || undefined; const radarSessionId = Session.getSessionId() || undefined; - const params: RadarAutocompleteSessionParams = { + const params: RadarAutocompleteSessionSelectionParams = { session: this.session, selection: index, userId, From 68ddb6e7457251a924816facf6ece63ba444e30c Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 12:57:00 -0500 Subject: [PATCH 07/16] package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 165a70bb..f32e09ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "radar-sdk-js", - "version": "4.1.9", + "version": "4.1.12", "license": "ISC", "dependencies": { "@types/geojson": "^7946.0.10" From 91f878e3bfd8e597703d133fb5e1b673412ab164 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 13:22:15 -0500 Subject: [PATCH 08/16] beta release --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f70f68a0..ee16e583 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index f32e09ce..28a1aa37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12", + "version": "4.12.1-beta.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 65657085..fb59b17b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12", + "version": "4.12.1-beta.0", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 316fc28e..8ea47f7b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12'; +export default '4.12.1-beta.0'; From f2cc78897f6dd0ea97e0fff5c862609d44952f76 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 13:40:16 -0500 Subject: [PATCH 09/16] Rename beta release --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ee16e583..f111450a 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 28a1aa37..7d127992 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.12.1-beta.0", + "version": "4.1.12-beta.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index fb59b17b..216f6084 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.12.1-beta.0", + "version": "4.1.12-beta.0", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 8ea47f7b..58383a85 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.12.1-beta.0'; +export default '4.1.12-beta.0'; From 5aa980b8d5a31df8cd4fd5f3dc8efd1747e6c073 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 14:23:18 -0500 Subject: [PATCH 10/16] use different random function --- src/ui/autocomplete.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 0cc79eeb..034452ca 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -549,7 +549,13 @@ class AutocompleteUI { } public generateUUID = (): string => { - return crypto.randomUUID(); + const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => { + const r = Math.random() * 16 | 0; + const v = (char == 'x') ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + + return uuid; } public setShowMarkers(showMarkers: boolean) { From d5dd0bae57c31065f742aa4216bb940aab1f88f9 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 14:32:08 -0500 Subject: [PATCH 11/16] updating beta release --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f111450a..a37341af 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 7d127992..ca5ccf69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.0", + "version": "4.1.12-beta.1", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 216f6084..19d964a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.0", + "version": "4.1.12-beta.1", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 58383a85..5cfd6352 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12-beta.0'; +export default '4.1.12-beta.1'; From 31da5cd361c3cf34b8e912d403a8366a815c8931 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Wed, 13 Dec 2023 14:36:03 -0500 Subject: [PATCH 12/16] 4.12.2 beta release --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a37341af..28447269 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index ca5ccf69..7f062778 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.1", + "version": "4.1.12-beta.2", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 19d964a0..6296d582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.1", + "version": "4.1.12-beta.2", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 5cfd6352..6ce8eea5 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12-beta.1'; +export default '4.1.12-beta.2'; From eb918913cb6d17fb9cd04bb4b824139d038d3e0d Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Mon, 18 Dec 2023 14:17:26 -0500 Subject: [PATCH 13/16] renaming vars --- src/api/search.ts | 6 +++--- src/types.ts | 6 +++--- src/ui/autocomplete.ts | 20 +++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/api/search.ts b/src/api/search.ts index 8c714281..8c31ce30 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -23,7 +23,7 @@ class SearchAPI { layers, countryCode, expandUnits, - session, + sessionToken, } = params; // near can be provided as a string or Location object @@ -44,7 +44,7 @@ class SearchAPI { layers, countryCode, expandUnits, - session, + sessionToken, }, }); @@ -61,7 +61,7 @@ class SearchAPI { static async autocompleteSelect(params: RadarAutocompleteSessionSelectionParams) { await Http.request({ - method: 'GET', + method: 'POST', path: 'search/autocomplete/selection', data: { ...params diff --git a/src/types.ts b/src/types.ts index 0574d62b..46f311df 100644 --- a/src/types.ts +++ b/src/types.ts @@ -342,12 +342,12 @@ export interface RadarAutocompleteParams { layers?: RadarGeocodeLayer[]; countryCode?: string; expandUnits?: boolean; - session?: string; + sessionToken?: string; } export interface RadarAutocompleteSessionSelectionParams { - session: string; - selection: number; + sessionToken: string; + selectionIndex: number; radarSessionId?: string; userId?: string; deviceId?: string; diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index 034452ca..ec5ec21b 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -7,8 +7,6 @@ import Storage from '../storage'; import { RadarAutocompleteContainerNotFound } from '../errors'; import type { RadarAutocompleteUIOptions, RadarAutocompleteConfig, RadarAutocompleteParams, Location, RadarAutocompleteSessionSelectionParams } from '../types'; -import crypto from 'crypto'; - const CLASSNAMES = { WRAPPER: 'radar-autocomplete-wrapper', INPUT: 'radar-autocomplete-input', @@ -91,7 +89,7 @@ class AutocompleteUI { resultsList: HTMLElement; wrapper: HTMLElement; poweredByLink?: HTMLElement; - session?: string; + sessionToken?: string; autocompleteParams?: RadarAutocompleteParams; // create a new AutocompleteUI instance @@ -245,10 +243,10 @@ class AutocompleteUI { public async fetchResults(query: string) { const { limit, layers, countryCode, expandUnits, onRequest } = this.config; - if (!this.session) { - this.session = this.generateUUID(); + if (!this.sessionToken) { + this.sessionToken = this.generateUUID(); } - const session = this.session; + const sessionToken = this.sessionToken; const params: RadarAutocompleteParams = { query, @@ -256,7 +254,7 @@ class AutocompleteUI { layers, countryCode, expandUnits, - session, + sessionToken, } if (this.near) { @@ -458,14 +456,14 @@ class AutocompleteUI { } // Radar Autocomplete Session - if (this.session) { + if (this.sessionToken) { const userId = Storage.getItem(Storage.USER_ID) || undefined; const deviceId = Device.getDeviceId() || undefined; const installId = Device.getInstallId() || undefined; const radarSessionId = Session.getSessionId() || undefined; const params: RadarAutocompleteSessionSelectionParams = { - session: this.session, - selection: index, + sessionToken: this.sessionToken, + selectionIndex: index, userId, deviceId, installId, @@ -476,7 +474,7 @@ class AutocompleteUI { } // Close out session - this.session = undefined; + this.sessionToken = undefined; this.autocompleteParams = undefined; // clear results list From 55b26072b380e629d8961286b2c83220835bccb2 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Tue, 19 Dec 2023 09:27:37 -0500 Subject: [PATCH 14/16] beta 3 --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 28447269..c6e3508a 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 7f062778..a8e71e7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.2", + "version": "4.1.12-beta.3", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 6296d582..34df2993 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.2", + "version": "4.1.12-beta.3", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 6ce8eea5..5bb7157f 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12-beta.2'; +export default '4.1.12-beta.3'; From d9ce5428b900a9b0a2cbeef818a67b3bfb045857 Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Tue, 19 Dec 2023 09:39:16 -0500 Subject: [PATCH 15/16] beta 4 --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c6e3508a..2d351f0b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index a8e71e7a..48c23b92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.3", + "version": "4.1.12-beta.4", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 34df2993..1b3717ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.3", + "version": "4.1.12-beta.4", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/version.ts b/src/version.ts index 5bb7157f..8bf33802 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12-beta.3'; +export default '4.1.12-beta.4'; From c2e5aae28e19013e8bc890f62caa2db746078eea Mon Sep 17 00:00:00 2001 From: Boon Boonsiri Date: Tue, 19 Dec 2023 14:10:44 -0500 Subject: [PATCH 16/16] beta 5, rename var --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/types.ts | 2 +- src/ui/autocomplete.ts | 2 +- src/version.ts | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2d351f0b..6ad288ad 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 48c23b92..7d344cac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.4", + "version": "4.1.12-beta.5", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 1b3717ef..351306fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.12-beta.4", + "version": "4.1.12-beta.5", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/types.ts b/src/types.ts index 46f311df..439ae14e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -347,7 +347,7 @@ export interface RadarAutocompleteParams { export interface RadarAutocompleteSessionSelectionParams { sessionToken: string; - selectionIndex: number; + selectedIndex: number; radarSessionId?: string; userId?: string; deviceId?: string; diff --git a/src/ui/autocomplete.ts b/src/ui/autocomplete.ts index ec5ec21b..16f93b9c 100644 --- a/src/ui/autocomplete.ts +++ b/src/ui/autocomplete.ts @@ -463,7 +463,7 @@ class AutocompleteUI { const radarSessionId = Session.getSessionId() || undefined; const params: RadarAutocompleteSessionSelectionParams = { sessionToken: this.sessionToken, - selectionIndex: index, + selectedIndex: index, userId, deviceId, installId, diff --git a/src/version.ts b/src/version.ts index 8bf33802..264bb1e2 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.12-beta.4'; +export default '4.1.12-beta.5';