Skip to content

feat: add Places API (New) support with session tokens#82

Open
Kyzegs wants to merge 1 commit into
AppAndFlow:mainfrom
Kyzegs:main
Open

feat: add Places API (New) support with session tokens#82
Kyzegs wants to merge 1 commit into
AppAndFlow:mainfrom
Kyzegs:main

Conversation

@Kyzegs

@Kyzegs Kyzegs commented Jun 5, 2026

Copy link
Copy Markdown

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.

⚠️ Release as 3.0.0 (major). Changes the network endpoint, request/response contract, the GoogleService API surface, and the GoogleLocationResult shape. Consumers must enable Places API (New) in Google Cloud — a separate API and SKU from the legacy one.

What changed

Service — endpoint places.googleapis.com/v1; autocomplete POST /v1/places:autocomplete, details GET /v1/places/{placeId}; auth via X-Goog-Api-Key; required X-Goog-FieldMask with exported DEFAULT_AUTOCOMPLETE_FIELD_MASK / DEFAULT_PLACE_DETAILS_FIELD_MASK; new AutocompleteRequest, Circle, LocationBias, LocationRestriction types; 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.random fallback) stable via ref; legacy options kept, @deprecated, auto-mapped.

ExportsGoogleService, both field-mask constants, new request types.

Tests/docs — tests expanded (+158); README rewritten for new options and setup.

Breaking changes

  1. Requires Places API (New) enabled in GCP.
  2. GoogleService.search/getDetails signatures changed; search resolves to GoogleLocationResult[] (was { predictions }).
  3. GoogleLocationResult dropped matched_substrings and terms; added distance_meters and isQueryPrediction.
  4. Legacy hook options deprecated (still functional).

Migration

  • Enable Places API (New) in Google Cloud.
  • languagelanguageCode, componentsincludedRegionCodes, queryTypesincludedPrimaryTypes, radius/lat/lng/strictBoundslocationBias/locationRestriction (legacy still auto-maps).
  • Replace reads of matched_substrings/terms with main_text_matched_substrings/description.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant