Skip to content

feat(api): Prospector two-way sync, Phase A (doNotContact, statusChangedAt, serverTime) - #94

Merged
juancodedev merged 2 commits into
mainfrom
feat/prospector-sync-phase-a
Nov 13, 2026
Merged

juancodedev merged 2 commits into
mainfrom
feat/prospector-sync-phase-a

Conversation

@juancodedev

Copy link
Copy Markdown
Owner

Summary

Phase A of the Prospector two-way sync. Unknown statuses are still accepted; rejection (Phase B) ships separately once the Prospector validates against the catalog.

  • GET /api/leads/statuses returns an array of { value, label, doNotContact } built from the user's pipeline stages (deduplicated by name).
  • New pipeline_stages.is_do_not_contact, settable through the stage create/update endpoints. Existing stages named Perdido, Descartado, Rebotó or No contactar are flagged by the migration.
  • New leads.status_changed_at, moved by the trigger only when status changes, so a contact-data push does not look like a CRM change.
  • GET /api/leads?updatedSince= filters on status_changed_at (ascending by default) and the response includes serverTime to use as the next cursor.
  • Also carries 7fd98a2 (updatedSince filter), which was committed after feat(api): finish the integration contract (status catalog + updatedSince) #93 merged and never reached main.

Breaking change

GET /api/leads/statuses changes from { statuses, names, default } to a bare array. The Prospector does not consume it yet.

Deploy

  1. Apply supabase/migrations/20261114000000_status_catalog_and_status_changed_at.sql (backfills status_changed_at, replaces fn_sync_lead_status_with_stage). Not yet run against a database.
  2. Deploy the app.

Checks

  • tsc --noEmit clean
  • jest: 117 suites, 869 tests pass

🤖 Generated with Claude Code

GET /api/leads?updatedSince=<iso> returns only the leads changed since that
instant, which lets an integration notice a lead the user marked as
do-not-contact and stop its sequence.

Ordering flips to updatedAt ascending by default so a poller can page with
limit + page and keep the highest updatedAt as its next cursor. An invalid
value answers 400 naming updatedSince.
…tus changes

Phase A of the Prospector two-way sync: the catalog is an array of
{ value, label, doNotContact }, stages carry is_do_not_contact,
updatedSince filters on status_changed_at and GET /api/leads returns
serverTime as the next cursor. Unknown statuses are still accepted.
@juancodedev
juancodedev merged commit 2d883df into main Nov 13, 2026
4 checks passed
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