feat: add Places API (New) support with session tokens#82
Open
Kyzegs wants to merge 1 commit into
Open
Conversation
Migrate GoogleService to the Places API (New) endpoints while keeping the legacy options working. Adds session token generation for billing, locationBias/locationRestriction, includedRegionCodes, languageCode and includedPrimaryTypes, plus query-prediction results. Legacy `components` and `queryTypes` are parsed into their new-API equivalents.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the underlying Google integration from the legacy Places API (
maps.googleapis.com/maps/api/place) to the Places API (New) (places.googleapis.com/v1). Adds session tokens, location bias/restriction, field masks, and query predictions, while keeping existing hook options working through a deprecation + auto-mapping layer.What changed
Service — endpoint
places.googleapis.com/v1; autocompletePOST /v1/places:autocomplete, detailsGET /v1/places/{placeId}; auth viaX-Goog-Api-Key; requiredX-Goog-FieldMaskwith exportedDEFAULT_AUTOCOMPLETE_FIELD_MASK/DEFAULT_PLACE_DETAILS_FIELD_MASK; newAutocompleteRequest,Circle,LocationBias,LocationRestrictiontypes; new-API responses normalized back into existing result types.Hook — new options
languageCode,regionCode,includedRegionCodes,includedPrimaryTypes,locationBias,locationRestriction,sessionToken; query predictions (isQueryPrediction); auto RFC4122 v4 session token (crypto.randomUUID+Math.randomfallback) stable via ref; legacy options kept,@deprecated, auto-mapped.Exports —
GoogleService, both field-mask constants, new request types.Tests/docs — tests expanded (+158); README rewritten for new options and setup.
Breaking changes
GoogleService.search/getDetailssignatures changed;searchresolves toGoogleLocationResult[](was{ predictions }).GoogleLocationResultdroppedmatched_substringsandterms; addeddistance_metersandisQueryPrediction.Migration
language→languageCode,components→includedRegionCodes,queryTypes→includedPrimaryTypes,radius/lat/lng/strictBounds→locationBias/locationRestriction(legacy still auto-maps).matched_substrings/termswithmain_text_matched_substrings/description.