Skip to content

feat(geocoding): migrate to Places API (New), add server-side geocoding for agents#78

Draft
jhb-dev wants to merge 14 commits intomainfrom
feat/geocoding-places-api-new
Draft

feat(geocoding): migrate to Places API (New), add server-side geocoding for agents#78
jhb-dev wants to merge 14 commits intomainfrom
feat/geocoding-places-api-new

Conversation

@jhb-dev
Copy link
Copy Markdown
Contributor

@jhb-dev jhb-dev commented Apr 6, 2026

Summary

Places API (New) Migration

  • Replace react-google-places-autocomplete with Google's Places API (New) AutocompleteSuggestion API and Payload's built-in ReactSelect
  • Rename _googlePlacesData field to _meta with a clean flat schema: { name, formattedAddress, googlePlaceId, types }
  • Rename geoDataFieldOverride config option to locationMetaOverride
  • Add JSON schema validation to the meta field
  • Add migration script for existing data (migrations/migrate-to-0.3.0.ts)
  • Extract Google Maps loader into separate utility file

Server-Side Geocoding for AI Agents / API

  • GET /api/geocoding-plugin/search?q=<address> — authenticated endpoint with custom access function support (geocodingEndpoint.access)
  • {field}_address virtual field — every geocodingField includes a hidden virtual _address text field; submitting an address string via the API auto-geocodes it and populates the point + _meta fields
  • geocodeAddress() exported service — server-side Google Geocoding HTTP API client, usable in custom code
  • Both field hooks share a single API call via req.context promise caching (Payload processes row fields in parallel)
  • README section: "Usage with AI Agents / API"

Test Infrastructure

  • Full integration test setup with SQLite (following pages plugin pattern)
  • Articles collection with Lexical editor block for testing geocoding in blocks
  • test-geocoding CI job added to workflow
  • 27 unit tests + 10 integration tests

Breaking Changes

  • Places API (New) must be enabled in Google Cloud project
  • _googlePlacesData field renamed to _meta with new data shape
  • geoDataFieldOverride config renamed to locationMetaOverride
  • react-google-places-autocomplete dependency removed

Test plan

  • 27 unit tests (service, endpoint, hooks, plugin config, field config)
  • 10 integration tests against real Payload + SQLite:
    • Field structure: point/meta in top-level, group, and array fields
    • Server-side geocoding: auto-geocode via _address on create and update
    • Lexical block: geocoding field inside a Lexical editor block
    • Endpoint registration verification
  • Type check passes (tsc --noEmit)
  • Lint passes (0 errors)
  • Formatting clean (prettier)
  • CI test-geocoding job passes
  • Verify autocomplete dropdown shows suggestions
  • Verify selecting a place stores coordinates in point field
  • Verify _meta field stores { name, formattedAddress, googlePlaceId, types }
  • Verify clearing selection resets both fields
  • Verify migration script transforms old data correctly

claude and others added 14 commits April 6, 2026 19:45
…completeElement

Google deprecated google.maps.places.AutocompleteService as of March 2025.
This replaces the react-google-places-autocomplete dependency with Google's
new PlaceAutocompleteElement web component and fetchFields API.

https://claude.ai/code/session_01TZQpaQ1MNq3SQ8uEU7iCSt
…ration

Also fix prettier config and lint-staged to handle .md files correctly
(default parser was set to typescript, causing markdown formatting to fail).

https://claude.ai/code/session_01TZQpaQ1MNq3SQ8uEU7iCSt
…nt/API usage

Adds two server-side geocoding mechanisms for AI agents and API consumers:

- GET /api/geocoding-plugin/search?q=<address> — authenticated endpoint
  with custom access function support
- {field}_address virtual field with beforeChange hooks — auto-geocodes
  address strings on create/update, populates point + _meta fields

Uses the new _meta field shape (name, formattedAddress, googlePlaceId, types).
Both hooks share a single API call via req.context promise caching.

Also adds:
- Full test infrastructure: 27 unit tests + 10 integration tests (SQLite)
- Articles collection with Lexical block for testing geocoding in blocks
- test-geocoding CI job
- "Usage with AI Agents / API" README section

https://claude.ai/code/session_01Ja3JVC48ozET22Z7yJkyY6
@jhb-dev jhb-dev changed the title feat(geocoding): migrate to Google Places API (New) feat(geocoding): migrate to Places API (New), add server-side geocoding for agents Apr 7, 2026
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.

2 participants