Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,31 @@ The response has `results`, plus `hasMore` when more churches ranked past `limit

## GET /v1/churches/:id

The autofill record. Every key in `fields` is always present, with `null` or `[]` when empty, plus `missing`, `completeness`, `hints`, `freshness.lastVerified` (when someone last confirmed it, in milliseconds, or `null`) and `links.heresMyChurch` (the church's page; add `?suggest=1` to open its fix form). Records are cached for a minute, and a change that goes live through Lookup refreshes it at once.
The autofill record. Every key in `fields` is always present, with `null` or `[]` when empty, plus `missing`, `completeness`, `hints`, `freshness.lastVerified` (when someone last confirmed it, in milliseconds, or `null`), `links.heresMyChurch` (the church's page; add `?suggest=1` to open its fix form) and `claimed` (`true` when the church has claimed its listing on Here's My Church, so others' changes go to the church first). Records are cached for a minute, and a change that goes live through Lookup refreshes it at once.

```bash
curl https://lookup.heresmychurch.com/v1/churches/CA-ON-56994145
```

## GET /v1/meta

Field names, what can be contributed and how it's reviewed (`contributableFields`), whether adding churches is on (`addEnabled`), completeness weights, counts and attribution.
Field names, what can be contributed and how it's checked (`contributableFields`, each with `countries`, `review` and `checks`), whether adding churches is on (`addEnabled`), completeness weights, counts and attribution.

## POST /v1/churches/:id/contributions

Send corrections as `{ client, changes: [{ field, value }] }`. Fields are `serviceTimes`, `denomination`, `languages`, `ministries`, `phone`, `website`, `email`, `pastorName`, the address, and the reports `reportClosed`, `reportDuplicate` and `reportRelocated`. Send an address as `{ "field": "address", "value": { "street", "city", "postalCode" } }` (any of the three), or as separate `street`, `city` and `postalCode` changes; either way it goes to Here's My Church as one change, and parts you leave out keep their listed values. Up to 8 changes at once. Each field comes back with its own status:

| Status | Meaning |
|---|---|
| `live` | Applied now. These fields go live on one vote. |
| `in_review` | Waits for a Here's My Church moderator. |
| `live` | Applied now, such as a blank field filled in. |
| `in_review` | Held. Here's My Church checks it automatically, and a reviewer decides what the checks can't. With `reviewBy: "church"`, the church reviews it first, since it has claimed its listing. |
| `not_applied` | Not changed: the listed value was already the same, or Here's My Church kept it. |
| `rejected` | Not accepted, with a `message` saying why. |
| `try_again` | A temporary problem, such as maintenance or a rate limit. Nothing was refused. |
| `coming_soon` | A field Lookup will accept soon. Name is coming soon. |

`reviewBy` is only present when Here's My Church says who reviews a held change, and so far it's only ever `"church"`. The statuses themselves don't change, so code that reads only `status` keeps working. [Data and review](/docs/data#sharing-fixes-back) has the rules for each field.

```bash
curl -X POST https://lookup.heresmychurch.com/v1/churches/CA-ON-56994145/contributions \
-H "content-type: application/json" \
Expand Down
25 changes: 16 additions & 9 deletions docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ Its map counts every listing, about 655,000. Lookup leaves out about 68,000 that

## Sharing fixes back

