Commit Graph
9 Commits
Author SHA1 Message Date
kemal.earth 6d8af8e950 chore(api-types): regenerate types from production specs (#54472)
## Problem

`packages/api-types` has drifted from the production OpenAPI specs.
#54394 regenerated them but was reverted in #54404, because the API had
rolled out ahead of its OpenFGA model. That has since been fixed on the
backend, so the regen can land.

...plus I need the new spec for #54391 and didn't want to blow up my
branch.

## Solution

Regenerated with `pnpm --filter=api-types codegen:prod` (production
specs, not the localhost `codegen`), plus the type fixes the new specs
require:

- `platform-webhooks-fetchers.ts` — `page` is now a deep object in the
spec, so the query params move from `page[limit]` keys to a nested
`page` object with a `deepObject` serializer.
- `InvoicesSettings.test.tsx` — four newly-required invoice fields in
the mock.
- `packages/shared-data` — `@supabase/shared-types` 0.1.98 → 0.1.102,
matching `apps/studio`.

Notable additions: the `environment_*` FGA scopes and `GET
/v2/projects/{ref}/analytics/traces/{trace_id}`.

## Review instructions

1. `pnpm --filter=api-types run verify-production-types` — passes.
2. `pnpm typecheck` and `pnpm --filter=studio test` — pass.
3. Only the three non-generated files need reading; the rest is
generated output.

Note: `verify-production-api-types` was removed from the required checks
during the #54394 incident and hasn't been restored. Worth putting back
after this merges.
2026-12-02 13:51:52 +00:00
K-Dog (Kevin) dc4f247e79 Revert "chore: update prod api types (#54394)" (#54404)
This reverts commit 37d4f444b4.

OpenFGA model needs updating first before updating the API types
2026-12-01 21:46:40 +08:00
K-Dog (Kevin) 37d4f444b4 chore: update prod api types (#54394)
Updated API types and addressed any type issues. Had to update
shared-types alongside.
2026-12-01 19:42:54 +08:00
Charis df742bdb3b refactor(studio): rename ResponseError to StudioError (#52707)
## What

Moves the `ResponseError` class (`types/base.ts`) and the classified
error classes (`types/api-errors.ts`) into
`lib/errors/studio-errors.ts`, and renames `ResponseError` to
`StudioError`.

## Why

Studio's error classification is being expanded to cover errors that
don't come from API responses (thrown network failures, aborted
requests, unexpected client errors). The API-specific name and location
no longer fit. Landing the rename on its own keeps the follow-up PR,
which introduces the classified error model, small and reviewable.

## Notes for reviewers

- Mechanical change, no behavior change. Most of the diff is a one-line
import change per file plus import re-sorting by Prettier.
- Files that only use the type now use `import type { StudioError }`.
- `ResponseError` is no longer re-exported from `@/types`; there are no
compatibility shims at the old paths.
- Unrelated identifiers like `QueryResponseError` and
`parseResponseErrors` are unchanged.
2026-11-03 11:09:30 -05:00
Monica Khoury 8bdc2bf0c5 feat(studio): refresh webhook deliveries on demand instead of polling (#52444)
## Problem

The deliveries table polled the API every 5 seconds, for as long as the
page was open. Studio tables are not polled by default, and polling is
only needed here because delivery results arrive asynchronously.

Stacked on #52314. Linear:
[FE-3750](https://linear.app/supabase/issue/FE-3750/add-pagination-to-platform-webhooks-deliveries-table)

## Solution

- Deliveries are no longer polled by default.
- A **Live** button turns polling on (every 5 seconds), and a
**Refresh** button reloads once.
- Polling also turns on by itself while a delivery is pending, and after
a test event or retry is sent until its delivery appears (30 seconds at
most). The action never looks like it did nothing.
- Hovering a failed delivery explains that failed deliveries are usually
retried automatically. The API returns no retry state yet, so a
scheduled retry only shows up once its attempt starts.

## Review instructions

1. Enable the Platform Webhooks feature preview, open an endpoint with
deliveries, and filter DevTools > Network by `deliveries`. No request
repeats on its own.
2. Click Refresh. One request is sent.
3. Click Live. A request is sent every 5 seconds and the dot pulses.
Click Live again and the requests stop.
4. Send a test event. Requests repeat for a few seconds until the new
row appears, then stop.
5. Set the endpoint URL to `https://httpbin.org/delay/10` and send a
test event. While the new row shows `pending`, requests repeat. Once it
shows `success`, they stop.
6. Hover a `failure` badge. The retry tooltip shows.
2026-10-29 12:44:44 +02:00
Monica Khoury d973267d27 feat(studio): paginate platform webhooks deliveries table by cursor (#52314)
## Problem

The deliveries table loaded one page from the API and split it into
pages of 5 in the browser, so older deliveries could not be reached.

Linear:
[FE-3750](https://linear.app/supabase/issue/FE-3750/add-pagination-to-platform-webhooks-deliveries-table)

## Solution

- **Cursor pagination:** the table requests deliveries 5 at a time
(`page[after]`), and Next and Previous load the next or previous page.
It asks for 6 and shows 5, so Next is never enabled on an empty page.
Previous uses the history of cursors we visited, because the API's
`prev` link can skip a row or land on an empty page.
- The footer reads "Showing N deliveries" (the API returns no total).
The delivery search still filters only the loaded page.
- **Loading and errors:** skeleton rows show while a page loads, and a
failed load shows an error with a Try again button instead of "No
deliveries found", and polling stops until you retry. If a later refresh
fails, the loaded rows stay with a notice that they may be out of date,
and polling continues.
- Retry and Send test event refresh every cached page of the endpoint's
deliveries. Switching endpoints starts again on page 1.
- Retry from the details sheet now works for a delivery that is not on
the current page.
- A pending delivery has no result yet, so its row no longer opens the
details sheet. Its Retry button is unchanged.
- Removed the "Attempt" field from the details sheet. It was the row's
position on the page, not an attempt number. A real one needs the API to
return it (CTRL-1974).

## Review instructions

1. Enable the Platform Webhooks feature preview, open an endpoint, and
send 7 test events (limited to 10 per minute).
2. Page 1 shows 5 deliveries, Previous is disabled and Next is enabled.
Next shows the other 2 and disables Next. Previous goes back to the
first 5.
3. On an endpoint with exactly 5 deliveries, both buttons are disabled.
4. In DevTools > Network, set throttling to "Slow 4G" and click Next.
Skeleton rows show. Then block the `deliveries` request and click Next.
"Failed to retrieve deliveries" shows with a Try again button. Wait 10
seconds: no new `deliveries` requests are sent. Unblock the request and
click Try again to load the rows. Also block the request while rows are
loaded: they stay, and an "Unable to refresh deliveries" notice appears
within about 5 seconds and clears once you unblock.
5. Open the details sheet from the bottom row of page 1. In a second
tab, send a test event and wait about 5 seconds. Click Retry delivery in
the first tab. A toast and a `POST .../retry` request appear, even
though the row has moved off page 1.
6. Set the endpoint URL to `https://httpbin.org/delay/10` and send a
test event. While the new row shows `pending` (about 10 seconds),
clicking it does nothing. Once it shows `success`, it opens the sheet.
2026-10-28 14:36:11 +02:00
Monica Khoury d0cf8dbc50 fix: align webhook FE with updated API changes (#51800)
## What
Aligns the webhooks FE with backend changes confirmed by Pawel
(FE-4621):

1. `custom_headers` is optional but never null, matches the updated
contract.
2. Removed the client-only `name` field (never persisted by the API).
Display name is now the endpoint's URL plus its subscribed event types.
3. The deliveries list endpoint now returns the full `event` object, so
`eventType`/`eventPayload` are always populated. Added an Event column
to the deliveries table.

Also regenerates `packages/api-types` from production to pick up these
changes.

While testing, found and fixed two more related issues:

4. A delivery can briefly exist before the backend finishes attaching
its event data, regardless of what triggered it (test, retry, or real
traffic). The deliveries list now polls every 5s while open, so new or
still-settling deliveries fill in automatically instead of requiring a
manual refresh.
5. "Send test event" always defaulted to an unrelated sample event type.
The test endpoint actually accepts a specific `event_type`, so this now
sends the endpoint's own subscribed type automatically, or shows a
picker when there's more than one to choose from.

## Testing
All webhooks component/unit tests pass (30/30), typecheck and lint
clean. Manually verified on localhost against a live backend.

## Note
This may clash with #51614 (`custom_headers: null` in a test fixture, no
longer a valid value once this merges). Will follow up there after this
lands.
2026-10-15 20:17:56 +03:00
Monica Khoury eaad809abf fix: webhook retry error handling (nested error envelope + unhandled rejections) (#51591)
## What
Fixes two bugs found while writing component tests for the platform
webhooks page (follow-up to FE-3749):

1. The webhooks API nests error details under an `error` key (`{ error:
{ code, message } }`), but the shared `handleError` only reads a
top-level `message`. This meant the friendly rate-limit message ("wait a
minute and try again") never actually fired, it always fell back to a
generic error. Fixed with a local unwrapping `handleError` in
`platform-webhooks-fetchers.ts`.
2. Every mutation handler on the page (`mutateAsync` for
create/update/delete/regenerate-secret/send-test-event/retry) left the
re-thrown error from React Query uncaught, producing an unhandled
promise rejection on every failure, even though the error toast itself
was already correct. Fixed by wrapping each call in try/catch.

## Why
Found while writing the stacked test PR for FE-3749; filed as
[FE-4620](https://linear.app/supabase/issue/FE-4620/two-webhook-error-handling-bugs-found-while-writing-retryrate-limit)
since it's a correctness fix independent of the test work.

## Testing
Manually verified both fixes on localhost: rate-limit retry now shows
the friendly message, and no `Uncaught (in promise)` errors appear in
the console on any mutation failure.
2026-10-13 19:44:21 +03:00
Monica KhouryandCharis Lam 2d5768d3c1 feat(studio): wire Platform Webhooks UI to real backend API (#51352)
## What
Wires the existing (mocked) Platform Webhooks UI to the real Management
API backend, per FE-3749.

- New `data/platform-webhooks/` query/mutation hooks, calling the real
`/v2/organizations/{slug}/webhooks/...` and
`/v2/projects/{ref}/webhooks/...` endpoints
- Updated `PlatformWebhooks.types.ts` to match the real API contract
(field names, shapes)
- Added a signing secret field to the create-endpoint form (API requires
a user-provided secret, not server-generated like the mock assumed)
- Removed the event-type column from the deliveries table (the real
list-deliveries endpoint doesn't return event type, only the
single-delivery endpoint does)
- Removed `PlatformWebhooks.mock.ts` / `.store.ts` and their tests

## Why
UI was built ~80% against mock data months ago; this closes the gap to a
real, working feature.

## Known open items (not blocking, tracked separately)
- `name` field has no backend storage yet — client-only for now, open
question with Ali/Paweł
- Deliveries table only fetches the backend's default single page — real
server-side pagination not yet wired (see FE-3750)

## Follow-up PR (stacked)
Tests for the new `data/platform-webhooks/` hooks (MSW-based), per the
ticket's own scope split.

## Testing
Manually tested end-to-end against local backend: created/edited/deleted
an endpoint, verified the real signature using webhook.site,
independently recomputed the HMAC and confirmed it matches the
`webhook-signature` header.

Linear: FE-3749

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
2026-10-09 22:41:09 +03:00