Skip to content

feat: list stored deals over REST and make export read them - #4

Merged
numarasSigmaSoftware merged 8 commits into
ui/devfrom
feature/deal-list-route
Sep 15, 2026
Merged

numarasSigmaSoftware merged 8 commits into
ui/devfrom
feature/deal-list-route

Conversation

@numarasSigmaSoftware

@numarasSigmaSoftware numarasSigmaSoftware commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Problem

Both booking paths persist deals under deal:<id>, but no route enumerates them. export_deals reads a deal_index key that nothing in the codebase writes, so GET /api/v1/deals/export always returns an empty list. Verified against a running instance on the CSV adapter: two deals booked through POST /api/v1/deals and POST /api/v1/deals/from-template, export still returned count: 0.

Change

  • Add GET /api/v1/deals, operator key required, with an optional status filter typed as the shared DealStatus wire enum and applied to the wire-mapped status, so ?status=booked returns template-booked deals stored as confirmed. Returns DealListResponse: the existing DealBookingResponse envelope per deal, count, and skipped, the ids of stored records that fail to serialize (logged with their id; one bad row no longer fails the whole list).
  • Scoping decision: the list is operator-only, the same posture as the rest of the admin surface. Buyers keep GET /api/v1/deals/{deal_id}. Export is unchanged, including its stored-status filter (confirmed / proposed / cancelled) that connectors already use.
  • Back the list with deal_service.list_deals(), which uses the storage base's existing deal:* scan. export_deals now reads the same set and the dead deal_index lookup is gone.
  • Regenerate docs/reference/endpoints.md; add the route to docs/api/overview.md; changelog entry under Unreleased.

Relies on IABTechLab#75 for the wire mapping of the template path's internal confirmed status. docs/api/openapi.json is not touched here: it is regenerated in IABTechLab#83, and this branch rebases onto that once merged and regenerates again so the list route lands in the document.

Verification

  • tests/unit/test_deal_list_route.py: route registration, list, wire-status filter (including the 422 on an internal name), operator gate (401 anonymous), skipped rows, empty store, non-matching filter, a real scan on a temp SQLite backend with an idempotency key in the store, and export after booking through both POST routes. Each behavior test was seen failing before its change.
  • tests/unit/test_route_shadowing.py: storage mock gained list_deals.
  • Full unit suite on a fresh database: all pass. On a reused working directory one pre-existing test fails, test_self_asserted_advertiser_identity_is_floored, because the suite leaves ad_seller.db behind; that is Unit suite leaves ./ad_seller.db behind, so a second consecutive local run can fail IABTechLab/seller-agent#82 and is not touched by this PR.

Not changed

No pagination on the list yet, since no other list route in the API pages either. Endpoint counts in the hand-written docs are bumped in IABTechLab#83; one further bump follows once both merge.

Note for maintainers, not part of this change

tests/unit/test_deal_list_route.py copies the sys.modules stub for ad_seller.flows.execution_activation_flow that test_route_shadowing.py, test_deal_booking_endpoints.py, and test_trust_tier_verification.py already carry. Each copy exists to dodge the cancel-scope leak tracked in IABTechLab#60. IABTechLab#66 landed as part 2 of that issue, so the four stub blocks may now be removable. Left untouched here; a separate cleanup PR should delete all four once the suite is confirmed green without them.

Both booking paths persist deals under deal:<id>, but no route enumerated
them: export_deals read a deal_index key that nothing writes, so
GET /api/v1/deals/export always returned an empty list.

- Add GET /api/v1/deals (optional ?status=) returning DealListResponse,
  a page of DealBookingResponse envelopes, registered with the other
  literal deal routes ahead of the {deal_id} catch-all.
- Back it with deal_service.list_deals(), which uses the storage
  backend's deal:* scan; export_deals now reads the same set.
- Regenerate docs/reference/endpoints.md.

Relies on IABTechLab#75 for the wire mapping of the template path's internal
"confirmed" status. docs/api/openapi.json is not touched here: the
committed file predates several routes, and a separate docs PR
regenerates it from the app.
@numarasSigmaSoftware
numarasSigmaSoftware changed the base branch from main to ui/dev September 15, 2026 20:15
@numarasSigmaSoftware
numarasSigmaSoftware marked this pull request as ready for review September 15, 2026 20:15
@numarasSigmaSoftware
numarasSigmaSoftware merged commit 8f1262a into ui/dev Sep 15, 2026
5 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