feat(api): resolve-by-pattern endpoint, purge threshold, contract tests (BIT-732)
Add POST /api/error-monitoring/resolve-by-pattern with advanced filters: severity, project_slug, fingerprint, message_pattern, time range. Enhance purge-resolved with optional older_than_days threshold so only stale resolved incidents are deleted. 27 contract tests (vitest) cover all four mutation endpoints: auth gating, validation, response shapes, and CRM-compatible behaviour. Paperclip-Agent: peter-spark Paperclip-Issue: BIT-732 Paperclip-Run: 749dfb41-182b-48c8-b6e7-74f14bdb9d41
This commit is contained in:
1 parent
de68f68103
commit
dee670ef9f
3 files changed
+775
-4
No files matched your search
@@ -63,6 +63,28 @@ Each row includes CRM-compatible fields. For non-resolved incidents, `status` is
|
||||
|
||||
If both `unique_ids` and `message_pattern` are sent, **`unique_ids` wins** (CRM behaviour).
|
||||
|
||||
## `POST /api/error-monitoring/resolve-by-pattern`
|
||||
|
||||
Bulk resolve incidents matching one or more advanced filters. At least one filter is required.
|
||||
|
||||
**Body (JSON):**
|
||||
|
||||
| Field | Required | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `message_pattern` | no | String or array of strings (max 20); matches occurrence `message` via `LIKE %pattern%` |
|
||||
| `fingerprint` | no | String or array of strings (max 50); exact match on incident fingerprint |
|
||||
| `severity` | no | String or array: `critical`, `high`, `medium`, `low`, `info` |
|
||||
| `project_slug` | no | Project slug (lowercase); exact match |
|
||||
| `from_date` | no | ISO 8601 datetime; only incidents with `last_seen_at >= from_date` |
|
||||
| `to_date` | no | ISO 8601 datetime; only incidents with `last_seen_at <= to_date` |
|
||||
| `resolution_notes` | no | Stored in state history (default message if omitted) |
|
||||
| `assigned_to` | no | Appended to change note for traceability |
|
||||
| `api_key` | no | Resolve key if not using header / session |
|
||||
|
||||
**Response:** `{ "success": true, "data": { "resolved": N, "matched": M } }`
|
||||
|
||||
**Auth:** Same as other mutations (`X-Error-Resolve-Key` / body `api_key` / session with `errors:triage`).
|
||||
|
||||
## `POST /api/error-monitoring/purge-resolved`
|
||||
|
||||
**Body (JSON):**
|
||||
@@ -70,6 +92,7 @@ If both `unique_ids` and `message_pattern` are sent, **`unique_ids` wins** (CRM
|
||||
| Field | Description |
|
||||
|--------|-------------|
|
||||
| `dry_run` | If true, returns `would_delete` count only |
|
||||
| `older_than_days` | Non-negative integer; only purge resolved incidents with `last_seen_at` older than this many days. If omitted, purges all resolved. |
|
||||
| `api_key` | Optional resolve key |
|
||||
|
||||
**Effect:** `DELETE` from `er_incidents` where `current_state = 'resolved'` (cascades occurrences and related rows per schema).
|
||||
|
||||
Reference in new issue
Block a user