When someone changes a detail Lookup filled, the widget offers to share it. Changed fields start checked, each says whether it goes live or waits for a moderator, and nothing is sent until they choose **Share** (or submit your form with a checked [`data-hmc-share`](/docs/widget#share-on-submit) box). Your form's own submit is never blocked.
When someone changes a detail Lookup filled, the widget offers to share it. Changed fields start checked, each says what will happen to it ("Goes live", "Checked automatically" or "The church reviews this"), and nothing is sent until they choose **Share** (or submit your form with a checked [`data-hmc-share`](/docs/widget#share-on-submit) box). Your form's own submit is never blocked.

| Field | Where | Review |
**Claimed listings come first.** When a church has claimed its listing on Here's My Church (verified its listed inbox), everyone else's changes go to the church to review. The record says `claimed: true`, and each held change comes back with `reviewBy: "church"`.

**Filling a blank field** goes live on one vote, with an automatic spam check afterwards. Email and pastor name are the exception: from Lookup they're always held, since a host's form can hold someone's personal details.

**Replacing a value that's already listed**, or reporting a problem, is held and checked automatically by Here's My Church:

| Field | Approved when | Otherwise |
|---|---|---|
| Service times, denomination, languages, ministries | Everywhere | Live on one vote |
| Phone | Everywhere | Live on one vote |
| Website | Everywhere | Waits for a moderator |
| Address (street, city and postal code, sent together) | Everywhere | Waits for a moderator |
| Email, pastor name | Everywhere | Always waits for a moderator, since a host's form can hold someone's personal details |
| Closed, duplicate or moved reports | Everywhere | Waits for a moderator |
| Name | Coming soon | Will wait for a moderator |
| Phone, service times | It appears on the church's own website, two or more people independently send the same value, or after three quiet days | A Here's My Church reviewer decides |
| Denomination, languages, ministries (additions only) | People agree, it passes the naming rules, or after three quiet days | A Here's My Church reviewer decides |
| Name, website, address (street, city and postal code, sent together) | There's evidence: the church's own website, a small spelling fix to a name, an address within 150 m of the map pin | A Here's My Church reviewer decides |
| Email, pastor name | There's evidence, such as the church's own website | A Here's My Church reviewer decides |
| Closed or duplicate reports | Strong evidence. The listing is hidden, not deleted, so it can come back | A Here's My Church reviewer decides |
| Moved reports | Never automatically | A Here's My Church reviewer decides |

Name corrections are coming soon through Lookup. The checks never let AI approve anything: where they read the church's website, an AI model only points to the sentence that should hold the value, and code confirms that the quote is really on the page and contains the value. `/v1/meta` lists each field with `checks`: `"automatic"`, `"automatic-then-reviewer"` or `"reviewer"`.

A change that goes live shows in Lookup's search and records within seconds, without waiting for the next sync.

Expand Down
2 changes: 1 addition & 1 deletion docs/how-search-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ A formula, not AI, orders results.
| Semantic search | One AI model, bge-m3 on Cloudflare Workers AI and Vectorize, runs only when no name matches every word. On the held-out test it moved "in top 5" from 85% to 87% and "no results" from 1% to 0%. |
| Ask AI in these docs | An instruct model on Workers AI answers questions using only these docs, and links the pages it used. Questions aren't stored. |
| Ranking | A formula, not AI. |
| Church details | AI never writes or changes them. Every fill comes from Here's My Church, and every shared fix goes through its review rules. |
| Church details | AI never writes or approves them. Every fill comes from Here's My Church, and every shared fix goes through its rules: the church first when it has claimed its listing, then automatic checks. When a check reads the church's own website, an AI model on Workers AI only points to the sentence that should hold the value; code confirms that quote is on the page and matches. What the checks can't decide goes to a person. |
| Searches | Lookup doesn't log them. |
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Church tools keep asking people for the same details. Lookup fills them in from

1. **Search as you type.** Prefixes, typos and places like "church in dallas" all work, nearby churches first.
2. **Fill your form.** Pick a church and the empty fields you tagged with `data-hmc-field` fill in. Anything already typed is left alone.
3. **Share fixes back.** When someone corrects a detail Lookup filled, they can share it back to Here's My Church, one checked box at a time.
3. **Share fixes back.** When someone corrects a detail Lookup filled, they can share it back to Here's My Church, one checked box at a time. A church that has claimed its listing reviews changes to it first. Otherwise Here's My Church checks them automatically, for example against the church's own website, where AI locates a quote and code confirms it, and a person reviews whatever the checks can't decide.

Because every pick comes from the same open directory, each app that uses Lookup helps keep church data accurate.

Expand Down
2 changes: 1 addition & 1 deletion docs/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pnpm dlx shadcn@latest add https://lookup.heresmychurch.com/r/church-consent.jso
<ChurchConsent record={record} values={form.watch()} labels={{ phone: "Phone" }} client="my-app" />
```

It shows only fields Here's My Church accepts for that church's country. Changed fields start checked, `street`, `city` and `postalCode` show as one Address row, each says whether it goes live or waits for a moderator, and nothing is sent until the person chooses Share. A checked `data-hmc-share` checkbox in the submitted form sends them too, without blocking the submit. When nothing changed, it asks "Still correct?" of listings nobody confirmed this year. It also offers **Report a problem** and a link to fix anything else on Here's My Church.
It shows only fields Here's My Church accepts for that church's country. Changed fields start checked, `street`, `city` and `postalCode` show as one Address row, each says whether it goes live, is checked automatically or goes to the church first (a claimed listing), and nothing is sent until the person chooses Share. A checked `data-hmc-share` checkbox in the submitted form sends them too, without blocking the submit. When nothing changed, it asks "Still correct?" of listings nobody confirmed this year. It also offers **Report a problem** and a link to fix anything else on Here's My Church.

## Your own UI

Expand Down
2 changes: 1 addition & 1 deletion docs/widget.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ document.querySelector("church-lookup").fieldMap = { website: "#site-url", phone

## Sharing fixes

After a fill, changing a field Lookup filled shows the changes below the church field, checked, with **Share N fixes**. Street, city and postal code show as one Address row. "Still correct?" appears only for listings nobody confirmed in the last year. See [Data and review](/docs/data#sharing-fixes-back) for what's accepted where.
After a fill, changing a field Lookup filled shows the changes below the church field, checked, with **Share N fixes**. Street, city and postal code show as one Address row. Each row says "Goes live" (a blank field), "Checked automatically" (a replacement) or, for a listing the church has claimed, "The church reviews this". "Still correct?" appears only for listings nobody confirmed in the last year. See [Data and review](/docs/data#sharing-fixes-back) for what's accepted where.

### Share on submit

Expand Down
20 changes: 11 additions & 9 deletions examples/shadcn-demo/src/components/church-consent.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client"

// ChurchConsent: after a ChurchLookup fill, offer to share the person's corrections back to Here's My
// Church. Changed fields start checked, each says whether it goes live or waits for a moderator, and
// nothing is sent until they choose Share (or submit the form with a checked data-hmc-share box).
// Church. Changed fields start checked, each says whether it goes live, is checked automatically or
// goes to the church first (a claimed listing), and nothing is sent until they choose Share (or
// submit the form with a checked data-hmc-share box).
// When nothing changed, it asks "Still correct?" of listings nobody confirmed this year. It also
// offers "Report a problem" and a link to fix anything else on Here's My Church.
import * as React from "react"
Expand All @@ -13,12 +14,14 @@ import { Checkbox } from "@/components/ui/checkbox"
import { cn } from "@/lib/utils"
import {
changeFor,
consentBadge,
consentDiff,
contributable,
createLookup,
fieldValue,
isStale,
mergeAddress,
resultText,
stringsFor,
suggestUrl,
type ChurchRecord,
Expand All @@ -42,15 +45,15 @@ export interface ChurchConsentProps {
client?: string
baseUrl?: string
lookup?: Lookup
onShared?: (results: { field: string; status: FieldStatus; message?: string }[], sandbox: boolean) => void
onShared?: (results: { field: string; status: FieldStatus; message?: string; reviewBy?: "church" }[], sandbox: boolean) => void
/** Text language, such as "es". Defaults to the page's. Load other languages with @/lib/lookup-strings. */
lang?: string
/** Override any text. */
strings?: Partial<Strings>
className?: string
}

type Result = { status: FieldStatus; message?: string }
type Result = { status: FieldStatus; message?: string; reviewBy?: "church" }
const REPORTS = ["reportClosed", "reportDuplicate", "reportRelocated"] as const

export function ChurchConsent({ record, values, labels = {}, client, baseUrl, lookup: own, onShared, lang, strings, className }: ChurchConsentProps) {
Expand Down Expand Up @@ -152,7 +155,7 @@ export function ChurchConsent({ record, values, labels = {}, client, baseUrl, lo
if (!picked.length) return
const changes = picked.map(changeFor)
setBusy(true)
let out: { sandbox?: boolean; results: { field: string; status: FieldStatus; message?: string }[] }
let out: { sandbox?: boolean; results: { field: string; status: FieldStatus; message?: string; reviewBy?: "church" }[] }
try {
out = await lookup.contribute(record!.id, changes)
} catch {
Expand Down Expand Up @@ -215,9 +218,8 @@ export function ChurchConsent({ record, values, labels = {}, client, baseUrl, lo
const soon = r.rule.status === "coming_soon"
const id = `${uid}-${r.field}`
const label = r.parts ? t.address : r.label
const badge = res
? res.status === "rejected" && res.message ? `${t.st.rejected}: ${res.message}` : t.st[res.status]
: soon ? t.soon : r.rule.review === "moderated" ? t.reviewed : t.goesLive
const before = consentBadge(t, r, soon, record.claimed)
const badge = res ? resultText(t, res) : before.text
return (
<li key={r.field} className="bg-background flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border px-3 py-2">
<Checkbox
Expand All @@ -230,7 +232,7 @@ export function ChurchConsent({ record, values, labels = {}, client, baseUrl, lo
<span className="text-muted-foreground min-w-0 flex-1 truncate">
<s>{r.was || "—"}</s> <span aria-hidden="true">→</span> <ins className="text-foreground no-underline">{sent.get(r.field) ?? r.value.trim()}</ins>
</span>
<Badge variant={!res && !soon && r.rule.review === "live" ? "secondary" : "outline"}>{badge}</Badge>
<Badge variant={!res && before.live ? "secondary" : "outline"}>{badge}</Badge>
</li>
)
})}
Expand Down
36 changes: 34 additions & 2 deletions examples/shadcn-demo/src/lib/lookup-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export interface ChurchRecord {
hints: { nearestPlace: string | null };
/** The church's page on Here's My Church, where people can fix anything else. Add ?suggest=1 to open the form. */
links?: { heresMyChurch: string | null };
/** The church has claimed its listing on Here's My Church. Others' changes go to the church first. */
claimed?: boolean;
attribution: string;
}

Expand All @@ -135,7 +137,8 @@ export type FieldStatus = "live" | "in_review" | "not_applied" | "rejected" | "t
export interface ContributionResult {
churchId: string;
sandbox?: boolean;
results: { field: string; status: FieldStatus; message?: string }[];
/** reviewBy "church": the change is held for the church itself to review (a claimed listing). */
results: { field: string; status: FieldStatus; message?: string; reviewBy?: "church" }[];
}
/** A church to add: record field names. Name, city and region (a code or name) are required. */
export interface NewChurch {
Expand All @@ -148,7 +151,8 @@ export interface AddResult { status: "live" | "similar" | "rejected" | "try_agai
export interface ConfirmResult { churchId: string; sandbox?: boolean; status: "confirmed" | FieldStatus; message?: string; lastVerified?: number }
export interface Meta {
fields: string[];
contributableFields: Record<string, { countries: "all" | string[]; review: "live" | "moderated"; status?: "coming_soon" }>;
/** `checks`: "automatic" fields are decided by Here's My Church's checks; "automatic-then-reviewer" ones go to a person when the checks can't decide; "reviewer" always does. */
contributableFields: Record<string, { countries: "all" | string[]; review: "live" | "moderated"; checks?: "automatic" | "automatic-then-reviewer" | "reviewer"; status?: "coming_soon" }>;
completenessWeights: Record<string, number>;
/** Whether addChurch() takes new churches right now. */
addEnabled?: boolean;
Expand Down Expand Up @@ -291,7 +295,14 @@ export interface Strings {
share: string;
notNow: string;
goesLive: string;
/** No longer shown: replacements say `checked`. Kept so existing overrides still type-check. */
reviewed: string;
/** A replacement, which Here's My Church checks automatically. */
checked: string;
/** Any change on a listing the church has claimed. */
churchReviews: string;
/** After sending, a change held for the church to review. */
sentToChurch: string;
soon: string;
st: { live: string; in_review: string; not_applied: string; rejected: string; try_again: string; coming_soon: string };
shared: (n: number) => string;
Expand Down Expand Up @@ -354,6 +365,9 @@ export const EN: Strings = {
notNow: "Not now",
goesLive: "Goes live",
reviewed: "A moderator reviews it",
checked: "Checked automatically",
churchReviews: "The church reviews this",
sentToChurch: "Sent to the church",
soon: "Coming soon",
st: { live: "Live now", in_review: "Sent for review", not_applied: "Not changed: Here's My Church kept the listed value", rejected: "Not accepted", try_again: "Couldn't send. Try again shortly.", coming_soon: "Coming soon" },
shared: (n) => `Shared ${n} ${n === 1 ? "change" : "changes"}.`,
Expand Down Expand Up @@ -792,6 +806,24 @@ export function mergeAddress<T extends ConsentRow>(rows: T[]): (T & { parts?: Re
return rows.flatMap((r) => (r === parts[0] ? [address] : parts.includes(r) ? [] : [r]));
}

/** Lookup always holds these, even into a blank field: a host form can hold someone's personal details. */
const ALWAYS_HELD = ["email", "pastorName"];

/**
* What a consent row's badge says before sending: coming soon, the church reviews it (a claimed
* listing), goes live (a blank field), or checked automatically (a replacement).
*/
export function consentBadge(t: Strings, r: { field: string; was: string }, soon: boolean, claimed?: boolean): { text: string; live: boolean } {
const live = !soon && !claimed && !r.was.trim() && !ALWAYS_HELD.includes(r.field);
return { text: soon ? t.soon : claimed ? t.churchReviews : live ? t.goesLive : t.checked, live };
}

/** A sent field's outcome, as the badge shows it. */
export function resultText(t: Strings, r: { status: FieldStatus; message?: string; reviewBy?: string }): string {
if (r.status === "rejected" && r.message) return `${t.st.rejected}: ${r.message}`;
return r.status === "in_review" && r.reviewBy === "church" ? t.sentToChurch : t.st[r.status];
}

/** The change to send for a consent row: an address goes as its parts. */
export const changeFor = (r: ConsentRow & { parts?: Record<string, string> }) => ({ field: r.field, value: r.parts ?? r.value.trim() });

Expand Down
Loading
Loading