fix(micropub): wire up q=geo, fix lint, add tests and changeset - #373
fix(micropub): wire up q=geo, fix lint, add tests and changeset#373davidwkeith wants to merge 2 commits into
Conversation
Implement read-only proximity search for the Location/Venue feature. - Add VenueStore with D1 storage for geospatial venue queries - Implement haversineDistance for proximity calculation - Parse Geo URIs (geo:lat,lon;u=radius) and lat/lon/u parameters - Return venues ordered by distance with pagination - Add venues config option to enable the extension when proposed group is enabled - Update README with usage examples Closes #354
Addresses PR #372 review feedback: q=geo was advertised in q=config but handler.ts never routed it, so every request 400'd; CI failed lint on an escaped import path and no-explicit-any casts; the venue store had zero test coverage; and no changeset was recorded for the @dwk/micropub change. Also fixes correctness issues flagged in review: the bounding-box prefilter now corrects longitude by cos(latitude) so it no longer excludes in-radius venues away from the equator, venue urls are built from a configured baseUrl instead of a hardcoded example.com placeholder, and the sort tie-breaker uses the canonical venue url (per spec) instead of name. Closes #354
davidwkeith
left a comment
There was a problem hiding this comment.
Automated review per CONTRIBUTING.md.
Template/title conformance: looks good. PR title (fix(micropub): wire up q=geo, fix lint, add tests and changeset) follows the required Conventional Commits format, the body keeps the Summary / Packages affected / Checklist headings verbatim, checklist items are ticked with a clear one-line reason on the two intentionally-unchecked ones, and a changeset (.changeset/micropub-q-geo.md) is included for the @dwk/micropub minor bump. This is the shape CONTRIBUTING.md §6/§7 asks for.
Two things worth resolving before merge:
- Close #372 instead of leaving it open alongside this one. This PR's own description says it "supersedes #372, carrying its
q=geoLocation/Venue commit forward" — both PRs targetmainand both close #354. Leaving #372 open invites a redundant merge/conflict; recommend closing it once this one is confirmed good (or vice versa if further review here turns something up). - CI was still in progress at review time —
build-testwasin_progressandgithub-advanced-securityshowsfailure(this failure is consistent across all three currently-open PRs, so it looks like a pre-existing/unrelated repo-wide GHAS configuration issue rather than something introduced here, but worth a quick check before merging that it isn't masking anything real).
No functional issues found in the diff itself — the cos(latitude) prefilter fix, the typed { row, distance } replacement for the as any casts, and the baseUrl-derived venue URL all look correct against the spec description in the PR body.
Generated by Claude Code
|
Closing as redundant with #372, which carries the same fix for the exact issues this PR addresses ( Generated by Claude Code |
Summary
This supersedes #372 (
feat/micropub-q-geo), carrying itsq=geoLocation/Venue commit forward and fixing everything the review on that PR
flagged so it's actually mergeable:
q=geo:handleQuerynever had aq === "geo"branch, soevery real request 400'd with
unsupported queryeven though it wasadvertised in
q=config. AddedhandleGeoQuery, routed it, and fixed theq=configadvertisement to use avenuesEnabled()gate (mirrorscontactsEnabled) instead of the previous mis-indentedif (config.venues)."./venues.js"import inconfig.tshad anunnecessary escape (
".\/venues.js"), andvenues.tsused three@typescript-eslint/no-explicit-anycasts to smuggle adistancefieldthrough sort/filter — replaced with a properly typed
{ row, distance }/{ distance, venue }shape.venues?: MicropubVenueStore | MicropubVenueStore→
MicropubVenueStore | MicropubVenueStoreProvider, mirroring the existingContacts provider pattern (
normalizeVenueStore,MicropubVenueStoreProvider)./111000for both latitude and longitude, which narrows incorrectly at higher
latitudes (a degree of longitude shrinks by
cos(latitude)) and couldsilently exclude in-radius venues before the exact haversine filter ran.
Now divides by
111000 * cos(latitude)(guarded near the poles).url: washttps://example.com/venues/${id}unconditionally;
createMicropubVenueStorenow takes a{ baseUrl }configargument and builds the canonical URL from it.
name; the spec calls forthe canonical venue
urlascending as the deterministic tie-breaker.venues.test.tscovers Geo URI/parametervalidation (all the malformed/out-of-range/combined-form cases the spec
lists), the cos(latitude) prefilter fix, distance/url ordering and
pagination, and the missing-D1-binding startup failure.
index.test.tsgets an end-to-end suite exercising
q=geothrough the real handler:disabled-by-default non-advertisement + 400, an authorized request
returning nearby venues, and a malformed-query 400.
.changeset/micropub-q-geo.md,@dwk/micropubminor).geosuggestion echoesthe input coordinates rather than performing real reverse-geocoding.
Closes #354.
Packages affected
@dwk/micropub
Checklist
spec/packages/and updated them ifbehaviour changed — no behavioural change to the spec text was needed;
README clarified re: the reverse-geocoding placeholder.
src/*.test.ts)pnpm lint && pnpm format:check && pnpm typecheck && pnpm build && pnpm testpnpm changeset) if this touches a publishablepackage
catalog.json/conformance/status.jsonif this adds a newmountable worker or changes conformance status — not applicable, no new
worker and
@dwk/micropubstays prerelease/exempt from the gate.Generated by Claude Code